dsh-ustc-quota 1.1.24 → 1.1.26

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 CHANGED
@@ -107,9 +107,10 @@ key-c 8.7/30 29% 8.7/70 12% 11.1/100 11%
107
107
 
108
108
  ## 面板位置
109
109
 
110
- - 卡片默认在左侧边栏底部。**鼠标移到卡片上时,标题左边的品牌图标会变成方向图标**(`→` 移到右侧、`←` 移回左侧),点一下即可换边;移开鼠标图标复原。选择会记住,重启后保持。
111
- - 右侧位置停在**聊天内容与轮次导航条之间的空白**:与聊天内容、导航条、上方分隔线各留 12px,宽度随空白自适应,不压住对话正文、不遮挡右侧原生按钮、不侵入轮次导航条。底色用左侧边栏的底色(`--dsw-specific-sidebar-fill`),阴影与左侧一致。拖动对话边界或开关任一侧边栏时,卡片跟着走。
112
- - 换边不重新加载:两处卡片共用同一份已取到的数据,切换时直接显示,之后在后台刷新。
110
+ - 卡片默认在左侧边栏底部。**鼠标移到卡片上时,标题左边的品牌图标会变成方向图标**(布局图示,标出卡片将要去的那一侧),点一下即可换边;移开鼠标图标复原。选择会记住,重启后保持。
111
+ - 右侧位置会在对话区右侧**预留一条槽**:插件给对话列加右侧内边距,正文与轮次导航条整体左移,卡片占住这条槽——因此不遮挡正文、不遮挡轮次导航条、也不遮挡右侧原生按钮。上沿从「对话 / 轨迹 / 看板」选项卡下的分隔线以下 6px 开始。
112
+ - 窄窗口或打开侧栏时槽宽自动收窄(下限 140px),卡片始终可见;如果连正文最小宽度都不够,则允许卡片比常规更窄,而不是消失。
113
+ - 换边不重新加载:两处卡片共用同一份已取到的数据。底色用左侧边栏的底色(`--dsw-specific-sidebar-fill`),阴影与左侧一致。
113
114
  ## 更新
114
115
 
115
116
  - 标题「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.24';
