dsh-ustc-quota 1.1.29 → 1.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +54 -33
- package/index.js +2 -2
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -11,7 +11,7 @@ window.__ModuleLoader__.load({
|
|
|
11
11
|
const UPDATE_ENDPOINT = 'plugins/dsh-ustc-quota/update';
|
|
12
12
|
const UPDATE_APPLY_ENDPOINT = 'plugins/dsh-ustc-quota/update/apply';
|
|
13
13
|
const WINDOW_IDS = ['3h', '12h', '24h'];
|
|
14
|
-
const CLIENT_VERSION = '1.1.
|
|
14
|
+
const CLIENT_VERSION = '1.1.31';
|
|
15
15
|
const UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
16
16
|
const CLIENT_VERSION_KEY = `${NS}:client-version`;
|
|
17
17
|
const CLIENT_RELOAD_KEY = `${NS}:client-reload`;
|
|
@@ -1157,6 +1157,36 @@ window.__ModuleLoader__.load({
|
|
|
1157
1157
|
// diagnostics are best-effort
|
|
1158
1158
|
}
|
|
1159
1159
|
}
|
|
1160
|
+
let reservedColumn = null;
|
|
1161
|
+
let reservedSaved = null;
|
|
1162
|
+
let reservedSavedPriority = '';
|
|
1163
|
+
|
|
1164
|
+
function applyReservedPadding(reserve) {
|
|
1165
|
+
const holder = document.querySelector('[data-slot="main.conversation"]');
|
|
1166
|
+
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
1167
|
+
if (!column) return false;
|
|
1168
|
+
if (reservedColumn !== column) {
|
|
1169
|
+
releaseReservedPadding();
|
|
1170
|
+
reservedColumn = column;
|
|
1171
|
+
reservedSaved = column.style.getPropertyValue('padding-right');
|
|
1172
|
+
reservedSavedPriority = column.style.getPropertyPriority('padding-right');
|
|
1173
|
+
}
|
|
1174
|
+
const wanted = reserve + 'px';
|
|
1175
|
+
if (column.style.getPropertyValue('padding-right') !== wanted) {
|
|
1176
|
+
column.style.setProperty('padding-right', wanted, 'important');
|
|
1177
|
+
}
|
|
1178
|
+
return true;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
function releaseReservedPadding() {
|
|
1182
|
+
if (!reservedColumn) return;
|
|
1183
|
+
if (reservedSaved) reservedColumn.style.setProperty('padding-right', reservedSaved, reservedSavedPriority);
|
|
1184
|
+
else reservedColumn.style.removeProperty('padding-right');
|
|
1185
|
+
reservedColumn = null;
|
|
1186
|
+
reservedSaved = null;
|
|
1187
|
+
reservedSavedPriority = '';
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1160
1190
|
function measureRightDock() {
|
|
1161
1191
|
const holder = document.querySelector('[data-slot="main.conversation"]');
|
|
1162
1192
|
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
@@ -1173,19 +1203,26 @@ window.__ModuleLoader__.load({
|
|
|
1173
1203
|
if (columnWidth - (width + DOCK_GAP * 2) < DOCK_TRANSCRIPT_FLOOR) {
|
|
1174
1204
|
width = Math.max(DOCK_FLOOR_WIDTH, columnWidth - DOCK_TRANSCRIPT_FLOOR - DOCK_GAP * 2);
|
|
1175
1205
|
}
|
|
1176
|
-
// A collapsed right sidebar keeps a narrow icon rail at the column's right
|
|
1177
|
-
//
|
|
1206
|
+
// A collapsed right sidebar keeps a narrow icon rail at the column's right
|
|
1207
|
+
// edge. Only a small inset counts as that rail: a wide one means the sidebar is
|
|
1208
|
+
// open and the dock must not try to dodge a whole panel.
|
|
1178
1209
|
let railInset = 0;
|
|
1179
1210
|
for (const button of document.querySelectorAll('button[aria-label]')) {
|
|
1180
1211
|
const label = button.getAttribute('aria-label') || '';
|
|
1181
1212
|
if (!/右侧边栏/.test(label)) continue;
|
|
1182
1213
|
const rect = button.getBoundingClientRect();
|
|
1183
1214
|
if (rect.width <= 0 || rect.height <= 0) continue;
|
|
1215
|
+
if (rect.left < columnRect.left || rect.left > columnRect.right) continue;
|
|
1184
1216
|
const inset = Math.round(columnRect.right - rect.left);
|
|
1185
|
-
if (inset > 0 && inset
|
|
1217
|
+
if (inset > 0 && inset <= 72) railInset = Math.max(railInset, inset);
|
|
1186
1218
|
}
|
|
1187
1219
|
width = Math.max(DOCK_FLOOR_WIDTH, width - railInset);
|
|
1188
|
-
|
|
1220
|
+
let reserve = width + railInset + DOCK_GAP * 2;
|
|
1221
|
+
const reserveCap = Math.round(columnRect.width * 0.34);
|
|
1222
|
+
if (reserve > reserveCap) {
|
|
1223
|
+
reserve = Math.max(DOCK_FLOOR_WIDTH + DOCK_GAP * 2, reserveCap);
|
|
1224
|
+
width = Math.max(DOCK_FLOOR_WIDTH, reserve - railInset - DOCK_GAP * 2);
|
|
1225
|
+
}
|
|
1189
1226
|
|
|
1190
1227
|
// Vertical bound: never cross or touch the separator under the tab strip.
|
|
1191
1228
|
let contentTop = Math.round(columnRect.top) + DOCK_GAP;
|
|
@@ -1256,6 +1293,8 @@ window.__ModuleLoader__.load({
|
|
|
1256
1293
|
const position = usePanelPosition();
|
|
1257
1294
|
const active = position === 'right';
|
|
1258
1295
|
const [box, setBox] = React.useState(null);
|
|
1296
|
+
const activeRef = React.useRef(active);
|
|
1297
|
+
activeRef.current = active;
|
|
1259
1298
|
React.useEffect(() => {
|
|
1260
1299
|
let frame = 0;
|
|
1261
1300
|
let observer = null;
|
|
@@ -1270,7 +1309,12 @@ window.__ModuleLoader__.load({
|
|
|
1270
1309
|
observer = new ResizeObserver(schedule);
|
|
1271
1310
|
observer.observe(column);
|
|
1272
1311
|
}
|
|
1273
|
-
|
|
1312
|
+
const next = measureRightDock();
|
|
1313
|
+
setBox(next);
|
|
1314
|
+
// Apply the reserved padding from the same loop that measured it; a React
|
|
1315
|
+
// effect can be skipped when DSH re-renders the column behind our back.
|
|
1316
|
+
if (activeRef.current && next) applyReservedPadding(next.reserve);
|
|
1317
|
+
else releaseReservedPadding();
|
|
1274
1318
|
};
|
|
1275
1319
|
function schedule() {
|
|
1276
1320
|
if (!frame) frame = window.requestAnimationFrame(measure);
|
|
@@ -1285,34 +1329,11 @@ window.__ModuleLoader__.load({
|
|
|
1285
1329
|
if (frame) window.cancelAnimationFrame(frame);
|
|
1286
1330
|
};
|
|
1287
1331
|
}, []);
|
|
1288
|
-
|
|
1332
|
+
React.useEffect(() => () => { releaseReservedPadding(); }, []);
|
|
1289
1333
|
React.useEffect(() => {
|
|
1290
|
-
if (!active
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
if (!column) return undefined;
|
|
1294
|
-
const saved = column.style.getPropertyValue('padding-right');
|
|
1295
|
-
const priority = column.style.getPropertyPriority('padding-right');
|
|
1296
|
-
const wanted = reserve + 'px';
|
|
1297
|
-
const apply = () => {
|
|
1298
|
-
if (column.style.getPropertyValue('padding-right') !== wanted) {
|
|
1299
|
-
column.style.setProperty('padding-right', wanted, 'important');
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
apply();
|
|
1303
|
-
// DSH re-renders the column and rewrites its style attribute, so watch it.
|
|
1304
|
-
const observer = typeof MutationObserver === 'function'
|
|
1305
|
-
? new MutationObserver(apply)
|
|
1306
|
-
: null;
|
|
1307
|
-
if (observer) observer.observe(column, { attributes: true, attributeFilter: ['style'] });
|
|
1308
|
-
const timer = window.setInterval(apply, 1000);
|
|
1309
|
-
return () => {
|
|
1310
|
-
if (observer) observer.disconnect();
|
|
1311
|
-
window.clearInterval(timer);
|
|
1312
|
-
if (saved) column.style.setProperty('padding-right', saved, priority);
|
|
1313
|
-
else column.style.removeProperty('padding-right');
|
|
1314
|
-
};
|
|
1315
|
-
}, [active, reserve]);
|
|
1334
|
+
if (!active) releaseReservedPadding();
|
|
1335
|
+
}, [active]);
|
|
1336
|
+
|
|
1316
1337
|
const shown = active && box !== null;
|
|
1317
1338
|
return h('div', {
|
|
1318
1339
|
'data-ustc-quota-dock': 'right',
|
package/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const ROUTE_PATH = '/plugins/dsh-ustc-quota/snapshot';
|
|
|
25
25
|
const UPDATE_PATH = '/plugins/dsh-ustc-quota/update';
|
|
26
26
|
const UPDATE_APPLY_PATH = '/plugins/dsh-ustc-quota/update/apply';
|
|
27
27
|
const UPDATE_TOKEN_TTL_MS = 30 * 60 * 1000;
|
|
28
|
-
const PLUGIN_VERSION = '1.1.
|
|
28
|
+
const PLUGIN_VERSION = '1.1.31';
|
|
29
29
|
const KEY_INFO_PATH = 'key/info';
|
|
30
30
|
const USER_INFO_PATH = 'user/info';
|
|
31
31
|
const DISCOVERY_TTL_MS = 30000;
|
|
@@ -87,7 +87,7 @@ export function apply(ctx, config) {
|
|
|
87
87
|
request.on('end', () => {
|
|
88
88
|
try {
|
|
89
89
|
const file = path.join(os.tmpdir(), 'dsh-ustc-quota-diag.jsonl');
|
|
90
|
-
fs.appendFileSync(file, String(body).replace(
|
|
90
|
+
fs.appendFileSync(file, String(body).replace(/[\r\n]+/g, ' ') + String.fromCharCode(10));
|
|
91
91
|
response.writeHead(204, { 'cache-control': 'no-store' });
|
|
92
92
|
response.end();
|
|
93
93
|
} catch {
|
package/package.json
CHANGED