dsh-ustc-quota 1.1.56 → 1.1.58
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/README.md +1 -1
- package/client.js +71 -5
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ key-c 8.7/30 29% 8.7/70 12% 11.1/100 11%
|
|
|
112
112
|
- 右侧位置会在对话区右侧**预留一条槽**:插件给对话列加右侧内边距(约列宽的 26%,封顶 34%),正文与轮次导航条整体左移,卡片占住这条槽——因此不遮挡正文、不遮挡轮次导航条、也不遮挡右侧原生按钮。上沿从「对话 / 轨迹 / 看板」选项卡下的分隔线以下 6px 开始。
|
|
113
113
|
- 窄窗口或打开侧栏时槽宽自动收窄(下限 140px),卡片始终可见;如果连正文最小宽度都不够,则允许卡片比常规更窄,而不是消失。
|
|
114
114
|
- 换边不重新加载:两处卡片共用同一份已取到的数据。底色用左侧边栏的底色(`--dsw-specific-sidebar-fill`),阴影与左侧一致。
|
|
115
|
-
- 右侧卡片宽度上限
|
|
115
|
+
- 右侧卡片宽度上限 480px,每列数值按该列最宽内容自动定宽,多余空间给进度条;与其它插件的右侧卡片(如 Codex Advisor)自动上下排开;测量一时失败时退回固定位置显示,不会整块消失。
|
|
116
116
|
## 更新
|
|
117
117
|
|
|
118
118
|
- 标题「USTC 词元额度」右侧显示灰色小字版本号;点击版本号可手动检查更新;
|
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.58';
|
|
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`;
|
|
@@ -1209,7 +1209,37 @@ window.__ModuleLoader__.load({
|
|
|
1209
1209
|
const DOCK_TRANSCRIPT_FLOOR = 360;
|
|
1210
1210
|
|
|
1211
1211
|
|
|
1212
|
-
|
|
1212
|
+
// First come, first served. Each plugin right dock claims an arrival number the
|
|
1213
|
+
// moment it becomes active on the right and publishes it as a data attribute, so
|
|
1214
|
+
// a neighbour can compare. The earlier arrival keeps the natural slot; the later
|
|
1215
|
+
// one stacks below it. Deliberately not id-ordered or height-ordered — whoever
|
|
1216
|
+
// got there first wins, which is the least surprising rule for the user.
|
|
1217
|
+
const ARRIVAL_KEY = '__dshRightDockArrival';
|
|
1218
|
+
function claimDockArrival() {
|
|
1219
|
+
try {
|
|
1220
|
+
const scope = typeof window === 'undefined' ? null : window;
|
|
1221
|
+
if (!scope) return 0;
|
|
1222
|
+
const next = (Number(scope[ARRIVAL_KEY]) || 0) + 1;
|
|
1223
|
+
scope[ARRIVAL_KEY] = next;
|
|
1224
|
+
return next;
|
|
1225
|
+
} catch {
|
|
1226
|
+
return 0;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function neighbourDockVisible() {
|
|
1231
|
+
try {
|
|
1232
|
+
for (const node of document.querySelectorAll('[data-codex-advisor-dock="right"]')) {
|
|
1233
|
+
const rect = node.getBoundingClientRect();
|
|
1234
|
+
if (rect.width > 0 && rect.height > 0) return true;
|
|
1235
|
+
}
|
|
1236
|
+
} catch {
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
return false;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
function measureRightDock(arrival, wasHereFirst) {
|
|
1213
1243
|
const holder = document.querySelector('[data-slot="main.conversation"]');
|
|
1214
1244
|
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
1215
1245
|
if (!column) return null;
|
|
@@ -1278,11 +1308,34 @@ window.__ModuleLoader__.load({
|
|
|
1278
1308
|
const floored = span < 240;
|
|
1279
1309
|
let stackTop = contentTop;
|
|
1280
1310
|
try {
|
|
1281
|
-
// Other plugins place their own right docks
|
|
1282
|
-
//
|
|
1311
|
+
// Other plugins place their own right docks on the same anchor. Deferring to
|
|
1312
|
+
// every overlapping neighbour makes two docks chase each other downwards, so
|
|
1313
|
+
// the rule is arrival order: yield to a neighbour only when it arrived first.
|
|
1314
|
+
// A neighbour that arrived later stacks below us instead. Neighbours that do
|
|
1315
|
+
// not publish an arrival number fall back to position: yield when it already
|
|
1316
|
+
// sits in this slot, and on an exact tie let the earlier id win so the very
|
|
1317
|
+
// first paint cannot deadlock.
|
|
1318
|
+
const MY_DOCK_ID = 'ustc-quota';
|
|
1283
1319
|
for (const node of document.querySelectorAll('[data-codex-advisor-dock="right"]')) {
|
|
1284
1320
|
const rect = node.getBoundingClientRect();
|
|
1285
1321
|
if (rect.height <= 0 || rect.width <= 0) continue;
|
|
1322
|
+
const NEIGHBOUR_DOCK_ID = 'codex-advisor';
|
|
1323
|
+
const neighbourArrival = Number(node.getAttribute('data-codex-advisor-dock-order')) || 0;
|
|
1324
|
+
let yieldToNeighbour;
|
|
1325
|
+
if (neighbourArrival > 0 && arrival > 0) {
|
|
1326
|
+
yieldToNeighbour = neighbourArrival < arrival;
|
|
1327
|
+
} else if (wasHereFirst && rect.top > contentTop) {
|
|
1328
|
+
// We were already on the right when the neighbour appeared and it sits
|
|
1329
|
+
// below us: never chase it. If instead it shares our slot (a neighbour
|
|
1330
|
+
// that has not adopted this contract yet) fall through to the position
|
|
1331
|
+
// rule, because two overlapping cards are worse than a wrong order.
|
|
1332
|
+
yieldToNeighbour = false;
|
|
1333
|
+
} else {
|
|
1334
|
+
const startsAbove = rect.top < contentTop - 1;
|
|
1335
|
+
const tiedAndEarlier = Math.abs(rect.top - contentTop) <= 1 && NEIGHBOUR_DOCK_ID < MY_DOCK_ID;
|
|
1336
|
+
yieldToNeighbour = startsAbove || tiedAndEarlier;
|
|
1337
|
+
}
|
|
1338
|
+
if (!yieldToNeighbour) continue;
|
|
1286
1339
|
if (rect.bottom > stackTop && rect.top < columnRect.bottom) {
|
|
1287
1340
|
stackTop = Math.max(stackTop, Math.round(rect.bottom) + DOCK_GAP);
|
|
1288
1341
|
}
|
|
@@ -1307,6 +1360,18 @@ window.__ModuleLoader__.load({
|
|
|
1307
1360
|
const [box, setBox] = React.useState(null);
|
|
1308
1361
|
const activeRef = React.useRef(active);
|
|
1309
1362
|
activeRef.current = active;
|
|
1363
|
+
const arrivalRef = React.useRef(0);
|
|
1364
|
+
const firstRef = React.useRef(false);
|
|
1365
|
+
React.useEffect(() => {
|
|
1366
|
+
if (active) {
|
|
1367
|
+
firstRef.current = !neighbourDockVisible();
|
|
1368
|
+
arrivalRef.current = claimDockArrival();
|
|
1369
|
+
setBox(measureRightDock(arrivalRef.current, firstRef.current));
|
|
1370
|
+
} else {
|
|
1371
|
+
arrivalRef.current = 0;
|
|
1372
|
+
firstRef.current = false;
|
|
1373
|
+
}
|
|
1374
|
+
}, [active]);
|
|
1310
1375
|
React.useEffect(() => {
|
|
1311
1376
|
let frame = 0;
|
|
1312
1377
|
let observer = null;
|
|
@@ -1321,7 +1386,7 @@ window.__ModuleLoader__.load({
|
|
|
1321
1386
|
observer = new ResizeObserver(schedule);
|
|
1322
1387
|
observer.observe(column);
|
|
1323
1388
|
}
|
|
1324
|
-
setBox(measureRightDock());
|
|
1389
|
+
setBox(measureRightDock(arrivalRef.current, firstRef.current));
|
|
1325
1390
|
};
|
|
1326
1391
|
function schedule() {
|
|
1327
1392
|
if (!frame) frame = window.requestAnimationFrame(measure);
|
|
@@ -1340,6 +1405,7 @@ window.__ModuleLoader__.load({
|
|
|
1340
1405
|
const shown = active && box !== null;
|
|
1341
1406
|
return h('div', {
|
|
1342
1407
|
'data-ustc-quota-dock': 'right',
|
|
1408
|
+
'data-ustc-quota-dock-order': arrivalRef.current || undefined,
|
|
1343
1409
|
style: {
|
|
1344
1410
|
position: 'fixed',
|
|
1345
1411
|
top: box ? box.top : 0,
|
package/index.js
CHANGED
|
@@ -22,7 +22,7 @@ const ROUTE_PATH = '/plugins/dsh-ustc-quota/snapshot';
|
|
|
22
22
|
const UPDATE_PATH = '/plugins/dsh-ustc-quota/update';
|
|
23
23
|
const UPDATE_APPLY_PATH = '/plugins/dsh-ustc-quota/update/apply';
|
|
24
24
|
const UPDATE_TOKEN_TTL_MS = 30 * 60 * 1000;
|
|
25
|
-
const PLUGIN_VERSION = '1.1.
|
|
25
|
+
const PLUGIN_VERSION = '1.1.58';
|
|
26
26
|
const KEY_INFO_PATH = 'key/info';
|
|
27
27
|
const USER_INFO_PATH = 'user/info';
|
|
28
28
|
const DISCOVERY_TTL_MS = 30000;
|
package/package.json
CHANGED