14
+ const CLIENT_VERSION = '1.1.26';
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`;
@@ -1134,55 +1134,32 @@ window.__ModuleLoader__.load({
1134
1134
  // measures the conversation column and pins itself into the blank strip
1135
1135
  // between the chat content and the turn navigator, so it follows the
1136
1136
  // conversation when either side is dragged or toggled.
1137
- const DOCK_GAP = 12;
1138
- const DOCK_MIN_WIDTH = 180;
1139
- const DOCK_MAX_WIDTH = 420;
1137
+ const DOCK_GAP = 6;
1138
+ const DOCK_MIN_WIDTH = 200;
1139
+ const DOCK_MAX_WIDTH = 340;
1140
+ const DOCK_FLOOR_WIDTH = 140;
1141
+ const DOCK_TRANSCRIPT_FLOOR = 360;
1140
1142
 
1141
1143
  function measureRightDock() {
1142
1144
  const holder = document.querySelector('[data-slot="main.conversation"]');
1143
1145
  const column = holder ? (holder.firstElementChild || holder) : null;
1144
1146
  if (!column) return null;
1145
1147
  const columnRect = column.getBoundingClientRect();
1146
- if (columnRect.width < 240 || columnRect.height < 160) return null;
1147
-
1148
- // The flow container spans the whole column; the visible conversation column is
1149
- // the widest chat row inside it, so measure the rows instead of the container.
1150
- let contentRight = null;
1151
- const flowHolder = document.querySelector('[data-slot="conversation.chat.flow"]');
1152
- if (flowHolder) {
1153
- const rows = flowHolder.querySelectorAll(':scope > *');
1154
- for (const row of rows) {
1155
- const rect = row.getBoundingClientRect();
1156
- if (rect.width < 80 || rect.height < 8) continue;
1157
- contentRight = contentRight === null ? rect.right : Math.max(contentRight, rect.right);
1158
- }
1159
- }
1160
- if (contentRight === null) {
1161
- const flow = flowHolder ? (flowHolder.firstElementChild || flowHolder) : null;
1162
- const flowRect = flow ? flow.getBoundingClientRect() : null;
1163
- if (flowRect && flowRect.width > 0) contentRight = flowRect.right;
1164
- }
1165
-
1166
- // The turn navigator is a rail of per-turn buttons at the column's right edge.
1167
- let navLeft = null;
1168
- for (const button of document.querySelectorAll('button[aria-label]')) {
1169
- const label = button.getAttribute('aria-label') || '';
1170
- if (!/turnNavigation|轮次|跳转/i.test(label)) continue;
1171
- const rect = button.getBoundingClientRect();
1172
- if (rect.width > 0 && rect.height > 0) navLeft = navLeft === null ? rect.left : Math.min(navLeft, rect.left);
1173
- }
1174
- if (navLeft === null) navLeft = columnRect.right - 26;
1175
-
1176
- let width = DOCK_MAX_WIDTH;
1177
- if (contentRight !== null && contentRight < navLeft - DOCK_MIN_WIDTH) {
1178
- const available = navLeft - contentRight - DOCK_GAP * 2;
1179
- width = Math.min(DOCK_MAX_WIDTH, Math.max(DOCK_MIN_WIDTH, Math.round(available)));
1148
+ if (columnRect.width < 220 || columnRect.height < 160) return null;
1149
+
1150
+ // Reserve a strip on the right of the conversation box instead of overlapping
1151
+ // it: DSH centres the transcript and the turn rail inside the padding box, so
1152
+ // padding-right slides both of them left and the dock owns the strip.
1153
+ const columnWidth = Math.round(columnRect.width);
1154
+ let width = Math.round(columnWidth * 0.26);
1155
+ width = Math.min(DOCK_MAX_WIDTH, Math.max(DOCK_MIN_WIDTH, width));
1156
+ if (columnWidth - (width + DOCK_GAP * 2) < DOCK_TRANSCRIPT_FLOOR) {
1157
+ width = Math.max(DOCK_FLOOR_WIDTH, columnWidth - DOCK_TRANSCRIPT_FLOOR - DOCK_GAP * 2);
1180
1158
  }
1181
- width = Math.max(DOCK_MIN_WIDTH, Math.min(width, Math.round(columnRect.width - DOCK_GAP * 2)));
1159
+ const reserve = width + DOCK_GAP * 2;
1182
1160
 
1183
- // Vertical bound: the dock may never cross or touch the separator under the
1184
- // conversation tab strip (对话 / 轨迹 / 看板 / Codex).
1185
- let contentTop = Math.round(columnRect.top) + 16;
1161
+ // Vertical bound: never cross or touch the separator under the tab strip.
1162
+ let contentTop = Math.round(columnRect.top) + DOCK_GAP;
1186
1163
  const tabStrip = document.querySelector('[data-conversation-tabs]');
1187
1164
  if (tabStrip) {
1188
1165
  const row = tabStrip.parentElement || tabStrip;
@@ -1191,13 +1168,12 @@ window.__ModuleLoader__.load({
1191
1168
  contentTop = Math.max(contentTop, Math.round(rowRect.bottom) + DOCK_GAP);
1192
1169
  }
1193
1170
  }
1194
- const bottomEdge = Math.round(columnRect.bottom);
1195
1171
 
1196
1172
  return {
1197
1173
  top: contentTop,
1198
- right: Math.max(8, Math.round(window.innerWidth - navLeft) + DOCK_GAP),
1199
1174
  width,
1200
- maxHeight: Math.max(120, bottomEdge - contentTop - DOCK_GAP / 2),
1175
+ reserve,
1176
+ maxHeight: Math.max(120, Math.round(columnRect.bottom) - contentTop - DOCK_GAP),
1201
1177
  };
1202
1178
  }
1203
1179
 
@@ -1234,14 +1210,28 @@ window.__ModuleLoader__.load({
1234
1210
  if (frame) window.cancelAnimationFrame(frame);
1235
1211
  };
1236
1212
  }, []);
1213
+ const reserve = box ? box.reserve : 0;
1214
+ React.useEffect(() => {
1215
+ if (!active || !reserve) return undefined;
1216
+ const holder = document.querySelector('[data-slot="main.conversation"]');
1217
+ const column = holder ? (holder.firstElementChild || holder) : null;
1218
+ if (!column) return undefined;
1219
+ const saved = column.style.getPropertyValue('padding-right');
1220
+ const priority = column.style.getPropertyPriority('padding-right');
1221
+ column.style.setProperty('padding-right', reserve + 'px', 'important');
1222
+ return () => {
1223
+ if (saved) column.style.setProperty('padding-right', saved, priority);
1224
+ else column.style.removeProperty('padding-right');
1225
+ };
1226
+ }, [active, reserve]);
1237
1227
  const shown = active && box !== null;
1238
1228
  return h('div', {
1239
1229
  'data-ustc-quota-dock': 'right',
1240
1230
  style: {
1241
1231
  position: 'fixed',
1242
1232
  top: box ? box.top : 0,
1243
- right: box ? box.right : 0,
1244
- width: box ? box.width : DOCK_MAX_WIDTH,
1233
+ right: DOCK_GAP,
1234
+ width: box ? box.width : DOCK_MIN_WIDTH,
1245
1235
  maxHeight: box ? box.maxHeight : 0,
1246
1236
  overflow: 'visible',
1247
1237
  display: shown ? 'flex' : 'none',
@@ -1252,7 +1242,6 @@ window.__ModuleLoader__.load({
1252
1242
  },
1253
1243
  }, h(QuotaStrip, Object.assign({}, props, { placement: 'right', wide: true, active, visible: active })));
1254
1244
  }
1255
-
1256
1245
  function QuotaStrip(props) {
1257
1246
  const t = typeof props.t === 'function' ? props.t : fallbackT;
1258
1247
  const placement = props.placement === 'right' ? 'right' : 'left';
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.24';
25
+ const PLUGIN_VERSION = '1.1.26';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ustc-quota",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Live 3h/12h/24h USTC token quota card in the DSH sidebar (works with the USTC TokenWorks distribution).",