dsh-volcengine-provider 0.2.14 → 0.2.16
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/docs/changelog.md +14 -0
- package/docs/model-capabilities.md +31 -33
- package/docs/usage.md +3 -3
- package/lib/catalog-snapshot.json +150 -121
- package/lib/catalog.mjs +9 -2
- package/lib/client.js +481 -93
- package/package.json +56 -11
package/lib/client.js
CHANGED
|
@@ -163,6 +163,65 @@ const ADAPTIVE_MODE_HINTS = {
|
|
|
163
163
|
false: `预算兼容模式:SDK 将 ${BUDGET_EFFORTS.join('/')} 转成预算,xhigh/max 会被折叠成 high,非 off 映射值须与档位同名;方舟官方档位使用原生模式。已有映射可手工调整 JSON。`
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* 思考预设:一键写入常用的档位组合,避免手写 JSON。
|
|
168
|
+
* 预设只组装已有的草稿字段(effortsMode/effortsText/defaultReasoning/adaptive),不引入新存储,
|
|
169
|
+
* 因此旧版 Host 与已有保存逻辑无需改动即可消费。
|
|
170
|
+
*/
|
|
171
|
+
const THINKING_PRESETS = [
|
|
172
|
+
{ value: 'inherit', label: '继承目录默认' },
|
|
173
|
+
{ value: 'server', label: '服务端默认(不强制档位)' },
|
|
174
|
+
{ value: 'saver', label: '省 token(低档位)' },
|
|
175
|
+
{ value: 'max', label: '最强思考(高档位)' },
|
|
176
|
+
{ value: 'off', label: '关闭思考(如模型支持)' }
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
/** 省 token / 最强思考在目录档位里的候选顺序:按顺序取目录实际声明的第一个。 */
|
|
180
|
+
const SAVER_TIER_ORDER = ['low', 'minimal', 'medium'];
|
|
181
|
+
const MAX_TIER_ORDER = ['max', 'xhigh', 'high'];
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 计算各思考预设在当前模型上是否可用。
|
|
185
|
+
* 不可用时返回 null/false,界面据此禁用对应预设按钮并给出原因。
|
|
186
|
+
*
|
|
187
|
+
* @param {object} model 目录里的模型对象
|
|
188
|
+
* @returns {{saver: string|null, max: string|null, off: boolean}} 可用的档位(不可用为 null/false)
|
|
189
|
+
*/
|
|
190
|
+
function thinkingPresetAvailability(model) {
|
|
191
|
+
const inherited = inheritedEfforts(model);
|
|
192
|
+
const tiers = inherited && typeof inherited === 'object' ? Object.keys(inherited) : [];
|
|
193
|
+
const pick = (order) => order.find((tier) => tiers.includes(tier)) ?? null;
|
|
194
|
+
return {
|
|
195
|
+
saver: pick(SAVER_TIER_ORDER),
|
|
196
|
+
max: pick(MAX_TIER_ORDER),
|
|
197
|
+
off: tiers.includes('off') && model?.canDisableThinking !== false
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 把思考预设展开成参数草稿补丁(只含已有草稿字段)。
|
|
203
|
+
* 省 token / 最强思考只改默认档位、不动档位映射,保留目录的全部可选档位;
|
|
204
|
+
* 关闭思考在目录已声明 off:null 时同样只改默认档位,否则才写入最小映射 {off:null}。
|
|
205
|
+
*
|
|
206
|
+
* @param {string} preset 预设标识
|
|
207
|
+
* @param {object} model 目录里的模型对象
|
|
208
|
+
* @returns {object|null} 草稿补丁,不可用时返回 null
|
|
209
|
+
*/
|
|
210
|
+
function applyThinkingPreset(preset, model) {
|
|
211
|
+
const availability = thinkingPresetAvailability(model);
|
|
212
|
+
if (preset === 'inherit') return { effortsMode: 'inherit', effortsText: '', defaultReasoning: 'inherit', adaptive: 'inherit' };
|
|
213
|
+
if (preset === 'server') return { effortsMode: 'inherit', effortsText: '', defaultReasoning: 'none', adaptive: 'inherit' };
|
|
214
|
+
if (preset === 'saver' && availability.saver) return { effortsMode: 'inherit', effortsText: '', defaultReasoning: availability.saver, adaptive: 'inherit' };
|
|
215
|
+
if (preset === 'max' && availability.max) return { effortsMode: 'inherit', effortsText: '', defaultReasoning: availability.max, adaptive: 'inherit' };
|
|
216
|
+
if (preset === 'off' && availability.off) {
|
|
217
|
+
const inherited = inheritedEfforts(model);
|
|
218
|
+
const declaredOff = inherited && typeof inherited === 'object' ? inherited.off : undefined;
|
|
219
|
+
if (declaredOff === null) return { effortsMode: 'inherit', effortsText: '', defaultReasoning: 'off', adaptive: 'inherit' };
|
|
220
|
+
return { effortsMode: 'map', effortsText: JSON.stringify({ off: null }), defaultReasoning: 'off', adaptive: 'inherit' };
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
|
|
166
225
|
/** 温度与输出 token 的已知约束:思考开启时上游可能忽略温度。 */
|
|
167
226
|
const TEMPERATURE_HINT = '开启思考时上游可能忽略温度;输出 token 还受思考预算与上下文长度约束。';
|
|
168
227
|
|
|
@@ -621,7 +680,8 @@ function busyMessage(key) {
|
|
|
621
680
|
quota: `正在查询${target}的额度…`, provider: `正在更新${target}的启用状态…`,
|
|
622
681
|
model: `正在更新模型 ${model} 的启用状态…`, settings: `正在保存模型 ${model} 的参数…`,
|
|
623
682
|
reset: `正在恢复模型 ${model} 的默认参数…`, login: '正在启动官方网页登录…',
|
|
624
|
-
'cancel-login': '正在取消登录…', save: '正在保存账号…', delete: '正在删除账号…'
|
|
683
|
+
'cancel-login': '正在取消登录…', save: '正在保存账号…', delete: '正在删除账号…',
|
|
684
|
+
'submit-login-code': '正在提交授权码并验证登录…'
|
|
625
685
|
};
|
|
626
686
|
return messages[operation] || '正在处理…';
|
|
627
687
|
}
|
|
@@ -784,6 +844,11 @@ function draftTiers(draft, model) {
|
|
|
784
844
|
*/
|
|
785
845
|
function parseModelSettings(draft, model) {
|
|
786
846
|
const problems = [];
|
|
847
|
+
const fieldErrors = {};
|
|
848
|
+
const fail = (field, message) => {
|
|
849
|
+
problems.push(message);
|
|
850
|
+
if (!fieldErrors[field]) fieldErrors[field] = message;
|
|
851
|
+
};
|
|
787
852
|
const settings = {};
|
|
788
853
|
const text = (key) => String(draft?.[key] ?? '').trim();
|
|
789
854
|
|
|
@@ -792,7 +857,7 @@ function parseModelSettings(draft, model) {
|
|
|
792
857
|
if (!raw) continue; // 空值=继承目录默认,不写进负载。
|
|
793
858
|
const value = Number(raw);
|
|
794
859
|
if (!/^\d+$/.test(raw) || !Number.isSafeInteger(value) || value <= 0) {
|
|
795
|
-
|
|
860
|
+
fail(key, `${MODEL_FIELD_LABELS[key]} 须为正整数。`);
|
|
796
861
|
continue;
|
|
797
862
|
}
|
|
798
863
|
settings[key] = value;
|
|
@@ -801,7 +866,7 @@ function parseModelSettings(draft, model) {
|
|
|
801
866
|
const temperature = text('temperature');
|
|
802
867
|
if (temperature) {
|
|
803
868
|
const value = Number(temperature);
|
|
804
|
-
if (!Number.isFinite(value) || value < 0 || value > 1)
|
|
869
|
+
if (!Number.isFinite(value) || value < 0 || value > 1) fail('temperature', '温度 temperature 须为 0 到 1 之间的数值。');
|
|
805
870
|
else settings.temperature = value;
|
|
806
871
|
}
|
|
807
872
|
|
|
@@ -834,7 +899,7 @@ function parseModelSettings(draft, model) {
|
|
|
834
899
|
if (entries.some(([tier, value]) => tier !== 'off' && (typeof value !== 'string' || !value.trim()))) effortProblems.push('除 off 外的档位必须映射到非空字符串。');
|
|
835
900
|
if (!entries.some(([tier]) => tier !== 'off')) effortProblems.push('至少要声明一个非 off 档位。');
|
|
836
901
|
}
|
|
837
|
-
if (effortProblems.length)
|
|
902
|
+
if (effortProblems.length) effortProblems.forEach((message) => fail('effortsText', message));
|
|
838
903
|
else {
|
|
839
904
|
settings.reasoningEfforts = parsed;
|
|
840
905
|
effortsMap = parsed;
|
|
@@ -858,17 +923,17 @@ function parseModelSettings(draft, model) {
|
|
|
858
923
|
? ';请手工调整 JSON 映射(不会自动删除已有映射)'
|
|
859
924
|
: ';当前档位映射来自目录默认,请改为自定义 JSON 映射';
|
|
860
925
|
if (badTiers.length || badValues.length) {
|
|
861
|
-
|
|
926
|
+
fail('adaptive', `预算模式仅支持 ${BUDGET_EFFORTS.join('/')},非 off 映射值与档位同名${suffix}`);
|
|
862
927
|
}
|
|
863
|
-
if (badOff.length)
|
|
928
|
+
if (badOff.length) fail('adaptive', `预算模式下 off 档位只能为空值(null)${suffix}`);
|
|
864
929
|
}
|
|
865
930
|
|
|
866
|
-
if (model?.canDisableThinking === false && effortsMap?.off === null)
|
|
931
|
+
if (model?.canDisableThinking === false && effortsMap?.off === null) fail('effortsText', '该模型为常驻思考,请移除 off 映射或改用思考预设。');
|
|
867
932
|
const defaultReasoning = draft?.defaultReasoning ?? 'inherit';
|
|
868
933
|
if (defaultReasoning === 'none') {
|
|
869
934
|
settings.defaultReasoning = null;
|
|
870
935
|
} else if (defaultReasoning !== 'inherit') {
|
|
871
|
-
if (!draftTiers(draft, model).includes(defaultReasoning))
|
|
936
|
+
if (!draftTiers(draft, model).includes(defaultReasoning)) fail('defaultReasoning', '默认思考档位必须是有效档位建议改用思考预设一键写入。');
|
|
872
937
|
else settings.defaultReasoning = defaultReasoning;
|
|
873
938
|
}
|
|
874
939
|
|
|
@@ -876,8 +941,8 @@ function parseModelSettings(draft, model) {
|
|
|
876
941
|
if (adaptive === 'true') settings.forceAdaptiveThinking = true;
|
|
877
942
|
else if (adaptive === 'false') settings.forceAdaptiveThinking = false;
|
|
878
943
|
|
|
879
|
-
if (problems.length) return { settings: null, error: problems.join(' ') };
|
|
880
|
-
return { settings, error: null };
|
|
944
|
+
if (problems.length) return { settings: null, error: problems.join(' '), fieldErrors };
|
|
945
|
+
return { settings, error: null, fieldErrors: null };
|
|
881
946
|
}
|
|
882
947
|
|
|
883
948
|
// ── 展示组件 ─────────────────────────────────────────────────────────────────
|
|
@@ -974,7 +1039,7 @@ function QuotaWindows({ quota }) {
|
|
|
974
1039
|
return h('div', { key: `${item?.kind ?? 'w'}-${position}`, className: 'vcp-quota-window', 'data-tone': summary.tone },
|
|
975
1040
|
h('div', { className: 'vcp-quota-line' },
|
|
976
1041
|
h('span', { className: 'vcp-quota-name' }, label),
|
|
977
|
-
summary.tone !== 'muted' ? h(StatusChip, { tone: summary.tone }, resetPassed ? '待刷新' : summary.tone === 'error' ? '已用尽' : '余量不足') : null,
|
|
1042
|
+
summary.tone !== 'muted' ? h(StatusChip, { tone: summary.tone }, resetPassed && remaining === 0 ? '已用尽 · 待刷新' : resetPassed ? '待刷新' : summary.tone === 'error' ? '已用尽' : '余量不足') : null,
|
|
978
1043
|
h('span', { className: 'vcp-quota-value' }, remaining === null
|
|
979
1044
|
? h('span', { style: style.muted }, '百分比未提供')
|
|
980
1045
|
: [
|
|
@@ -987,37 +1052,205 @@ function QuotaWindows({ quota }) {
|
|
|
987
1052
|
'aria-label': `${label}剩余额度`, 'aria-valuetext': `剩余 ${formatPercent(remaining)}%`
|
|
988
1053
|
}, h('div', { className: 'vcp-quota-fill', style: { width: `${remaining}%`, minWidth: remaining > 0 ? 4 : 0 } })) : null,
|
|
989
1054
|
usageParts.length ? h('div', { className: 'vcp-quota-meta' }, usageParts.join(' · ')) : null,
|
|
990
|
-
h('div', { className: 'vcp-quota-reset' },
|
|
1055
|
+
h('div', { className: 'vcp-quota-reset', 'aria-live': 'off' },
|
|
991
1056
|
h('span', null, resetCountdown(item?.resetsAt, now)),
|
|
992
1057
|
resetEpoch(item?.resetsAt) !== null
|
|
993
|
-
? h('time', { dateTime: item.resetsAt }, `重置于 ${formatTime(item.resetsAt)}`) : null));
|
|
1058
|
+
? h('time', { dateTime: item.resetsAt, title: '仅在接口返回有效时间时显示倒计时' }, `重置于 ${formatTime(item.resetsAt)}`) : null));
|
|
994
1059
|
})
|
|
995
1060
|
))
|
|
996
1061
|
);
|
|
997
1062
|
}
|
|
998
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* 按模型的目录理论上限给稀疏档位(codex 式 standard/extended/maximum 思路):
|
|
1066
|
+
* 上下文固定档 128K/256K/512K/1M,输出固定档 32K/64K/128K/256K,
|
|
1067
|
+
* 只保留不超过该模型上限的部分;理论上限本身总是顶档("最大"),
|
|
1068
|
+
* 已有自定义值保留为独立凹点,不因改成滑块而吞掉任意整数。
|
|
1069
|
+
* ceiling 为字段的真实上限:上下文取目录 contextWindow,输出取目录 maxTokensCeiling
|
|
1070
|
+
* (未声明时退回默认 maxTokens)——部分模型可协商输出上限高于目录默认值。
|
|
1071
|
+
*/
|
|
1072
|
+
const CAPACITY_LEVELS = {
|
|
1073
|
+
contextWindow: [131072, 262144, 524288, 1048576],
|
|
1074
|
+
maxTokens: [32768, 65536, 131072, 262144]
|
|
1075
|
+
};
|
|
1076
|
+
function capacityStops(key, ceilingValue, currentValue) {
|
|
1077
|
+
const ceiling = Number.isSafeInteger(ceilingValue) && ceilingValue > 0 ? ceilingValue : undefined;
|
|
1078
|
+
const stops = new Set((CAPACITY_LEVELS[key] ?? []).filter(level => ceiling === undefined || level <= ceiling));
|
|
1079
|
+
if (ceiling !== undefined) stops.add(ceiling);
|
|
1080
|
+
if (Number.isSafeInteger(currentValue) && currentValue > 0) stops.add(currentValue);
|
|
1081
|
+
return [...stops].sort((a, b) => a - b);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* codex-connect 式离散凹点滑块:键盘方向键/Home/End 与 pointer 拖拽均可到达档位。
|
|
1086
|
+
* choices 为升序整数刻度;value 必须等于某个刻度(调用方负责把自定义值并进 choices)。
|
|
1087
|
+
*/
|
|
1088
|
+
function CapacitySlider({ choices, value, label, disabled, onChange }) {
|
|
1089
|
+
const selected = Math.max(0, choices.indexOf(value));
|
|
1090
|
+
const [preview, setPreview] = react.useState();
|
|
1091
|
+
const drag = react.useRef();
|
|
1092
|
+
react.useEffect(() => { if (drag.current === undefined) setPreview(undefined); }, [value]);
|
|
1093
|
+
const locked = disabled || choices.length === 1;
|
|
1094
|
+
const current = preview === undefined ? selected : preview;
|
|
1095
|
+
const active = choices[Math.max(0, Math.min(choices.length - 1, Math.round(current)))];
|
|
1096
|
+
const color = 'var(--dsw-alias-brand-primary, #2563eb)';
|
|
1097
|
+
const position = (index) => `${(index + 0.5) * 100 / choices.length}%`;
|
|
1098
|
+
const rawPosition = (event) => {
|
|
1099
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1100
|
+
return rect.width > 0 ? Math.max(0, Math.min(choices.length - 1, (event.clientX - rect.left) / rect.width * choices.length - 0.5)) : selected;
|
|
1101
|
+
};
|
|
1102
|
+
const cancel = () => { drag.current = undefined; setPreview(undefined); };
|
|
1103
|
+
const choose = (index) => {
|
|
1104
|
+
const choice = choices[index];
|
|
1105
|
+
if (!locked && choice !== undefined && choice !== value) onChange(choice);
|
|
1106
|
+
};
|
|
1107
|
+
return h('div', {
|
|
1108
|
+
role: 'slider', tabIndex: locked ? -1 : 0,
|
|
1109
|
+
'aria-label': label, 'aria-disabled': locked,
|
|
1110
|
+
'aria-valuemin': 0, 'aria-valuemax': choices.length - 1,
|
|
1111
|
+
'aria-valuenow': Math.round(current), 'aria-valuetext': formatTokenCount(active),
|
|
1112
|
+
'data-stops': choices.join(','),
|
|
1113
|
+
style: { position: 'relative', width: '100%', maxWidth: 560, height: 30, flexShrink: 0, touchAction: 'pan-y', userSelect: 'none', cursor: locked ? 'default' : 'ew-resize', opacity: disabled ? 0.5 : 1 },
|
|
1114
|
+
onKeyDown: (event) => {
|
|
1115
|
+
if (event.key === 'Escape') { cancel(); return; }
|
|
1116
|
+
if (locked) return;
|
|
1117
|
+
const index = event.key === 'Home' ? 0 : event.key === 'End' ? choices.length - 1
|
|
1118
|
+
: event.key === 'ArrowLeft' || event.key === 'ArrowDown' ? Math.max(0, selected - 1)
|
|
1119
|
+
: event.key === 'ArrowRight' || event.key === 'ArrowUp' ? Math.min(choices.length - 1, selected + 1) : undefined;
|
|
1120
|
+
if (index !== undefined) { event.preventDefault(); choose(index); }
|
|
1121
|
+
},
|
|
1122
|
+
onPointerDown: (event) => {
|
|
1123
|
+
if (locked || event.button !== 0) return;
|
|
1124
|
+
event.preventDefault(); event.currentTarget.focus(); event.currentTarget.setPointerCapture(event.pointerId);
|
|
1125
|
+
const index = Math.round(rawPosition(event));
|
|
1126
|
+
drag.current = { pointer: event.pointerId, index }; setPreview(index);
|
|
1127
|
+
},
|
|
1128
|
+
onPointerMove: (event) => {
|
|
1129
|
+
const state = drag.current;
|
|
1130
|
+
if (locked || state === undefined || state.pointer !== event.pointerId) return;
|
|
1131
|
+
const raw = rawPosition(event);
|
|
1132
|
+
// 边界滞回:指针越过凹点边界一段距离才切换,避免悬停抖动。
|
|
1133
|
+
if (raw > state.index + 0.62 || raw < state.index - 0.62) state.index = Math.round(raw);
|
|
1134
|
+
setPreview(state.index + Math.tanh((raw - state.index) * 3) * 0.09);
|
|
1135
|
+
},
|
|
1136
|
+
onPointerUp: (event) => {
|
|
1137
|
+
const state = drag.current;
|
|
1138
|
+
if (state === undefined || state.pointer !== event.pointerId) return;
|
|
1139
|
+
const index = state.index;
|
|
1140
|
+
drag.current = undefined;
|
|
1141
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
|
|
1142
|
+
setPreview(index);
|
|
1143
|
+
choose(index);
|
|
1144
|
+
},
|
|
1145
|
+
onPointerCancel: cancel,
|
|
1146
|
+
onLostPointerCapture: cancel
|
|
1147
|
+
},
|
|
1148
|
+
h('span', {
|
|
1149
|
+
'aria-hidden': 'true',
|
|
1150
|
+
style: { display: 'grid', gridTemplateColumns: `repeat(${choices.length}, 1fr)`, fontSize: 10, lineHeight: '16px', textAlign: 'center' }
|
|
1151
|
+
}, choices.map((choice, index) => h('span', {
|
|
1152
|
+
key: choice,
|
|
1153
|
+
style: { color: index === Math.round(current) ? color : 'var(--dsw-alias-label-secondary, #64748b)', whiteSpace: 'nowrap', overflow: 'hidden' }
|
|
1154
|
+
}, formatTokenCount(choice)))),
|
|
1155
|
+
h('span', { 'aria-hidden': 'true', style: { position: 'absolute', left: position(0), right: position(0), bottom: 5, height: 2, borderRadius: 999, background: 'var(--dsw-alias-border-l2, rgba(128,128,128,.35))' } }),
|
|
1156
|
+
choices.map((choice, index) => h('span', {
|
|
1157
|
+
key: choice, 'aria-hidden': 'true',
|
|
1158
|
+
style: { position: 'absolute', left: position(index), transform: 'translateX(-50%)', bottom: 3, width: 6, height: 6, borderRadius: '50%', background: 'var(--dsw-alias-border-l2, rgba(128,128,128,.35))' }
|
|
1159
|
+
})),
|
|
1160
|
+
h('span', {
|
|
1161
|
+
'aria-hidden': 'true', 'data-capacity-thumb': '',
|
|
1162
|
+
style: { position: 'absolute', left: position(current), transform: 'translateX(-50%)', bottom: 0, width: 12, height: 12, borderRadius: '50%', border: 0, boxSizing: 'border-box', background: color, transition: drag.current === undefined ? 'left 100ms ease-out' : 'none' }
|
|
1163
|
+
})
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
999
1167
|
/**
|
|
1000
1168
|
* 模型参数编辑面板。
|
|
1001
1169
|
*
|
|
1002
1170
|
* 空数字=继承目录默认;档位映射可整段关闭(false)或自定义 JSON;
|
|
1003
1171
|
* 默认档位分「继承 / 不强制 / 有效档位」三态;思考模式分「继承 / 原生 effort / 固定预算」。
|
|
1172
|
+
* 上下文长度与最大输出用档位滑块选择(刻度含目录默认与已有自定义值),勾选「继承」时不写覆盖。
|
|
1004
1173
|
*
|
|
1005
1174
|
* @param {object} props 组件属性
|
|
1006
1175
|
* @returns {object} 元素树
|
|
1007
1176
|
*/
|
|
1008
|
-
function ModelSettingsEditor({ model, draft, error, disabled, onChange, onSave, onCancel }) {
|
|
1177
|
+
function ModelSettingsEditor({ model, draft, error, fieldErrors, disabled, onChange, onSave, onCancel }) {
|
|
1009
1178
|
const stackedField = { ...style.field, flex: '0 0 auto', minWidth: 0 };
|
|
1010
1179
|
const effortsMode = draft?.effortsMode ?? 'inherit';
|
|
1011
1180
|
const tiers = draftTiers(draft, model);
|
|
1012
1181
|
const selectedDefault = draft?.defaultReasoning ?? 'inherit';
|
|
1013
1182
|
const staleDefault = !['inherit', 'none'].includes(selectedDefault) && !tiers.includes(selectedDefault);
|
|
1183
|
+
const presetAvailability = thinkingPresetAvailability(model);
|
|
1184
|
+
const presetUsable = (value) => {
|
|
1185
|
+
if (value === 'inherit' || value === 'server') return { usable: true, reason: '' };
|
|
1186
|
+
if (value === 'saver') return presetAvailability.saver
|
|
1187
|
+
? { usable: true, reason: `将默认档位设为 ${presetAvailability.saver},保留目录的全部可选档位。` }
|
|
1188
|
+
: { usable: false, reason: '该模型目录未声明低档位(low/minimal/medium),无法使用省 token 预设。' };
|
|
1189
|
+
if (value === 'max') return presetAvailability.max
|
|
1190
|
+
? { usable: true, reason: `将默认档位设为 ${presetAvailability.max},保留目录的全部可选档位。` }
|
|
1191
|
+
: { usable: false, reason: '该模型目录未声明高档位(max/xhigh/high),无法使用最强思考预设。' };
|
|
1192
|
+
return presetAvailability.off
|
|
1193
|
+
? { usable: true, reason: '将默认档位设为关闭思考。' }
|
|
1194
|
+
: { usable: false, reason: model?.canDisableThinking === false ? '该模型为常驻思考,不支持关闭。' : '该模型目录未声明 off 档位,无法使用关闭预设。' };
|
|
1195
|
+
};
|
|
1196
|
+
const fieldError = (key) => fieldErrors?.[key]
|
|
1197
|
+
? h('p', { role: 'alert', style: style.error }, fieldErrors[key])
|
|
1198
|
+
: null;
|
|
1014
1199
|
const numberField = (key, label) => h('label', { style: style.field },
|
|
1015
1200
|
h('span', { style: style.label }, label),
|
|
1016
1201
|
h('input', {
|
|
1017
1202
|
type: 'text', inputMode: 'numeric', style: style.input, value: draft?.[key] ?? '', disabled,
|
|
1018
1203
|
'aria-label': label, placeholder: '留空表示继承目录默认', autoComplete: 'off', spellCheck: false,
|
|
1019
1204
|
onChange: (event) => onChange({ [key]: event.target.value })
|
|
1020
|
-
})
|
|
1205
|
+
}),
|
|
1206
|
+
fieldError(key));
|
|
1207
|
+
/**
|
|
1208
|
+
* 容量档位滑块行:勾选「继承目录默认」不写覆盖(草稿为空),取消勾选落到目录默认值上再拖档。
|
|
1209
|
+
* 刻度 = 固定档位 ∪ 目录默认 ∪ 当前自定义值(旧设置里的任意整数保留为独立凹点,不被滑块吞掉)。
|
|
1210
|
+
*/
|
|
1211
|
+
const capacityRow = (key, label) => {
|
|
1212
|
+
const inherited = (draft?.[key] ?? '') === '';
|
|
1213
|
+
const inheritedValue = model?.defaults?.[key];
|
|
1214
|
+
// 滑块顶档是字段真实上限:输出取目录声明的可协商上限(未声明时即默认值)。
|
|
1215
|
+
// 上游注册目录另有 maxReasoningTokenLength:思考开启时输出上限更低(如 DeepSeek V4 系
|
|
1216
|
+
// 非思考 384K / 思考 128K)。思考映射整体停用(effortsMode 'none')时才放开到非思考上限。
|
|
1217
|
+
let ceiling = key === 'maxTokens' ? (model?.defaults?.maxTokensCeiling ?? inheritedValue) : inheritedValue;
|
|
1218
|
+
let reasoningCapped = false;
|
|
1219
|
+
if (key === 'maxTokens') {
|
|
1220
|
+
const mr = model?.defaults?.maxReasoningTokenLength;
|
|
1221
|
+
const thinkingOn = (draft?.effortsMode ?? 'inherit') !== 'none';
|
|
1222
|
+
if (thinkingOn && Number.isSafeInteger(mr) && mr > 0 && mr < ceiling) {
|
|
1223
|
+
ceiling = mr;
|
|
1224
|
+
reasoningCapped = true;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
const draftValue = Number.parseInt(draft?.[key], 10);
|
|
1228
|
+
const sliderValue = inherited ? inheritedValue : draftValue;
|
|
1229
|
+
const stops = capacityStops(key, ceiling, Number.isFinite(sliderValue) ? sliderValue : undefined);
|
|
1230
|
+
return h('div', { style: { display: 'grid', gap: 6 } },
|
|
1231
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
|
|
1232
|
+
h('span', { style: style.label }, label),
|
|
1233
|
+
h('label', { className: 'vcp-plan-toggle', style: { display: 'inline-flex', alignItems: 'center', gap: 6 } },
|
|
1234
|
+
h('input', {
|
|
1235
|
+
type: 'checkbox', checked: inherited, disabled,
|
|
1236
|
+
'aria-label': `继承 ${label}`,
|
|
1237
|
+
style: { width: 18, height: 18, margin: 0, flex: '0 0 auto', accentColor: 'var(--dsw-alias-brand-primary, Highlight)' },
|
|
1238
|
+
// 取消继承先落到目录默认值,再由用户向顶档拖;不直接跳到理论上限。
|
|
1239
|
+
onChange: (event) => onChange({ [key]: event.target.checked ? '' : String(inheritedValue ?? stops[stops.length - 1] ?? '') })
|
|
1240
|
+
}),
|
|
1241
|
+
h('span', { style: { fontSize: 12 } }, '继承目录默认')),
|
|
1242
|
+
h('span', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary, #64748b)', fontVariantNumeric: 'tabular-nums' } },
|
|
1243
|
+
inherited
|
|
1244
|
+
? `目录默认 ${formatTokenCount(inheritedValue)}${ceiling && ceiling !== inheritedValue ? ` · 上限 ${formatTokenCount(ceiling)}${reasoningCapped ? '(思考)' : ''}` : ''}`
|
|
1245
|
+
: `当前 ${formatTokenCount(sliderValue)}(${Number.isFinite(sliderValue) ? sliderValue : '—'} token)${reasoningCapped ? ` · 思考上限 ${formatTokenCount(ceiling)}` : ''}`)),
|
|
1246
|
+
h(CapacitySlider, {
|
|
1247
|
+
choices: stops,
|
|
1248
|
+
value: stops.includes(sliderValue) ? sliderValue : stops[0],
|
|
1249
|
+
label, disabled: disabled || inherited,
|
|
1250
|
+
onChange: (choice) => onChange({ [key]: String(choice) })
|
|
1251
|
+
}),
|
|
1252
|
+
fieldError(key));
|
|
1253
|
+
};
|
|
1021
1254
|
const capabilityCheckbox = (key, label) => {
|
|
1022
1255
|
const mode = draft?.[key] ?? 'inherit';
|
|
1023
1256
|
const inherited = model?.defaults?.[key];
|
|
@@ -1044,10 +1277,10 @@ function ModelSettingsEditor({ model, draft, error, disabled, onChange, onSave,
|
|
|
1044
1277
|
capabilityCheckbox(key, label), h('span', null, text));
|
|
1045
1278
|
return h('div', { className: 'vcp-editor' },
|
|
1046
1279
|
h('div', { style: { fontWeight: 650, fontSize: 13 } }, `模型参数:${model?.name || model?.id}`),
|
|
1047
|
-
h('div', { className: 'vcp-fields
|
|
1048
|
-
numberField('contextWindow', MODEL_FIELD_LABELS.contextWindow),
|
|
1049
|
-
numberField('maxTokens', MODEL_FIELD_LABELS.maxTokens),
|
|
1280
|
+
h('div', { className: 'vcp-fields' },
|
|
1050
1281
|
numberField('temperature', MODEL_FIELD_LABELS.temperature)),
|
|
1282
|
+
capacityRow('contextWindow', MODEL_FIELD_LABELS.contextWindow),
|
|
1283
|
+
capacityRow('maxTokens', MODEL_FIELD_LABELS.maxTokens),
|
|
1051
1284
|
h('p', { style: style.muted }, TEMPERATURE_HINT),
|
|
1052
1285
|
h('section', { className: 'vcp-section', 'aria-label': '模型输入与工具调用' },
|
|
1053
1286
|
h('div', { className: 'vcp-actions' },
|
|
@@ -1072,48 +1305,67 @@ function ModelSettingsEditor({ model, draft, error, disabled, onChange, onSave,
|
|
|
1072
1305
|
? h('p', { style: style.muted }, '禁用后模型不能发起新工具调用;历史消息中的工具调用回放保留。') : null,
|
|
1073
1306
|
h('p', { style: style.muted }, '音频 / 视频:本 DSH 通道不可用,不提供能力覆盖开关。'),
|
|
1074
1307
|
h('p', { style: style.muted }, '独立 JSON Schema 结构化输出:本 DSH 通道暂不可用,不提供配置开关。')),
|
|
1075
|
-
h('
|
|
1076
|
-
h('
|
|
1077
|
-
h('
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
'
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
h('
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
},
|
|
1115
|
-
|
|
1116
|
-
|
|
1308
|
+
h('section', { className: 'vcp-section', 'aria-label': '思考配置(高级)' },
|
|
1309
|
+
h('strong', { style: { fontSize: 13 } }, '思考配置(高级)'),
|
|
1310
|
+
h('p', { style: style.muted }, '多数情况用预设一键写入即可;只有需要自定义档位组合时才手工改 JSON。'),
|
|
1311
|
+
h('div', { className: 'vcp-actions', role: 'group', 'aria-label': '思考预设' },
|
|
1312
|
+
THINKING_PRESETS.map((preset) => {
|
|
1313
|
+
const state = presetUsable(preset.value);
|
|
1314
|
+
return h('button', {
|
|
1315
|
+
key: preset.value, type: 'button', style: style.btn,
|
|
1316
|
+
disabled: disabled || !state.usable, title: state.reason || preset.label,
|
|
1317
|
+
'aria-label': `思考预设:${preset.label}`,
|
|
1318
|
+
onClick: () => {
|
|
1319
|
+
const patch = applyThinkingPreset(preset.value, model);
|
|
1320
|
+
if (patch) onChange(patch);
|
|
1321
|
+
}
|
|
1322
|
+
}, preset.label);
|
|
1323
|
+
})),
|
|
1324
|
+
h('label', { style: stackedField },
|
|
1325
|
+
h('span', { style: style.label }, '思考档位映射 reasoningEfforts'),
|
|
1326
|
+
h('select', {
|
|
1327
|
+
style: style.input, value: effortsMode, disabled, 'aria-label': '思考档位映射 reasoningEfforts',
|
|
1328
|
+
onChange: (event) => onChange({ effortsMode: event.target.value })
|
|
1329
|
+
},
|
|
1330
|
+
h('option', { value: 'inherit' }, '继承目录默认'),
|
|
1331
|
+
h('option', { value: 'none' }, '不提供可选思考档位(false)'),
|
|
1332
|
+
h('option', { value: 'map' }, '自定义 JSON 映射'))),
|
|
1333
|
+
effortsMode === 'none'
|
|
1334
|
+
? h('p', { style: style.muted }, 'reasoningEfforts=false 表示不提供可选思考档位(按模型默认);底层可能不发 thinking 字段,不等于强制关闭思考。真正关闭思考需要把默认档位设为 off 且映射声明 off:null。')
|
|
1335
|
+
: null,
|
|
1336
|
+
effortsMode === 'map'
|
|
1337
|
+
? h('label', { style: stackedField },
|
|
1338
|
+
h('span', { style: style.label }, 'JSON 映射'),
|
|
1339
|
+
h('textarea', {
|
|
1340
|
+
style: { ...style.input, minHeight: 64 }, value: draft?.effortsText ?? '', disabled,
|
|
1341
|
+
'aria-label': 'JSON 映射', spellCheck: false, autoComplete: 'off',
|
|
1342
|
+
onChange: (event) => onChange({ effortsText: event.target.value })
|
|
1343
|
+
}),
|
|
1344
|
+
fieldError('effortsText'))
|
|
1345
|
+
: null,
|
|
1346
|
+
effortsMode === 'map' ? h('p', { style: style.muted }, EFFORTS_HINT) : null,
|
|
1347
|
+
h('label', { style: stackedField },
|
|
1348
|
+
h('span', { style: style.label }, '默认思考档位 defaultReasoning'),
|
|
1349
|
+
h('select', {
|
|
1350
|
+
style: style.input, value: draft?.defaultReasoning ?? 'inherit', disabled,
|
|
1351
|
+
'aria-label': '默认思考档位 defaultReasoning',
|
|
1352
|
+
onChange: (event) => onChange({ defaultReasoning: event.target.value })
|
|
1353
|
+
},
|
|
1354
|
+
h('option', { value: 'inherit' }, '继承目录默认'),
|
|
1355
|
+
h('option', { value: 'none' }, '不强制档位(使用服务端默认)'),
|
|
1356
|
+
staleDefault ? h('option', { value: selectedDefault, disabled: true }, `${selectedDefault}(已失效,请重选)`) : null,
|
|
1357
|
+
tiers.map((tier) => h('option', { key: tier, value: tier }, tier)))),
|
|
1358
|
+
fieldError('defaultReasoning'),
|
|
1359
|
+
h('label', { style: stackedField },
|
|
1360
|
+
h('span', { style: style.label }, '思考模式 forceAdaptiveThinking'),
|
|
1361
|
+
h('select', {
|
|
1362
|
+
style: style.input, value: draft?.adaptive ?? 'inherit', disabled,
|
|
1363
|
+
'aria-label': '思考模式 forceAdaptiveThinking',
|
|
1364
|
+
onChange: (event) => onChange({ adaptive: event.target.value })
|
|
1365
|
+
},
|
|
1366
|
+
ADAPTIVE_MODE_OPTIONS.map((option) => h('option', { key: option.value, value: option.value }, option.label)))),
|
|
1367
|
+
ADAPTIVE_MODE_HINTS[draft?.adaptive] ? h('p', { style: style.muted }, ADAPTIVE_MODE_HINTS[draft.adaptive]) : null,
|
|
1368
|
+
fieldError('adaptive')),
|
|
1117
1369
|
error ? h('p', { role: 'alert', style: style.error }, error) : null,
|
|
1118
1370
|
h('div', { style: style.row },
|
|
1119
1371
|
h('button', { type: 'button', style: style.primary, disabled, onClick: onSave }, '保存参数'),
|
|
@@ -1129,7 +1381,7 @@ function ModelSettingsEditor({ model, draft, error, disabled, onChange, onSave,
|
|
|
1129
1381
|
* @param {object} props 组件属性
|
|
1130
1382
|
* @returns {object} 元素树
|
|
1131
1383
|
*/
|
|
1132
|
-
function ModelRow({ plan, model, disabled, routingError, editor, draftError, onToggle, onOpenEditor, onCloseEditor, onChangeDraft, onSave, onReset }) {
|
|
1384
|
+
function ModelRow({ plan, model, disabled, routingError, editor, draftError, fieldErrors, onToggle, onOpenEditor, onCloseEditor, onChangeDraft, onSave, onReset }) {
|
|
1133
1385
|
const enabled = model?.enabled !== false;
|
|
1134
1386
|
const editing = editor?.modelId === model?.id;
|
|
1135
1387
|
const effectiveSummary = describeEffective(model);
|
|
@@ -1146,11 +1398,12 @@ function ModelRow({ plan, model, disabled, routingError, editor, draftError, onT
|
|
|
1146
1398
|
onChange: (event) => onToggle(model, Boolean(event.target.checked))
|
|
1147
1399
|
}),
|
|
1148
1400
|
h('span', { className: 'vcp-model-heading' },
|
|
1149
|
-
h('span', { className: 'vcp-model-name', title: model?.id }, model?.name || model?.id),
|
|
1150
|
-
|
|
1401
|
+
h('span', { className: 'vcp-model-name', title: model?.id }, model?.name || model?.id))),
|
|
1402
|
+
h(ConsumptionBadge, { plan, consumption: model?.consumption }),
|
|
1151
1403
|
h('span', { className: 'vcp-chip-row' },
|
|
1152
1404
|
capabilityLabel ? h('span', { style: style.chip }, capabilityLabel) : null,
|
|
1153
1405
|
enabled ? null : h('span', { style: style.chip }, '已停用'))),
|
|
1406
|
+
model?.positioning ? h('p', { style: { ...style.muted, margin: 0, fontSize: 12, lineHeight: 1.6 } }, model.positioning) : null,
|
|
1154
1407
|
h('div', { className: 'vcp-model-tags' },
|
|
1155
1408
|
h(ModelTag, { tone: values.imageInput ? 'accent' : 'muted' }, values.imageInput ? '视觉' : '纯文本'),
|
|
1156
1409
|
h(ModelTag, { tone: values.reasoningEfforts ? 'accent' : 'muted' }, thinkingLabel),
|
|
@@ -1170,7 +1423,7 @@ function ModelRow({ plan, model, disabled, routingError, editor, draftError, onT
|
|
|
1170
1423
|
model?.settingsWarning ? h('p', { role: 'alert', style: style.warn }, model.settingsWarning) : null,
|
|
1171
1424
|
editing
|
|
1172
1425
|
? h(ModelSettingsEditor, {
|
|
1173
|
-
model, draft: editor.draft, error: draftError, disabled,
|
|
1426
|
+
model, draft: editor.draft, error: draftError, fieldErrors, disabled,
|
|
1174
1427
|
onChange: onChangeDraft, onSave: () => onSave(model), onCancel: onCloseEditor
|
|
1175
1428
|
})
|
|
1176
1429
|
: null
|
|
@@ -1186,7 +1439,7 @@ function ModelRow({ plan, model, disabled, routingError, editor, draftError, onT
|
|
|
1186
1439
|
* @param {object} props 组件属性
|
|
1187
1440
|
* @returns {object} 元素树
|
|
1188
1441
|
*/
|
|
1189
|
-
function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModels, onQuota, onToggleProvider, onToggleModel, onSaveModelSettings, onResetModelSettings }) {
|
|
1442
|
+
function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModels, onQuota, onToggleProvider, onToggleModel, onSaveModelSettings, onResetModelSettings, onGoLogin, onScrollAccounts }) {
|
|
1190
1443
|
const accounts = Array.isArray(snapshot?.accounts) ? snapshot.accounts : [];
|
|
1191
1444
|
const activeId = snapshot?.active?.[plan] ?? null;
|
|
1192
1445
|
const account = accounts.find((item) => item?.id === activeId) ?? null;
|
|
@@ -1211,11 +1464,13 @@ function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModel
|
|
|
1211
1464
|
const [storedEditor, setEditor] = react.useState(null);
|
|
1212
1465
|
const [modelsOpen, setModelsOpen] = react.useState(false);
|
|
1213
1466
|
const [draftError, setDraftError] = react.useState(null);
|
|
1467
|
+
const [draftFieldErrors, setDraftFieldErrors] = react.useState(null);
|
|
1214
1468
|
// 渲染与提交时立即隔离旧账号草稿,effect 再清掉本地状态。
|
|
1215
1469
|
const editor = storedEditor?.accountId === activeId ? storedEditor : null;
|
|
1216
1470
|
react.useEffect(() => {
|
|
1217
1471
|
setEditor(null);
|
|
1218
1472
|
setDraftError(null);
|
|
1473
|
+
setDraftFieldErrors(null);
|
|
1219
1474
|
setModelsOpen(false);
|
|
1220
1475
|
}, [activeId]);
|
|
1221
1476
|
|
|
@@ -1235,11 +1490,13 @@ function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModel
|
|
|
1235
1490
|
const openEditor = (model) => {
|
|
1236
1491
|
setEditor({ accountId: activeId, modelId: model.id, draft: modelDraftFrom(model), synced: JSON.stringify(model?.settings ?? null) });
|
|
1237
1492
|
setDraftError(null);
|
|
1493
|
+
setDraftFieldErrors(null);
|
|
1238
1494
|
};
|
|
1239
1495
|
|
|
1240
1496
|
const closeEditor = () => {
|
|
1241
1497
|
setEditor(null);
|
|
1242
1498
|
setDraftError(null);
|
|
1499
|
+
setDraftFieldErrors(null);
|
|
1243
1500
|
};
|
|
1244
1501
|
|
|
1245
1502
|
const changeDraft = (patch) => {
|
|
@@ -1251,6 +1508,7 @@ function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModel
|
|
|
1251
1508
|
return { ...previous, draft };
|
|
1252
1509
|
});
|
|
1253
1510
|
setDraftError(null);
|
|
1511
|
+
setDraftFieldErrors(null);
|
|
1254
1512
|
};
|
|
1255
1513
|
|
|
1256
1514
|
// 校验不通过时不发 RPC:只在界面上说明原因。
|
|
@@ -1259,9 +1517,11 @@ function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModel
|
|
|
1259
1517
|
const parsed = parseModelSettings(editor.draft, model);
|
|
1260
1518
|
if (parsed.error) {
|
|
1261
1519
|
setDraftError(parsed.error);
|
|
1520
|
+
setDraftFieldErrors(parsed.fieldErrors);
|
|
1262
1521
|
return;
|
|
1263
1522
|
}
|
|
1264
1523
|
setDraftError(null);
|
|
1524
|
+
setDraftFieldErrors(null);
|
|
1265
1525
|
onSaveModelSettings(plan, activeId, model.id, parsed.settings);
|
|
1266
1526
|
};
|
|
1267
1527
|
|
|
@@ -1304,21 +1564,24 @@ function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModel
|
|
|
1304
1564
|
onChange: (event) => onSelect(plan, event.target.value || null)
|
|
1305
1565
|
},
|
|
1306
1566
|
h('option', { value: '' }, '未选择'),
|
|
1307
|
-
accounts.map((item) => h('option', { key: item.id, value: item.id
|
|
1567
|
+
accounts.map((item) => h('option', { key: item.id, value: item.id, title: `${accountName(item)}(${item.id})${item.label && item.label !== accountName(item) ? ` · 本地备注:${item.label}` : ''}` }, `${accountName(item)}(${item.id})`)))),
|
|
1308
1568
|
!providerEnabled ? h('p', { className: 'vcp-plan-note', style: style.muted }, '路由已停用;账号选择与模型参数保留。') : null),
|
|
1309
1569
|
!account ? h('p', { style: style.muted }, '该套餐尚未选择账号,请选择已登录的账号。') : null,
|
|
1310
1570
|
account && auth.oauth && !auth.bound
|
|
1311
|
-
? h(Notice, { tone: 'warn' }, '此账号尚未绑定该套餐,暂不能拉取模型或查询额度。请先确认已订阅此个人套餐,再到账号管理区重新网页登录更新绑定。')
|
|
1571
|
+
? h(Notice, { tone: 'warn', action: h('button', { type: 'button', style: style.btn, disabled, onClick: () => onGoLogin(account.id) }, '去账号区重新登录') }, '此账号尚未绑定该套餐,暂不能拉取模型或查询额度。请先确认已订阅此个人套餐,再到账号管理区重新网页登录更新绑定。')
|
|
1312
1572
|
: null,
|
|
1313
1573
|
account && !auth.oauth && !auth.inference
|
|
1314
|
-
? h(Notice, { tone: 'warn' }, '该账号尚未配置此套餐的推理凭据,请在账号高级配置中填写引用名,或使用网页登录。')
|
|
1574
|
+
? h(Notice, { tone: 'warn', action: h('button', { type: 'button', style: style.btn, disabled, onClick: onScrollAccounts }, '去账号区编辑') }, '该账号尚未配置此套餐的推理凭据,请在账号高级配置中填写引用名,或使用网页登录。')
|
|
1315
1575
|
: null,
|
|
1316
1576
|
h('section', { className: 'vcp-quota-section', 'aria-busy': Boolean(quotaBusy), 'aria-label': `${PLAN_TITLES[plan]}额度` },
|
|
1317
1577
|
h('div', { className: 'vcp-heading' },
|
|
1318
1578
|
h('h4', { style: { margin: 0, fontSize: 13, fontWeight: 650 } }, '套餐额度'),
|
|
1319
1579
|
h('button', { type: 'button', style: style.btn, disabled: disabled || quotaBusy || !auth.quota, 'aria-busy': quotaBusy || undefined, onClick: () => onQuota(plan) }, quotaBusy ? '正在刷新额度…' : quota?.state === 'error' ? '重试额度查询' : '刷新额度')),
|
|
1320
1580
|
account && !auth.quota && (!auth.oauth || auth.bound)
|
|
1321
|
-
? h(
|
|
1581
|
+
? h(Notice, { tone: 'warn', action: auth.oauth
|
|
1582
|
+
? h('button', { type: 'button', style: style.btn, disabled, onClick: () => onGoLogin(account.id) }, '去账号区重新登录')
|
|
1583
|
+
: h('button', { type: 'button', style: style.btn, disabled, onClick: onScrollAccounts }, '去账号区编辑') },
|
|
1584
|
+
auth.oauth ? '该套餐的登录身份暂不可查询额度,请重新登录后重试。' : '该账号缺少 AK/SK 凭据引用,额度窗口无法查询。')
|
|
1322
1585
|
: null,
|
|
1323
1586
|
quotaBusy ? h('p', { role: 'status', style: style.muted }, `正在查询${PLAN_TITLES[plan]}的额度…`) : null,
|
|
1324
1587
|
!account ? h('p', { style: style.muted }, '请先登录或添加账号,再为此套餐选择账号。')
|
|
@@ -1348,7 +1611,7 @@ function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModel
|
|
|
1348
1611
|
h('div', { className: 'vcp-model-list' },
|
|
1349
1612
|
models.map((model, index) => h(ModelRow, {
|
|
1350
1613
|
key: model?.id ?? `model-${index}`,
|
|
1351
|
-
plan, model, disabled, routingError: snapshot?.routingError, editor, draftError,
|
|
1614
|
+
plan, model, disabled, routingError: snapshot?.routingError, editor, draftError, fieldErrors: draftFieldErrors,
|
|
1352
1615
|
onToggle: (item, enabled) => onToggleModel(plan, activeId, item.id, enabled),
|
|
1353
1616
|
onOpenEditor: openEditor,
|
|
1354
1617
|
onCloseEditor: closeEditor,
|
|
@@ -1377,7 +1640,7 @@ function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModel
|
|
|
1377
1640
|
* @param {object} props 组件属性
|
|
1378
1641
|
* @returns {object} 元素树
|
|
1379
1642
|
*/
|
|
1380
|
-
function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, busy, onNew, onEdit, onCancelEdit, onChangeDraft, onSave, onRequestDelete, onConfirmDelete, onCancelDelete, onRequestLogin, onConfirmLogin, onCancelLoginConfirm, onCancelLogin, onSubmitLoginCode, onUsePlan }) {
|
|
1643
|
+
function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, busy, onNew, onEdit, onCancelEdit, onChangeDraft, onSave, onRequestDelete, onConfirmDelete, onCancelDelete, onRequestLogin, onConfirmLogin, onCancelLoginConfirm, onCancelLogin, onSubmitLoginCode, onUsePlan, onUseBoth }) {
|
|
1381
1644
|
const accounts = Array.isArray(snapshot?.accounts) ? snapshot.accounts : [];
|
|
1382
1645
|
const disabled = busy !== null;
|
|
1383
1646
|
const loginActive = LOGIN_ACTIVE_STATES.includes(login.state);
|
|
@@ -1385,6 +1648,9 @@ function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, bu
|
|
|
1385
1648
|
const [loginCode, setLoginCode] = react.useState('');
|
|
1386
1649
|
const [accountsOpen, setAccountsOpen] = react.useState(false);
|
|
1387
1650
|
const mustShowAccounts = !accounts.length || loginActive || Boolean(editor || confirmDelete || loginConfirm || loginUrl);
|
|
1651
|
+
// 新登录任务开始 / 登录结束时清理授权码,避免跨会话残留误提交;提交失败保留原值。
|
|
1652
|
+
react.useEffect(() => { setLoginCode(''); }, [login.jobId]);
|
|
1653
|
+
react.useEffect(() => { if (!loginActive) setLoginCode(''); }, [loginActive]);
|
|
1388
1654
|
react.useEffect(() => {
|
|
1389
1655
|
if (loginActive || editor || confirmDelete || loginConfirm) setAccountsOpen(true);
|
|
1390
1656
|
}, [loginActive, editor, confirmDelete, loginConfirm]);
|
|
@@ -1392,16 +1658,19 @@ function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, bu
|
|
|
1392
1658
|
const loginAccount = accounts.find((item) => item?.id === login.accountId) ?? null;
|
|
1393
1659
|
const authMode = loginAccount?.authMode ?? login.authMode ?? null;
|
|
1394
1660
|
|
|
1395
|
-
return h('section', { className: 'vcp-card vcp-account-panel', style: style.card, 'data-section': '01', 'aria-label': '账号管理' },
|
|
1661
|
+
return h('section', { id: 'vcp-account-panel', className: 'vcp-card vcp-account-panel', style: style.card, 'data-section': '01', 'aria-label': '账号管理' },
|
|
1396
1662
|
h(SectionHeading, {
|
|
1397
1663
|
title: '账号与登录',
|
|
1398
1664
|
action: h('span', { style: style.chip }, `${accounts.length} 个账号`)
|
|
1399
1665
|
}),
|
|
1400
|
-
h('details', { className: 'vcp-accounts-disclosure', open: mustShowAccounts || accountsOpen
|
|
1401
|
-
|
|
1402
|
-
event?.
|
|
1403
|
-
|
|
1404
|
-
|
|
1666
|
+
h('details', { className: 'vcp-accounts-disclosure', open: mustShowAccounts || accountsOpen,
|
|
1667
|
+
onToggle: (event) => {
|
|
1668
|
+
const nextOpen = event?.target?.open ?? false;
|
|
1669
|
+
// 强制展开期间(登录/编辑/确认)不允许折叠:原生切换已发生,直接回写保持可见。
|
|
1670
|
+
if (mustShowAccounts && !nextOpen && event?.target) event.target.open = true;
|
|
1671
|
+
if (!mustShowAccounts) setAccountsOpen(nextOpen);
|
|
1672
|
+
} },
|
|
1673
|
+
h('summary', { className: 'vcp-account-summary' }, accounts.length ? `管理账号 · ${accounts.slice(0, 2).map(accountName).join('、')}${accounts.length > 2 ? ' 等' : ''}` : '添加账号'),
|
|
1405
1674
|
h('div', { className: 'vcp-account-body' },
|
|
1406
1675
|
accounts.length
|
|
1407
1676
|
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } },
|
|
@@ -1419,7 +1688,15 @@ function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, bu
|
|
|
1419
1688
|
if (!planAuth(account, plan).inference || (selected && providerEnabledOf(snapshot, plan))) return null;
|
|
1420
1689
|
return h('button', { key: plan, type: 'button', style: style.primary, disabled: disabled || loginActive,
|
|
1421
1690
|
onClick: () => onUsePlan(plan, account.id) }, `${selected ? '启用' : '用于'} ${plan === 'agent-plan' ? 'Agent' : '编程'}套餐`);
|
|
1422
|
-
})
|
|
1691
|
+
}).concat(
|
|
1692
|
+
PLANS.every((plan) => planAuth(account, plan).inference)
|
|
1693
|
+
&& !PLANS.every((plan) => snapshot?.active?.[plan] === account.id)
|
|
1694
|
+
? [h('button', {
|
|
1695
|
+
key: '__both__', type: 'button', style: style.btn, disabled: disabled || loginActive,
|
|
1696
|
+
title: '两个套餐同时选择此账号;启用状态不动,可在套餐卡片分别启停。',
|
|
1697
|
+
onClick: () => onUseBoth(account.id)
|
|
1698
|
+
}, '两套餐都用此账号')]
|
|
1699
|
+
: [])),
|
|
1423
1700
|
h('details', { className: 'vcp-details' },
|
|
1424
1701
|
h('summary', { style: style.summary }, '账号高级配置与标识'),
|
|
1425
1702
|
h('div', { className: 'vcp-details-body' },
|
|
@@ -1475,14 +1752,18 @@ function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, bu
|
|
|
1475
1752
|
h('button', { type: 'button', style: style.btn, disabled, onClick: onCancelLoginConfirm }, '取消'))) : null,
|
|
1476
1753
|
editor ? h(AccountForm, { editor, busy: busy ?? (loginActive ? 'login-active' : null), onChangeDraft, onSave, onCancel: onCancelEdit }) : null,
|
|
1477
1754
|
login.state === 'idle' && !login.message && !loginUrl ? null
|
|
1478
|
-
:
|
|
1479
|
-
? h(Notice, {
|
|
1755
|
+
: ['success', 'cancelled', 'error'].includes(login.state)
|
|
1756
|
+
? h(Notice, {
|
|
1757
|
+
tone: login.state === 'success' ? 'success' : login.state === 'cancelled' ? 'muted' : 'error',
|
|
1758
|
+
role: login.state === 'success' ? 'status' : 'alert'
|
|
1759
|
+
}, `${loginAccount ? `账号 ${accountName(loginAccount)}:` : ''}${LOGIN_STATE_LABELS[login.state] ?? login.state}${login.message ? ` ${login.message}` : ''}`)
|
|
1480
1760
|
: h('div', { className: 'vcp-login-status', role: loginActive ? 'status' : undefined },
|
|
1481
1761
|
h('div', { style: { fontWeight: 650, fontSize: 13 } }, '登录状态'),
|
|
1482
1762
|
loginAccount ? h('p', { style: style.muted }, `当前登录账号:${accountName(loginAccount)}(${loginAccount.id})`) : null,
|
|
1483
1763
|
authMode ? h('p', { style: style.muted }, `凭据来源:${AUTH_MODE_LABELS[authMode] ?? authMode}`) : null,
|
|
1484
1764
|
h('p', { style: style.muted }, LOGIN_STATE_LABELS[login.state] ?? login.state),
|
|
1485
1765
|
login.message ? h('p', { style: style.muted }, login.message) : null,
|
|
1766
|
+
login.url && !loginUrl ? h(Notice, { tone: 'error', role: 'alert' }, '登录链接未通过安全校验,已隐藏;请重新发起登录。') : null,
|
|
1486
1767
|
loginUrl ? h('a', { href: loginUrl, target: '_blank', rel: 'noopener noreferrer', style: { fontSize: 12, color: 'var(--dsw-alias-link, inherit)' } }, '打开官方登录链接') : null,
|
|
1487
1768
|
loginUrl && login.state === 'waiting'
|
|
1488
1769
|
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
@@ -1490,9 +1771,16 @@ function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, bu
|
|
|
1490
1771
|
h('span', { style: style.label }, '粘贴官方页面显示的授权码'),
|
|
1491
1772
|
h('input', {
|
|
1492
1773
|
type: 'text', style: style.input, value: loginCode,
|
|
1493
|
-
placeholder: '授权码', autoComplete: '
|
|
1494
|
-
disabled: disabled || !login.jobId,
|
|
1495
|
-
onChange: (event) => setLoginCode(String(event?.target?.value ?? ''))
|
|
1774
|
+
placeholder: '授权码', autoComplete: 'one-time-code', spellCheck: false, maxLength: 512,
|
|
1775
|
+
enterKeyHint: 'send', disabled: disabled || !login.jobId,
|
|
1776
|
+
onChange: (event) => setLoginCode(String(event?.target?.value ?? '')),
|
|
1777
|
+
onKeyDown: (event) => {
|
|
1778
|
+
if (event?.key !== 'Enter') return;
|
|
1779
|
+
event.preventDefault();
|
|
1780
|
+
const value = loginCode.trim();
|
|
1781
|
+
if (!value || disabled || !login.jobId) return;
|
|
1782
|
+
onSubmitLoginCode?.(value);
|
|
1783
|
+
}
|
|
1496
1784
|
})),
|
|
1497
1785
|
h('div', { style: style.row },
|
|
1498
1786
|
h('button', {
|
|
@@ -1501,7 +1789,6 @@ function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, bu
|
|
|
1501
1789
|
onClick: () => {
|
|
1502
1790
|
const value = loginCode.trim();
|
|
1503
1791
|
if (!value) return;
|
|
1504
|
-
setLoginCode('');
|
|
1505
1792
|
onSubmitLoginCode?.(value);
|
|
1506
1793
|
}
|
|
1507
1794
|
}, '提交授权码'))) : null,
|
|
@@ -1636,8 +1923,12 @@ function VolcengineProviderSection({ client }) {
|
|
|
1636
1923
|
react.useEffect(() => { void refresh(); }, [refresh]);
|
|
1637
1924
|
|
|
1638
1925
|
// 统一的忙态闸门:同一时刻只跑一个写操作,避免 revision 互相打架。
|
|
1926
|
+
// 忙时重复点击直接忽略会让人以为按钮失灵,这里抛一个可读错误由调用方提示。
|
|
1639
1927
|
const run = async (key, task) => {
|
|
1640
|
-
if (busyRef.current)
|
|
1928
|
+
if (busyRef.current) {
|
|
1929
|
+
setNotice({ ok: false, text: '已有操作正在进行,请等待完成后再试。' });
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1641
1932
|
busyRef.current = key;
|
|
1642
1933
|
setBusy(key);
|
|
1643
1934
|
try {
|
|
@@ -1688,6 +1979,22 @@ function VolcengineProviderSection({ client }) {
|
|
|
1688
1979
|
} catch (error) { await reportSaveError(error, '启用套餐失败'); }
|
|
1689
1980
|
});
|
|
1690
1981
|
|
|
1982
|
+
// Explicit onboarding action: use the verified account for both plans without touching
|
|
1983
|
+
// provider enablement; the user toggles each plan card separately afterwards.
|
|
1984
|
+
const useBothAccounts = (accountId) => run('select:both', async () => {
|
|
1985
|
+
let current = snapshot;
|
|
1986
|
+
if (!current?.revision) return;
|
|
1987
|
+
try {
|
|
1988
|
+
for (const plan of PLANS) {
|
|
1989
|
+
if (current.active?.[plan] === accountId) continue;
|
|
1990
|
+
current = await client.invoke({ op: 'select', revision: current.revision, plan, accountId });
|
|
1991
|
+
applySnapshot(current);
|
|
1992
|
+
}
|
|
1993
|
+
setQuotas((previous) => ({ ...previous, 'agent-plan': null, 'coding-plan': null }));
|
|
1994
|
+
setNotice({ ok: true, text: '已为两个套餐选择此账号(启用状态未动)可在套餐卡片分别启停。' });
|
|
1995
|
+
} catch (error) { await reportSaveError(error, '为两个套餐选择账号失败'); }
|
|
1996
|
+
});
|
|
1997
|
+
|
|
1691
1998
|
const pullModels = (plan) => run(`models:${plan}`, async () => {
|
|
1692
1999
|
const accountId = snapshot?.active?.[plan] ?? null;
|
|
1693
2000
|
if (!snapshot?.revision || !accountId) return;
|
|
@@ -1709,7 +2016,7 @@ function VolcengineProviderSection({ client }) {
|
|
|
1709
2016
|
try {
|
|
1710
2017
|
const value = await client.invoke({ op: 'quota', plan, accountId, force: true });
|
|
1711
2018
|
if (!aliveRef.current || epoch !== quotaEpochRef.current) return;
|
|
1712
|
-
setQuotas((previous) => ({ ...previous, [plan]: value }));
|
|
2019
|
+
setQuotas((previous) => ({ ...previous, [plan]: { ...value, accountId, plan } }));
|
|
1713
2020
|
} catch (error) {
|
|
1714
2021
|
if (!aliveRef.current || epoch !== quotaEpochRef.current) return;
|
|
1715
2022
|
setQuotas((previous) => ({ ...previous, [plan]: { accountId, plan, state: 'error', windows: [], error: describeError(error), updatedAt: new Date().toISOString() } }));
|
|
@@ -1781,7 +2088,7 @@ function VolcengineProviderSection({ client }) {
|
|
|
1781
2088
|
const saved = await client.invoke({ op: 'saveAccount', revision, account: { id: accountId, label: '方舟账号', apiKeyRefs: {}, accessKeyRef: '', secretKeyRef: '' } });
|
|
1782
2089
|
applySnapshot(saved);
|
|
1783
2090
|
revision = saved.revision;
|
|
1784
|
-
|
|
2091
|
+
// 编辑草稿由 requestLogin / confirmLogin 两道门保护;此处不再清空,避免任何竞态下丢弃用户输入。
|
|
1785
2092
|
}
|
|
1786
2093
|
const value = await client.invoke({ op: 'startLogin', revision, accountId });
|
|
1787
2094
|
if (aliveRef.current) setLogin(normalizeLogin(value));
|
|
@@ -1796,18 +2103,89 @@ function VolcengineProviderSection({ client }) {
|
|
|
1796
2103
|
} else if (isRevisionConflict(error)) {
|
|
1797
2104
|
setNotice({ ok: false, text: '设置已在别处被改动,已刷新;请重新确认登录。', refresh: true });
|
|
1798
2105
|
} else {
|
|
1799
|
-
setNotice({
|
|
2106
|
+
setNotice({
|
|
2107
|
+
ok: false,
|
|
2108
|
+
text: (() => {
|
|
2109
|
+
const message = describeError(error);
|
|
2110
|
+
return /ArkCli|arkCliPath|原生可执行文件/.test(message)
|
|
2111
|
+
? `启动登录失败:${message} 请在插件配置中填写 arkCliPath(官方 ArkCli 原生可执行文件绝对路径,Windows 指向 .exe,不是 .cmd/.bat),或确认 PATH 能找到官方 CLI;插件不会自动安装或升级 CLI。已创建的本地账号会保留,配置好 CLI 后可在该账号上重试。`
|
|
2112
|
+
: `启动登录失败:${message}。已创建的本地账号会保留,可在该账号上重试。`;
|
|
2113
|
+
})(),
|
|
2114
|
+
refresh: true,
|
|
2115
|
+
copyText: `火山方舟 Provider 登录诊断\n时间:${new Date().toISOString()}\n错误:${describeError(error)}`,
|
|
2116
|
+
})
|
|
1800
2117
|
}
|
|
1801
2118
|
}
|
|
1802
2119
|
});
|
|
1803
2120
|
|
|
1804
2121
|
// 登录前先把副作用讲清楚,确认后才让后端打开官方窗口。
|
|
2122
|
+
// 表单编辑中不允许另起登录,避免 setEditor(null) 丢弃草稿。
|
|
1805
2123
|
const requestLogin = (accountId) => {
|
|
2124
|
+
if (editor) {
|
|
2125
|
+
setNotice({ ok: false, text: '请先保存或取消账号表单,再开始网页登录,避免草稿丢失。' });
|
|
2126
|
+
return;
|
|
2127
|
+
}
|
|
2128
|
+
setConfirmDelete(null);
|
|
1806
2129
|
setLoginConfirm(accountId);
|
|
1807
2130
|
setNotice(null);
|
|
1808
2131
|
};
|
|
1809
2132
|
|
|
2133
|
+
// 从套餐卡片一键回到账号区:滚动到账号面板并为指定账号展开登录确认。
|
|
2134
|
+
const scrollToAccounts = () => {
|
|
2135
|
+
try { document.getElementById('vcp-account-panel')?.scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch {
|
|
2136
|
+
// 非浏览器预览环境没有 document:登录确认本身会强制展开账号区。
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
const goAccountLogin = (accountId) => { scrollToAccounts(); requestLogin(accountId); };
|
|
2140
|
+
|
|
2141
|
+
// 复制脱敏诊断信息:只含文案不含密钥,失败时给明确提示。
|
|
2142
|
+
const copyText = async (value) => {
|
|
2143
|
+
try {
|
|
2144
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
|
|
2145
|
+
await navigator.clipboard.writeText(value);
|
|
2146
|
+
return true;
|
|
2147
|
+
}
|
|
2148
|
+
} catch {
|
|
2149
|
+
// 回退到 textarea 方案。
|
|
2150
|
+
}
|
|
2151
|
+
try {
|
|
2152
|
+
const area = document.createElement('textarea');
|
|
2153
|
+
area.value = value;
|
|
2154
|
+
area.setAttribute('readonly', '');
|
|
2155
|
+
area.style.position = 'fixed';
|
|
2156
|
+
area.style.opacity = '0';
|
|
2157
|
+
document.body.append(area);
|
|
2158
|
+
area.select();
|
|
2159
|
+
const ok = document.execCommand('copy');
|
|
2160
|
+
area.remove();
|
|
2161
|
+
return ok;
|
|
2162
|
+
} catch { return false; }
|
|
2163
|
+
};
|
|
2164
|
+
const copyDiagnostics = (value) => {
|
|
2165
|
+
void copyText(value).then((ok) => {
|
|
2166
|
+
if (!aliveRef.current) return;
|
|
2167
|
+
setNotice(ok
|
|
2168
|
+
? { ok: true, text: '诊断信息已复制,粘贴到 Issue 时请确认不含密钥与授权码。' }
|
|
2169
|
+
: { ok: false, text: '复制失败,请手动记录错误文案。' });
|
|
2170
|
+
});
|
|
2171
|
+
};
|
|
2172
|
+
// 路由错误的诊断包:所选与实际生效账号对照,方便一次定位。
|
|
2173
|
+
const routingDiagnostics = () => [
|
|
2174
|
+
'火山方舟 Provider 路由诊断',
|
|
2175
|
+
`时间:${new Date().toISOString()}`,
|
|
2176
|
+
`错误:${describeError(snapshot?.routingError)}`,
|
|
2177
|
+
...PLANS.map((option) => {
|
|
2178
|
+
const applied = snapshot?.appliedAccounts?.[option];
|
|
2179
|
+
return `${PLAN_TITLES[option]}:所选 ${snapshot?.active?.[option] ?? '未选择'} / 生效 ${applied ? applied.id : '无'}`;
|
|
2180
|
+
}),
|
|
2181
|
+
].join('\n');
|
|
2182
|
+
|
|
1810
2183
|
const confirmLogin = (accountId) => {
|
|
2184
|
+
// 确认框弹出后用户仍可能打开账号表单,此处再拦一次,避免 startLogin 丢弃草稿。
|
|
2185
|
+
if (editor) {
|
|
2186
|
+
setNotice({ ok: false, text: '请先保存或取消账号表单,再确认网页登录,避免草稿丢失。' });
|
|
2187
|
+
return;
|
|
2188
|
+
}
|
|
1811
2189
|
setLoginConfirm(null);
|
|
1812
2190
|
void startLogin(accountId);
|
|
1813
2191
|
};
|
|
@@ -1952,11 +2330,18 @@ function VolcengineProviderSection({ client }) {
|
|
|
1952
2330
|
busy ? h(Notice, { role: 'status' }, h('span', { 'aria-live': 'polite' }, busyMessage(busy))) : null,
|
|
1953
2331
|
loginActive ? h(Notice, { tone: 'warn', role: 'status' }, '登录期间暂不能修改账号与套餐,请完成登录或取消后继续。') : null,
|
|
1954
2332
|
loadError ? h(Notice, { tone: 'error', role: 'alert', action: h('button', { type: 'button', style: style.btn, disabled: busyAccount || loading, onClick: () => { void refresh(); } }, '重试读取状态') }, `读取状态失败:${loadError}`) : null,
|
|
1955
|
-
snapshot?.routingError ? h(Notice, {
|
|
2333
|
+
snapshot?.routingError ? h(Notice, {
|
|
2334
|
+
tone: 'error', role: 'alert',
|
|
2335
|
+
action: h('button', { type: 'button', style: style.btn, disabled: busyAccount, onClick: () => { void copyDiagnostics(routingDiagnostics()); } }, '复制诊断')
|
|
2336
|
+
}, describeError(snapshot.routingError)) : null,
|
|
1956
2337
|
notice
|
|
1957
2338
|
? h(Notice, {
|
|
1958
2339
|
tone: notice.ok ? 'success' : 'error', role: notice.ok ? 'status' : 'alert',
|
|
1959
|
-
action: notice.refresh
|
|
2340
|
+
action: (notice.refresh || notice.copyText)
|
|
2341
|
+
? h('div', { style: style.row },
|
|
2342
|
+
notice.refresh ? h('button', { type: 'button', style: style.btn, disabled: busyAccount, onClick: () => { setNotice(null); void refresh(); } }, '刷新') : null,
|
|
2343
|
+
notice.copyText ? h('button', { type: 'button', style: style.btn, disabled: busyAccount, onClick: () => { void copyDiagnostics(notice.copyText); } }, '复制诊断') : null)
|
|
2344
|
+
: null
|
|
1960
2345
|
}, notice.text)
|
|
1961
2346
|
: null,
|
|
1962
2347
|
!snapshot
|
|
@@ -1967,23 +2352,26 @@ function VolcengineProviderSection({ client }) {
|
|
|
1967
2352
|
plan: 'agent-plan', snapshot, rawQuota: quotas['agent-plan'], busy: planBusy, quotaBusy: Boolean(quotaBusy['agent-plan']),
|
|
1968
2353
|
onSelect: selectAccount, onModels: pullModels, onQuota: pullQuota,
|
|
1969
2354
|
onToggleProvider: toggleProvider, onToggleModel: toggleModel,
|
|
1970
|
-
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings
|
|
2355
|
+
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings,
|
|
2356
|
+
onGoLogin: goAccountLogin, onScrollAccounts: scrollToAccounts
|
|
1971
2357
|
}),
|
|
1972
2358
|
h(PlanCard, {
|
|
1973
2359
|
plan: 'coding-plan', snapshot, rawQuota: quotas['coding-plan'], busy: planBusy, quotaBusy: Boolean(quotaBusy['coding-plan']),
|
|
1974
2360
|
onSelect: selectAccount, onModels: pullModels, onQuota: pullQuota,
|
|
1975
2361
|
onToggleProvider: toggleProvider, onToggleModel: toggleModel,
|
|
1976
|
-
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings
|
|
2362
|
+
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings,
|
|
2363
|
+
onGoLogin: goAccountLogin, onScrollAccounts: scrollToAccounts
|
|
1977
2364
|
})),
|
|
1978
2365
|
h(AccountPanel, {
|
|
1979
2366
|
snapshot, editor, confirmDelete, loginConfirm, login, busy,
|
|
1980
2367
|
onNew: openNew, onEdit: openEdit, onCancelEdit: () => setEditor(null),
|
|
1981
2368
|
onChangeDraft: changeDraft, onSave: saveAccount,
|
|
1982
|
-
onRequestDelete: (accountId) => setConfirmDelete(accountId),
|
|
2369
|
+
onRequestDelete: (accountId) => { setLoginConfirm(null); setConfirmDelete(accountId); },
|
|
1983
2370
|
onConfirmDelete: (accountId) => { void removeAccount(accountId); },
|
|
1984
2371
|
onCancelDelete: () => setConfirmDelete(null),
|
|
1985
2372
|
onRequestLogin: requestLogin,
|
|
1986
2373
|
onUsePlan: usePlan,
|
|
2374
|
+
onUseBoth: useBothAccounts,
|
|
1987
2375
|
onConfirmLogin: confirmLogin,
|
|
1988
2376
|
onCancelLoginConfirm: () => setLoginConfirm(null),
|
|
1989
2377
|
onCancelLogin: () => { void cancelLogin(); },
|