codexmate 0.0.38 → 0.0.39
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/cli/builtin-proxy.js +626 -207
- package/cli/openai-bridge.js +541 -210
- package/cli.js +19 -1
- package/package.json +1 -1
- package/web-ui/app.js +12 -3
- package/web-ui/modules/app.computed.main-tabs.mjs +37 -30
- package/web-ui/modules/app.methods.claude-config.mjs +111 -9
- package/web-ui/modules/app.methods.openclaw-editing.mjs +48 -0
- package/web-ui/modules/app.methods.openclaw-persist.mjs +13 -7
- package/web-ui/modules/app.methods.providers.mjs +36 -10
- package/web-ui/modules/app.methods.runtime.mjs +76 -1
- package/web-ui/modules/app.methods.startup-claude.mjs +1 -0
- package/web-ui/modules/config-mode.computed.mjs +3 -3
- package/web-ui/modules/i18n.dict.mjs +13 -0
- package/web-ui/modules/i18n.mjs +65 -16
- package/web-ui/partials/index/layout-header.html +16 -46
- package/web-ui/partials/index/modal-openclaw-config.html +135 -71
- package/web-ui/partials/index/modal-webhook.html +8 -8
- package/web-ui/partials/index/modals-basic.html +56 -16
- package/web-ui/partials/index/panel-config-claude.html +20 -20
- package/web-ui/partials/index/panel-config-codex.html +5 -5
- package/web-ui/partials/index/panel-config-openclaw.html +70 -64
- package/web-ui/partials/index/panel-dashboard.html +62 -77
- package/web-ui/partials/index/panel-settings.html +28 -7
- package/web-ui/partials/index/panel-trash.html +14 -14
- package/web-ui/res/web-ui-render.precompiled.js +846 -539
- package/web-ui/styles/controls-forms.css +6 -0
- package/web-ui/styles/dashboard.css +46 -14
- package/web-ui/styles/layout-shell.css +45 -0
- package/web-ui/styles/navigation-panels.css +3 -3
- package/web-ui/styles/openclaw-structured.css +383 -33
- package/web-ui/styles/responsive.css +68 -0
- package/web-ui/styles/sessions-usage.css +105 -9
- package/web-ui/styles/settings-panel.css +4 -0
|
@@ -47,6 +47,12 @@ function normalizeProviderDraftState(target) {
|
|
|
47
47
|
if (typeof target.url === 'string') {
|
|
48
48
|
target.url = normalizeProviderUrl(target.url);
|
|
49
49
|
}
|
|
50
|
+
if (typeof target.model === 'string') {
|
|
51
|
+
target.model = target.model.trim();
|
|
52
|
+
}
|
|
53
|
+
if (typeof target.key === 'string') {
|
|
54
|
+
target.key = target.key.trim();
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
function maskKeyLocal(key) {
|
|
@@ -66,9 +72,13 @@ function getProviderValidationForContext(vm, mode = 'add') {
|
|
|
66
72
|
const editingName = mode === 'edit' ? normalizeText(draft && draft.name) : '';
|
|
67
73
|
const name = normalizeText(draft && draft.name);
|
|
68
74
|
const url = normalizeProviderUrl(draft && draft.url);
|
|
75
|
+
const model = normalizeText(draft && draft.model);
|
|
76
|
+
const key = normalizeText(draft && draft.key);
|
|
69
77
|
const errors = {
|
|
70
78
|
name: '',
|
|
71
|
-
url: ''
|
|
79
|
+
url: '',
|
|
80
|
+
key: '',
|
|
81
|
+
model: ''
|
|
72
82
|
};
|
|
73
83
|
|
|
74
84
|
if (mode === 'add') {
|
|
@@ -91,12 +101,22 @@ function getProviderValidationForContext(vm, mode = 'add') {
|
|
|
91
101
|
errors.url = 'URL 仅支持 http/https';
|
|
92
102
|
}
|
|
93
103
|
|
|
104
|
+
if (mode === 'add' && !key) {
|
|
105
|
+
errors.key = 'API Key 必填';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (mode === 'add' && !model) {
|
|
109
|
+
errors.model = '模型名称必填';
|
|
110
|
+
}
|
|
111
|
+
|
|
94
112
|
return {
|
|
95
113
|
mode,
|
|
96
114
|
name,
|
|
97
115
|
url,
|
|
116
|
+
key,
|
|
117
|
+
model,
|
|
98
118
|
errors,
|
|
99
|
-
ok: !errors.name && !errors.url
|
|
119
|
+
ok: !errors.name && !errors.url && !errors.key && !errors.model
|
|
100
120
|
};
|
|
101
121
|
}
|
|
102
122
|
|
|
@@ -150,21 +170,20 @@ export function createProvidersMethods(options = {}) {
|
|
|
150
170
|
normalizeProviderDraftState(this.newProvider);
|
|
151
171
|
const validation = getProviderValidationForContext(this, 'add');
|
|
152
172
|
if (!validation.ok) {
|
|
153
|
-
return this.showMessage(validation.errors.name || validation.errors.url || '
|
|
173
|
+
return this.showMessage(validation.errors.name || validation.errors.url || validation.errors.key || validation.errors.model || '名称、URL、API Key 和模型名称必填', 'error');
|
|
154
174
|
}
|
|
155
175
|
|
|
156
176
|
try {
|
|
157
177
|
const payload = {
|
|
158
178
|
name: validation.name,
|
|
159
179
|
url: validation.url,
|
|
160
|
-
key:
|
|
180
|
+
key: validation.key,
|
|
181
|
+
model: validation.model
|
|
161
182
|
};
|
|
162
183
|
if (this.newProvider && this.newProvider.useTransform) {
|
|
163
184
|
payload.useTransform = true;
|
|
164
185
|
}
|
|
165
|
-
const suggestedModel =
|
|
166
|
-
? this.newProvider._suggestedModel.trim()
|
|
167
|
-
: '';
|
|
186
|
+
const suggestedModel = validation.model;
|
|
168
187
|
const res = await api('add-provider', payload);
|
|
169
188
|
if (res.error) {
|
|
170
189
|
this.showMessage(res.error, 'error');
|
|
@@ -179,7 +198,7 @@ export function createProvidersMethods(options = {}) {
|
|
|
179
198
|
codexmate_bridge: payload.useTransform ? 'openai' : '',
|
|
180
199
|
key: maskKeyLocal(payload.key),
|
|
181
200
|
hasKey: !!payload.key,
|
|
182
|
-
models: [],
|
|
201
|
+
models: suggestedModel ? [{ id: suggestedModel, name: suggestedModel, cost: null, contextWindow: undefined, maxTokens: undefined }] : [],
|
|
183
202
|
current: false,
|
|
184
203
|
readOnly: false,
|
|
185
204
|
nonDeletable: false,
|
|
@@ -208,7 +227,7 @@ export function createProvidersMethods(options = {}) {
|
|
|
208
227
|
const configured = !!(provider && provider.hasKey);
|
|
209
228
|
return {
|
|
210
229
|
configured,
|
|
211
|
-
text: configured ? '
|
|
230
|
+
text: configured ? this.t('common.configured') : this.t('common.notConfigured')
|
|
212
231
|
};
|
|
213
232
|
},
|
|
214
233
|
|
|
@@ -300,8 +319,10 @@ export function createProvidersMethods(options = {}) {
|
|
|
300
319
|
name: '',
|
|
301
320
|
url: cloneUrl,
|
|
302
321
|
key: '',
|
|
322
|
+
model: '',
|
|
303
323
|
useTransform: isTransform
|
|
304
324
|
};
|
|
325
|
+
this.showAddProviderKey = false;
|
|
305
326
|
this.showAddModal = true;
|
|
306
327
|
},
|
|
307
328
|
|
|
@@ -513,7 +534,12 @@ export function createProvidersMethods(options = {}) {
|
|
|
513
534
|
|
|
514
535
|
closeAddModal() {
|
|
515
536
|
this.showAddModal = false;
|
|
516
|
-
this.
|
|
537
|
+
this.showAddProviderKey = false;
|
|
538
|
+
this.newProvider = { name: '', url: '', key: '', model: '', useTransform: false };
|
|
539
|
+
},
|
|
540
|
+
|
|
541
|
+
toggleAddProviderKey() {
|
|
542
|
+
this.showAddProviderKey = !this.showAddProviderKey;
|
|
517
543
|
},
|
|
518
544
|
|
|
519
545
|
closeModelModal() {
|
|
@@ -3,6 +3,81 @@ import {
|
|
|
3
3
|
formatLatency
|
|
4
4
|
} from '../logic.mjs';
|
|
5
5
|
|
|
6
|
+
const UI_MESSAGE_KEY_BY_TEXT = Object.freeze({
|
|
7
|
+
'操作成功': 'toast.operationSuccess',
|
|
8
|
+
'操作失败': 'toast.operationFailed',
|
|
9
|
+
'添加失败': 'toast.addFailed',
|
|
10
|
+
'更新失败': 'toast.updateFailed',
|
|
11
|
+
'删除失败': 'toast.deleteFailed',
|
|
12
|
+
'已删除': 'toast.deleted',
|
|
13
|
+
'已复制': 'toast.copied',
|
|
14
|
+
'复制失败': 'toast.copyFailed',
|
|
15
|
+
'剪贴板为空': 'toast.clipboardEmpty',
|
|
16
|
+
'无法读取剪贴板': 'toast.clipboardReadFailed',
|
|
17
|
+
'已粘贴': 'toast.pasted',
|
|
18
|
+
'未检测到改动': 'toast.noChanges',
|
|
19
|
+
'配置已应用': 'toast.configApplied',
|
|
20
|
+
'应用配置失败': 'toast.applyConfigFailed',
|
|
21
|
+
'应用失败': 'toast.applyFailed',
|
|
22
|
+
'配置已加载': 'toast.configLoaded',
|
|
23
|
+
'配置就绪': 'toast.configReady',
|
|
24
|
+
'加载配置失败': 'toast.loadConfigFailed',
|
|
25
|
+
'读取配置失败': 'toast.readConfigFailed',
|
|
26
|
+
'读取配置超时': 'toast.readConfigTimeout',
|
|
27
|
+
'备份失败': 'toast.backupFailed',
|
|
28
|
+
'备份成功,开始下载': 'toast.backupReadyDownload',
|
|
29
|
+
'导入失败': 'toast.importFailed',
|
|
30
|
+
'导入成功': 'toast.importSuccess',
|
|
31
|
+
'导入 skill 失败': 'toast.importSkillFailed',
|
|
32
|
+
'导出失败': 'toast.exportFailed',
|
|
33
|
+
'保存失败': 'toast.saveFailed',
|
|
34
|
+
'加载文件失败': 'toast.loadFileFailed',
|
|
35
|
+
'请填写名称': 'toast.nameRequired',
|
|
36
|
+
'请输入名称': 'toast.nameRequired',
|
|
37
|
+
'名称已存在': 'toast.nameExists',
|
|
38
|
+
'至少保留一项': 'toast.keepOneItem',
|
|
39
|
+
'请输入模型': 'toast.modelRequired',
|
|
40
|
+
'请选择提供商和模型': 'toast.providerModelRequired',
|
|
41
|
+
'请先配置 API Key': 'toast.apiKeyRequired',
|
|
42
|
+
'配置已存在': 'toast.configExists',
|
|
43
|
+
'不支持此操作': 'toast.unsupportedOperation',
|
|
44
|
+
'参数无效': 'toast.invalidParams',
|
|
45
|
+
'不可分享': 'toast.notShareable',
|
|
46
|
+
'已移入回收站': 'toast.movedToTrash',
|
|
47
|
+
'生成命令失败': 'toast.commandGenerationFailed',
|
|
48
|
+
'没有可复制内容': 'toast.nothingToCopy',
|
|
49
|
+
'没有可导出内容': 'toast.nothingToExport',
|
|
50
|
+
'会话已恢复': 'toast.sessionRestored',
|
|
51
|
+
'恢复失败': 'toast.restoreFailed',
|
|
52
|
+
'已彻底删除': 'toast.purged',
|
|
53
|
+
'彻底删除失败': 'toast.purgeFailed',
|
|
54
|
+
'回收站已清空': 'toast.trashCleared',
|
|
55
|
+
'清空回收站失败': 'toast.trashClearFailed',
|
|
56
|
+
'加载回收站失败': 'toast.trashLoadFailed',
|
|
57
|
+
'加载回收站数量失败': 'toast.trashCountLoadFailed',
|
|
58
|
+
'任务计划已更新': 'toast.taskPlanUpdated',
|
|
59
|
+
'任务计划生成失败': 'toast.taskPlanFailed',
|
|
60
|
+
'计划存在问题,请先修复再执行': 'toast.taskPlanHasIssues',
|
|
61
|
+
'已发出取消请求': 'toast.cancelRequested',
|
|
62
|
+
'取消任务失败': 'toast.cancelTaskFailed'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const UI_MESSAGE_PREFIX_ENTRIES = Object.freeze(
|
|
66
|
+
Object.entries(UI_MESSAGE_KEY_BY_TEXT).sort((a, b) => b[0].length - a[0].length)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
function translateUiMessage(context, text) {
|
|
70
|
+
if (!context || typeof context.t !== 'function' || typeof text !== 'string') return text;
|
|
71
|
+
const exactKey = UI_MESSAGE_KEY_BY_TEXT[text];
|
|
72
|
+
if (exactKey) return context.t(exactKey);
|
|
73
|
+
const prefixEntry = UI_MESSAGE_PREFIX_ENTRIES.find(([sourceText]) => {
|
|
74
|
+
return text.length > sourceText.length && text.startsWith(sourceText);
|
|
75
|
+
});
|
|
76
|
+
if (!prefixEntry) return text;
|
|
77
|
+
const [sourceText, key] = prefixEntry;
|
|
78
|
+
return `${context.t(key)}${text.slice(sourceText.length)}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
6
81
|
function clearProgressResetTimer(context, timerKey) {
|
|
7
82
|
if (!context || !timerKey || !context[timerKey]) {
|
|
8
83
|
return;
|
|
@@ -334,7 +409,7 @@ export function createRuntimeMethods(options = {}) {
|
|
|
334
409
|
if (this._messageTimer) {
|
|
335
410
|
clearTimeout(this._messageTimer);
|
|
336
411
|
}
|
|
337
|
-
this.message = text;
|
|
412
|
+
this.message = translateUiMessage(this, text);
|
|
338
413
|
this.messageType = type || 'info';
|
|
339
414
|
this._messageTimer = setTimeout(() => {
|
|
340
415
|
this.message = '';
|
|
@@ -35,16 +35,16 @@ export function createConfigModeComputed() {
|
|
|
35
35
|
return this.activeProviderModeMeta.modelPlaceholder;
|
|
36
36
|
},
|
|
37
37
|
activeProviderConfigChipLabel() {
|
|
38
|
-
return this.
|
|
38
|
+
return this.t('field.provider');
|
|
39
39
|
},
|
|
40
40
|
activeProviderModelChipLabel() {
|
|
41
|
-
return this.
|
|
41
|
+
return this.t('field.model');
|
|
42
42
|
},
|
|
43
43
|
activeProviderBridgeHint() {
|
|
44
44
|
if (!this.isProviderConfigMode || this.isCodexConfigMode) {
|
|
45
45
|
return '';
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return this.t('config.providerBridgeHint', { label: this.activeProviderModeLabel });
|
|
48
48
|
},
|
|
49
49
|
inspectorMainTabLabel() {
|
|
50
50
|
if (this.mainTab === 'dashboard') return '概览';
|
|
@@ -154,6 +154,7 @@ const DICT = Object.freeze({
|
|
|
154
154
|
'side.sessions.browser.meta': '浏览 / 导出 / 清理',
|
|
155
155
|
'side.plugins.tools': '提示词工具',
|
|
156
156
|
'side.plugins.tools.meta': '模板 / 变量',
|
|
157
|
+
'side.plugins.templatesCount': '{count} 个模板',
|
|
157
158
|
'side.system.settings': '运行设置',
|
|
158
159
|
'side.system.settings.meta': '数据 / 备份',
|
|
159
160
|
|
|
@@ -912,6 +913,7 @@ const DICT = Object.freeze({
|
|
|
912
913
|
'settings.tab.data': '数据',
|
|
913
914
|
'settings.tabs.aria': '设置分类',
|
|
914
915
|
'settings.quickSettings.title': '快捷设置',
|
|
916
|
+
'settings.language.sideLabel': '语言:{language}',
|
|
915
917
|
'settings.sharePrefix.title': '分享命令前缀',
|
|
916
918
|
'settings.sharePrefix.meta': '影响 Web UI 里“复制分享命令”的前缀',
|
|
917
919
|
'settings.sharePrefix.label': '前缀',
|
|
@@ -1052,6 +1054,8 @@ const DICT = Object.freeze({
|
|
|
1052
1054
|
|
|
1053
1055
|
// OpenClaw config panel
|
|
1054
1056
|
'openclaw.applyHint': '写入 ~/.openclaw/openclaw.json,支持 JSON5。',
|
|
1057
|
+
'openclaw.workspace.title': 'OpenClaw 工作区',
|
|
1058
|
+
'openclaw.configs.hint': '选择常用配置,或进入编辑器维护完整 JSON5。',
|
|
1055
1059
|
'openclaw.agents.hint': '读写 Workspace 的 AGENTS.md,默认路径 ~/.openclaw/workspace/AGENTS.md。',
|
|
1056
1060
|
'openclaw.agents.open': '打开 AGENTS.md',
|
|
1057
1061
|
'openclaw.workspaceFile': '工作区文件',
|
|
@@ -1065,6 +1069,7 @@ const DICT = Object.freeze({
|
|
|
1065
1069
|
'modal.openclaw.quick.subtitle': '按 3 步完成:填 Provider 和模型,写入编辑器,保存并应用。',
|
|
1066
1070
|
'modal.openclaw.quick.step2': '点击写入编辑器',
|
|
1067
1071
|
'modal.openclaw.structured.writeHint': '写入编辑器会重排 JSON,注释可能丢失。',
|
|
1072
|
+
'openclaw.action.applyAria': '应用 OpenClaw 配置:{name}',
|
|
1068
1073
|
'openclaw.action.editAria': '编辑 OpenClaw 配置:{name}',
|
|
1069
1074
|
'openclaw.action.deleteAria': '删除 OpenClaw 配置:{name}'
|
|
1070
1075
|
},
|
|
@@ -1224,6 +1229,7 @@ const DICT = Object.freeze({
|
|
|
1224
1229
|
'side.sessions.browser.meta': '閲覧 / エクスポート / クリーンアップ',
|
|
1225
1230
|
'side.plugins.tools': 'プロンプトツール',
|
|
1226
1231
|
'side.plugins.tools.meta': 'テンプレート / 変数',
|
|
1232
|
+
'side.plugins.templatesCount': '{count} 件のテンプレート',
|
|
1227
1233
|
'side.system.settings': '実行設定',
|
|
1228
1234
|
'side.system.settings.meta': 'データ / バックアップ',
|
|
1229
1235
|
|
|
@@ -1970,6 +1976,7 @@ const DICT = Object.freeze({
|
|
|
1970
1976
|
'settings.tab.data': 'データ',
|
|
1971
1977
|
'settings.tabs.aria': '設定カテゴリ',
|
|
1972
1978
|
'settings.quickSettings.title': 'クイック設定',
|
|
1979
|
+
'settings.language.sideLabel': '言語:{language}',
|
|
1973
1980
|
'settings.sharePrefix.title': '共有コマンドプレフィックス',
|
|
1974
1981
|
'settings.sharePrefix.meta': 'Web UI の「共有コマンドをコピー」のプレフィックスに影響',
|
|
1975
1982
|
'settings.sharePrefix.label': 'プレフィックス',
|
|
@@ -2123,6 +2130,7 @@ const DICT = Object.freeze({
|
|
|
2123
2130
|
'modal.openclaw.quick.subtitle': '3ステップで完了:Provider とモデルを入力、エディタに書き込み、保存して適用。',
|
|
2124
2131
|
'modal.openclaw.quick.step2': 'エディタに書き込みをクリック',
|
|
2125
2132
|
'modal.openclaw.structured.writeHint': 'エディタに書き込むと JSON が再配置され、コメントが失われる可能性があります。',
|
|
2133
|
+
'openclaw.action.applyAria': 'OpenClaw 設定を適用:{name}',
|
|
2126
2134
|
'openclaw.action.editAria': 'OpenClaw 設定を編集:{name}',
|
|
2127
2135
|
'openclaw.action.deleteAria': 'OpenClaw 設定を削除:{name}',
|
|
2128
2136
|
|
|
@@ -2283,6 +2291,7 @@ const DICT = Object.freeze({
|
|
|
2283
2291
|
'side.sessions.browser.meta': 'Browse / Export / Cleanup',
|
|
2284
2292
|
'side.plugins.tools': 'Prompt Tools',
|
|
2285
2293
|
'side.plugins.tools.meta': 'Templates / Variables',
|
|
2294
|
+
'side.plugins.templatesCount': '{count} templates',
|
|
2286
2295
|
'side.system.settings': 'Runtime Settings',
|
|
2287
2296
|
'side.system.settings.meta': 'Data / Backup',
|
|
2288
2297
|
|
|
@@ -3042,6 +3051,7 @@ const DICT = Object.freeze({
|
|
|
3042
3051
|
'settings.tab.data': 'Data',
|
|
3043
3052
|
'settings.tabs.aria': 'Settings categories',
|
|
3044
3053
|
'settings.quickSettings.title': 'Quick Settings',
|
|
3054
|
+
'settings.language.sideLabel': 'Language: {language}',
|
|
3045
3055
|
'settings.sharePrefix.title': 'Share command prefix',
|
|
3046
3056
|
'settings.sharePrefix.meta': 'Used as the prefix for “Copy share command” in the Web UI',
|
|
3047
3057
|
'settings.sharePrefix.label': 'Prefix',
|
|
@@ -3178,6 +3188,8 @@ const DICT = Object.freeze({
|
|
|
3178
3188
|
|
|
3179
3189
|
// OpenClaw config panel
|
|
3180
3190
|
'openclaw.applyHint': 'Writes to ~/.openclaw/openclaw.json (JSON5 supported).',
|
|
3191
|
+
'openclaw.workspace.title': 'OpenClaw workspace',
|
|
3192
|
+
'openclaw.configs.hint': 'Select a saved config, or open the editor to maintain full JSON5.',
|
|
3181
3193
|
'openclaw.agents.hint': 'Read/write Workspace AGENTS.md. Default: ~/.openclaw/workspace/AGENTS.md.',
|
|
3182
3194
|
'openclaw.agents.open': 'Open AGENTS.md',
|
|
3183
3195
|
'openclaw.workspaceFile': 'Workspace file',
|
|
@@ -3191,6 +3203,7 @@ const DICT = Object.freeze({
|
|
|
3191
3203
|
'modal.openclaw.quick.subtitle': '3 steps: fill provider/model, write to editor, save & apply.',
|
|
3192
3204
|
'modal.openclaw.quick.step2': 'Write to editor',
|
|
3193
3205
|
'modal.openclaw.structured.writeHint': 'Writing to editor may reformat JSON and drop comments.',
|
|
3206
|
+
'openclaw.action.applyAria': 'Apply OpenClaw config: {name}',
|
|
3194
3207
|
'openclaw.action.editAria': 'Edit OpenClaw config: {name}',
|
|
3195
3208
|
'openclaw.action.deleteAria': 'Delete OpenClaw config: {name}'
|
|
3196
3209
|
}
|
package/web-ui/modules/i18n.mjs
CHANGED
|
@@ -2,11 +2,41 @@ import { DICT } from './i18n.dict.mjs';
|
|
|
2
2
|
|
|
3
3
|
const I18N_STORAGE_KEY = 'codexmateLang';
|
|
4
4
|
|
|
5
|
+
const LANGUAGE_META = Object.freeze([
|
|
6
|
+
Object.freeze({ code: 'zh', nativeName: '中文', englishName: 'Chinese', htmlLang: 'zh-CN', dir: 'ltr' }),
|
|
7
|
+
Object.freeze({ code: 'en', nativeName: 'English', englishName: 'English', htmlLang: 'en', dir: 'ltr' }),
|
|
8
|
+
Object.freeze({ code: 'ja', nativeName: '日本語', englishName: 'Japanese', htmlLang: 'ja', dir: 'ltr' }),
|
|
9
|
+
Object.freeze({ code: 'vi', nativeName: 'Tiếng Việt', englishName: 'Vietnamese', htmlLang: 'vi', dir: 'ltr' })
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
function getAvailableLanguages() {
|
|
13
|
+
return LANGUAGE_META.filter((item) => item && item.code && DICT[item.code]);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getDefaultLanguageMeta() {
|
|
17
|
+
const available = getAvailableLanguages();
|
|
18
|
+
return available[0] || LANGUAGE_META[0];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getLanguageMeta(code) {
|
|
22
|
+
const normalized = typeof code === 'string' ? code.trim().toLowerCase() : '';
|
|
23
|
+
return getAvailableLanguages().find((item) => item.code === normalized) || getDefaultLanguageMeta();
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
function normalizeLang(value) {
|
|
6
27
|
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
28
|
+
const available = getAvailableLanguages();
|
|
29
|
+
const fallback = available[0] && available[0].code ? available[0].code : 'zh';
|
|
30
|
+
return available.some((item) => item.code === normalized) ? normalized : fallback;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function applyDocumentLanguage(next) {
|
|
34
|
+
try {
|
|
35
|
+
if (typeof document === 'undefined' || !document.documentElement) return;
|
|
36
|
+
const meta = getLanguageMeta(next);
|
|
37
|
+
document.documentElement.lang = meta.htmlLang || meta.code || 'zh-CN';
|
|
38
|
+
document.documentElement.dir = meta.dir || 'ltr';
|
|
39
|
+
} catch (_) {}
|
|
10
40
|
}
|
|
11
41
|
|
|
12
42
|
function interpolate(template, params) {
|
|
@@ -26,13 +56,38 @@ export function createI18nMethods() {
|
|
|
26
56
|
: '';
|
|
27
57
|
const next = normalizeLang(saved);
|
|
28
58
|
this.lang = next;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
59
|
+
applyDocumentLanguage(next);
|
|
60
|
+
},
|
|
61
|
+
languageOptions() {
|
|
62
|
+
return getAvailableLanguages();
|
|
63
|
+
},
|
|
64
|
+
currentLanguageLabel() {
|
|
65
|
+
return getLanguageMeta(this.lang).nativeName || '中文';
|
|
66
|
+
},
|
|
67
|
+
openLanguageSettings() {
|
|
68
|
+
if (typeof this.switchMainTab === 'function') {
|
|
69
|
+
this.switchMainTab('settings');
|
|
70
|
+
} else {
|
|
71
|
+
this.mainTab = 'settings';
|
|
72
|
+
if (typeof this.saveNavState === 'function') {
|
|
73
|
+
this.saveNavState();
|
|
34
74
|
}
|
|
35
|
-
}
|
|
75
|
+
}
|
|
76
|
+
this.settingsTab = 'general';
|
|
77
|
+
this.$nextTick(() => {
|
|
78
|
+
const target = typeof document !== 'undefined'
|
|
79
|
+
? document.getElementById('settings-language')
|
|
80
|
+
: null;
|
|
81
|
+
if (target && typeof target.scrollIntoView === 'function') {
|
|
82
|
+
target.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
83
|
+
}
|
|
84
|
+
const select = typeof document !== 'undefined'
|
|
85
|
+
? document.getElementById('settings-language-select')
|
|
86
|
+
: null;
|
|
87
|
+
if (select && typeof select.focus === 'function') {
|
|
88
|
+
select.focus();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
36
91
|
},
|
|
37
92
|
setLang(nextLang) {
|
|
38
93
|
const next = normalizeLang(nextLang);
|
|
@@ -42,13 +97,7 @@ export function createI18nMethods() {
|
|
|
42
97
|
localStorage.setItem(I18N_STORAGE_KEY, next);
|
|
43
98
|
}
|
|
44
99
|
} catch (_) {}
|
|
45
|
-
|
|
46
|
-
if (typeof document !== 'undefined' && document.documentElement) {
|
|
47
|
-
if (next === 'en') document.documentElement.lang = 'en';
|
|
48
|
-
else if (next === 'ja') document.documentElement.lang = 'ja';
|
|
49
|
-
else document.documentElement.lang = 'zh-CN';
|
|
50
|
-
}
|
|
51
|
-
} catch (_) {}
|
|
100
|
+
applyDocumentLanguage(next);
|
|
52
101
|
},
|
|
53
102
|
t(key, params = null) {
|
|
54
103
|
const lang = normalizeLang(this.lang);
|
|
@@ -93,27 +93,12 @@
|
|
|
93
93
|
@click="onMainTabClick('settings', $event)">{{ t('tab.settings') }}</button>
|
|
94
94
|
</div>
|
|
95
95
|
|
|
96
|
-
<div v-if="!sessionStandalone" class="lang-fab"
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
:class="{ active: (lang || 'zh') === 'zh' }"
|
|
103
|
-
@click="setLang('zh')">ZH</button>
|
|
104
|
-
<button
|
|
105
|
-
type="button"
|
|
106
|
-
class="lang-choice-btn"
|
|
107
|
-
:aria-pressed="(lang || 'zh') === 'en'"
|
|
108
|
-
:class="{ active: (lang || 'zh') === 'en' }"
|
|
109
|
-
@click="setLang('en')">EN</button>
|
|
110
|
-
<button
|
|
111
|
-
type="button"
|
|
112
|
-
class="lang-choice-btn"
|
|
113
|
-
:aria-pressed="(lang || 'zh') === 'ja'"
|
|
114
|
-
:class="{ active: (lang || 'zh') === 'ja' }"
|
|
115
|
-
@click="setLang('ja')">日本語</button>
|
|
116
|
-
</div>
|
|
96
|
+
<div v-if="!sessionStandalone" class="lang-fab">
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
class="language-settings-link"
|
|
100
|
+
:aria-label="t('settings.language.sideLabel', { language: currentLanguageLabel() })"
|
|
101
|
+
@click="openLanguageSettings">{{ t('settings.language.sideLabel', { language: currentLanguageLabel() }) }}</button>
|
|
117
102
|
</div>
|
|
118
103
|
|
|
119
104
|
<div :class="['app-shell', { standalone: sessionStandalone }]">
|
|
@@ -282,7 +267,7 @@
|
|
|
282
267
|
<div class="side-item-title">{{ t('side.plugins.tools') }}</div>
|
|
283
268
|
<div class="side-item-meta">
|
|
284
269
|
<span>{{ t('side.plugins.tools.meta') }}</span>
|
|
285
|
-
<span>{{ promptTemplatesList.length }}
|
|
270
|
+
<span>{{ t('side.plugins.templatesCount', { count: promptTemplatesList.length }) }}</span>
|
|
286
271
|
</div>
|
|
287
272
|
</button>
|
|
288
273
|
</div>
|
|
@@ -308,40 +293,25 @@
|
|
|
308
293
|
:class="['side-item', { active: isMainTabNavActive('trash') }]"
|
|
309
294
|
@pointerdown="onMainTabPointerDown('trash', $event)"
|
|
310
295
|
@click="onMainTabClick('trash', $event)">
|
|
311
|
-
<div class="side-item-title"
|
|
296
|
+
<div class="side-item-title">{{ t('settings.trash.title') }}</div>
|
|
312
297
|
<div class="side-item-meta">
|
|
313
|
-
<span
|
|
298
|
+
<span>{{ t('settings.trash.meta') }}</span>
|
|
314
299
|
<span v-if="sessionTrashCount > 0" class="side-item-badge">{{ sessionTrashCount }}</span>
|
|
315
300
|
</div>
|
|
316
301
|
</button>
|
|
317
302
|
</div>
|
|
318
303
|
<div id="side-tab-new" class="side-item side-item-ghost" tabindex="-1" aria-hidden="true">
|
|
319
|
-
<div class="side-item-title">
|
|
304
|
+
<div class="side-item-title">{{ t('side.newTab') }}</div>
|
|
320
305
|
<div class="side-item-meta"><span> </span></div>
|
|
321
306
|
</div>
|
|
322
307
|
</div>
|
|
323
308
|
|
|
324
|
-
<div class="side-rail-lang"
|
|
325
|
-
<
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
:class="{ active: (lang || 'zh') === 'zh' }"
|
|
331
|
-
@click="setLang('zh')">ZH</button>
|
|
332
|
-
<button
|
|
333
|
-
type="button"
|
|
334
|
-
class="lang-choice-btn"
|
|
335
|
-
:aria-pressed="(lang || 'zh') === 'en'"
|
|
336
|
-
:class="{ active: (lang || 'zh') === 'en' }"
|
|
337
|
-
@click="setLang('en')">EN</button>
|
|
338
|
-
<button
|
|
339
|
-
type="button"
|
|
340
|
-
class="lang-choice-btn"
|
|
341
|
-
:aria-pressed="(lang || 'zh') === 'ja'"
|
|
342
|
-
:class="{ active: (lang || 'zh') === 'ja' }"
|
|
343
|
-
@click="setLang('ja')">日本語</button>
|
|
344
|
-
</div>
|
|
309
|
+
<div class="side-rail-lang">
|
|
310
|
+
<button
|
|
311
|
+
type="button"
|
|
312
|
+
class="language-settings-link"
|
|
313
|
+
:aria-label="t('settings.language.sideLabel', { language: currentLanguageLabel() })"
|
|
314
|
+
@click="openLanguageSettings">{{ t('settings.language.sideLabel', { language: currentLanguageLabel() }) }}</button>
|
|
345
315
|
</div>
|
|
346
316
|
</aside>
|
|
347
317
|
<main class="main-panel">
|