codexmate 0.1.29 → 0.1.30

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.
Files changed (33) hide show
  1. package/cli/skills.js +33 -8
  2. package/cli.js +10 -4
  3. package/package.json +6 -1
  4. package/web-ui/app.js +10 -2
  5. package/web-ui/logic.sessions.mjs +24 -0
  6. package/web-ui/modules/app.computed.dashboard.mjs +1 -1
  7. package/web-ui/modules/app.methods.codex-config.mjs +1 -1
  8. package/web-ui/modules/app.methods.session-browser.mjs +5 -1
  9. package/web-ui/modules/app.methods.system-prompt.mjs +1 -8
  10. package/web-ui/modules/i18n/locales/en.mjs +6 -0
  11. package/web-ui/modules/i18n/locales/ja.mjs +6 -0
  12. package/web-ui/modules/i18n/locales/vi.mjs +6 -0
  13. package/web-ui/modules/i18n/locales/zh-tw.mjs +6 -0
  14. package/web-ui/modules/i18n/locales/zh.mjs +6 -0
  15. package/web-ui/modules/i18n.mjs +16 -0
  16. package/web-ui/modules/skills.computed.mjs +11 -0
  17. package/web-ui/modules/skills.methods.mjs +58 -8
  18. package/web-ui/partials/index/layout-footer.html +1 -1
  19. package/web-ui/partials/index/layout-header.html +32 -12
  20. package/web-ui/partials/index/panel-market.html +23 -5
  21. package/web-ui/partials/index/panel-sessions.html +30 -37
  22. package/web-ui/partials/index/panel-trash.html +3 -0
  23. package/web-ui/res/web-ui-render.precompiled.js +406 -341
  24. package/web-ui/styles/feedback.css +26 -0
  25. package/web-ui/styles/layout-shell.css +66 -2
  26. package/web-ui/styles/navigation-panels.css +4 -10
  27. package/web-ui/styles/sessions-list.css +19 -1
  28. package/web-ui/styles/sessions-preview.css +39 -29
  29. package/web-ui/styles/sessions-toolbar-trash.css +2 -2
  30. package/web-ui/styles/settings-panel.css +1 -1
  31. package/web-ui/styles/skills-market.css +47 -0
  32. package/web-ui/styles/titles-cards.css +1 -1
  33. package/web-ui/styles/trash-panel.css +43 -6
package/cli/skills.js CHANGED
@@ -938,16 +938,26 @@ async function exportSkills(params = {}) {
938
938
  if (!target) {
939
939
  return { error: '目标宿主不支持' };
940
940
  }
941
+ const includeAll = params.all === true;
941
942
  const rawNames = Array.isArray(params.names) ? params.names : [];
942
- const uniqueNames = Array.from(new Set(rawNames
943
- .map((item) => (typeof item === 'string' ? item.trim() : ''))
944
- .filter(Boolean)));
943
+ const uniqueNames = includeAll
944
+ ? listSkills({ targetApp: target.app }).items.map((item) => item && item.name).filter(Boolean)
945
+ : Array.from(new Set(rawNames
946
+ .map((item) => (typeof item === 'string' ? item.trim() : ''))
947
+ .filter(Boolean)));
945
948
  if (uniqueNames.length === 0) {
946
- return { error: '请先选择要导出的 skill' };
949
+ return { error: includeAll ? '当前目标没有可备份的 skill' : '请先选择要导出的 skill' };
947
950
  }
948
-
949
951
  const exported = [];
950
952
  const failed = [];
953
+ const manifest = {
954
+ format: 'codexmate-skills-backup',
955
+ version: 1,
956
+ createdAt: new Date().toISOString(),
957
+ targetApp: target.app,
958
+ targetLabel: target.label,
959
+ skills: []
960
+ };
951
961
  const stagingTempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codex-skills-export-'));
952
962
  const stagingRoot = path.join(stagingTempDir, 'skills');
953
963
  ensureDir(stagingRoot);
@@ -991,7 +1001,12 @@ async function exportSkills(params = {}) {
991
1001
  });
992
1002
  exported.push({
993
1003
  name: normalizedName.name,
994
- path: sourcePath
1004
+ path: sourcePath,
1005
+ hasSkillFile: fs.existsSync(path.join(targetPath, 'SKILL.md'))
1006
+ });
1007
+ manifest.skills.push({
1008
+ name: normalizedName.name,
1009
+ hasSkillFile: fs.existsSync(path.join(targetPath, 'SKILL.md'))
995
1010
  });
