dsh-ustc-quota 1.1.40 → 1.1.46
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 +112 -113
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ key-c 8.7/30 29% 8.7/70 12% 11.1/100 11%
|
|
|
108
108
|
## 面板位置
|
|
109
109
|
|
|
110
110
|
- 卡片默认在左侧边栏底部。**鼠标移到卡片上时,标题左边的品牌图标会变成方向图标**(布局图示,标出卡片将要去的那一侧),点一下即可换边;移开鼠标图标复原。选择会记住,重启后保持。
|
|
111
|
-
-
|
|
111
|
+
- 排版自适应:**只在右侧并且卡片宽度 ≥ 340px** 时才用单行式(每个窗口一行「数值 · 进度条 · 百分比」,两端对齐、重置时间与窗口名同行)。左侧边栏与窄卡片始终沿用原紧凑双行式,不因宽度变化而跳动。
|
|
112
112
|
- 右侧位置会在对话区右侧**预留一条槽**:插件给对话列加右侧内边距(约列宽的 26%,封顶 34%),正文与轮次导航条整体左移,卡片占住这条槽——因此不遮挡正文、不遮挡轮次导航条、也不遮挡右侧原生按钮。上沿从「对话 / 轨迹 / 看板」选项卡下的分隔线以下 6px 开始。
|
|
113
113
|
- 窄窗口或打开侧栏时槽宽自动收窄(下限 140px),卡片始终可见;如果连正文最小宽度都不够,则允许卡片比常规更窄,而不是消失。
|
|
114
114
|
- 换边不重新加载:两处卡片共用同一份已取到的数据。底色用左侧边栏的底色(`--dsw-specific-sidebar-fill`),阴影与左侧一致。
|
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.46';
|
|
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`;
|
|
@@ -477,7 +477,7 @@ window.__ModuleLoader__.load({
|
|
|
477
477
|
legendRow: {
|
|
478
478
|
display: 'grid',
|
|
479
479
|
gridTemplateColumns: 'var(--ustc-key-col, 36px) repeat(3, minmax(0, 1fr))',
|
|
480
|
-
columnGap:
|
|
480
|
+
columnGap: 'var(--ustc-gap, 4px)',
|
|
481
481
|
alignItems: 'center',
|
|
482
482
|
minWidth: 0,
|
|
483
483
|
paddingBottom: 4,
|
|
@@ -486,13 +486,20 @@ window.__ModuleLoader__.load({
|
|
|
486
486
|
keyRow: {
|
|
487
487
|
display: 'grid',
|
|
488
488
|
gridTemplateColumns: 'var(--ustc-key-col, 36px) repeat(3, minmax(0, 1fr))',
|
|
489
|
-
columnGap:
|
|
489
|
+
columnGap: 'var(--ustc-gap, 4px)',
|
|
490
490
|
alignItems: 'center',
|
|
491
491
|
minWidth: 0,
|
|
492
492
|
paddingTop: 6,
|
|
493
493
|
paddingBottom: 2,
|
|
494
494
|
},
|
|
495
495
|
legendCell: {
|
|
496
|
+
minWidth: 0,
|
|
497
|
+
display: 'flex',
|
|
498
|
+
flexDirection: 'column',
|
|
499
|
+
alignItems: 'center',
|
|
500
|
+
gap: 0,
|
|
501
|
+
},
|
|
502
|
+
legendCellWide: {
|
|
496
503
|
minWidth: 0,
|
|
497
504
|
display: 'flex',
|
|
498
505
|
flexDirection: 'row',
|
|
@@ -515,7 +522,7 @@ window.__ModuleLoader__.load({
|
|
|
515
522
|
paddingLeft: 2,
|
|
516
523
|
},
|
|
517
524
|
legendReset: {
|
|
518
|
-
|
|
525
|
+
width: '100%',
|
|
519
526
|
fontSize: 8,
|
|
520
527
|
color: 'var(--dsw-alias-label-secondary)',
|
|
521
528
|
whiteSpace: 'nowrap',
|
|
@@ -562,6 +569,12 @@ window.__ModuleLoader__.load({
|
|
|
562
569
|
cursor: 'help',
|
|
563
570
|
},
|
|
564
571
|
cell: {
|
|
572
|
+
minWidth: 0,
|
|
573
|
+
display: 'flex',
|
|
574
|
+
flexDirection: 'column',
|
|
575
|
+
gap: 2,
|
|
576
|
+
},
|
|
577
|
+
cellWide: {
|
|
565
578
|
minWidth: 0,
|
|
566
579
|
display: 'flex',
|
|
567
580
|
flexDirection: 'row',
|
|
@@ -585,8 +598,17 @@ window.__ModuleLoader__.load({
|
|
|
585
598
|
minWidth: 0,
|
|
586
599
|
},
|
|
587
600
|
value: {
|
|
601
|
+
minWidth: 0,
|
|
602
|
+
fontSize: 10.5,
|
|
603
|
+
fontWeight: 650,
|
|
604
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
605
|
+
whiteSpace: 'nowrap',
|
|
606
|
+
overflow: 'hidden',
|
|
607
|
+
textOverflow: 'ellipsis',
|
|
608
|
+
},
|
|
609
|
+
valueWide: {
|
|
588
610
|
flex: '0 0 auto',
|
|
589
|
-
width:
|
|
611
|
+
width: 'var(--ustc-value-w, 44px)',
|
|
590
612
|
textAlign: 'right',
|
|
591
613
|
fontSize: 10,
|
|
592
614
|
fontWeight: 650,
|
|
@@ -595,7 +617,7 @@ window.__ModuleLoader__.load({
|
|
|
595
617
|
overflow: 'hidden',
|
|
596
618
|
textOverflow: 'ellipsis',
|
|
597
619
|
},
|
|
598
|
-
|
|
620
|
+
percentWide: {
|
|
599
621
|
flex: '0 0 auto',
|
|
600
622
|
width: 24,
|
|
601
623
|
textAlign: 'right',
|
|
@@ -603,6 +625,12 @@ window.__ModuleLoader__.load({
|
|
|
603
625
|
color: 'var(--dsw-alias-label-secondary)',
|
|
604
626
|
whiteSpace: 'nowrap',
|
|
605
627
|
},
|
|
628
|
+
percent: {
|
|
629
|
+
flex: '0 0 auto',
|
|
630
|
+
fontSize: 8.5,
|
|
631
|
+
color: 'var(--dsw-alias-label-secondary)',
|
|
632
|
+
whiteSpace: 'nowrap',
|
|
633
|
+
},
|
|
606
634
|
bar: {
|
|
607
635
|
position: 'relative',
|
|
608
636
|
height: 6,
|
|
@@ -1166,72 +1194,6 @@ window.__ModuleLoader__.load({
|
|
|
1166
1194
|
const DOCK_TRANSCRIPT_FLOOR = 360;
|
|
1167
1195
|
|
|
1168
1196
|
|
|
1169
|
-
// When the blank strip beside the transcript is too narrow, free room on the
|
|
1170
|
-
// right instead of letting the card shrink: pad the conversation column and pin
|
|
1171
|
-
// the transcript to the left edge of that padded box.
|
|
1172
|
-
const DOCK_COMFORT = 220;
|
|
1173
|
-
let pushedColumn = null;
|
|
1174
|
-
let pushedTarget = null;
|
|
1175
|
-
let pushedSaved = null;
|
|
1176
|
-
let padState = 0;
|
|
1177
|
-
|
|
1178
|
-
function transcriptOf() {
|
|
1179
|
-
const flow = document.querySelector('[data-slot="conversation.chat.flow"]');
|
|
1180
|
-
if (!flow) return null;
|
|
1181
|
-
let node = flow;
|
|
1182
|
-
for (let i = 0; i < 6 && node; i += 1) {
|
|
1183
|
-
const style = getComputedStyle(node);
|
|
1184
|
-
if (style.marginLeft === 'auto' || style.marginRight === 'auto') return node;
|
|
1185
|
-
node = node.parentElement;
|
|
1186
|
-
}
|
|
1187
|
-
return flow.firstElementChild || flow;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
function pushConversation(reserve) {
|
|
1191
|
-
const holder = document.querySelector('[data-slot="main.conversation"]');
|
|
1192
|
-
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
1193
|
-
if (!column) return;
|
|
1194
|
-
const target = transcriptOf();
|
|
1195
|
-
if (!target) return;
|
|
1196
|
-
if (pushedColumn !== column) {
|
|
1197
|
-
releaseConversation();
|
|
1198
|
-
pushedColumn = column;
|
|
1199
|
-
pushedSaved = {
|
|
1200
|
-
pad: column.style.getPropertyValue('padding-right'),
|
|
1201
|
-
padPriority: column.style.getPropertyPriority('padding-right'),
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
if (pushedTarget !== target) {
|
|
1205
|
-
if (pushedTarget) {
|
|
1206
|
-
pushedTarget.style.removeProperty('margin-left');
|
|
1207
|
-
pushedTarget.style.removeProperty('margin-right');
|
|
1208
|
-
}
|
|
1209
|
-
pushedTarget = target;
|
|
1210
|
-
target.style.setProperty('margin-left', '0px', 'important');
|
|
1211
|
-
target.style.setProperty('margin-right', 'auto', 'important');
|
|
1212
|
-
}
|
|
1213
|
-
const wanted = reserve + 'px';
|
|
1214
|
-
if (column.style.getPropertyValue('padding-right') !== wanted) {
|
|
1215
|
-
column.style.setProperty('padding-right', wanted, 'important');
|
|
1216
|
-
}
|
|
1217
|
-
padState = reserve;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
function releaseConversation() {
|
|
1221
|
-
if (pushedTarget) {
|
|
1222
|
-
pushedTarget.style.removeProperty('margin-left');
|
|
1223
|
-
pushedTarget.style.removeProperty('margin-right');
|
|
1224
|
-
pushedTarget = null;
|
|
1225
|
-
}
|
|
1226
|
-
if (pushedColumn && pushedSaved) {
|
|
1227
|
-
if (pushedSaved.pad) pushedColumn.style.setProperty('padding-right', pushedSaved.pad, pushedSaved.padPriority);
|
|
1228
|
-
else pushedColumn.style.removeProperty('padding-right');
|
|
1229
|
-
}
|
|
1230
|
-
pushedColumn = null;
|
|
1231
|
-
pushedSaved = null;
|
|
1232
|
-
padState = 0;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
1197
|
function measureRightDock() {
|
|
1236
1198
|
const holder = document.querySelector('[data-slot="main.conversation"]');
|
|
1237
1199
|
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
@@ -1251,15 +1213,18 @@ window.__ModuleLoader__.load({
|
|
|
1251
1213
|
}
|
|
1252
1214
|
if (boundaryRight === null) boundaryRight = columnRect.left + columnRect.width * 0.5 + 24;
|
|
1253
1215
|
|
|
1254
|
-
// Right bound:
|
|
1255
|
-
//
|
|
1216
|
+
// Right bound: the turn rail when there are turns; otherwise the collapsed
|
|
1217
|
+
// right-sidebar icon rail, which only counts when it sits at the far right.
|
|
1256
1218
|
let rightLimit = columnRect.right;
|
|
1257
1219
|
for (const button of document.querySelectorAll('button[aria-label]')) {
|
|
1258
1220
|
const label = button.getAttribute('aria-label') || '';
|
|
1259
|
-
|
|
1221
|
+
const isTurn = /turnNavigation|轮次|跳转/i.test(label);
|
|
1222
|
+
const isRail = /右侧边栏/.test(label);
|
|
1223
|
+
if (!isTurn && !isRail) continue;
|
|
1260
1224
|
const rect = button.getBoundingClientRect();
|
|
1261
1225
|
if (rect.width <= 0 || rect.height <= 0) continue;
|
|
1262
1226
|
if (rect.left <= boundaryRight) continue;
|
|
1227
|
+
if (isRail && columnRect.right - rect.left > 72) continue;
|
|
1263
1228
|
if (rect.left < rightLimit) rightLimit = rect.left;
|
|
1264
1229
|
}
|
|
1265
1230
|
if (rightLimit > columnRect.right) rightLimit = columnRect.right;
|
|
@@ -1311,20 +1276,7 @@ window.__ModuleLoader__.load({
|
|
|
1311
1276
|
observer = new ResizeObserver(schedule);
|
|
1312
1277
|
observer.observe(column);
|
|
1313
1278
|
}
|
|
1314
|
-
|
|
1315
|
-
if (activeRef.current && next) {
|
|
1316
|
-
const natural = next.naturalSpan;
|
|
1317
|
-
let pad = padState;
|
|
1318
|
-
if (natural < DOCK_COMFORT - 8) pad = pad + (DOCK_COMFORT - natural);
|
|
1319
|
-
else if (natural > DOCK_COMFORT + 24) pad = Math.max(0, pad - (natural - DOCK_COMFORT));
|
|
1320
|
-
const limit = Math.max(0, next.columnWidth - 340);
|
|
1321
|
-
pad = Math.min(Math.round(pad), limit);
|
|
1322
|
-
if (pad > 0) pushConversation(pad);
|
|
1323
|
-
else releaseConversation();
|
|
1324
|
-
} else {
|
|
1325
|
-
releaseConversation();
|
|
1326
|
-
}
|
|
1327
|
-
setBox(next);
|
|
1279
|
+
setBox(measureRightDock());
|
|
1328
1280
|
};
|
|
1329
1281
|
function schedule() {
|
|
1330
1282
|
if (!frame) frame = window.requestAnimationFrame(measure);
|
|
@@ -1364,6 +1316,9 @@ window.__ModuleLoader__.load({
|
|
|
1364
1316
|
const position = usePanelPosition();
|
|
1365
1317
|
const active = props.active !== false;
|
|
1366
1318
|
const [cardHovered, setCardHovered] = React.useState(false);
|
|
1319
|
+
const [narrow, setNarrow] = React.useState(false);
|
|
1320
|
+
// The one-line layout needs ~340px of card width; below that keep the compact card.
|
|
1321
|
+
const wideLayout = placement === 'right' && !narrow;
|
|
1367
1322
|
const [markHovered, setMarkHovered] = React.useState(false);
|
|
1368
1323
|
const activeRef = React.useRef(active);
|
|
1369
1324
|
activeRef.current = active;
|
|
@@ -1549,6 +1504,19 @@ window.__ModuleLoader__.load({
|
|
|
1549
1504
|
};
|
|
1550
1505
|
}, [load]);
|
|
1551
1506
|
|
|
1507
|
+
React.useLayoutEffect(() => {
|
|
1508
|
+
const root = rootRef.current;
|
|
1509
|
+
if (!root || typeof ResizeObserver !== 'function') return undefined;
|
|
1510
|
+
const observer = new ResizeObserver(() => {
|
|
1511
|
+
// Border-box width: the padding-free content box is always smaller and would
|
|
1512
|
+
// misfire the threshold by the card's own insets.
|
|
1513
|
+
const width = root.getBoundingClientRect().width;
|
|
1514
|
+
setNarrow(width < 340);
|
|
1515
|
+
});
|
|
1516
|
+
observer.observe(root);
|
|
1517
|
+
return () => { observer.disconnect(); };
|
|
1518
|
+
}, [props.wide]);
|
|
1519
|
+
|
|
1552
1520
|
React.useLayoutEffect(() => {
|
|
1553
1521
|
const root = rootRef.current;
|
|
1554
1522
|
if (!root) return undefined;
|
|
@@ -1748,7 +1716,7 @@ window.__ModuleLoader__.load({
|
|
|
1748
1716
|
...candidates.map((window) => `${window.id}: ${window.resetAt ? formatFull(window.resetAt) : t('notConfigured')}`),
|
|
1749
1717
|
].join('\n')
|
|
1750
1718
|
: label;
|
|
1751
|
-
return h('div', { style: STYLE.legendCell, title },
|
|
1719
|
+
return h('div', { style: wideLayout ? STYLE.legendCellWide : STYLE.legendCell, title },
|
|
1752
1720
|
h('div', { style: STYLE.legendName }, label),
|
|
1753
1721
|
h('div', { style: STYLE.legendReset }, resetText)
|
|
1754
1722
|
);
|
|
@@ -1805,30 +1773,44 @@ window.__ModuleLoader__.load({
|
|
|
1805
1773
|
if (window.source) titleParts.push(sourceLabel(window.source));
|
|
1806
1774
|
if (isStale) titleParts.push(t('stale'));
|
|
1807
1775
|
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1776
|
+
const barNode = (style) => h('div', {
|
|
1777
|
+
style: { ...style, opacity: isStale ? 0.55 : 1 },
|
|
1778
|
+
role: 'progressbar',
|
|
1779
|
+
'aria-label': label,
|
|
1780
|
+
'aria-valuemin': 0,
|
|
1781
|
+
'aria-valuemax': 100,
|
|
1782
|
+
'aria-valuenow': ratio === null ? undefined : Math.round(Math.min(1, Math.max(0, ratio)) * 100),
|
|
1783
|
+
'aria-valuetext': percent || valueText,
|
|
1784
|
+
},
|
|
1785
|
+
h('div', { style: STYLE.track, 'aria-hidden': true }),
|
|
1786
|
+
h('div', {
|
|
1787
|
+
style: {
|
|
1788
|
+
position: 'relative',
|
|
1789
|
+
height: '100%',
|
|
1790
|
+
width: fillWidth,
|
|
1791
|
+
background: usedColor,
|
|
1792
|
+
borderRadius: 999,
|
|
1793
|
+
transition: 'width 200ms ease',
|
|
1818
1794
|
},
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1795
|
+
})
|
|
1796
|
+
);
|
|
1797
|
+
const valueNode = (style) => h('span', { style }, `${isStale ? '≈ ' : ''}${valueText}`);
|
|
1798
|
+
const percentNode = (style) => (percent ? h('span', { style: { ...style, color: percentColor } }, percent) : null);
|
|
1799
|
+
|
|
1800
|
+
if (wideLayout) {
|
|
1801
|
+
return h('div', { style: STYLE.cellWide, title: titleParts.join(' · ') },
|
|
1802
|
+
valueNode(STYLE.valueWide),
|
|
1803
|
+
barNode(STYLE.inlineBar),
|
|
1804
|
+
percentNode(STYLE.percentWide)
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
return h('div', { style: STYLE.cell, title: titleParts.join(' · ') },
|
|
1809
|
+
h('div', { style: STYLE.valueLine },
|
|
1810
|
+
valueNode(STYLE.value),
|
|
1811
|
+
percentNode(STYLE.percent)
|
|
1830
1812
|
),
|
|
1831
|
-
|
|
1813
|
+
barNode(STYLE.bar)
|
|
1832
1814
|
);
|
|
1833
1815
|
}
|
|
1834
1816
|
|
|
@@ -1882,7 +1864,24 @@ window.__ModuleLoader__.load({
|
|
|
1882
1864
|
|
|
1883
1865
|
const failed = keys.filter((key) => key.ok === false);
|
|
1884
1866
|
const keyColumnWidth = keyColumnWidthFor(keys, activeProvider, defaultProvider);
|
|
1885
|
-
|
|
1867
|
+
// Align the bars by sizing the value column to the longest value on screen.
|
|
1868
|
+
let valueChars = 3;
|
|
1869
|
+
for (const key of keys) {
|
|
1870
|
+
for (const window of (key.windows || [])) {
|
|
1871
|
+
const usedValue = typeof window.used === 'number' && Number.isFinite(window.used) ? window.used : null;
|
|
1872
|
+
const limitValue = typeof window.limit === 'number' && Number.isFinite(window.limit) ? window.limit : null;
|
|
1873
|
+
const text = usedValue === null
|
|
1874
|
+
? '—'
|
|
1875
|
+
: `${formatNumber(usedValue)}/${limitValue === null ? '—' : formatNumber(limitValue)}`;
|
|
1876
|
+
if (text.length > valueChars) valueChars = text.length;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
const tableStyle = {
|
|
1880
|
+
...STYLE.table,
|
|
1881
|
+
'--ustc-key-col': `${keyColumnWidth}px`,
|
|
1882
|
+
'--ustc-gap': wideLayout ? '16px' : '4px',
|
|
1883
|
+
'--ustc-value-w': `${Math.min(12, valueChars + 0.5)}ch`,
|
|
1884
|
+
};
|
|
1886
1885
|
const versionTitle = updateInfo && updateInfo.updateAvailable
|
|
1887
1886
|
? `${t('updateAvailable')} v${updateInfo.latestVersion}`
|
|
1888
1887
|
: updateChecking
|
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.46';
|
|
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