dsh-ustc-quota 1.1.27 → 1.1.29
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 +42 -5
- package/index.js +1 -1
- 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.29';
|
|
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`;
|
|
@@ -1173,7 +1173,19 @@ window.__ModuleLoader__.load({
|
|
|
1173
1173
|
if (columnWidth - (width + DOCK_GAP * 2) < DOCK_TRANSCRIPT_FLOOR) {
|
|
1174
1174
|
width = Math.max(DOCK_FLOOR_WIDTH, columnWidth - DOCK_TRANSCRIPT_FLOOR - DOCK_GAP * 2);
|
|
1175
1175
|
}
|
|
1176
|
-
|
|
1176
|
+
// A collapsed right sidebar keeps a narrow icon rail at the column's right edge;
|
|
1177
|
+
// the dock must stop before it, or it covers those native buttons.
|
|
1178
|
+
let railInset = 0;
|
|
1179
|
+
for (const button of document.querySelectorAll('button[aria-label]')) {
|
|
1180
|
+
const label = button.getAttribute('aria-label') || '';
|
|
1181
|
+
if (!/右侧边栏/.test(label)) continue;
|
|
1182
|
+
const rect = button.getBoundingClientRect();
|
|
1183
|
+
if (rect.width <= 0 || rect.height <= 0) continue;
|
|
1184
|
+
const inset = Math.round(columnRect.right - rect.left);
|
|
1185
|
+
if (inset > 0 && inset < Math.round(columnRect.width * 0.3)) railInset = Math.max(railInset, inset);
|
|
1186
|
+
}
|
|
1187
|
+
width = Math.max(DOCK_FLOOR_WIDTH, width - railInset);
|
|
1188
|
+
const reserve = width + railInset + DOCK_GAP * 2;
|
|
1177
1189
|
|
|
1178
1190
|
// Vertical bound: never cross or touch the separator under the tab strip.
|
|
1179
1191
|
let contentTop = Math.round(columnRect.top) + DOCK_GAP;
|
|
@@ -1218,13 +1230,24 @@ window.__ModuleLoader__.load({
|
|
|
1218
1230
|
}
|
|
1219
1231
|
return { count, left: min === null ? null : Math.round(min) };
|
|
1220
1232
|
})(),
|
|
1221
|
-
dock: { width, reserve, top: contentTop },
|
|
1233
|
+
dock: { width, reserve, top: contentTop, railInset },
|
|
1234
|
+
position: (() => { try { return window.localStorage.getItem(POSITION_KEY); } catch { return null; } })(),
|
|
1235
|
+
dockRect: (() => {
|
|
1236
|
+
const el = document.querySelector('[data-ustc-quota-dock]');
|
|
1237
|
+
if (!el) return null;
|
|
1238
|
+
const r = el.getBoundingClientRect();
|
|
1239
|
+
return { x: Math.round(r.left), w: Math.round(r.width), display: getComputedStyle(el).display };
|
|
1240
|
+
})(),
|
|
1241
|
+
railButtons: [...document.querySelectorAll('button[aria-label]')]
|
|
1242
|
+
.filter((b) => /右侧边栏/.test(b.getAttribute('aria-label') || ''))
|
|
1243
|
+
.map((b) => ({ label: b.getAttribute('aria-label'), r: rectOf(b) })),
|
|
1222
1244
|
viewport: window.innerWidth,
|
|
1223
1245
|
});
|
|
1224
1246
|
return {
|
|
1225
1247
|
top: contentTop,
|
|
1226
1248
|
width,
|
|
1227
1249
|
reserve,
|
|
1250
|
+
railInset,
|
|
1228
1251
|
maxHeight: Math.max(120, Math.round(columnRect.bottom) - contentTop - DOCK_GAP),
|
|
1229
1252
|
};
|
|
1230
1253
|
}
|
|
@@ -1270,8 +1293,22 @@ window.__ModuleLoader__.load({
|
|
|
1270
1293
|
if (!column) return undefined;
|
|
1271
1294
|
const saved = column.style.getPropertyValue('padding-right');
|
|
1272
1295
|
const priority = column.style.getPropertyPriority('padding-right');
|
|
1273
|
-
|
|
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);
|
|
1274
1309
|
return () => {
|
|
1310
|
+
if (observer) observer.disconnect();
|
|
1311
|
+
window.clearInterval(timer);
|
|
1275
1312
|
if (saved) column.style.setProperty('padding-right', saved, priority);
|
|
1276
1313
|
else column.style.removeProperty('padding-right');
|
|
1277
1314
|
};
|
|
@@ -1282,7 +1319,7 @@ window.__ModuleLoader__.load({
|
|
|
1282
1319
|
style: {
|
|
1283
1320
|
position: 'fixed',
|
|
1284
1321
|
top: box ? box.top : 0,
|
|
1285
|
-
right: DOCK_GAP,
|
|
1322
|
+
right: DOCK_GAP + (box ? box.railInset : 0),
|
|
1286
1323
|
width: box ? box.width : DOCK_MIN_WIDTH,
|
|
1287
1324
|
maxHeight: box ? box.maxHeight : 0,
|
|
1288
1325
|
overflow: 'visible',
|
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.29';
|
|
29
29
|
const KEY_INFO_PATH = 'key/info';
|
|
30
30
|
const USER_INFO_PATH = 'user/info';
|
|
31
31
|
const DISCOVERY_TTL_MS = 30000;
|
package/package.json
CHANGED