dsh-codearts 1.3.0 → 1.4.0
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/CHANGELOG.md +598 -559
- package/lib/{auth-CF9XHMX-.mjs → auth-Ch0vYSAo.mjs} +327 -48
- package/lib/bin.mjs +2 -2
- package/lib/client/index.d.cts +15 -0
- package/lib/client/index.js +454 -176
- package/lib/index.d.mts +71 -4
- package/lib/index.mjs +214 -80
- package/lib/keeper-main.mjs +20 -9
- package/lib/{version-CJTTrulR.mjs → version-BjBwEMks.mjs} +3 -3
- package/package.json +125 -125
- package/lib/{keeper-P4FkDUEd.mjs → keeper-MHeAp_eV.mjs} +1 -1
package/lib/client/index.js
CHANGED
|
@@ -24,38 +24,105 @@ function stripModelSuffixes(name) {
|
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/client/panel-switch.ts
|
|
27
|
+
/** 一个纯内存的布尔开关 + 订阅表;不持久化,真实值来自 `/api/codearts/dock`。 */
|
|
28
|
+
function createWantedSwitch(initial) {
|
|
29
|
+
let wanted = initial;
|
|
30
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
31
|
+
return {
|
|
32
|
+
get: () => wanted,
|
|
33
|
+
set(next) {
|
|
34
|
+
if (wanted === next) return;
|
|
35
|
+
wanted = next;
|
|
36
|
+
for (const listener of [...listeners]) try {
|
|
37
|
+
listener();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error("[dsh-codearts] entry switch listener failed:", error);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
subscribe(listener) {
|
|
43
|
+
listeners.add(listener);
|
|
44
|
+
return () => {
|
|
45
|
+
listeners.delete(listener);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** 侧边栏图标列里的入口(缺省关)。 */
|
|
51
|
+
const sidebarEntrySwitch = createWantedSwitch(false);
|
|
52
|
+
/** 设置左侧导航里的入口(缺省开)。 */
|
|
53
|
+
const settingsEntrySwitch = createWantedSwitch(true);
|
|
54
|
+
const sidebarPanelWanted = sidebarEntrySwitch.get;
|
|
55
|
+
const setSidebarPanelWanted = sidebarEntrySwitch.set;
|
|
56
|
+
const subscribeSidebarPanelWanted = sidebarEntrySwitch.subscribe;
|
|
57
|
+
const settingsEntryWanted = settingsEntrySwitch.get;
|
|
58
|
+
const setSettingsEntryWanted = settingsEntrySwitch.set;
|
|
59
|
+
const subscribeSettingsEntryWanted = settingsEntrySwitch.subscribe;
|
|
60
|
+
BigInt("0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551") >> 1n;
|
|
61
|
+
new TextEncoder();
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/web-status.ts
|
|
27
64
|
/**
|
|
28
|
-
*
|
|
65
|
+
* 开关的默认值:没有 settings provider(或老配置没这两个键)时保持原有行为 ——
|
|
66
|
+
* 底部两行都显示;侧边栏相反,缺省不开(那一格是所有插件共用的全局座位)。
|
|
67
|
+
* `modelDetail` 缺省开(保持老版本的样子),`autoClaim` 缺省关。
|
|
68
|
+
*/
|
|
69
|
+
const DEFAULT_DOCK_FLAGS = {
|
|
70
|
+
credits: true,
|
|
71
|
+
queue: true,
|
|
72
|
+
sidebar: false,
|
|
73
|
+
settingsEntry: true,
|
|
74
|
+
modelDetail: true,
|
|
75
|
+
autoClaim: false,
|
|
76
|
+
keepAliveDaemon: false
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/client/dock-store.ts
|
|
80
|
+
/**
|
|
81
|
+
* 「显示」页那些开关在浏览器侧的共享状态。
|
|
82
|
+
*
|
|
83
|
+
* 为什么需要它:同一张卡片会被挂到三个地方 —— 设置里的 CodeArts 页、侧边栏的整页
|
|
84
|
+
* 面板、插件详情页。每个实例各自 fetch `/api/codearts/dock` 的话,在 A 处改了开关,
|
|
85
|
+
* B 处只要已经挂载过就永远显示旧值(实测:设置页取消「设置左侧导航显示 CodeArts」,
|
|
86
|
+
* 侧边栏那张卡片仍显示勾选)。
|
|
29
87
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* 真正的注册动作由 index.tsx 的 sync 控制器按它做。
|
|
88
|
+
* 所以开关值只存一份:谁 fetch/POST 成功就写进来,所有挂着的实例订阅它。
|
|
89
|
+
* 乐观更新只改调用方自己的局部状态,成功后才 publish —— 别的实例不该看到还没被
|
|
90
|
+
* 服务端确认的值。
|
|
34
91
|
*
|
|
35
|
-
*
|
|
36
|
-
* 猜错的代价比「少一个入口」大得多(用户还能从「设置 → 插件」进同一张卡片)。
|
|
92
|
+
* @module dsh-codearts/client/dock-store
|
|
37
93
|
*/
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
94
|
+
let snapshot = {
|
|
95
|
+
dock: DEFAULT_DOCK_FLAGS,
|
|
96
|
+
writable: false,
|
|
97
|
+
loaded: false
|
|
98
|
+
};
|
|
43
99
|
const listeners = /* @__PURE__ */ new Set();
|
|
100
|
+
function dockSnapshot() {
|
|
101
|
+
return snapshot;
|
|
102
|
+
}
|
|
44
103
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
104
|
+
* 写入新值。`patch.dock` 只给变化的键也行:缺省键用 DEFAULT_DOCK_FLAGS 补齐,
|
|
105
|
+
* 老后端少字段时不会把已经打开的开关注销成 undefined。
|
|
47
106
|
*/
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
107
|
+
function publishDock(patch) {
|
|
108
|
+
const dock = patch.dock === void 0 ? snapshot.dock : {
|
|
109
|
+
...DEFAULT_DOCK_FLAGS,
|
|
110
|
+
...patch.dock
|
|
111
|
+
};
|
|
112
|
+
const writable = patch.writable ?? snapshot.writable;
|
|
113
|
+
if (dock === snapshot.dock && writable === snapshot.writable && snapshot.loaded) return;
|
|
114
|
+
snapshot = {
|
|
115
|
+
dock,
|
|
116
|
+
writable,
|
|
117
|
+
loaded: true
|
|
118
|
+
};
|
|
51
119
|
for (const listener of [...listeners]) try {
|
|
52
120
|
listener();
|
|
53
121
|
} catch (error) {
|
|
54
|
-
console.error("[dsh-codearts]
|
|
122
|
+
console.error("[dsh-codearts] dock-store listener failed:", error);
|
|
55
123
|
}
|
|
56
124
|
}
|
|
57
|
-
|
|
58
|
-
function subscribeSidebarPanelWanted(listener) {
|
|
125
|
+
function subscribeDock(listener) {
|
|
59
126
|
listeners.add(listener);
|
|
60
127
|
return () => {
|
|
61
128
|
listeners.delete(listener);
|
|
@@ -88,98 +155,98 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
|
|
|
88
155
|
document.head.appendChild(tag);
|
|
89
156
|
}
|
|
90
157
|
var CodeArtsPluginCard_module_css_default = {
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"heatHourCell": "xoziZG_heatHourCell",
|
|
97
|
-
"accountInfo": "xoziZG_accountInfo",
|
|
158
|
+
"skeletonRow": "xoziZG_skeletonRow",
|
|
159
|
+
"meta": "xoziZG_meta",
|
|
160
|
+
"fieldLabel": "xoziZG_fieldLabel",
|
|
161
|
+
"usageTipSep": "xoziZG_usageTipSep",
|
|
162
|
+
"usageTipRow": "xoziZG_usageTipRow",
|
|
98
163
|
"heatHours": "xoziZG_heatHours",
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"count": "xoziZG_count",
|
|
103
|
-
"avatar": "xoziZG_avatar",
|
|
104
|
-
"statSub": "xoziZG_statSub",
|
|
164
|
+
"balance": "xoziZG_balance",
|
|
165
|
+
"name": "xoziZG_name",
|
|
166
|
+
"heatHourCell": "xoziZG_heatHourCell",
|
|
105
167
|
"heatLegendChip": "xoziZG_heatLegendChip",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"expiryLabel": "xoziZG_expiryLabel",
|
|
109
|
-
"desc": "xoziZG_desc",
|
|
110
|
-
"body": "xoziZG_body",
|
|
111
|
-
"updated": "xoziZG_updated",
|
|
112
|
-
"usageTipRow": "xoziZG_usageTipRow",
|
|
113
|
-
"heatWeekday": "xoziZG_heatWeekday",
|
|
114
|
-
"doctorRow": "xoziZG_doctorRow",
|
|
115
|
-
"manualForm": "xoziZG_manualForm",
|
|
168
|
+
"choices": "xoziZG_choices",
|
|
169
|
+
"hint": "xoziZG_hint",
|
|
116
170
|
"heatLegend": "xoziZG_heatLegend",
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"tabPanel": "xoziZG_tabPanel",
|
|
125
|
-
"accountToggleLabel": "xoziZG_accountToggleLabel",
|
|
171
|
+
"accountCard": "xoziZG_accountCard",
|
|
172
|
+
"accountNameRow": "xoziZG_accountNameRow",
|
|
173
|
+
"heatCell": "xoziZG_heatCell",
|
|
174
|
+
"desc": "xoziZG_desc",
|
|
175
|
+
"accountToolbar": "xoziZG_accountToolbar",
|
|
176
|
+
"danger": "xoziZG_danger",
|
|
177
|
+
"modelSpec": "xoziZG_modelSpec",
|
|
126
178
|
"creditRow": "xoziZG_creditRow",
|
|
127
|
-
"
|
|
128
|
-
"
|
|
179
|
+
"doctorRow": "xoziZG_doctorRow",
|
|
180
|
+
"updated": "xoziZG_updated",
|
|
129
181
|
"usageTip": "xoziZG_usageTip",
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"accountCard": "xoziZG_accountCard",
|
|
133
|
-
"accountRow": "xoziZG_accountRow",
|
|
182
|
+
"modelRequests": "xoziZG_modelRequests",
|
|
183
|
+
"skeleton": "xoziZG_skeleton",
|
|
134
184
|
"tabs": "xoziZG_tabs",
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"statValue": "xoziZG_statValue",
|
|
138
|
-
"statLabel": "xoziZG_statLabel",
|
|
139
|
-
"trendTip": "xoziZG_trendTip",
|
|
140
|
-
"doctorList": "xoziZG_doctorList",
|
|
141
|
-
"usageFill": "xoziZG_usageFill",
|
|
142
|
-
"heatCell": "xoziZG_heatCell",
|
|
143
|
-
"balanceUnit": "xoziZG_balanceUnit",
|
|
144
|
-
"meta": "xoziZG_meta",
|
|
145
|
-
"name": "xoziZG_name",
|
|
185
|
+
"body": "xoziZG_body",
|
|
186
|
+
"area": "xoziZG_area",
|
|
146
187
|
"claimAllRow": "xoziZG_claimAllRow",
|
|
147
|
-
"
|
|
188
|
+
"statGrid": "xoziZG_statGrid",
|
|
189
|
+
"creditLink": "xoziZG_creditLink",
|
|
190
|
+
"accountToggle": "xoziZG_accountToggle",
|
|
191
|
+
"creditFooter": "xoziZG_creditFooter",
|
|
192
|
+
"expiryRow": "xoziZG_expiryRow",
|
|
193
|
+
"expiryLabel": "xoziZG_expiryLabel",
|
|
194
|
+
"section": "xoziZG_section",
|
|
195
|
+
"accountRowActions": "xoziZG_accountRowActions",
|
|
148
196
|
"modelRow": "xoziZG_modelRow",
|
|
149
|
-
"
|
|
197
|
+
"accountHint": "xoziZG_accountHint",
|
|
198
|
+
"modelShare": "xoziZG_modelShare",
|
|
199
|
+
"manual": "xoziZG_manual",
|
|
200
|
+
"avatar": "xoziZG_avatar",
|
|
201
|
+
"trendTip": "xoziZG_trendTip",
|
|
202
|
+
"manualSummary": "xoziZG_manualSummary",
|
|
203
|
+
"doctorList": "xoziZG_doctorList",
|
|
204
|
+
"creditRows": "xoziZG_creditRows",
|
|
205
|
+
"accountEntry": "xoziZG_accountEntry",
|
|
150
206
|
"balanceRow": "xoziZG_balanceRow",
|
|
207
|
+
"doctorName": "xoziZG_doctorName",
|
|
208
|
+
"accountName": "xoziZG_accountName",
|
|
209
|
+
"balanceMeta": "xoziZG_balanceMeta",
|
|
210
|
+
"barFill": "xoziZG_barFill",
|
|
211
|
+
"count": "xoziZG_count",
|
|
212
|
+
"header": "xoziZG_header",
|
|
213
|
+
"heatWeekday": "xoziZG_heatWeekday",
|
|
214
|
+
"accountToggleLabel": "xoziZG_accountToggleLabel",
|
|
215
|
+
"choiceRow": "xoziZG_choiceRow",
|
|
216
|
+
"statCard": "xoziZG_statCard",
|
|
151
217
|
"heatAxis": "xoziZG_heatAxis",
|
|
218
|
+
"check": "xoziZG_check",
|
|
219
|
+
"skeletonBreath": "xoziZG_skeletonBreath",
|
|
152
220
|
"usageTipName": "xoziZG_usageTipName",
|
|
153
|
-
"card": "xoziZG_card",
|
|
154
|
-
"accountEntry": "xoziZG_accountEntry",
|
|
155
|
-
"balanceMeta": "xoziZG_balanceMeta",
|
|
156
|
-
"error": "xoziZG_error",
|
|
157
|
-
"usageTipSep": "xoziZG_usageTipSep",
|
|
158
|
-
"hint": "xoziZG_hint",
|
|
159
|
-
"modelName": "xoziZG_modelName",
|
|
160
221
|
"creditBlock": "xoziZG_creditBlock",
|
|
222
|
+
"bar": "xoziZG_bar",
|
|
223
|
+
"creditHint": "xoziZG_creditHint",
|
|
224
|
+
"actions": "xoziZG_actions",
|
|
225
|
+
"statValue": "xoziZG_statValue",
|
|
226
|
+
"statLabel": "xoziZG_statLabel",
|
|
227
|
+
"card": "xoziZG_card",
|
|
228
|
+
"modelFill": "xoziZG_modelFill",
|
|
229
|
+
"accountInfo": "xoziZG_accountInfo",
|
|
230
|
+
"accountRow": "xoziZG_accountRow",
|
|
231
|
+
"usageFill": "xoziZG_usageFill",
|
|
161
232
|
"modelTrack": "xoziZG_modelTrack",
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
"
|
|
233
|
+
"manualForm": "xoziZG_manualForm",
|
|
234
|
+
"balanceUnit": "xoziZG_balanceUnit",
|
|
235
|
+
"statusLine": "xoziZG_statusLine",
|
|
236
|
+
"link": "xoziZG_link",
|
|
237
|
+
"sectionHead": "xoziZG_sectionHead",
|
|
165
238
|
"field": "xoziZG_field",
|
|
166
|
-
"
|
|
167
|
-
"area": "xoziZG_area",
|
|
239
|
+
"modelTokens": "xoziZG_modelTokens",
|
|
168
240
|
"heatGrid": "xoziZG_heatGrid",
|
|
241
|
+
"error": "xoziZG_error",
|
|
169
242
|
"sectionLabel": "xoziZG_sectionLabel",
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
"
|
|
177
|
-
"manual": "xoziZG_manual",
|
|
178
|
-
"balance": "xoziZG_balance",
|
|
179
|
-
"skeleton": "xoziZG_skeleton",
|
|
180
|
-
"accountNameRow": "xoziZG_accountNameRow",
|
|
181
|
-
"statGrid": "xoziZG_statGrid",
|
|
182
|
-
"expiryRow": "xoziZG_expiryRow"
|
|
243
|
+
"headText": "xoziZG_headText",
|
|
244
|
+
"modelName": "xoziZG_modelName",
|
|
245
|
+
"tabPanel": "xoziZG_tabPanel",
|
|
246
|
+
"modelChart": "xoziZG_modelChart",
|
|
247
|
+
"usageBar": "xoziZG_usageBar",
|
|
248
|
+
"statSub": "xoziZG_statSub",
|
|
249
|
+
"heatAxisSlot": "xoziZG_heatAxisSlot"
|
|
183
250
|
};
|
|
184
251
|
//#endregion
|
|
185
252
|
//#region src/client/CodeArtsPluginCard.tsx
|
|
@@ -230,19 +297,6 @@ function claimMessagesOf(data, accountIds, t) {
|
|
|
230
297
|
return out;
|
|
231
298
|
}
|
|
232
299
|
/**
|
|
233
|
-
* 开关的兜底值:后端没这条路由(老版本)时按「都显示」渲染,与原有行为一致。
|
|
234
|
-
* 侧边栏那一格相反 —— 缺省关闭;自动领取与常驻保活也缺省关(不替用户动余额、
|
|
235
|
-
* 不替用户在系统里留后台进程)。
|
|
236
|
-
*/
|
|
237
|
-
const DOCK_DEFAULT = {
|
|
238
|
-
credits: true,
|
|
239
|
-
queue: true,
|
|
240
|
-
sidebar: false,
|
|
241
|
-
modelDetail: true,
|
|
242
|
-
autoClaim: false,
|
|
243
|
-
keepAliveDaemon: false
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
300
|
* 上一次读到的状态。`/api/codearts/status` 会顺带去上游拉积分(有 TTL 缓存),
|
|
247
301
|
* 冷的时候要等近一秒;模块级留一份快照,再进这一页就能立刻按旧值画出来,
|
|
248
302
|
* 后台再刷新 —— 比每次都先闪骨架舒服,也不会把「还没读到」误判成未登录。
|
|
@@ -346,6 +400,8 @@ function CreditBlock({ credits, error, t, onClaim, claiming, claimResult, justCl
|
|
|
346
400
|
if (credits === void 0 && error === void 0) return null;
|
|
347
401
|
const c = credits?.credits;
|
|
348
402
|
const claimedToday = justClaimed || credits?.welfare?.claimedToday === true;
|
|
403
|
+
/** 上游当前每日签到活动给多少分;没有就退回不带数字的文案。 */
|
|
404
|
+
const claimAmount = credits?.welfare?.amount ?? 0;
|
|
349
405
|
const expiring = c?.total.expiring ?? 0;
|
|
350
406
|
const expiringRatio = c !== void 0 && c.total.total > 0 ? Math.min(100, Math.max(0, expiring / c.total.total * 100)) : 0;
|
|
351
407
|
const usedRatio = c !== void 0 && c.total.total > 0 ? Math.min(100, Math.max(0, c.total.used / c.total.total * 100)) : 0;
|
|
@@ -450,7 +506,7 @@ function CreditBlock({ credits, error, t, onClaim, claiming, claimResult, justCl
|
|
|
450
506
|
}),
|
|
451
507
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
452
508
|
className: CodeArtsPluginCard_module_css_default.creditHint,
|
|
453
|
-
children: claimResult ?? t("claimHint")
|
|
509
|
+
children: claimResult ?? (claimAmount > 0 ? t("claimHintAmount", { amount: formatCredits(claimAmount) }) : t("claimHint"))
|
|
454
510
|
})
|
|
455
511
|
]
|
|
456
512
|
});
|
|
@@ -1031,9 +1087,15 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1031
1087
|
const [tab, setTab] = (0, react.useState)("accounts");
|
|
1032
1088
|
const tabIdBase = (0, react.useId)();
|
|
1033
1089
|
/** 对话底部那一行的两个显隐开关(后端 = 插件 settings 里的两个布尔)。 */
|
|
1034
|
-
const [dock, setDock] = (0, react.useState)(
|
|
1035
|
-
const [dockWritable, setDockWritable] = (0, react.useState)(
|
|
1036
|
-
|
|
1090
|
+
const [dock, setDock] = (0, react.useState)(() => dockSnapshot().dock);
|
|
1091
|
+
const [dockWritable, setDockWritable] = (0, react.useState)(() => dockSnapshot().writable);
|
|
1092
|
+
/**
|
|
1093
|
+
* 正在保存的开关(按键记录)。
|
|
1094
|
+
*
|
|
1095
|
+
* 早先是一个共享布尔:点任何一个勾选框都会把**全部**勾选框置灰,POST 回来再恢复 ——
|
|
1096
|
+
* 肉眼就是「整个配置页的勾选都在闪」。现在只有被点的那一个在处理中。
|
|
1097
|
+
*/
|
|
1098
|
+
const [dockSavingKeys, setDockSavingKeys] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
1037
1099
|
const [dockError, setDockError] = (0, react.useState)(null);
|
|
1038
1100
|
/** 「结束守护进程」按钮在飞,防止连点。 */
|
|
1039
1101
|
const [keeperStopping, setKeeperStopping] = (0, react.useState)(false);
|
|
@@ -1052,14 +1114,11 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1052
1114
|
if (!res.ok) return;
|
|
1053
1115
|
const data = await res.json();
|
|
1054
1116
|
if (data.dock !== void 0) {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
};
|
|
1059
|
-
setDock(next);
|
|
1060
|
-
setSidebarPanelWanted(next.sidebar);
|
|
1117
|
+
publishDock({ dock: data.dock });
|
|
1118
|
+
setSidebarPanelWanted(data.dock.sidebar === true);
|
|
1119
|
+
setSettingsEntryWanted(data.dock.settingsEntry !== false);
|
|
1061
1120
|
}
|
|
1062
|
-
|
|
1121
|
+
publishDock({ writable: data.writable === true });
|
|
1063
1122
|
} catch {}
|
|
1064
1123
|
}
|
|
1065
1124
|
/**
|
|
@@ -1074,7 +1133,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1074
1133
|
...dock,
|
|
1075
1134
|
[key]: on
|
|
1076
1135
|
});
|
|
1077
|
-
|
|
1136
|
+
setDockSavingKeys((current) => new Set(current).add(key));
|
|
1078
1137
|
setDockError(null);
|
|
1079
1138
|
if (key === "sidebar") setSidebarPanelWanted(on);
|
|
1080
1139
|
try {
|
|
@@ -1092,19 +1151,21 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1092
1151
|
}
|
|
1093
1152
|
const data = await res.json();
|
|
1094
1153
|
if (data.dock !== void 0) {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
};
|
|
1099
|
-
setDock(next);
|
|
1100
|
-
setSidebarPanelWanted(next.sidebar);
|
|
1154
|
+
publishDock({ dock: data.dock });
|
|
1155
|
+
setSidebarPanelWanted(data.dock.sidebar === true);
|
|
1156
|
+
setSettingsEntryWanted(data.dock.settingsEntry !== false);
|
|
1101
1157
|
}
|
|
1102
1158
|
} catch (error) {
|
|
1103
1159
|
setDock(previous);
|
|
1104
1160
|
if (key === "sidebar") setSidebarPanelWanted(previous.sidebar);
|
|
1105
1161
|
setDockError(error instanceof Error ? error.message : String(error));
|
|
1106
1162
|
} finally {
|
|
1107
|
-
|
|
1163
|
+
setDockSavingKeys((current) => {
|
|
1164
|
+
if (!current.has(key)) return current;
|
|
1165
|
+
const next = new Set(current);
|
|
1166
|
+
next.delete(key);
|
|
1167
|
+
return next;
|
|
1168
|
+
});
|
|
1108
1169
|
}
|
|
1109
1170
|
}
|
|
1110
1171
|
/**
|
|
@@ -1128,10 +1189,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1128
1189
|
body: "{}"
|
|
1129
1190
|
});
|
|
1130
1191
|
const data = await res.json().catch(() => ({}));
|
|
1131
|
-
if (data.dock !== void 0)
|
|
1132
|
-
...DOCK_DEFAULT,
|
|
1133
|
-
...data.dock
|
|
1134
|
-
});
|
|
1192
|
+
if (data.dock !== void 0) publishDock({ dock: data.dock });
|
|
1135
1193
|
if (!res.ok || data.ok === false) setKeeperNotice(t("displayKeeperStopFailed", { message: data.reason ?? data.error ?? `HTTP ${res.status}` }));
|
|
1136
1194
|
else setKeeperNotice(t("displayKeeperStopped"));
|
|
1137
1195
|
} catch (error) {
|
|
@@ -1214,6 +1272,10 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1214
1272
|
(0, react.useEffect)(() => {
|
|
1215
1273
|
refreshDock();
|
|
1216
1274
|
}, []);
|
|
1275
|
+
(0, react.useEffect)(() => subscribeDock(() => {
|
|
1276
|
+
setDock(dockSnapshot().dock);
|
|
1277
|
+
setDockWritable(dockSnapshot().writable);
|
|
1278
|
+
}), []);
|
|
1217
1279
|
(0, react.useEffect)(() => {
|
|
1218
1280
|
if (status?.status === "signed-in") refreshSelection();
|
|
1219
1281
|
}, [status?.status]);
|
|
@@ -1984,7 +2046,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1984
2046
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
1985
2047
|
className: CodeArtsPluginCard_module_css_default.check,
|
|
1986
2048
|
checked: dock.credits,
|
|
1987
|
-
disabled: !dockWritable ||
|
|
2049
|
+
disabled: !dockWritable || dockSavingKeys.has("credits"),
|
|
1988
2050
|
onChange: (on) => void toggleDock("credits", on),
|
|
1989
2051
|
label: t("displayCreditsToggle")
|
|
1990
2052
|
})
|
|
@@ -1994,7 +2056,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
1994
2056
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
1995
2057
|
className: CodeArtsPluginCard_module_css_default.check,
|
|
1996
2058
|
checked: dock.queue,
|
|
1997
|
-
disabled: !dockWritable ||
|
|
2059
|
+
disabled: !dockWritable || dockSavingKeys.has("queue"),
|
|
1998
2060
|
onChange: (on) => void toggleDock("queue", on),
|
|
1999
2061
|
label: t("displayQueueToggle")
|
|
2000
2062
|
})
|
|
@@ -2004,7 +2066,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
2004
2066
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
2005
2067
|
className: CodeArtsPluginCard_module_css_default.check,
|
|
2006
2068
|
checked: dock.modelDetail,
|
|
2007
|
-
disabled: !dockWritable ||
|
|
2069
|
+
disabled: !dockWritable || dockSavingKeys.has("modelDetail"),
|
|
2008
2070
|
onChange: (on) => void toggleDock("modelDetail", on),
|
|
2009
2071
|
label: t("displayModelDetailToggle")
|
|
2010
2072
|
})
|
|
@@ -2042,7 +2104,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
2042
2104
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
2043
2105
|
className: CodeArtsPluginCard_module_css_default.check,
|
|
2044
2106
|
checked: dock.autoClaim,
|
|
2045
|
-
disabled: !dockWritable ||
|
|
2107
|
+
disabled: !dockWritable || dockSavingKeys.has("autoClaim"),
|
|
2046
2108
|
onChange: (on) => void toggleDock("autoClaim", on),
|
|
2047
2109
|
label: t("displayAutoClaimToggle")
|
|
2048
2110
|
})
|
|
@@ -2077,7 +2139,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
2077
2139
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
2078
2140
|
className: CodeArtsPluginCard_module_css_default.check,
|
|
2079
2141
|
checked: dock.keepAliveDaemon,
|
|
2080
|
-
disabled: !dockWritable ||
|
|
2142
|
+
disabled: !dockWritable || dockSavingKeys.has("keepAliveDaemon"),
|
|
2081
2143
|
onChange: (on) => void toggleDock("keepAliveDaemon", on),
|
|
2082
2144
|
label: t("displayKeeperToggle")
|
|
2083
2145
|
})
|
|
@@ -2100,6 +2162,35 @@ function CodeArtsPluginCard({ t }) {
|
|
|
2100
2162
|
})
|
|
2101
2163
|
]
|
|
2102
2164
|
}),
|
|
2165
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2166
|
+
className: CodeArtsPluginCard_module_css_default.section,
|
|
2167
|
+
children: [
|
|
2168
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2169
|
+
className: CodeArtsPluginCard_module_css_default.sectionHead,
|
|
2170
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2171
|
+
className: CodeArtsPluginCard_module_css_default.sectionLabel,
|
|
2172
|
+
children: t("displaySettingsEntryTitle")
|
|
2173
|
+
})
|
|
2174
|
+
}),
|
|
2175
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2176
|
+
className: CodeArtsPluginCard_module_css_default.hint,
|
|
2177
|
+
children: t("displaySettingsEntryHint")
|
|
2178
|
+
}),
|
|
2179
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2180
|
+
className: CodeArtsPluginCard_module_css_default.choices,
|
|
2181
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2182
|
+
className: CodeArtsPluginCard_module_css_default.choiceRow,
|
|
2183
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
2184
|
+
className: CodeArtsPluginCard_module_css_default.check,
|
|
2185
|
+
checked: dock.settingsEntry,
|
|
2186
|
+
disabled: !dockWritable || dockSavingKeys.has("settingsEntry"),
|
|
2187
|
+
onChange: (on) => void toggleDock("settingsEntry", on),
|
|
2188
|
+
label: t("displaySettingsEntryToggle")
|
|
2189
|
+
})
|
|
2190
|
+
})
|
|
2191
|
+
})
|
|
2192
|
+
]
|
|
2193
|
+
}),
|
|
2103
2194
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2104
2195
|
className: CodeArtsPluginCard_module_css_default.section,
|
|
2105
2196
|
children: [
|
|
@@ -2121,7 +2212,7 @@ function CodeArtsPluginCard({ t }) {
|
|
|
2121
2212
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
2122
2213
|
className: CodeArtsPluginCard_module_css_default.check,
|
|
2123
2214
|
checked: dock.sidebar,
|
|
2124
|
-
disabled: !dockWritable ||
|
|
2215
|
+
disabled: !dockWritable || dockSavingKeys.has("sidebar"),
|
|
2125
2216
|
onChange: (on) => void toggleDock("sidebar", on),
|
|
2126
2217
|
label: t("displaySidebarToggle")
|
|
2127
2218
|
})
|
|
@@ -2232,23 +2323,6 @@ function CodeArtsPluginCard({ t }) {
|
|
|
2232
2323
|
})]
|
|
2233
2324
|
});
|
|
2234
2325
|
}
|
|
2235
|
-
BigInt("0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551") >> 1n;
|
|
2236
|
-
new TextEncoder();
|
|
2237
|
-
//#endregion
|
|
2238
|
-
//#region src/web-status.ts
|
|
2239
|
-
/**
|
|
2240
|
-
* 开关的默认值:没有 settings provider(或老配置没这两个键)时保持原有行为 ——
|
|
2241
|
-
* 底部两行都显示;侧边栏相反,缺省不开(那一格是所有插件共用的全局座位)。
|
|
2242
|
-
* `modelDetail` 缺省开(保持老版本的样子),`autoClaim` 缺省关。
|
|
2243
|
-
*/
|
|
2244
|
-
const DEFAULT_DOCK_FLAGS = {
|
|
2245
|
-
credits: true,
|
|
2246
|
-
queue: true,
|
|
2247
|
-
sidebar: false,
|
|
2248
|
-
modelDetail: true,
|
|
2249
|
-
autoClaim: false,
|
|
2250
|
-
keepAliveDaemon: false
|
|
2251
|
-
};
|
|
2252
2326
|
//#endregion
|
|
2253
2327
|
//#region src/client/dock-line.ts
|
|
2254
2328
|
/** 段分隔符 —— 与邻居插件一致,改这里等于改整行的样子。 */
|
|
@@ -2362,7 +2436,7 @@ const QUEUE_INTERVAL_MS = 5e3;
|
|
|
2362
2436
|
* `min(248px, …)`)取一档窄宽度 —— 这一层回答的是「哪个号还有多少积分」,
|
|
2363
2437
|
* 用量数字不该把它撑成一张报表。
|
|
2364
2438
|
*/
|
|
2365
|
-
const PANEL_WIDTH =
|
|
2439
|
+
const PANEL_WIDTH = 280;
|
|
2366
2440
|
/** 弹层与那一行之间的缝隙。 */
|
|
2367
2441
|
const PANEL_GAP = 8;
|
|
2368
2442
|
/**
|
|
@@ -2474,7 +2548,7 @@ function rowsOf(data) {
|
|
|
2474
2548
|
function placeAbove(rect) {
|
|
2475
2549
|
return rect.top > PANEL_MIN_ABOVE;
|
|
2476
2550
|
}
|
|
2477
|
-
function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
|
|
2551
|
+
function CodeArtsCreditDock({ useProjection, t, zone = "dock", onOpenSettings }) {
|
|
2478
2552
|
const selection = readSelection(useProjection);
|
|
2479
2553
|
const active = isCodeArts(selection);
|
|
2480
2554
|
const [remain, setRemain] = (0, react.useState)(null);
|
|
@@ -2486,8 +2560,12 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
|
|
|
2486
2560
|
* 名字用 `stripModelSuffixes` 剥掉尾巴,倍率直接用服务端算好的 `ratio`。
|
|
2487
2561
|
*/
|
|
2488
2562
|
const [modelInfo, setModelInfo] = (0, react.useState)({});
|
|
2489
|
-
const [flags, setFlags] = (0, react.useState)(
|
|
2563
|
+
const [flags, setFlags] = (0, react.useState)(() => dockSnapshot().dock);
|
|
2564
|
+
/** 开关的共享状态:设置页改了「显示」里的勾选,弹层这边立刻跟上。 */
|
|
2565
|
+
(0, react.useEffect)(() => subscribeDock(() => setFlags(dockSnapshot().dock)), []);
|
|
2490
2566
|
const [queued, setQueued] = (0, react.useState)(null);
|
|
2567
|
+
/** 「设置」按钮两条路都没走通时的提示(宿主壳形状不认识)。 */
|
|
2568
|
+
const [settingsFailed, setSettingsFailed] = (0, react.useState)(false);
|
|
2491
2569
|
const [anchor, setAnchor] = (0, react.useState)(null);
|
|
2492
2570
|
/**
|
|
2493
2571
|
* 弹层的包含块原点(视口坐标)。
|
|
@@ -2519,7 +2597,7 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
|
|
|
2519
2597
|
if (!res.ok) return;
|
|
2520
2598
|
const data = await res.json().catch(() => void 0);
|
|
2521
2599
|
if (data === void 0 || !mounted.current) return;
|
|
2522
|
-
|
|
2600
|
+
if (data.dock !== void 0) publishDock({ dock: data.dock });
|
|
2523
2601
|
setRows(rowsOf(data));
|
|
2524
2602
|
setModelInfo(Object.fromEntries((data.models ?? []).map((model) => [model.id, {
|
|
2525
2603
|
name: model.name,
|
|
@@ -2739,16 +2817,46 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
|
|
|
2739
2817
|
gap: 8
|
|
2740
2818
|
},
|
|
2741
2819
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2742
|
-
style: {
|
|
2820
|
+
style: {
|
|
2821
|
+
fontWeight: 600,
|
|
2822
|
+
flex: "1 1 auto",
|
|
2823
|
+
minWidth: 0,
|
|
2824
|
+
overflow: "hidden",
|
|
2825
|
+
textOverflow: "ellipsis",
|
|
2826
|
+
whiteSpace: "nowrap"
|
|
2827
|
+
},
|
|
2743
2828
|
children: t("creditsDockPanelTitle")
|
|
2744
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2829
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2830
|
+
style: {
|
|
2831
|
+
display: "inline-flex",
|
|
2832
|
+
alignItems: "center",
|
|
2833
|
+
gap: 6,
|
|
2834
|
+
flex: "0 0 auto",
|
|
2835
|
+
whiteSpace: "nowrap"
|
|
2836
|
+
},
|
|
2837
|
+
children: [onOpenSettings !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2838
|
+
variant: "outline",
|
|
2839
|
+
size: "sm",
|
|
2840
|
+
style: { whiteSpace: "nowrap" },
|
|
2841
|
+
onClick: () => setSettingsFailed(!onOpenSettings()),
|
|
2842
|
+
children: t("creditsDockSettings")
|
|
2843
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2844
|
+
variant: "outline",
|
|
2845
|
+
size: "sm",
|
|
2846
|
+
style: { whiteSpace: "nowrap" },
|
|
2847
|
+
disabled: refreshing,
|
|
2848
|
+
onClick: () => void forceRefresh(),
|
|
2849
|
+
children: refreshing ? t("creditsDockRefreshing") : t("creditsDockRefresh")
|
|
2850
|
+
})]
|
|
2750
2851
|
})]
|
|
2751
2852
|
}),
|
|
2853
|
+
settingsFailed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2854
|
+
style: {
|
|
2855
|
+
fontSize: 11,
|
|
2856
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
2857
|
+
},
|
|
2858
|
+
children: t("creditsDockSettingsFailed")
|
|
2859
|
+
}),
|
|
2752
2860
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2753
2861
|
style: {
|
|
2754
2862
|
display: "flex",
|
|
@@ -2837,14 +2945,14 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
|
|
|
2837
2945
|
document.head.appendChild(tag);
|
|
2838
2946
|
}
|
|
2839
2947
|
var CodeArtsPanel_module_css_default = {
|
|
2840
|
-
"body": "Z66cgG_body",
|
|
2841
|
-
"title": "Z66cgG_title",
|
|
2842
|
-
"back": "Z66cgG_back",
|
|
2843
2948
|
"icon": "Z66cgG_icon",
|
|
2844
|
-
"head": "Z66cgG_head",
|
|
2845
2949
|
"desc": "Z66cgG_desc",
|
|
2950
|
+
"back": "Z66cgG_back",
|
|
2951
|
+
"backCaret": "Z66cgG_backCaret",
|
|
2846
2952
|
"page": "Z66cgG_page",
|
|
2847
|
-
"
|
|
2953
|
+
"body": "Z66cgG_body",
|
|
2954
|
+
"head": "Z66cgG_head",
|
|
2955
|
+
"title": "Z66cgG_title"
|
|
2848
2956
|
};
|
|
2849
2957
|
//#endregion
|
|
2850
2958
|
//#region src/client/CodeArtsPanel.tsx
|
|
@@ -2915,6 +3023,84 @@ function CodeArtsPanelPage({ t, backToConversation }) {
|
|
|
2915
3023
|
});
|
|
2916
3024
|
}
|
|
2917
3025
|
//#endregion
|
|
3026
|
+
//#region src/client/settings-route.ts
|
|
3027
|
+
/**
|
|
3028
|
+
* 「打开设置 → CodeArts」这条路的实现。
|
|
3029
|
+
*
|
|
3030
|
+
* 宿主没有给插件一个直白的「打开某节设置」服务,但设置壳把自己挂在
|
|
3031
|
+
* `sidebar.settings` 槽位上,并且带了一个 **store seat**:
|
|
3032
|
+
*
|
|
3033
|
+
* const shellHandle = createSettingsShellStore()
|
|
3034
|
+
* const shellInstance = shellHandle.create()
|
|
3035
|
+
* ctx.slots.register({ name: 'sidebar.settings', store: { ...shellHandle, create: () => shellInstance }, … })
|
|
3036
|
+
*
|
|
3037
|
+
* 这个 seat 是壳公开的状态把手(`StoredEntry.store` 是文档字段,`slots.entries()`
|
|
3038
|
+
* 是公开方法;宿主自己的客户端测试也这么读)。`actions.openSection(id)` 一次把
|
|
3039
|
+
* `activeId = id` 和 `open = true` 都设上,正好是「在 CodeArts 那一节打开设置」。
|
|
3040
|
+
*
|
|
3041
|
+
* 旧壳没有 `openSection` 时退回到「打开设置面板 + 点同名导航行」。判断按**逐字**
|
|
3042
|
+
* 相等:`模型` 是 `模型与预设` 的子串,模糊匹配会点错节。两条路都不抛异常 ——
|
|
3043
|
+
* 调用方是一个按钮的 click handler,抛出去会把整条积分行带没。
|
|
3044
|
+
*
|
|
3045
|
+
* @module dsh-codearts/client/settings-route
|
|
3046
|
+
*/
|
|
3047
|
+
/** 设置壳所在的槽位:它的 store seat 就是对外唯一的状态把手。 */
|
|
3048
|
+
const SETTINGS_SLOT = "sidebar.settings";
|
|
3049
|
+
/** 面板挂载后导航行的标签要等一次 locale 快照,所以重试几次、总共约 300ms。 */
|
|
3050
|
+
const RETRY_DELAYS_MS = [
|
|
3051
|
+
0,
|
|
3052
|
+
60,
|
|
3053
|
+
70,
|
|
3054
|
+
80,
|
|
3055
|
+
90
|
|
3056
|
+
];
|
|
3057
|
+
function defaultSchedule(run, ms) {
|
|
3058
|
+
globalThis.setTimeout(run, ms);
|
|
3059
|
+
}
|
|
3060
|
+
function findSectionRow(scope, label) {
|
|
3061
|
+
const want = label.trim();
|
|
3062
|
+
if (want === "") return void 0;
|
|
3063
|
+
return Array.from(scope.querySelectorAll("button")).find((button) => (button.textContent ?? "").trim() === want);
|
|
3064
|
+
}
|
|
3065
|
+
/**
|
|
3066
|
+
* 打开本插件的设置节。
|
|
3067
|
+
*
|
|
3068
|
+
* @returns true = 已经走通一条路(设置面板会在我们这一节打开,或至少已打开)。
|
|
3069
|
+
*/
|
|
3070
|
+
function openPluginSettings(deps) {
|
|
3071
|
+
try {
|
|
3072
|
+
const openSection = ((deps.slots?.entries?.(SETTINGS_SLOT))?.[0]?.store?.create?.())?.actions?.openSection;
|
|
3073
|
+
if (typeof openSection === "function") {
|
|
3074
|
+
openSection(deps.sectionId);
|
|
3075
|
+
return true;
|
|
3076
|
+
}
|
|
3077
|
+
} catch {}
|
|
3078
|
+
const doc = deps.doc ?? (typeof document === "undefined" ? void 0 : document);
|
|
3079
|
+
const label = deps.label?.() ?? "";
|
|
3080
|
+
try {
|
|
3081
|
+
const invoke = deps.shortcuts?.invoke;
|
|
3082
|
+
if (typeof invoke === "function") invoke("settings.open", { modal: null });
|
|
3083
|
+
else return false;
|
|
3084
|
+
} catch {
|
|
3085
|
+
return false;
|
|
3086
|
+
}
|
|
3087
|
+
if (doc === void 0 || label.trim() === "") return true;
|
|
3088
|
+
const schedule = deps.schedule ?? defaultSchedule;
|
|
3089
|
+
const scopeOf = () => doc.querySelector("[data-shortcut-modal=\"settings\"]") ?? doc;
|
|
3090
|
+
let clicked = false;
|
|
3091
|
+
for (const delay of RETRY_DELAYS_MS) schedule(() => {
|
|
3092
|
+
if (clicked) return;
|
|
3093
|
+
try {
|
|
3094
|
+
const row = findSectionRow(scopeOf(), label);
|
|
3095
|
+
if (row !== void 0) {
|
|
3096
|
+
clicked = true;
|
|
3097
|
+
row.click();
|
|
3098
|
+
}
|
|
3099
|
+
} catch {}
|
|
3100
|
+
}, delay);
|
|
3101
|
+
return true;
|
|
3102
|
+
}
|
|
3103
|
+
//#endregion
|
|
2918
3104
|
//#region src/client/locales.ts
|
|
2919
3105
|
const zh = {
|
|
2920
3106
|
tabLabel: "CodeArts",
|
|
@@ -3071,6 +3257,8 @@ const zh = {
|
|
|
3071
3257
|
creditsDockPanelTitle: "CodeArts 积分",
|
|
3072
3258
|
creditsDockRefresh: "刷新积分",
|
|
3073
3259
|
creditsDockRefreshing: "刷新中…",
|
|
3260
|
+
creditsDockSettings: "设置",
|
|
3261
|
+
creditsDockSettingsFailed: "打不开设置面板,请从「设置 → CodeArts」进入。",
|
|
3074
3262
|
creditsDockNoTokens: "今天还没有经插件发出的请求",
|
|
3075
3263
|
creditsDockEmpty: "暂时没有积分数据",
|
|
3076
3264
|
creditsDockExpiring: "{account}:{expiring} 积分将在本周期结束时作废",
|
|
@@ -3100,6 +3288,9 @@ const zh = {
|
|
|
3100
3288
|
displayKeeperLog: "进程日志:{path}",
|
|
3101
3289
|
displayNotWritable: "这个宿主没给插件开配置存储,开关只能看不能改。",
|
|
3102
3290
|
displayFailed: "保存失败:{message}",
|
|
3291
|
+
displaySettingsEntryTitle: "设置左侧入口",
|
|
3292
|
+
displaySettingsEntryHint: "勾上以后,DSH 设置左侧那一列里会多一项 CodeArts,点开就是当前这一页。默认勾上:插件自带的配置页本来挂在「内置插件」的详情页里,第一次用的人基本找不到。不想要可以在这里关掉,关掉后仍可从「内置插件 → dsh-codearts」进入。改完立刻生效。",
|
|
3293
|
+
displaySettingsEntryToggle: "在设置左侧导航显示 CodeArts",
|
|
3103
3294
|
displaySidebarTitle: "侧边栏图标",
|
|
3104
3295
|
displaySidebarHint: "勾上以后,DSH 左侧那一列图标里会多一个 CodeArts,点它直接在中间列打开当前这一页,不必每次都绕进设置。默认不勾:这列图标是全宿主共用的,每个插件都来占一格很快就挤满了。改完立刻生效,没有保存步骤。",
|
|
3105
3296
|
displaySidebarToggle: "在侧边栏图标列显示 CodeArts",
|
|
@@ -3109,7 +3300,8 @@ const zh = {
|
|
|
3109
3300
|
claimButtonDone: "今日已领",
|
|
3110
3301
|
claimPending: "领取中…",
|
|
3111
3302
|
claimAll: "全部账号领取",
|
|
3112
|
-
claimHint: "
|
|
3303
|
+
claimHint: "每天可领一次签到积分,走官方福利中心接口(与客户端里那个「每日签到」同一件事)。",
|
|
3304
|
+
claimHintAmount: "每天领一次 {amount} 积分,走官方福利中心接口(与客户端里那个「每日签到」同一件事)。",
|
|
3113
3305
|
claimDone: "已领取 {amount} 积分",
|
|
3114
3306
|
claimAlready: "今日已领,明天再来",
|
|
3115
3307
|
claimUnavailable: "这个账号当前没有可领的签到活动",
|
|
@@ -3272,6 +3464,8 @@ const en = {
|
|
|
3272
3464
|
creditsDockPanelTitle: "CodeArts credits",
|
|
3273
3465
|
creditsDockRefresh: "Refresh credits",
|
|
3274
3466
|
creditsDockRefreshing: "Refreshing…",
|
|
3467
|
+
creditsDockSettings: "Settings",
|
|
3468
|
+
creditsDockSettingsFailed: "Could not open Settings. Open Settings → CodeArts instead.",
|
|
3275
3469
|
creditsDockNoTokens: "No requests through the plugin today yet",
|
|
3276
3470
|
creditsDockEmpty: "No credit data yet",
|
|
3277
3471
|
creditsDockExpiring: "{account}: {expiring} credits expire when this cycle ends",
|
|
@@ -3301,6 +3495,9 @@ const en = {
|
|
|
3301
3495
|
displayKeeperLog: "Process log: {path}",
|
|
3302
3496
|
displayNotWritable: "This host gives the plugin nowhere to persist settings, so the switches are read-only.",
|
|
3303
3497
|
displayFailed: "Failed to save: {message}",
|
|
3498
|
+
displaySettingsEntryTitle: "Settings entry",
|
|
3499
|
+
displaySettingsEntryHint: "Once checked, a CodeArts item joins the left navigation of DSH Settings and opens this very page. On by default: the plugin-owned page otherwise lives inside the Built-in plugins detail page, which first-time users rarely find. Uncheck to hide it — the page stays reachable from Built-in plugins → dsh-codearts. Takes effect immediately.",
|
|
3500
|
+
displaySettingsEntryToggle: "Show CodeArts in the Settings navigation",
|
|
3304
3501
|
displaySidebarTitle: "Sidebar icon",
|
|
3305
3502
|
displaySidebarHint: "Once checked, a CodeArts icon joins the icon column on the left of DSH and opens this very page in the middle column, so you do not have to go through Settings each time. Off by default: that column is shared by the whole host, and it fills up quickly if every plugin claims a slot. Takes effect immediately — there is nothing to save.",
|
|
3306
3503
|
displaySidebarToggle: "Show CodeArts in the sidebar icon column",
|
|
@@ -3310,7 +3507,8 @@ const en = {
|
|
|
3310
3507
|
claimButtonDone: "Claimed today",
|
|
3311
3508
|
claimPending: "Claiming…",
|
|
3312
3509
|
claimAll: "Claim for all accounts",
|
|
3313
|
-
claimHint: "Claim
|
|
3510
|
+
claimHint: "Claim your check-in credits once a day through CodeArts’ welfare centre — the same check-in the official client does.",
|
|
3511
|
+
claimHintAmount: "Claim {amount} credits once a day through CodeArts’ welfare centre — the same check-in the official client does.",
|
|
3314
3512
|
claimDone: "Claimed {amount} credits",
|
|
3315
3513
|
claimAlready: "Already claimed today — come back tomorrow",
|
|
3316
3514
|
claimUnavailable: "No check-in campaign available for this account",
|
|
@@ -3347,6 +3545,19 @@ function apply(ctx) {
|
|
|
3347
3545
|
en
|
|
3348
3546
|
}), "dsh-codearts: settings copy");
|
|
3349
3547
|
const t = ctx.locale.bind(namespace);
|
|
3548
|
+
/**
|
|
3549
|
+
* 打开「设置 → CodeArts」。
|
|
3550
|
+
*
|
|
3551
|
+
* 宿主没有直白的「打开某节设置」服务,走设置壳公开挂在 `sidebar.settings`
|
|
3552
|
+
* 槽位上的 store seat(见 settings-route.ts 的说明)。点按钮时现取,不缓存:
|
|
3553
|
+
* 那个槽位属于另一个 bundle,apply 顺序不是我们能假定的。
|
|
3554
|
+
*/
|
|
3555
|
+
const openSettings = () => openPluginSettings({
|
|
3556
|
+
slots: ctx.slots,
|
|
3557
|
+
shortcuts: ctx.get("shortcuts"),
|
|
3558
|
+
sectionId: PANEL_ID,
|
|
3559
|
+
label: () => t("tabLabel")
|
|
3560
|
+
});
|
|
3350
3561
|
ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
|
|
3351
3562
|
name: "plugins.bundle.config",
|
|
3352
3563
|
key: "dsh-codearts",
|
|
@@ -3359,7 +3570,8 @@ function apply(ctx) {
|
|
|
3359
3570
|
locale: namespace,
|
|
3360
3571
|
inject: () => ({
|
|
3361
3572
|
t,
|
|
3362
|
-
zone: "bar"
|
|
3573
|
+
zone: "bar",
|
|
3574
|
+
onOpenSettings: openSettings
|
|
3363
3575
|
})
|
|
3364
3576
|
}, CodeArtsCreditDock));
|
|
3365
3577
|
ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
|
|
@@ -3369,7 +3581,8 @@ function apply(ctx) {
|
|
|
3369
3581
|
locale: namespace,
|
|
3370
3582
|
inject: () => ({
|
|
3371
3583
|
t,
|
|
3372
|
-
zone: "dock"
|
|
3584
|
+
zone: "dock",
|
|
3585
|
+
onOpenSettings: openSettings
|
|
3373
3586
|
})
|
|
3374
3587
|
}, CodeArtsCreditDock));
|
|
3375
3588
|
/** 每次 claim 拿到的 inject disposer;拆的时候逐个调用(连带注销里面的注册)。 */
|
|
@@ -3444,11 +3657,76 @@ function apply(ctx) {
|
|
|
3444
3657
|
dropPanelSlots();
|
|
3445
3658
|
};
|
|
3446
3659
|
}, "dsh-codearts: sidebar panel opt-in");
|
|
3660
|
+
/**
|
|
3661
|
+
* 设置左侧导航里的入口(settings.section)。
|
|
3662
|
+
*
|
|
3663
|
+
* 和侧边栏那格一样按「注册 / 拆注册」实现:宿主是按槽位条目画导航行的,
|
|
3664
|
+
* 渲染 null 只会留下一个空白可点的行。缺省开 —— 这是用户找插件的主路径
|
|
3665
|
+
* (issue #7),只有明确关掉才拆。
|
|
3666
|
+
*/
|
|
3667
|
+
const settingsEntryClaims = [];
|
|
3668
|
+
const dropSettingsEntry = () => {
|
|
3669
|
+
for (const dispose of settingsEntryClaims.splice(0)) try {
|
|
3670
|
+
dispose();
|
|
3671
|
+
} catch (error) {
|
|
3672
|
+
console.error("[dsh-codearts] failed to release settings entry:", error);
|
|
3673
|
+
}
|
|
3674
|
+
};
|
|
3675
|
+
const syncSettingsEntry = () => {
|
|
3676
|
+
dropSettingsEntry();
|
|
3677
|
+
if (!settingsEntryWanted()) return;
|
|
3678
|
+
try {
|
|
3679
|
+
settingsEntryClaims.push(ctx.slots.inject("settings.section", () => {
|
|
3680
|
+
try {
|
|
3681
|
+
return ctx.slots.register({
|
|
3682
|
+
name: "settings.section",
|
|
3683
|
+
id: PANEL_ID,
|
|
3684
|
+
order: 50,
|
|
3685
|
+
label: () => t("tabLabel"),
|
|
3686
|
+
locale: namespace,
|
|
3687
|
+
inject: () => ({ t })
|
|
3688
|
+
}, CodeArtsPluginCard);
|
|
3689
|
+
} catch (error) {
|
|
3690
|
+
console.error("[dsh-codearts] settings entry unavailable:", error);
|
|
3691
|
+
return () => {};
|
|
3692
|
+
}
|
|
3693
|
+
}));
|
|
3694
|
+
} catch (error) {
|
|
3695
|
+
console.error("[dsh-codearts] settings section slot unavailable:", error);
|
|
3696
|
+
}
|
|
3697
|
+
};
|
|
3698
|
+
ctx.effect(() => {
|
|
3699
|
+
const off = subscribeSettingsEntryWanted(syncSettingsEntry);
|
|
3700
|
+
syncSettingsEntry();
|
|
3701
|
+
return () => {
|
|
3702
|
+
off();
|
|
3703
|
+
dropSettingsEntry();
|
|
3704
|
+
};
|
|
3705
|
+
}, "dsh-codearts: settings entry opt-out");
|
|
3706
|
+
/**
|
|
3707
|
+
* 共享的 dock 状态一变,两个入口的注册/拆注册跟着走。
|
|
3708
|
+
*
|
|
3709
|
+
* 以前只有「卡片挂载时」才把开关值写进 panel-switch;如果另一张卡片或 60 秒
|
|
3710
|
+
* 轮询先拿到新值,就会出现「卡片上勾着、导航里却没有入口」(实测)。
|
|
3711
|
+
*/
|
|
3712
|
+
ctx.effect(() => {
|
|
3713
|
+
const apply = () => {
|
|
3714
|
+
const { dock, loaded } = dockSnapshot();
|
|
3715
|
+
if (!loaded) return;
|
|
3716
|
+
setSettingsEntryWanted(dock.settingsEntry !== false);
|
|
3717
|
+
setSidebarPanelWanted(dock.sidebar === true);
|
|
3718
|
+
};
|
|
3719
|
+
const off = subscribeDock(apply);
|
|
3720
|
+
apply();
|
|
3721
|
+
return off;
|
|
3722
|
+
}, "dsh-codearts: entry switches follow dock state");
|
|
3447
3723
|
(async () => {
|
|
3448
3724
|
try {
|
|
3449
3725
|
const res = await fetch("/api/codearts/dock", { headers: { Accept: "application/json" } });
|
|
3450
3726
|
if (!res.ok) return;
|
|
3451
|
-
|
|
3727
|
+
const data = await res.json();
|
|
3728
|
+
setSidebarPanelWanted(data.dock?.sidebar === true);
|
|
3729
|
+
setSettingsEntryWanted(data.dock?.settingsEntry !== false);
|
|
3452
3730
|
} catch {}
|
|
3453
3731
|
})();
|
|
3454
3732
|
} catch (error) {
|