996
1011
  } catch (e) {
997
1012
  failed.push({
@@ -1013,13 +1028,18 @@ async function exportSkills(params = {}) {
1013
1028
  }
1014
1029
 
1015
1030
  const randomToken = crypto.randomBytes(12).toString('hex');
1016
- const zipFileName = `${target.app}-skills-${randomToken}.zip`;
1031
+ const zipFileName = includeAll
1032
+ ? `${target.app}-skills-backup-${randomToken}.zip`
1033
+ : `${target.app}-skills-${randomToken}.zip`;
1017
1034
  const zipFilePath = path.join(os.tmpdir(), zipFileName);
1018
1035
  if (fs.existsSync(zipFilePath)) {
1019
1036
  try {
1020
1037
  fs.unlinkSync(zipFilePath);
1021
1038
  } catch (_) {}
1022
1039
  }
1040
+ if (includeAll) {
1041
+ fs.writeFileSync(path.join(stagingRoot, 'codexmate-skills-backup.json'), JSON.stringify(manifest, null, 2), 'utf8');
1042
+ }
1023
1043
  await zipLib.archiveFolder(stagingRoot, zipFilePath);
1024
1044
  const artifact = registerDownloadArtifact(zipFilePath, {
1025
1045
  fileName: zipFileName,
@@ -1034,7 +1054,8 @@ async function exportSkills(params = {}) {
1034
1054
  failed,
1035
1055
  targetApp: target.app,
1036
1056
  targetLabel: target.label,
1037
- root: target.dir
1057
+ root: target.dir,
1058
+ backup: includeAll ? manifest : null
1038
1059
  };
1039
1060
  } catch (e) {
1040
1061
  return {
@@ -1056,6 +1077,9 @@ async function exportCodexSkills(params = {}) {
1056
1077
  return exportSkills({ ...(params || {}), targetApp: 'codex' });
1057
1078
  }
1058
1079
 
1080
+ async function backupSkills(params = {}) {
1081
+ return exportSkills({ ...(params || {}), all: true });
1082
+ }
1059
1083
  function removeDirectoryRecursive(targetPath) {
1060
1084
  if (typeof fs.rmSync === 'function') {
1061
1085
  fs.rmSync(targetPath, { recursive: true, force: false });
@@ -1152,6 +1176,7 @@ module.exports = {
1152
1176
  importCodexSkillsFromZip,
1153
1177
  exportSkills,
1154
1178
  exportCodexSkills,
1179
+ backupSkills,
1155
1180
  deleteSkills,
1156
1181
  deleteCodexSkills
1157
1182
  };
package/cli.js CHANGED
@@ -149,6 +149,7 @@ const {
149
149
  importCodexSkillsFromZip,
150
150
  exportSkills,
151
151
  exportCodexSkills,
152
+ backupSkills,
152
153
  deleteSkills,
153
154
  deleteCodexSkills
154
155
  } = require('./cli/skills');
@@ -14574,6 +14575,9 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
14574
14575
  case 'export-skills':
14575
14576
  result = await exportSkills(params || {});
14576
14577
  break;
14578
+ case 'backup-skills':
14579
+ result = await backupSkills(params || {});
14580
+ break;
14577
14581
  case 'list-codex-skills':
14578
14582
  result = listCodexSkills();
14579
14583
  break;
@@ -15230,10 +15234,12 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
15230
15234
  console.log(' 退出: Ctrl+C\n');
15231
15235
  if (isAnyAddressHost(host)) {
15232
15236
  const tokenEnabled = typeof process.env.CODEXMATE_HTTP_TOKEN === 'string' && process.env.CODEXMATE_HTTP_TOKEN.trim().length > 0;
15233
- console.warn(`! 安全提示: 当前监听所有网卡(${tokenEnabled ? '已启用鉴权' : '无鉴权'})。`);
15234
- if (!tokenEnabled) {
15235
- console.warn(' 建议仅在可信网络使用,或改用 --host 127.0.0.1。');
15236
- console.warn(' 如需远程访问,请设置 CODEXMATE_HTTP_TOKEN。');
15237
+ if (tokenEnabled) {
15238
+ console.warn('! 安全提示: 当前监听所有网卡,局域网访问需要访问令牌。');
15239
+ } else {
15240
+ console.warn('! 安全提示: 当前监听所有网卡,但未配置访问令牌,远程访问已禁用。');
15241
+ console.warn(' 如需局域网访问,请先设置 CODEXMATE_HTTP_TOKEN。');
15242
+ console.warn(' 如需仅限本机访问,请改用 --host 127.0.0.1。');
15237
15243
  }
15238
15244
  }
15239
15245
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexmate",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "Codex/Claude Code/OpenClaw 配置、会话与任务编排 CLI + Web 工具",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -41,6 +41,9 @@
41
41
  "test:ci": "node tools/ci/run-check.js all",
42
42
  "test:unit": "node tests/unit/run.mjs",
43
43
  "test:e2e": "node tests/e2e/run.js",
44
+ "test:e2e:browser": "e2e run",
45
+ "test:e2e:browser:install": "e2e-web install chromium --with-deps",
46
+ "test:e2e:browser:list": "e2e list",
44
47
  "setup:git": "git remote set-url origin https://github.com/SakuraByteCore/codexmate.git && gh auth setup-git",
45
48
  "reset:dev": "node tools/dev/reset-and-dev.js",
46
49
  "pretest": "node tools/ci/ensure-test-deps.js"
@@ -72,7 +75,9 @@
72
75
  "author": "ymkiux",
73
76
  "license": "Apache-2.0",
74
77
  "devDependencies": {
78
+ "@e2e-dev/web": "0.15.4",
75
79
  "@vue/compiler-dom": "^3.5.34",
80
+ "e2e": "0.22.0",
76
81
  "opencc-js": "^1.3.1",
77
82
  "vitepress": "^1.6.4"
78
83
  }
package/web-ui/app.js CHANGED
@@ -60,8 +60,10 @@ document.addEventListener('DOMContentLoaded', () => {
60
60
  data() {
61
61
  return {
62
62
  lang: 'zh',
63
+ languageMenuOpen: false,
63
64
  appVersion: '',
64
65
  mainTab: 'dashboard',
66
+ navigationReady: false,
65
67
  configMode: 'codex',
66
68
  currentProvider: '',
67
69
  currentModel: '',
@@ -264,6 +266,7 @@ document.addEventListener('DOMContentLoaded', () => {
264
266
  skillsRootPath: '',
265
267
  skillsList: [],
266
268
  skillsSelectedNames: [],
269
+ skillsMarketSelectedNames: [],
267
270
  skillsLoading: false,
268
271
  skillsDeleting: false,
269
272
  skillsKeyword: '',
@@ -274,6 +277,7 @@ document.addEventListener('DOMContentLoaded', () => {
274
277
  skillsImporting: false,
275
278
  skillsZipImporting: false,
276
279
  skillsExporting: false,
280
+ skillsBackingUp: false,
277
281
  skillsMarketLoading: false,
278
282
  skillsMarketLocalLoadedOnce: false,
279
283
  skillsMarketImportLoadedOnce: false,
@@ -333,7 +337,6 @@ document.addEventListener('DOMContentLoaded', () => {
333
337
  opencode: 0
334
338
  },
335
339
  sessionExporting: {},
336
- sessionExportRange: 'default',
337
340
  sessionExportNotice: null,
338
341
  sessionSearchInfo: null,
339
342
  sessionConverting: {},
@@ -624,11 +627,16 @@ document.addEventListener('DOMContentLoaded', () => {
624
627
  return true;
625
628
  }
626
629
  })();
627
- this.loadWebUiPreferences({ applyNavigation: applyPreferenceNavigation }).then(() => {
630
+ const preferencesReady = this.loadWebUiPreferences({ applyNavigation: applyPreferenceNavigation });
631
+ preferencesReady.then(() => {
628
632
  if (this.mainTab === 'prompts' && typeof this.loadPromptsTabContent === 'function') {
629
633
  this.loadPromptsTabContent();
630
634
  }
635
+ }).finally(() => {
636
+ this.navigationReady = true;
631
637
  });
638
+ } else {
639
+ this.navigationReady = true;
632
640
  }
633
641
  if (typeof this.t === 'function') {
634
642
  this.confirmDialogConfirmText = this.t('confirm.ok');
@@ -2,6 +2,30 @@ export const DEFAULT_SESSION_CONTENT_SCAN_LIMIT = 50;
2
2
  export const DEFAULT_SESSION_LIST_LIMIT = 200;
3
3
  export const DEFAULT_SESSION_LIST_FAST_LIMIT = 20;
4
4
 
5
+
6
+ function decodeSessionTitleValue(value) {
7
+ return String(value || '')
8
+ .replace(/\x26quot;/gi, '"')
9
+ .replace(/\x26apos;/gi, "'")
10
+ .replace(/\x26lt;/gi, '<')
11
+ .replace(/\x26gt;/gi, '>')
12
+ .replace(/\x26amp;/gi, '&')
13
+ .trim();
14
+ }
15
+
16
+ export function parseSessionTitleInfo(session = {}) {
17
+ const rawTitle = typeof session.title === 'string' ? session.title.trim() : '';
18
+ const skillTag = rawTitle.match(/<skill\b([^>]*)>/i);
19
+ const attributes = {};
20
+ const attributePattern = /([\w:-]+)\s*=\s*(["'])(.*?)\2/g;
21
+ let match;
22
+ while ((match = attributePattern.exec(skillTag ? skillTag[1] : '')) !== null) {
23
+ attributes[match[1].toLowerCase()] = decodeSessionTitleValue(match[3]);
24
+ }
25
+ const title = attributes.name || (skillTag ? '' : rawTitle) || session.sessionId || '';
26
+ const location = attributes.location || (typeof session.cwd === 'string' ? session.cwd.trim() : '');
27
+ return { title, location };
28
+ }
5
29
  function shouldUseFastSessionBrowseLimit(options = {}) {
6
30
  if (options.forceRefresh) {
7
31
  return false;
@@ -184,7 +184,7 @@ export function createDashboardComputed() {
184
184
  if (this.codexModelsLoading || this.claudeModelsLoading) tasks.push(this.t('dashboard.busy.models'));
185
185
  if (this.codexApplying || this.configTemplateApplying || this.openclawApplying) tasks.push(this.t('dashboard.busy.configApply'));
186
186
  if (this.agentsSaving) tasks.push(this.t('dashboard.busy.agents'));
187
- if (this.skillsLoading || this.skillsDeleting || this.skillsScanningImports || this.skillsImporting || this.skillsZipImporting || this.skillsExporting) tasks.push(this.t('dashboard.busy.skills'));
187
+ if (this.skillsLoading || this.skillsDeleting || this.skillsScanningImports || this.skillsImporting || this.skillsZipImporting || this.skillsExporting || this.skillsBackingUp) tasks.push(this.t('dashboard.busy.skills'));
188
188
  return tasks.length ? tasks.join(' / ') : this.t('dashboard.busy.idle');
189
189
  },
190
190
  inspectorMessageSummary() {
@@ -76,7 +76,7 @@ export function createCodexConfigMethods(options = {}) {
76
76
  source: session.source,
77
77
  sessionId: session.sessionId,
78
78
  filePath: session.filePath,
79
- ...(this.sessionExportRange === 'all' ? { maxMessages: 'all' } : {})
79
+ maxMessages: 'all'
80
80
  });
81
81
  if (res.error) {
82
82
  this.showMessage(res.error, 'error');
@@ -3,7 +3,8 @@ import {
3
3
  isSessionQueryEnabled,
4
4
  normalizeSessionMessageRole,
5
5
  normalizeSessionPathFilter,
6
- normalizeSessionSource
6
+ normalizeSessionSource,
7
+ parseSessionTitleInfo
7
8
  } from '../logic.mjs';
8
9
  import {
9
10
  applySessionsFilterUrlState,
@@ -78,6 +79,9 @@ export function createSessionBrowserMethods(options = {}) {
78
79
  normalizeSessionPathValue(value) {
79
80
  return normalizeSessionPathFilter(value);
80
81
  },
82
+ parseSessionTitleInfo(session) {
83
+ return parseSessionTitleInfo(session);
84
+ },
81
85
 
82
86
  mergeSessionPathOptions(baseList = [], incomingList = []) {
83
87
  const merged = [];
@@ -248,14 +248,7 @@ export function createSystemPromptMethods(options = {}) {
248
248
  const content = typeof this.sysPromptContent === 'string' ? this.sysPromptContent : '';
249
249
  if (!content) return;
250
250
  const filename = (this.sysPromptMode === 'system' ? 'SYSTEM.md' : 'APPEND_SYSTEM.md');
251
- const blob = new Blob([content], { type: 'text/markdown' });
252
- const a = document.createElement('a');
253
- a.href = URL.createObjectURL(blob);
254
- a.download = filename;
255
- document.body.appendChild(a);
256
- a.click();
257
- a.remove();
258
- URL.revokeObjectURL(a.href);
251
+ this.downloadTextFile(filename, content, 'text/markdown;charset=utf-8');
259
252
  },
260
253
 
261
254
  async pasteSysPromptContent() {
@@ -1303,6 +1303,12 @@ const en = Object.freeze({
1303
1303
  'market.summary.importableDirect': 'Direct importable',
1304
1304
  'market.root.fallback': 'Default path',
1305
1305
 
1306
+ 'market.backup.action': 'Back up current target',
1307
+ 'market.backup.running': 'Backing up...',
1308
+ 'market.export.action': 'Export selected',
1309
+ 'market.export.running': 'Exporting...',
1310
+ 'market.selection.all': 'Select all',
1311
+ 'market.selection.count': '{count} selected',
1306
1312
  'market.installed.title': 'Installed skills',
1307
1313
  'market.installed.note': 'Showing top 6 only.',
1308
1314
  'market.local.refresh': 'Refresh local',
@@ -1305,6 +1305,12 @@ const ja = Object.freeze({
1305
1305
  'market.summary.importableDirect': '直接インポート可',
1306
1306
  'market.root.fallback': 'デフォルトディレクトリ',
1307
1307
 
1308
+ 'market.backup.action': '現在のターゲットをバックアップ',
1309
+ 'market.backup.running': 'バックアップ中...',
1310
+ 'market.export.action': '選択をエクスポート',
1311
+ 'market.export.running': 'エクスポート中...',
1312
+ 'market.selection.all': 'すべて選択',
1313
+ 'market.selection.count': '{count} 件選択',
1308
1314
  'market.installed.title': 'インストール済 Skills',
1309
1315
  'market.installed.note': '上位 6 項目のみ表示。',
1310
1316
  'market.local.refresh': 'ローカルを更新',
@@ -1293,6 +1293,12 @@ const vi = Object.freeze({
1293
1293
  'market.summary.importable': 'Có thể nhập',
1294
1294
  'market.summary.importableDirect': 'Nhập trực tiếp',
1295
1295
  'market.root.fallback': 'Đường dẫn mặc định',
1296
+ 'market.backup.action': 'Sao lưu mục tiêu hiện tại',
1297
+ 'market.backup.running': 'Đang sao lưu...',
1298
+ 'market.export.action': 'Xuất đã chọn',
1299
+ 'market.export.running': 'Đang xuất...',
1300
+ 'market.selection.all': 'Chọn tất cả',
1301
+ 'market.selection.count': 'Đã chọn {count}',
1296
1302
  'market.installed.title': 'Skills đã cài',
1297
1303
  'market.installed.note': 'Chỉ hiển thị top 6.',
1298
1304
  'market.local.refresh': 'Làm mới cục bộ',
@@ -1301,6 +1301,12 @@ const zhTw = Object.freeze({
1301
1301
  'market.summary.importableDirect': '可直接匯入',
1302
1302
  'market.root.fallback': '預設目錄',
1303
1303
 
1304
+ 'market.backup.action': '備份目前目標',
1305
+ 'market.backup.running': '備份中...',
1306
+ 'market.export.action': '匯出選中',
1307
+ 'market.export.running': '匯出中...',
1308
+ 'market.selection.all': '全選',
1309
+ 'market.selection.count': '已選 {count}',
1304
1310
  'market.installed.title': '已安裝 Skills',
1305
1311
  'market.installed.note': '僅顯示前 6 項。',
1306
1312
  'market.local.refresh': '重新整理本地',
@@ -1301,6 +1301,12 @@ const zh = Object.freeze({
1301
1301
  'market.summary.importableDirect': '可直接导入',
1302
1302
  'market.root.fallback': '默认目录',
1303
1303
 
1304
+ 'market.backup.action': '备份当前目标',
1305
+ 'market.backup.running': '备份中...',
1306
+ 'market.export.action': '导出选中',
1307
+ 'market.export.running': '导出中...',
1308
+ 'market.selection.all': '全选',
1309
+ 'market.selection.count': '已选 {count}',
1304
1310
  'market.installed.title': '已安装 Skills',
1305
1311
  'market.installed.note': '仅显示前 6 项。',
1306
1312
  'market.local.refresh': '刷新本地',
@@ -67,6 +67,22 @@ export function createI18nMethods() {
67
67
  currentLanguageLabel() {
68
68
  return getLanguageMeta(this.lang).nativeName || '中文';
69
69
  },
70
+ toggleLanguageMenu() {
71
+ this.languageMenuOpen = !this.languageMenuOpen;
72
+ },
73
+ closeLanguageMenu() {
74
+ this.languageMenuOpen = false;
75
+ },
76
+ selectLanguage(nextLang) {
77
+ this.setLang(nextLang);
78
+ this.languageMenuOpen = false;
79
+ },
80
+ handleLanguageMenuFocusOut(event) {
81
+ const currentTarget = event && event.currentTarget;
82
+ const relatedTarget = event && event.relatedTarget;
83
+ if (currentTarget && relatedTarget && currentTarget.contains(relatedTarget)) return;
84
+ this.languageMenuOpen = false;
85
+ },
70
86
  openLanguageSettings() {
71
87
  if (typeof this.switchMainTab === 'function') {
72
88
  this.switchMainTab('settings');
@@ -52,6 +52,10 @@
52
52
  const selected = Array.isArray(this.skillsSelectedNames) ? this.skillsSelectedNames : [];
53
53
  return Array.from(new Set(selected.map((item) => String(item || '').trim()).filter(Boolean))).length;
54
54
  },
55
+ skillsMarketSelectedCount() {
56
+ const selected = Array.isArray(this.skillsMarketSelectedNames) ? this.skillsMarketSelectedNames : [];
57
+ return Array.from(new Set(selected.map((item) => String(item || '').trim()).filter(Boolean))).length;
58
+ },
55
59
  skillsVisibleSelectedCount() {
56
60
  const selectable = this.skillsSelectableNames;
57
61
  const selectedSet = new Set(Array.isArray(this.skillsSelectedNames) ? this.skillsSelectedNames : []);
@@ -63,6 +67,12 @@
63
67
  const selectedSet = new Set(Array.isArray(this.skillsSelectedNames) ? this.skillsSelectedNames : []);
64
68
  return selectable.every((name) => selectedSet.has(name));
65
69
  },
70
+ skillsMarketAllSelected() {
71
+ const selectable = this.skillsList.map((item) => item && item.name).filter(Boolean);
72
+ if (!selectable.length) return false;
73
+ const selectedSet = new Set(Array.isArray(this.skillsMarketSelectedNames) ? this.skillsMarketSelectedNames : []);
74
+ return selectable.every((name) => selectedSet.has(name));
75
+ },
66
76
  skillsImportSelectableKeys() {
67
77
  const list = Array.isArray(this.skillsImportList) ? this.skillsImportList : [];
68
78
  return list
@@ -97,6 +107,7 @@
97
107
  || this.skillsImporting
98
108
  || this.skillsZipImporting
99
109
  || this.skillsExporting
110
+ || this.skillsBackingUp
100
111
  );
101
112
  },
102
113
  skillsMarketInstalledPreview() {
@@ -20,6 +20,7 @@ export function createSkillsMethods({ api }) {
20
20
 
21
21
  resetSkillsTargetState() {
22
22
  this.skillsSelectedNames = [];
23
+ this.skillsMarketSelectedNames = [];
23
24
  this.skillsKeyword = '';
24
25
  this.skillsStatusFilter = 'all';
25
26
  this.skillsRootPath = '';
@@ -38,6 +39,7 @@ export function createSkillsMethods({ api }) {
38
39
  || this.skillsImporting
39
40
  || this.skillsZipImporting
40
41
  || this.skillsExporting
42
+ || this.skillsBackingUp
41
43
  || this.skillsMarketLoading
42
44
  ) {
43
45
  return false;
@@ -73,6 +75,7 @@ export function createSkillsMethods({ api }) {
73
75
  || this.skillsImporting
74
76
  || this.skillsZipImporting
75
77
  || this.skillsExporting
78
+ || this.skillsBackingUp
76
79
  || this.skillsMarketLoading
77
80
  ) {
78
81
  return false;
@@ -93,6 +96,7 @@ export function createSkillsMethods({ api }) {
93
96
  this.skillsKeyword = '';
94
97
  this.skillsStatusFilter = 'all';
95
98
  this.skillsImportSelectedKeys = [];
99
+ this.skillsMarketSelectedNames = [];
96
100
  }
97
101
  this.showSkillsModal = true;
98
102
  await this.refreshSkillsList({ silent: false });
@@ -106,6 +110,7 @@ export function createSkillsMethods({ api }) {
106
110
  || this.skillsImporting
107
111
  || this.skillsZipImporting
108
112
  || this.skillsExporting
113
+ || this.skillsBackingUp
109
114
  );
110
115
  if (busy) return;
111
116
  this.showSkillsModal = false;
@@ -213,7 +218,7 @@ export function createSkillsMethods({ api }) {
213
218
  },
214
219
 
215
220
  async scanImportableSkills(options = {}) {
216
- if (this.skillsDeleting || this.skillsScanningImports || this.skillsImporting || this.skillsZipImporting || this.skillsExporting) return false;
221
+ if (this.skillsDeleting || this.skillsScanningImports || this.skillsImporting || this.skillsZipImporting || this.skillsExporting || this.skillsBackingUp) return false;
217
222
  const silent = !!(options && options.silent);
218
223
  this.skillsScanningImports = true;
219
224
  try {
@@ -251,7 +256,7 @@ export function createSkillsMethods({ api }) {
251
256
  },
252
257
 
253
258
  async importSelectedSkills() {
254
- if (this.skillsDeleting || this.skillsScanningImports || this.skillsImporting || this.skillsZipImporting || this.skillsExporting) return;
259
+ if (this.skillsDeleting || this.skillsScanningImports || this.skillsImporting || this.skillsZipImporting || this.skillsExporting || this.skillsBackingUp) return;
255
260
  const selectedSet = new Set(Array.isArray(this.skillsImportSelectedKeys) ? this.skillsImportSelectedKeys : []);
256
261
  const selectedItems = (Array.isArray(this.skillsImportList) ? this.skillsImportList : [])
257
262
  .filter((item) => selectedSet.has(this.buildSkillImportKey(item)))
@@ -343,7 +348,7 @@ export function createSkillsMethods({ api }) {
343
348
  },
344
349
 
345
350
  async importSkillsFromZipFile(file) {
346
- if (this.skillsDeleting || this.skillsScanningImports || this.skillsZipImporting || this.skillsImporting || this.skillsExporting) return;
351
+ if (this.skillsDeleting || this.skillsScanningImports || this.skillsZipImporting || this.skillsImporting || this.skillsExporting || this.skillsBackingUp) return;
347
352
  const maxSize = 20 * 1024 * 1024;
348
353
  if (file.size > maxSize) {
349
354
  this.showMessage('ZIP 文件过大,限制 20MB', 'error');
@@ -378,9 +383,16 @@ export function createSkillsMethods({ api }) {
378
383
  },
379
384
 
380
385
  async exportSelectedSkills() {
381
- if (this.skillsDeleting || this.skillsExporting || this.skillsZipImporting || this.skillsImporting) return;
382
- const selected = Array.isArray(this.skillsSelectedNames)
383
- ? Array.from(new Set(this.skillsSelectedNames.map((item) => String(item || '').trim()).filter(Boolean)))
386
+ if (this.skillsDeleting || this.skillsExporting || this.skillsBackingUp || this.skillsZipImporting || this.skillsImporting) return;
387
+ return this.exportSkillSelection(this.skillsSelectedNames);
388
+ },
389
+ async exportMarketSelectedSkills() {
390
+ if (this.skillsDeleting || this.skillsExporting || this.skillsBackingUp || this.skillsZipImporting || this.skillsImporting) return;
391
+ return this.exportSkillSelection(this.skillsMarketSelectedNames);
392
+ },
393
+ async exportSkillSelection(sourceNames) {
394
+ const selected = Array.isArray(sourceNames)
395
+ ? Array.from(new Set(sourceNames.map((item) => String(item || '').trim()).filter(Boolean)))
384
396
  : [];
385
397
  if (!selected.length) {
386
398
  this.showMessage('请先选择要导出的 skill', 'error');
@@ -423,6 +435,33 @@ export function createSkillsMethods({ api }) {
423
435
  }
424
436
  },
425
437
 
438
+ async backupCurrentSkills() {
439
+ if (this.skillsDeleting || this.skillsExporting || this.skillsBackingUp || this.skillsZipImporting || this.skillsImporting) return;
440
+ this.skillsBackingUp = true;
441
+ try {
442
+ const res = await api('backup-skills', { targetApp: this.skillsTargetApp });
443
+ if (res && res.error) {
444
+ this.showMessage(res.error, 'error');
445
+ return;
446
+ }
447
+ if (!res || !res.fileName) {
448
+ this.showMessage('备份失败:未生成压缩包', 'error');
449
+ return;
450
+ }
451
+ const link = document.createElement('a');
452
+ link.href = res.downloadPath || `/download/${encodeURIComponent(res.fileName)}`;
453
+ link.download = res.fileName;
454
+ document.body.appendChild(link);
455
+ link.click();
456
+ document.body.removeChild(link);
457
+ const count = Array.isArray(res.exported) ? res.exported.length : 0;
458
+ this.showMessage(`已备份 ${this.skillsTargetLabel} 的 ${count} 个 skill`, 'success');
459
+ } catch (e) {
460
+ this.showMessage('备份 skill 失败', 'error');
461
+ } finally {
462
+ this.skillsBackingUp = false;
463
+ }
464
+ },
426
465
  async deleteSelectedSkills() {
427
466
  if (this.skillsDeleting || this.skillsZipImporting || this.skillsExporting || this.skillsImporting) return;
428
467
  if (this.skillsScanningImports) {
@@ -479,11 +518,22 @@ export function createSkillsMethods({ api }) {
479
518
  }
480
519
  },
481
520
 
521
+ toggleSkillsMarketSelection(name) {
522
+ const value = String(name || '').trim();
523
+ if (!value) return;
524
+ const selected = new Set(Array.isArray(this.skillsMarketSelectedNames) ? this.skillsMarketSelectedNames : []);
525
+ if (selected.has(value)) selected.delete(value);
526
+ else selected.add(value);
527
+ this.skillsMarketSelectedNames = Array.from(selected);
528
+ },
529
+ toggleAllSkillsMarketSelection() {
530
+ const names = (Array.isArray(this.skillsList) ? this.skillsList : []).map((item) => item && item.name).filter(Boolean);
531
+ this.skillsMarketSelectedNames = this.skillsMarketAllSelected ? [] : names;
532
+ },
533
+
482
534
  openSkillsMenu() {
483
- // Open skills manager modal as menu
484
535
  this.openSkillsManager();
485
536
  },
486
-
487
537
  async importSingleSkill(skill) {
488
538
  if (this.skillsImporting || this.skillsZipImporting) return;
489
539
  const key = this.buildSkillImportKey(skill);
@@ -1,5 +1,5 @@
1
1
  <!-- 加载状态 -->
2
- <div v-if="loading && mainTab !== 'usage'" class="state-message">
2
+ <div v-if="loading && mainTab !== 'usage'" class="state-message app-loading-state">
3
3
  {{ t('app.loadingConfig') }}
4
4
  </div>
5
5
 
@@ -1,4 +1,7 @@
1
- <div id="app" class="container" v-cloak>
1
+ <div id="app" class="container" :class="{ 'navigation-pending': !navigationReady }" v-cloak>
2
+ <div v-if="!navigationReady" class="app-navigation-loading-state" role="status" aria-live="polite">
3
+ {{ t('app.loadingConfig') }}
4
+ </div>
2
5
  <div v-if="!sessionStandalone" class="mobile-brand-bar">
3
6
  <div class="mobile-brand-title">Codex Mate<span v-if="appVersion" class="brand-version"> v{{ appVersion }}</span></div>
4
7
  <button
@@ -412,11 +415,34 @@
412
415
 
413
416
  <div class="side-rail-lang">
414
417
  <div class="side-rail-lang-actions">
415
- <button
416
- type="button"
417
- class="language-settings-link"
418
- :aria-label="t('settings.language.sideLabel', { language: currentLanguageLabel() })"
419
- @click="openLanguageSettings">{{ t('settings.language.sideLabel', { language: currentLanguageLabel() }) }}</button>
418
+ <div class="side-language-menu">
419
+ <button
420
+ type="button"
421
+ class="language-settings-link"
422
+ :aria-label="t('settings.language.sideLabel', { language: currentLanguageLabel() })"
423
+ :aria-expanded="languageMenuOpen ? 'true' : 'false'"
424
+ aria-haspopup="menu"
425
+ @click="toggleLanguageMenu"
426
+ @keydown.esc.prevent="closeLanguageMenu">
427
+ {{ t('settings.language.sideLabel', { language: currentLanguageLabel() }) }}
428
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6l4 4 4-4"/></svg>
429
+ </button>
430
+ <div v-if="languageMenuOpen" class="side-language-dropdown" role="menu" @focusout="handleLanguageMenuFocusOut">
431
+ <button
432
+ v-for="option in languageOptions()"
433
+ :key="option.code"
434
+ type="button"
435
+ class="side-language-option"
436
+ :class="{ active: option.code === lang }"
437
+ role="menuitemradio"
438
+ :aria-checked="option.code === lang ? 'true' : 'false'"
439
+ @click="selectLanguage(option.code)">
440
+ <span>{{ option.nativeName }}</span>
441
+ <small>{{ option.englishName }}</small>
442
+ <svg v-if="option.code === lang" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7"/></svg>
443
+ </button>
444
+ </div>
445
+ </div>
420
446
  <button
421
447
  type="button"
422
448
  class="side-announcement-button"
@@ -583,12 +609,6 @@
583
609
  <span class="value">{{ installRegistryPreview || 'npmmirror' }}</span>
584
610
  </div>
585
611
  </div>
586
- <div class="status-strip status-strip-placeholder" v-else-if="!sessionStandalone" aria-hidden="true">
587
- <div class="status-chip">
588
- <span class="label">&nbsp;</span>
589
- <span class="value">&nbsp;</span>
590
- </div>
591
- </div>
592
612
  <div
593
613
  v-if="!sessionStandalone && mainTab === 'config' && isProviderConfigMode && forceCompactLayout && !loading && !initError && displayProvidersList.length > 1"
594
614
  class="provider-fast-switch">