@dsh-plugin/dsh-pack-plugin 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +178 -3
- package/cordis.patch.yml +9 -0
- package/icons/folder-zip-line.svg +1 -0
- package/lib/ball.js +597 -0
- package/lib/client.js +2934 -0
- package/lib/host.js +51745 -0
- package/lib/migrate-helper.js +35346 -0
- package/lib/progress-main.cjs +79 -0
- package/lib/progress-window.ps1 +114 -0
- package/lib/progress.html +126 -0
- package/lib/publish-to-github/SKILL.md +132 -0
- package/package.json +77 -4
- package/src/ball-entry.js +5 -0
- package/src/ball-host.js +99 -0
- package/src/ball-settings.js +352 -0
- package/src/ball.js +418 -0
- package/src/channel.js +12 -0
- package/src/client-plugin.js +58 -0
- package/src/client-rpc.js +14 -0
- package/src/client.js +5 -0
- package/src/core/discovery.js +192 -0
- package/src/core/dspack.js +93 -0
- package/src/core/extension-files.js +102 -0
- package/src/core/extension-install.js +295 -0
- package/src/core/extension-patch.js +369 -0
- package/src/core/extension-skills.js +164 -0
- package/src/core/extension-validate.js +127 -0
- package/src/core/extensions.js +207 -0
- package/src/core/home-store.js +32 -0
- package/src/core/host.js +149 -0
- package/src/core/index.js +59 -0
- package/src/core/inspect.js +162 -0
- package/src/core/install.js +775 -0
- package/src/core/managed-install.js +84 -0
- package/src/core/manifest.js +717 -0
- package/src/core/market.js +268 -0
- package/src/core/mcp-composition.js +189 -0
- package/src/core/mcp-install.js +112 -0
- package/src/core/mcp-transport.js +116 -0
- package/src/core/pack.js +371 -0
- package/src/core/plugin-metadata.js +355 -0
- package/src/core/registry.js +316 -0
- package/src/core/repo.js +339 -0
- package/src/core/scan.js +78 -0
- package/src/core/security.js +101 -0
- package/src/core/special.js +50 -0
- package/src/core/tar.js +103 -0
- package/src/core/update-config.js +234 -0
- package/src/core/update.js +792 -0
- package/src/core/vendored.js +715 -0
- package/src/core/workspace.js +95 -0
- package/src/endpoints.js +455 -0
- package/src/ensure-manager.js +186 -0
- package/src/host-node.js +625 -0
- package/src/host.js +17 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +39 -0
- package/src/junction.js +142 -0
- package/src/migrate-helper.js +225 -0
- package/src/migrate.js +56 -0
- package/src/packaged.js +9 -0
- package/src/profiles.js +106 -0
- package/src/progress-main.cjs +79 -0
- package/src/progress-window.ps1 +114 -0
- package/src/progress.html +126 -0
- package/src/progress.js +132 -0
- package/src/rpc.js +157 -0
- package/src/runtime.js +43 -0
- package/src/section-gate.js +50 -0
- package/src/settings-nav-icon.js +188 -0
- package/src/settings.js +1611 -0
- package/src/skills/index.js +90 -0
- package/src/skills/publish-to-github/SKILL.md +132 -0
- package/src/tasks.js +145 -0
- package/src/v6-dialogs.js +312 -0
package/src/settings.js
ADDED
|
@@ -0,0 +1,1611 @@
|
|
|
1
|
+
import { chooseExportResources, reviewInstall } from './v6-dialogs.js';
|
|
2
|
+
// DSH 客户端插件 · 整合包管理器主面板(三 Tab:管理 / 导出 / 市场)。
|
|
3
|
+
//
|
|
4
|
+
// 所有按钮经 ctx.connection.rpc 直连宿主 endpoint(静默,不进聊天栏),
|
|
5
|
+
// 业务逻辑全在宿主 endpoint 层;这里只做表单收集 + 结果展示。
|
|
6
|
+
//
|
|
7
|
+
// slots 契约(已从 DSH 源码确证):
|
|
8
|
+
// ctx.slots.inject("settings.section", () => ctx.slots.register(options, Component))
|
|
9
|
+
import { createElement as h, useState, useEffect, useRef, Fragment } from 'react';
|
|
10
|
+
import { PROFILE_NAME_RE, RESERVED_PROFILE_NAMES } from './channel.js';
|
|
11
|
+
import { installSettingsNavIcon, installSectionFocusHook, navIconMaskSvg, navIconMaskUrl } from './settings-nav-icon.js';
|
|
12
|
+
import { createSectionGate } from './section-gate.js';
|
|
13
|
+
|
|
14
|
+
const NS = 'dspack';
|
|
15
|
+
const MANAGER_PKG = '@dsh-plugin/dsh-pack-plugin';
|
|
16
|
+
// 版本号由 bundle-client.mjs 用 esbuild define 注入(__PACKAGE_VERSION__);未注入(如单测直连源码)时兜底。
|
|
17
|
+
const VERSION = typeof __PACKAGE_VERSION__ === 'undefined' ? '0.0.1' : __PACKAGE_VERSION__;
|
|
18
|
+
// logo(icons/folder-zip-line.svg 的 path),About 页用 currentColor 上色。
|
|
19
|
+
const LOGO_PATH = 'M444.330667 128l85.333333 85.333333H896a42.666667 42.666667 0 0 1 42.666667 42.666667v597.333333a42.666667 42.666667 0 0 1-42.666667 42.666667H128a42.666667 42.666667 0 0 1-42.666667-42.666667V170.666667a42.666667 42.666667 0 0 1 42.666667-42.666667h316.330667zM768 768h-170.666667v-128h85.333334v-85.333333h-85.333334v-85.333334h85.333334V384h-85.333334V298.666667h-102.997333l-85.333333-85.333334H170.666667v597.333334h682.666666V298.666667h-170.666666v85.333333h85.333333v85.333333h-85.333333v85.333334h85.333333v213.333333z';
|
|
20
|
+
|
|
21
|
+
// About 页外部链接(作者 / 仓库 / 求 Star / 生态),点击经 plugin/open-url 用系统浏览器打开。
|
|
22
|
+
const AUTHOR = 'hxh230802';
|
|
23
|
+
const AUTHOR_URL = 'https://github.com/hxh230802';
|
|
24
|
+
const REPO_URL = 'https://github.com/dsh-plugins/dsh-pack-plugin';
|
|
25
|
+
const NPM_URL = 'https://www.npmjs.com/package/' + MANAGER_PKG;
|
|
26
|
+
const SPEC_URL = 'https://github.com/DSH-PackForge/DSH-PackForge';
|
|
27
|
+
const APP_URL = 'https://github.com/DSH-PackForge/dsh-packforge-app';
|
|
28
|
+
const MARKET_URL = 'https://github.com/DSH-PackForge/dsh-pack-market';
|
|
29
|
+
|
|
30
|
+
function localizedLabel(value) {
|
|
31
|
+
if (typeof value === 'string') return value;
|
|
32
|
+
if (!value || typeof value !== 'object') return '';
|
|
33
|
+
const language = globalThis.navigator?.language || 'zh';
|
|
34
|
+
return [value[language],value[language.split('-')[0]],...Object.values(value)].find(v=>typeof v === 'string' && v) || '';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function displayIcon(icon,cache) {
|
|
38
|
+
if (typeof icon !== 'string') return undefined;
|
|
39
|
+
if (icon.startsWith('assets/plugins/')) {
|
|
40
|
+
const value = cache?.[icon];
|
|
41
|
+
return typeof value === 'string' && /^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[a-z0-9+/]+=*$/i.test(value) ? value : undefined;
|
|
42
|
+
}
|
|
43
|
+
try { const url = new URL(icon); return url.protocol === 'https:' && !url.username && !url.password ? url.href : undefined; }
|
|
44
|
+
catch { return undefined; }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function marketResources(manifest,icons,t) {
|
|
48
|
+
if (manifest?.manifestVersion !== 6) return null;
|
|
49
|
+
const units = manifest.type === 'dshhome' ? Object.entries(manifest.profiles || {}) : [['',manifest]];
|
|
50
|
+
const groups = [];
|
|
51
|
+
function group(id,title,items) {
|
|
52
|
+
if (!items.length) return;
|
|
53
|
+
groups.push(h('section',{key:id},h('h4',null,title),h('ul',null,...items)));
|
|
54
|
+
}
|
|
55
|
+
function display(id,name,desc,meta,icon) {
|
|
56
|
+
const title = localizedLabel(name) || id;
|
|
57
|
+
return h('li',{key:id},
|
|
58
|
+
icon ? h('img',{src:icon,width:24,height:24,alt:'',loading:'lazy',referrerPolicy:'no-referrer',
|
|
59
|
+
onError:e=>{
|
|
60
|
+
const image = e.currentTarget;
|
|
61
|
+
if (image.src.startsWith('https://cdn.jsdelivr.com/npm/')) image.src = image.src.replace('https://cdn.jsdelivr.com/npm/','https://cdn.jsdelivr.net/npm/');
|
|
62
|
+
}}) : null,
|
|
63
|
+
h('strong',null,title), ' ', h('code',null,[title === id ? '' : id, ...meta].filter(Boolean).join(' · ')),
|
|
64
|
+
desc ? h('p',null,localizedLabel(desc)) : null);
|
|
65
|
+
}
|
|
66
|
+
for (const [scope,unit] of units) {
|
|
67
|
+
const items = Object.entries(unit.plugins || {}).map(([id,p])=>display(id,p.name,p.desc,[unit.dependencies?.[id]],displayIcon(p.icon,icons)));
|
|
68
|
+
group('plugins:'+scope,[t('market.plugins'),scope].filter(Boolean).join(' · '),items);
|
|
69
|
+
}
|
|
70
|
+
const labels = {'path.json':'market.paths','provider.json':'market.providers','mcp.json':'market.mcp','skill.json':'market.skills'};
|
|
71
|
+
for (const [file,label] of Object.entries(labels)) {
|
|
72
|
+
const list = manifest.resources?.[file];
|
|
73
|
+
if (Array.isArray(list)) group(file,t(label),list.map(item=>h('li',{key:[item.scope,item.plugin,item.id].join(':')},
|
|
74
|
+
h('strong',null,localizedLabel(item.name) || item.id),' ',h('code',null,[item.plugin,item.scope,item.ref,item.commit].filter(Boolean).join(' · ')),
|
|
75
|
+
item.desc ? h('p',null,localizedLabel(item.desc)) : null)));
|
|
76
|
+
}
|
|
77
|
+
return groups;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const dict = {
|
|
81
|
+
zh: {
|
|
82
|
+
nav: '整合包',
|
|
83
|
+
'tab.manage': '管理',
|
|
84
|
+
'tab.export': '导出',
|
|
85
|
+
'tab.market': '市场',
|
|
86
|
+
'running.title': '正在运行的整合包',
|
|
87
|
+
'running.profile': 'profile名:',
|
|
88
|
+
'action.openDir': '打开目录',
|
|
89
|
+
'create.title': '创建整合包',
|
|
90
|
+
'action.newEmpty': '空整合包',
|
|
91
|
+
'action.import': '导入新包',
|
|
92
|
+
'action.market': '浏览市场',
|
|
93
|
+
'action.refresh': '刷新',
|
|
94
|
+
'action.tasks': '任务中心',
|
|
95
|
+
'tasks.empty': '暂无任务',
|
|
96
|
+
'tasks.close': '关闭',
|
|
97
|
+
'installed.title': '已安装的整合包',
|
|
98
|
+
'action.delete': '删除',
|
|
99
|
+
'hint.restart': '点切换后重启生效',
|
|
100
|
+
'group.meta': '元数据(留空用 profile 默认)',
|
|
101
|
+
'group.output': '输出',
|
|
102
|
+
'field.name': '整合包名',
|
|
103
|
+
'field.version': '版本',
|
|
104
|
+
'field.displayName': '展示名',
|
|
105
|
+
'field.description': '描述',
|
|
106
|
+
'field.author': '作者',
|
|
107
|
+
'field.icon': '图标 URL',
|
|
108
|
+
'field.dshVersion': 'DSH 版本(留空取最新已装)',
|
|
109
|
+
'field.out': '输出目录(留空用当前目录)',
|
|
110
|
+
'field.profile': '导出范围',
|
|
111
|
+
'scope.home': '整个 DSH_HOME(全部配置档)',
|
|
112
|
+
'field.defaultProfile': '安装后的默认配置档',
|
|
113
|
+
'content.data': '导出 data/',
|
|
114
|
+
'action.editResources': '插件与资源',
|
|
115
|
+
'market.plugins':'插件','market.paths':'插件数据','market.providers':'模型服务商','market.mcp':'MCP 服务','market.skills':'技能',
|
|
116
|
+
'field.source': '.dspack 路径或 URL',
|
|
117
|
+
'field.newName': '新 profile 名',
|
|
118
|
+
'action.export': '导出',
|
|
119
|
+
'action.quickExport': '快捷导出',
|
|
120
|
+
'action.upload': '上传到 GitHub',
|
|
121
|
+
'upload.hint': '先导出,再点此切回聊天框让 AI 帮你发 Release',
|
|
122
|
+
'upload.sent': '已切回聊天框,AI 接手上传',
|
|
123
|
+
'upload.failed': '发送失败',
|
|
124
|
+
'upload.noService': '聊天服务不可用(DSH 版本过低)',
|
|
125
|
+
'action.install': '安装',
|
|
126
|
+
'action.switch': '切换',
|
|
127
|
+
'action.create': '新建',
|
|
128
|
+
'action.save': '保存',
|
|
129
|
+
'action.load': '读取',
|
|
130
|
+
'field.profileName': '安装名(覆盖 manifest profileName)',
|
|
131
|
+
'field.mode': '导出形态',
|
|
132
|
+
'mode.dspack': '单文件(.dspack)',
|
|
133
|
+
'mode.repo': '源仓库',
|
|
134
|
+
'field.content': '仓库内容档',
|
|
135
|
+
'content.manifest': '仅清单(manifest.json)',
|
|
136
|
+
'content.readme': '清单 + README',
|
|
137
|
+
'content.full': '全套文件(overrides/ + release/)',
|
|
138
|
+
'vendor.title': '内嵌依赖(vendored · 离线分发)',
|
|
139
|
+
'vendor.hint': '勾选要内嵌进 .dspack 的插件:上游已消失 / 魔改 / 需离线分发的依赖建议内嵌;体积大时优先 files[] 指针制',
|
|
140
|
+
'vendor.reload': '刷新依赖',
|
|
141
|
+
'vendor.none': '该 profile 没有依赖',
|
|
142
|
+
'vendor.already': '已内嵌(复用原 tarball)',
|
|
143
|
+
'vendor.notInstalled': '未安装(无法内嵌)',
|
|
144
|
+
'vendor.selected': '已选',
|
|
145
|
+
'vendor.kind.npm': 'npm',
|
|
146
|
+
'vendor.kind.git': 'git',
|
|
147
|
+
'vendor.kind.vendored': '内嵌',
|
|
148
|
+
'vendor.mode': '内嵌档位',
|
|
149
|
+
'vendor.mode.auto': '自动(手动勾选 + 已内嵌复用)',
|
|
150
|
+
'vendor.mode.off': '关闭(不内嵌)',
|
|
151
|
+
'vendor.mode.full': '全量(全部直接依赖 · 离线包)',
|
|
152
|
+
'compat.title': '兼容性(v5 r2)',
|
|
153
|
+
'compat.dshVersions': '兼容 DSH 版本集(dshVersions)',
|
|
154
|
+
'compat.dshVersionsHint': '逗号分隔的实测兼容版本枚举(如 0.1.1-rc.2, 0.1.0);「DSH 版本」必须包含在内;留空 = 仅按 dshVersion',
|
|
155
|
+
'compat.launchers': '启动器兼容声明(launchers)',
|
|
156
|
+
'launcher.none': '未声明',
|
|
157
|
+
'launcher.support': '支持',
|
|
158
|
+
'launcher.conflict': '冲突',
|
|
159
|
+
'launcher.minVersion': '最低版本(可选)',
|
|
160
|
+
'launcher.reason': '冲突原因(建议填写)',
|
|
161
|
+
'group.content': '导出内容(上一级目录开关)',
|
|
162
|
+
'content.preset': '导出 .agent-presets/',
|
|
163
|
+
'content.instruction': '导出 AGENTS.md',
|
|
164
|
+
'result.saved': '已保存工作区配置',
|
|
165
|
+
'result.loaded': '已读取工作区配置',
|
|
166
|
+
'result.noCfg': '该导出范围还没有保存的工作区配置',
|
|
167
|
+
'result.pending': '处理中…',
|
|
168
|
+
'result.taskStarted': '已加入任务中心,进度见面板',
|
|
169
|
+
'result.noRpc': '后端 RPC 不可用(connection 服务缺失)',
|
|
170
|
+
'err.name': '请填写 profile 名',
|
|
171
|
+
'err.source': '请填写 .dspack 路径或 URL',
|
|
172
|
+
'err.nameInvalid': '名字格式不对:只能用小写字母、数字和连字符(如 aaa-bb-c)',
|
|
173
|
+
'err.nameReserved': '「{name}」是保留名,不能作为 profile 名',
|
|
174
|
+
'hint.nameFormat': '小写字母、数字,用连字符分隔,如 aaa-bb-c',
|
|
175
|
+
'hint.import': '.dspack 文件路径或 URL',
|
|
176
|
+
'dialog.createTitle': '创建空的整合包',
|
|
177
|
+
'dialog.importTitle': '导入新包',
|
|
178
|
+
'profile.active': '当前',
|
|
179
|
+
'market.loading': '加载市场中…',
|
|
180
|
+
'market.empty': '市场暂无内容',
|
|
181
|
+
'market.error': '市场加载失败',
|
|
182
|
+
'market.none': '(无)',
|
|
183
|
+
'market.detail': '详情',
|
|
184
|
+
'market.detailTitle': '整合包详情',
|
|
185
|
+
'market.launcherRestricted': '启动器限制',
|
|
186
|
+
'market.r2.launcherRequire': '需启动器 {id} ≥ {ver}',
|
|
187
|
+
'market.r2.launcherConflict': '不支持在 {id} 上运行:{reason}',
|
|
188
|
+
'market.r2.noReason': '未提供原因',
|
|
189
|
+
'market.r2.vendored': '内嵌 {count} 个依赖(离线分发)',
|
|
190
|
+
'market.r2.dshVersions': '兼容 DSH 版本:{versions}',
|
|
191
|
+
'market.r2.none': '无启动器兼容限制,未内嵌依赖',
|
|
192
|
+
'installConfirm.title': '安装确认',
|
|
193
|
+
'installConfirm.hint': '该整合包的启动器兼容声明存在警告,确认后将照常安装:',
|
|
194
|
+
'installConfirm.ok': '仍要安装',
|
|
195
|
+
'confirm.title': '切换 profile',
|
|
196
|
+
'confirm.from': '当前',
|
|
197
|
+
'confirm.to': '目标',
|
|
198
|
+
'confirm.firstTime': '首次切换:会把当前目录存档为 default',
|
|
199
|
+
'confirm.warning': '检测到目标 profile 没有 {pkg},需要安装。若没有此插件,将无法从应用内再次切换 profile。',
|
|
200
|
+
'confirm.cancel': '取消',
|
|
201
|
+
'confirm.ok': '确认切换',
|
|
202
|
+
'confirm.hintRestart': '切换后会自动重启客户端;若长时间未自动重启,请手动拉起客户端。',
|
|
203
|
+
'confirm.managerSource': '目标缺少插件,安装方式:',
|
|
204
|
+
'confirm.source.copy': '从当前 profile 复制',
|
|
205
|
+
'confirm.source.npm': '从 NPM 拉取最新',
|
|
206
|
+
'tab.about': '关于',
|
|
207
|
+
'about.version': '版本',
|
|
208
|
+
'about.desc': 'DSH 整合包管理插件:.dspack 导出/导入、多 profile 切换,零官方源码改动。',
|
|
209
|
+
'about.philosophy': '整合——包罗万象',
|
|
210
|
+
'about.author': '作者',
|
|
211
|
+
'about.repo': '仓库',
|
|
212
|
+
'about.star': '求 Star',
|
|
213
|
+
'about.checkUpdate': '检查更新',
|
|
214
|
+
'about.checking': '检查中…',
|
|
215
|
+
'about.upToDate': '已是最新版本',
|
|
216
|
+
'about.newVersion': '有新版本 {latest}(当前 {current})',
|
|
217
|
+
'about.checkFailed': '检查更新失败',
|
|
218
|
+
'about.viewNpm': '在 npm 查看',
|
|
219
|
+
'about.ecosystem': '生态',
|
|
220
|
+
'about.ecosystem.spec': '理念及规范',
|
|
221
|
+
'about.ecosystem.app': '包管理器',
|
|
222
|
+
'about.ecosystem.market': '市场',
|
|
223
|
+
'group.network': '网络',
|
|
224
|
+
'field.proxyMode': '代理模式',
|
|
225
|
+
'proxyMode.auto': '自动(跟随系统代理)',
|
|
226
|
+
'proxyMode.direct': '直连(不使用代理)',
|
|
227
|
+
'proxyMode.manual': '手动指定代理',
|
|
228
|
+
'field.proxy': '代理地址',
|
|
229
|
+
'hint.proxy': '自动模式回落环境变量(HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXY)与 Windows 系统代理;手动支持 http / https / socks / socks5,如 http://127.0.0.1:7890',
|
|
230
|
+
'result.proxySaved': '已保存代理设置(立即生效)',
|
|
231
|
+
'about.copyright': '© 2026 DSH-PackForge contributors · MIT License',
|
|
232
|
+
},
|
|
233
|
+
en: {
|
|
234
|
+
nav: 'Modpacks',
|
|
235
|
+
'tab.manage': 'Manage',
|
|
236
|
+
'tab.export': 'Export',
|
|
237
|
+
'tab.market': 'Market',
|
|
238
|
+
'running.title': 'Running modpack',
|
|
239
|
+
'running.profile': 'profile: ',
|
|
240
|
+
'action.openDir': 'Open folder',
|
|
241
|
+
'create.title': 'Create modpack',
|
|
242
|
+
'action.newEmpty': 'Empty pack',
|
|
243
|
+
'action.import': 'Import pack',
|
|
244
|
+
'action.market': 'Browse market',
|
|
245
|
+
'action.refresh': 'Refresh',
|
|
246
|
+
'action.tasks': 'Task Center',
|
|
247
|
+
'tasks.empty': 'No tasks',
|
|
248
|
+
'tasks.close': 'Close',
|
|
249
|
+
'installed.title': 'Installed modpacks',
|
|
250
|
+
'action.delete': 'Delete',
|
|
251
|
+
'hint.restart': 'Takes effect after restart',
|
|
252
|
+
'group.meta': 'Metadata (blank = profile default)',
|
|
253
|
+
'group.output': 'Output',
|
|
254
|
+
'field.name': 'Pack name',
|
|
255
|
+
'field.version': 'Version',
|
|
256
|
+
'field.displayName': 'Display name',
|
|
257
|
+
'field.description': 'Description',
|
|
258
|
+
'field.author': 'Author',
|
|
259
|
+
'field.icon': 'Icon URL',
|
|
260
|
+
'field.dshVersion': 'DSH version (blank = latest)',
|
|
261
|
+
'field.out': 'Output dir (blank = current)',
|
|
262
|
+
'field.profile': 'Export scope',
|
|
263
|
+
'scope.home': 'Entire DSH_HOME (all profiles)',
|
|
264
|
+
'field.defaultProfile': 'Default profile after installation',
|
|
265
|
+
'content.data': 'Include data/',
|
|
266
|
+
'action.editResources': 'Plugins and resources',
|
|
267
|
+
'market.plugins':'Plugins','market.paths':'Plugin data','market.providers':'Model providers','market.mcp':'MCP servers','market.skills':'Skills',
|
|
268
|
+
'field.source': '.dspack path or URL',
|
|
269
|
+
'field.newName': 'New profile name',
|
|
270
|
+
'vendor.title': 'Vendored deps (offline distribution)',
|
|
271
|
+
'vendor.hint': 'Pick plugins to embed into the .dspack: dead-upstream / modified / offline deps are good candidates; prefer files[] pointers for large content',
|
|
272
|
+
'vendor.reload': 'Reload deps',
|
|
273
|
+
'vendor.none': 'No dependencies in this profile',
|
|
274
|
+
'vendor.already': 'Vendored (reuses original tarball)',
|
|
275
|
+
'vendor.notInstalled': 'Not installed (cannot embed)',
|
|
276
|
+
'vendor.selected': 'selected',
|
|
277
|
+
'vendor.kind.npm': 'npm',
|
|
278
|
+
'vendor.kind.git': 'git',
|
|
279
|
+
'vendor.kind.vendored': 'vendored',
|
|
280
|
+
'vendor.mode': 'Vendor mode',
|
|
281
|
+
'vendor.mode.auto': 'Auto (manual picks + re-use embedded)',
|
|
282
|
+
'vendor.mode.off': 'Off (no embedding)',
|
|
283
|
+
'vendor.mode.full': 'Full (all direct deps · offline pack)',
|
|
284
|
+
'compat.title': 'Compatibility (v5 r2)',
|
|
285
|
+
'compat.dshVersions': 'Compatible DSH versions (dshVersions)',
|
|
286
|
+
'compat.dshVersionsHint': 'Comma-separated tested versions (e.g. 0.1.1-rc.2, 0.1.0); must include the "DSH version" field; blank = dshVersion only',
|
|
287
|
+
'compat.launchers': 'Launcher compatibility (launchers)',
|
|
288
|
+
'launcher.none': 'Unspecified',
|
|
289
|
+
'launcher.support': 'Supported',
|
|
290
|
+
'launcher.conflict': 'Conflict',
|
|
291
|
+
'launcher.minVersion': 'Min version (optional)',
|
|
292
|
+
'launcher.reason': 'Conflict reason (recommended)',
|
|
293
|
+
'action.export': 'Export',
|
|
294
|
+
'action.quickExport': 'Quick export',
|
|
295
|
+
'action.upload': 'Upload to GitHub',
|
|
296
|
+
'upload.hint': 'Export first, then switch to chat and let the AI publish the release',
|
|
297
|
+
'upload.sent': 'Switched to chat — the AI is on it',
|
|
298
|
+
'upload.failed': 'Send failed',
|
|
299
|
+
'upload.noService': 'Chat service unavailable (DSH too old)',
|
|
300
|
+
'action.install': 'Install',
|
|
301
|
+
'action.switch': 'Switch',
|
|
302
|
+
'action.create': 'Create',
|
|
303
|
+
'result.pending': 'Working…',
|
|
304
|
+
'result.taskStarted': 'Added to task center — see the panel',
|
|
305
|
+
'result.noRpc': 'Backend RPC unavailable (no connection service)',
|
|
306
|
+
'err.name': 'Please fill a profile name',
|
|
307
|
+
'err.source': 'Please fill a .dspack path or URL',
|
|
308
|
+
'err.nameInvalid': 'Invalid name: lowercase letters, digits and hyphens only (e.g. aaa-bb-c)',
|
|
309
|
+
'err.nameReserved': '"{name}" is a reserved name and cannot be used as a profile name',
|
|
310
|
+
'hint.nameFormat': 'Lowercase letters and digits separated by hyphens, e.g. aaa-bb-c',
|
|
311
|
+
'hint.import': '.dspack file path or URL',
|
|
312
|
+
'dialog.createTitle': 'Create empty modpack',
|
|
313
|
+
'dialog.importTitle': 'Import modpack',
|
|
314
|
+
'profile.active': 'current',
|
|
315
|
+
'market.loading': 'Loading market…',
|
|
316
|
+
'market.empty': 'Market is empty',
|
|
317
|
+
'market.error': 'Market load failed',
|
|
318
|
+
'market.none': '(none)',
|
|
319
|
+
'market.detail': 'Details',
|
|
320
|
+
'market.detailTitle': 'Modpack details',
|
|
321
|
+
'market.launcherRestricted': 'launcher-restricted',
|
|
322
|
+
'market.r2.launcherRequire': 'Requires launcher {id} ≥ {ver}',
|
|
323
|
+
'market.r2.launcherConflict': 'Not supported on {id}: {reason}',
|
|
324
|
+
'market.r2.noReason': 'no reason given',
|
|
325
|
+
'market.r2.vendored': '{count} vendored deps (offline distribution)',
|
|
326
|
+
'market.r2.dshVersions': 'Compatible DSH versions: {versions}',
|
|
327
|
+
'market.r2.none': 'No launcher restrictions, no vendored deps',
|
|
328
|
+
'installConfirm.title': 'Install confirmation',
|
|
329
|
+
'installConfirm.hint': 'This pack has launcher-compatibility warnings. It will still be installed after you confirm:',
|
|
330
|
+
'installConfirm.ok': 'Install anyway',
|
|
331
|
+
'confirm.title': 'Switch profile',
|
|
332
|
+
'confirm.from': 'current',
|
|
333
|
+
'confirm.to': 'target',
|
|
334
|
+
'confirm.firstTime': 'First switch: current folder will be archived as default',
|
|
335
|
+
'confirm.warning': 'Target profile has no {pkg}; it must be installed. Without it you cannot switch again from inside the app.',
|
|
336
|
+
'confirm.cancel': 'Cancel',
|
|
337
|
+
'confirm.ok': 'Confirm switch',
|
|
338
|
+
'confirm.hintRestart': 'The client restarts automatically after switching; if it does not restart for a while, please launch it manually.',
|
|
339
|
+
'confirm.managerSource': 'Target profile is missing the plugin. Install via:',
|
|
340
|
+
'confirm.source.copy': 'Copy from current profile',
|
|
341
|
+
'confirm.source.npm': 'Pull latest from NPM',
|
|
342
|
+
'tab.about': 'About',
|
|
343
|
+
'about.version': 'Version',
|
|
344
|
+
'about.desc': 'DSH modpack plugin: .dspack export/import, multi-profile switching, zero official source changes.',
|
|
345
|
+
'about.philosophy': 'Integrate — embrace everything',
|
|
346
|
+
'about.author': 'Author',
|
|
347
|
+
'about.repo': 'Repository',
|
|
348
|
+
'about.star': 'Star on GitHub',
|
|
349
|
+
'about.checkUpdate': 'Check for updates',
|
|
350
|
+
'about.checking': 'Checking…',
|
|
351
|
+
'about.upToDate': 'You are up to date',
|
|
352
|
+
'about.newVersion': 'New version {latest} (current {current})',
|
|
353
|
+
'about.checkFailed': 'Update check failed',
|
|
354
|
+
'about.viewNpm': 'View on npm',
|
|
355
|
+
'about.ecosystem': 'Ecosystem',
|
|
356
|
+
'about.ecosystem.spec': 'Philosophy & Spec',
|
|
357
|
+
'about.ecosystem.app': 'Package Manager',
|
|
358
|
+
'about.ecosystem.market': 'Market',
|
|
359
|
+
'group.network': 'Network',
|
|
360
|
+
'field.proxyMode': 'Proxy mode',
|
|
361
|
+
'proxyMode.auto': 'Auto (follow system proxy)',
|
|
362
|
+
'proxyMode.direct': 'Direct (no proxy)',
|
|
363
|
+
'proxyMode.manual': 'Manual proxy',
|
|
364
|
+
'field.proxy': 'Proxy',
|
|
365
|
+
'hint.proxy': 'Auto mode falls back to env vars (HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXY) and the Windows system proxy; manual supports http / https / socks / socks5, e.g. http://127.0.0.1:7890',
|
|
366
|
+
'result.proxySaved': 'Proxy saved (takes effect immediately)',
|
|
367
|
+
'about.copyright': '© 2026 DSH-PackForge contributors · MIT License',
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
export function registerSettingsSection(ctx, packforge = {}) {
|
|
372
|
+
const slots = ctx?.slots;
|
|
373
|
+
const locale = ctx?.locale;
|
|
374
|
+
if (!slots || typeof slots.inject !== 'function') return false;
|
|
375
|
+
if (!locale || typeof locale.register !== 'function' || typeof locale.bind !== 'function') return false;
|
|
376
|
+
|
|
377
|
+
const registerLocale = () => {
|
|
378
|
+
try {
|
|
379
|
+
locale.register(NS, dict);
|
|
380
|
+
} catch (e) {
|
|
381
|
+
// DSH locale 服务全局去重:同一 namespace+locale 重复注册抛错,且旧注册不随
|
|
382
|
+
// 插件 fiber 卸载清理。热重载(关→开)时 dict 内容不变,重复注册安全忽略;
|
|
383
|
+
// 其余错误照抛,避免掩盖真正的注册失败。
|
|
384
|
+
if (/already has locale/.test(String(e?.message ?? e))) return;
|
|
385
|
+
throw e;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
if (typeof ctx.effect === 'function') ctx.effect(registerLocale, 'dspack: settings dict');
|
|
389
|
+
else registerLocale();
|
|
390
|
+
|
|
391
|
+
const t = locale.bind(NS);
|
|
392
|
+
|
|
393
|
+
// 导航 tab 图标:settings.section 契约没有 icon 字段,shell 对未知 id 一律
|
|
394
|
+
// 回退齿轮;这里在对话框挂载后把属于本插件的那一行换成 logo(folder-zip)。
|
|
395
|
+
installSettingsNavIcon(ctx, () => t('nav'), navIconMaskUrl(navIconMaskSvg(LOGO_PATH)));
|
|
396
|
+
// 悬浮球点开设置后要切到本插件分区:把「认标签找那一行」的能力交给客户端插件
|
|
397
|
+
// (球在页面 DOM 里跑,不该依赖图标标记的时机)。
|
|
398
|
+
installSectionFocusHook(ctx, () => t('nav'));
|
|
399
|
+
|
|
400
|
+
// 经 section-gate 注册:register 幂等、disposer 显式持有,热重载时不二次 register,
|
|
401
|
+
// 从而避免命中 SlotCore 的重复 id 校验(dsh-market 同款做法,实测重载不丢入口)。
|
|
402
|
+
const sectionGate = createSectionGate(() => {
|
|
403
|
+
const off = slots.register(
|
|
404
|
+
{
|
|
405
|
+
name: 'settings.section',
|
|
406
|
+
id: 'dspack',
|
|
407
|
+
order: 20,
|
|
408
|
+
label: () => t('nav'),
|
|
409
|
+
locale: NS,
|
|
410
|
+
inject: () => ({ t, packforge }),
|
|
411
|
+
},
|
|
412
|
+
DspackSection,
|
|
413
|
+
);
|
|
414
|
+
// slots.register 在不支持 disposer 的宿主上可能返回 undefined;闸门需要一个恒有的
|
|
415
|
+
// disposer,缺省退化为 no-op,避免变成无法撤销的注册。
|
|
416
|
+
return typeof off === 'function' ? off : () => {};
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
slots.inject('settings.section', () => {
|
|
420
|
+
sectionGate.available();
|
|
421
|
+
});
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const META_FIELDS = ['name', 'version', 'displayName', 'description', 'author', 'icon', 'profileName'];
|
|
426
|
+
const OUTPUT_FIELDS = ['dshVersion', 'out'];
|
|
427
|
+
const MODES = ['dspack', 'repo'];
|
|
428
|
+
const CONTENT_LEVELS = ['manifest', 'readme', 'full'];
|
|
429
|
+
const HOME_EXPORT = '@dshhome';
|
|
430
|
+
const exportLocation = name => name === HOME_EXPORT ? {type:'dshhome'} : {type:'profile',profile:name};
|
|
431
|
+
|
|
432
|
+
// 启动器编辑器回落清单(launchers/registry 端点不可用时用;与 specs/launcher-registry.md §1 同步维护)。
|
|
433
|
+
const LAUNCHER_IDS = ['dshl', 'hdsl', 'dsh-packforge-app', 'official-desktop', 'dsh-cli'];
|
|
434
|
+
|
|
435
|
+
export function DspackSection({ t, packforge }) {
|
|
436
|
+
const rpc = packforge?.rpc;
|
|
437
|
+
const sendToChat = packforge?.sendToChat;
|
|
438
|
+
const [tab, setTab] = useState('manage');
|
|
439
|
+
const [profiles, setProfiles] = useState([]);
|
|
440
|
+
const [result, setResult] = useState(null); // null | {pending:true} | {ok:true,text} | {ok:false,error}
|
|
441
|
+
const [dialog, setDialog] = useState(null); // null | 'create' | 'import'
|
|
442
|
+
const [newName, setNewName] = useState('');
|
|
443
|
+
const [source, setSource] = useState('');
|
|
444
|
+
const [fieldError, setFieldError] = useState('');
|
|
445
|
+
const [submitting, setSubmitting] = useState(false);
|
|
446
|
+
const [market, setMarket] = useState(null); // null=未加载 undefined=加载中 {packs,error}
|
|
447
|
+
const [meta, setMeta] = useState({});
|
|
448
|
+
const [resources, setResources] = useState({});
|
|
449
|
+
const [exportProfile, setExportProfile] = useState('');
|
|
450
|
+
const wholeHome = exportProfile === HOME_EXPORT;
|
|
451
|
+
const selectedExport = useRef(exportProfile);
|
|
452
|
+
selectedExport.current = exportProfile;
|
|
453
|
+
const metadataFields = wholeHome ? META_FIELDS.filter(k=>k !== 'profileName').concat('defaultProfile') : META_FIELDS;
|
|
454
|
+
const [mode, setMode] = useState('dspack');
|
|
455
|
+
const [contentLevel, setContentLevel] = useState('readme');
|
|
456
|
+
const [exportContent, setExportContent] = useState({preset:false,instruction:false,data:false});
|
|
457
|
+
const [loadedFor, setLoadedFor] = useState(null); // 已自动加载过配置的 profile 名
|
|
458
|
+
const [deps, setDeps] = useState(null); // 导出依赖清单(null=未加载;[] = 无依赖)
|
|
459
|
+
const [depsFor, setDepsFor] = useState(null); // 已加载依赖清单的 profile 名
|
|
460
|
+
const [vendorSel, setVendorSel] = useState({}); // 勾选内嵌:{ 坐标: reason }(reason 缺省 explicit)
|
|
461
|
+
const [dshVersionsText, setDshVersionsText] = useState(''); // 兼容 DSH 版本集(逗号分隔文本)
|
|
462
|
+
// 启动器兼容编辑:{ [id]: { mode: 'support'|'conflict', minVersion, reason } };无条目 = 未声明
|
|
463
|
+
const [launchersState, setLaunchersState] = useState({});
|
|
464
|
+
const [vendorMode, setVendorMode] = useState('auto'); // vendoring 档位(workspace-config v1 r2):auto | off | full
|
|
465
|
+
const [installedDsh, setInstalledDsh] = useState([]); // 本机已装 DSH 版本(dshVersions 建议列表)
|
|
466
|
+
// 启动器注册表(launchers/registry 端点,机器可读版):[{id, name}];null = 未加载(回落 LAUNCHER_IDS)
|
|
467
|
+
const [launchersReg, setLaunchersReg] = useState(null);
|
|
468
|
+
const [confirm, setConfirm] = useState(null); // null | {from,to,hasManager,firstTime}
|
|
469
|
+
const [managerSource, setManagerSource] = useState('npm'); // 'npm'(拉取最新,默认)| 'copy'(次之复制)
|
|
470
|
+
const [tasksOpen, setTasksOpen] = useState(false); // 任务中心面板是否展开(内嵌视图,替代旧版独立小窗)
|
|
471
|
+
const [taskList, setTaskList] = useState([]); // task/list 轮询结果
|
|
472
|
+
const [update, setUpdate] = useState(null); // null | {checking:true} | {current,latest,outdated,npmUrl} | {error}
|
|
473
|
+
const [proxy, setProxy] = useState(''); // 代理地址(config.proxy;空 = 回落环境变量)
|
|
474
|
+
const [proxyMode, setProxyMode] = useState('auto'); // auto | direct | manual
|
|
475
|
+
const [upload, setUpload] = useState(null); // null | {pending:true} | {ok:true,text} | {ok:false,error}
|
|
476
|
+
// 安装确认(v5 r2 §8.4 判定表第 4 行):pack/view 预检出 warn 级 launchers 警告时弹确认,
|
|
477
|
+
// 用户点「仍要安装」后才继续 pack/install。null | { source, extra, warnings, fromDialog }
|
|
478
|
+
const [installConfirm, setInstallConfirm] = useState(null);
|
|
479
|
+
// 市场详情弹窗(v5 r2 徽标 + README 懒加载):null | {pending:true,pack} | {error,pack} | {pack,manifest,readme,r2,badges}
|
|
480
|
+
const [detail, setDetail] = useState(null);
|
|
481
|
+
|
|
482
|
+
const call = async (endpoint, payload) => {
|
|
483
|
+
if (!rpc) return { ok: false, error: t('result.noRpc') };
|
|
484
|
+
try {
|
|
485
|
+
const res = await rpc.call(endpoint, payload ?? {});
|
|
486
|
+
return res?.ok ? { ok: true, value: res.value } : { ok: false, error: res?.error?.message ?? String(res?.error ?? '失败') };
|
|
487
|
+
} catch (e) {
|
|
488
|
+
return { ok: false, error: String(e?.message ?? e) };
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const refresh = async () => {
|
|
493
|
+
const r = await call('profile/list', {});
|
|
494
|
+
if (r.ok) {
|
|
495
|
+
const list = r.value.profiles ?? [];
|
|
496
|
+
setProfiles(list);
|
|
497
|
+
setExportProfile((prev) => prev || list.find((p) => p.active)?.name || list[0]?.name || HOME_EXPORT);
|
|
498
|
+
} else setResult(r);
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// 轮询任务到结束:完成后刷新 profile 列表;失败就地把错误弹到面板。
|
|
502
|
+
const watch = (id) => {
|
|
503
|
+
setTasksOpen(true); // 任务开始即展开任务中心面板(替代旧版自动弹出独立小窗)
|
|
504
|
+
const timer = setInterval(async () => {
|
|
505
|
+
const r = await call('task/get', { id });
|
|
506
|
+
if (!r.ok) { clearInterval(timer); return; }
|
|
507
|
+
const t = r.value;
|
|
508
|
+
if (!t || (t.status !== 'done' && t.status !== 'failed')) return;
|
|
509
|
+
clearInterval(timer);
|
|
510
|
+
if (t.status === 'failed') showErr(t.error || '任务失败');
|
|
511
|
+
void refresh();
|
|
512
|
+
}, 600);
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
516
|
+
useEffect(() => { void refresh(); }, []);
|
|
517
|
+
|
|
518
|
+
// 挂载时读一次已存代理设置回填(保存后 host 立即生效,无需重启)。
|
|
519
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
520
|
+
useEffect(() => {
|
|
521
|
+
void (async () => {
|
|
522
|
+
const r = await call('config/get', {});
|
|
523
|
+
if (!r.ok) return;
|
|
524
|
+
const v = r.value?.proxy ?? '';
|
|
525
|
+
if (v === 'direct') { setProxyMode('direct'); setProxy(''); }
|
|
526
|
+
else if (v) { setProxyMode('manual'); setProxy(v); }
|
|
527
|
+
else { setProxyMode('auto'); setProxy(''); }
|
|
528
|
+
})();
|
|
529
|
+
// 已装 DSH 版本(dshVersions 多选建议来源)
|
|
530
|
+
void (async () => {
|
|
531
|
+
const r = await call('runtime/get', {});
|
|
532
|
+
if (r.ok && Array.isArray(r.value?.installedDshVersions)) setInstalledDsh(r.value.installedDshVersions);
|
|
533
|
+
})();
|
|
534
|
+
// 启动器注册表(机器可读版,launchers/registry 端点):失败静默回落内置清单
|
|
535
|
+
void (async () => {
|
|
536
|
+
const r = await call('launchers/registry', {});
|
|
537
|
+
if (r.ok && Array.isArray(r.value?.launchers) && r.value.launchers.length) {
|
|
538
|
+
setLaunchersReg(r.value.launchers);
|
|
539
|
+
}
|
|
540
|
+
})();
|
|
541
|
+
}, []);
|
|
542
|
+
|
|
543
|
+
const active = profiles.find((p) => p.active) ?? null;
|
|
544
|
+
|
|
545
|
+
const showOk = (text) => setResult({ ok: true, text });
|
|
546
|
+
const showErr = (error) => setResult({ ok: false, error });
|
|
547
|
+
|
|
548
|
+
// About 页:用系统浏览器打开外部链接(经 host,避免 renderer 里 target=_blank 不可控)。
|
|
549
|
+
const openUrl = (url) => {
|
|
550
|
+
void call('plugin/open-url', { url });
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
// About 页:检查更新(host 拉 registry 最新版并与本地比较)。
|
|
554
|
+
const doCheckUpdate = async () => {
|
|
555
|
+
setUpdate({ checking: true });
|
|
556
|
+
const r = await call('plugin/check-update', {});
|
|
557
|
+
if (!r.ok) setUpdate({ error: r.error });
|
|
558
|
+
else setUpdate(r.value);
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
// About 页:保存代理设置(config/set 里 host 会立即 setProxy,无需重启)。
|
|
562
|
+
const doSaveProxy = async () => {
|
|
563
|
+
const value = proxyMode === 'direct' ? 'direct' : proxyMode === 'manual' ? proxy.trim() : '';
|
|
564
|
+
const r = await call('config/set', { proxy: value });
|
|
565
|
+
if (!r.ok) return showErr(r.error);
|
|
566
|
+
showOk(t('result.proxySaved'));
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// 点击「切换」先做只读预检,弹确认窗;用户点「确认切换」才真正调 profile/switch。
|
|
570
|
+
const askSwitch = async (name) => {
|
|
571
|
+
const r = await call('profile/switch-check', { name });
|
|
572
|
+
if (!r.ok) return showErr(r.error);
|
|
573
|
+
setManagerSource('npm');
|
|
574
|
+
setConfirm({
|
|
575
|
+
from: r.value.from,
|
|
576
|
+
to: r.value.to,
|
|
577
|
+
hasManager: r.value.hasManager,
|
|
578
|
+
firstTime: r.value.firstTime,
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const confirmSwitch = async () => {
|
|
583
|
+
if (!confirm) return;
|
|
584
|
+
const name = confirm.to;
|
|
585
|
+
setConfirm(null);
|
|
586
|
+
setResult({ pending: true });
|
|
587
|
+
const r = await call('profile/switch', { name, managerSource });
|
|
588
|
+
if (!r.ok) return showErr(r.error);
|
|
589
|
+
showOk(r.value?.restarting
|
|
590
|
+
? `切换中:桌面将自动重启到「${name}」`
|
|
591
|
+
: `已切换到「${name}」,重启 DSH 后生效`);
|
|
592
|
+
void refresh();
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
const doDelete = async (name) => {
|
|
596
|
+
setResult({ pending: true });
|
|
597
|
+
const r = await call('profile/delete', { name });
|
|
598
|
+
if (!r.ok) return showErr(r.error);
|
|
599
|
+
showOk(`已删除「${name}」`);
|
|
600
|
+
void refresh();
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
const doExportProfile = async (name) => {
|
|
604
|
+
setResult({ pending: true });
|
|
605
|
+
const r = await call('pack/export', name ? { profile: name } : {});
|
|
606
|
+
if (!r.ok) return showErr(r.error);
|
|
607
|
+
showOk(t('result.taskStarted'));
|
|
608
|
+
watch(r.value.taskId);
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
const doOpenTasks = () => {
|
|
612
|
+
setTasksOpen((v) => !v);
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
const doOpenDir = async (name) => {
|
|
616
|
+
const r = await call('profile/open-dir', { name });
|
|
617
|
+
if (r.ok) showOk(`已打开 ${r.value.dir}`);
|
|
618
|
+
else showErr(r.error);
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
// 弹窗:点「空整合包」/「导入新包」打开,收集名字/路径,校验通过才提交。
|
|
622
|
+
const openDialog = (type) => {
|
|
623
|
+
setFieldError('');
|
|
624
|
+
setSubmitting(false);
|
|
625
|
+
setDialog(type);
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
const closeDialog = () => {
|
|
629
|
+
setDialog(null);
|
|
630
|
+
setFieldError('');
|
|
631
|
+
setSubmitting(false);
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
const doCreate = async () => {
|
|
635
|
+
const name = newName.trim();
|
|
636
|
+
if (!name) return setFieldError(t('err.name'));
|
|
637
|
+
if (!PROFILE_NAME_RE.test(name)) return setFieldError(t('err.nameInvalid'));
|
|
638
|
+
if (RESERVED_PROFILE_NAMES.includes(name)) return setFieldError(t('err.nameReserved').replace('{name}', name));
|
|
639
|
+
setSubmitting(true);
|
|
640
|
+
const r = await call('profile/create', { name });
|
|
641
|
+
setSubmitting(false);
|
|
642
|
+
if (!r.ok) return setFieldError(r.error);
|
|
643
|
+
setNewName('');
|
|
644
|
+
closeDialog();
|
|
645
|
+
showOk(t('result.taskStarted'));
|
|
646
|
+
watch(r.value.taskId);
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
const doImport = async () => {
|
|
650
|
+
const src = source.trim();
|
|
651
|
+
if (!src) return setFieldError(t('err.source'));
|
|
652
|
+
setSubmitting(true);
|
|
653
|
+
// 安装前预检(v5 r2 §8.4):pack/view 做 launchers 判定——warn 级须用户确认后才安装。
|
|
654
|
+
const v = await call('pack/view', { source: src });
|
|
655
|
+
setSubmitting(false);
|
|
656
|
+
if (!v.ok) return setFieldError(v.error);
|
|
657
|
+
const warnings = v.value?.launchersWarnings ?? [];
|
|
658
|
+
if (warnings.some((w) => w.level === 'warn')) {
|
|
659
|
+
// 重警告(supported:false):弹确认对话框,确认后走 confirmInstall(导入弹窗暂留,取消可返回)
|
|
660
|
+
setInstallConfirm({ source: src, extra: {}, warnings, fromDialog: true });
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
// info 级(版本不足 / 白名单未含本启动器):轻提示放行,不打断
|
|
664
|
+
const infos = warnings.filter((w) => w.level === 'info');
|
|
665
|
+
if (infos.length) showOk(infos.map((w) => w.message).join('\n'));
|
|
666
|
+
setSource('');
|
|
667
|
+
closeDialog();
|
|
668
|
+
await doInstallTask(src, {});
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
const loadMarket = async () => {
|
|
672
|
+
setMarket(undefined);
|
|
673
|
+
const r = await call('pack/market', {});
|
|
674
|
+
if (r.ok) setMarket({ packs: r.value.packs ?? [], error: r.value.error ?? null });
|
|
675
|
+
else setMarket({ packs: [], error: r.error });
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// 真正的安装(任务中心非阻塞):launchers 确认流的终点,市场 / 本地导入两条路径共用。
|
|
679
|
+
const doInstallTask = async (src, extra) => {
|
|
680
|
+
setResult({ pending: true });
|
|
681
|
+
let reviewed;
|
|
682
|
+
try {
|
|
683
|
+
const preview = async (options) => {
|
|
684
|
+
const result = await call('pack/preview-install', options);
|
|
685
|
+
if (!result.ok) throw new Error(result.error);
|
|
686
|
+
return result.value;
|
|
687
|
+
};
|
|
688
|
+
reviewed = await reviewInstall(preview, { source: src, ...extra });
|
|
689
|
+
if (!reviewed) { setResult(null); return; }
|
|
690
|
+
} catch (error) { return showErr(error.message); }
|
|
691
|
+
const r = await call('pack/install', reviewed);
|
|
692
|
+
if (!r.ok) return showErr(r.error);
|
|
693
|
+
showOk(t('result.taskStarted'));
|
|
694
|
+
watch(r.value.taskId);
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
const doInstallFromMarket = async (pack) => {
|
|
698
|
+
const src = pack?.downloadUrl || pack?.urls?.[0];
|
|
699
|
+
if (!src) return showErr('该包没有可下载地址');
|
|
700
|
+
setResult({ pending: true });
|
|
701
|
+
// 安装前预检(v5 r2 §8.4):与本地导入同一条 pack/view 校验点。
|
|
702
|
+
const v = await call('pack/view', { source: src });
|
|
703
|
+
if (!v.ok) return showErr(v.error);
|
|
704
|
+
const warnings = v.value?.launchersWarnings ?? [];
|
|
705
|
+
const extra = {
|
|
706
|
+
expectedSha256: pack?.sha256 || undefined,
|
|
707
|
+
expectedSize: pack?.size || undefined,
|
|
708
|
+
};
|
|
709
|
+
if (warnings.some((w) => w.level === 'warn')) {
|
|
710
|
+
setInstallConfirm({ source: src, extra, warnings, fromDialog: false });
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
const infos = warnings.filter((w) => w.level === 'info');
|
|
714
|
+
if (infos.length) showOk(infos.map((w) => w.message).join('\n'));
|
|
715
|
+
await doInstallTask(src, extra);
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
// 安装确认弹窗的「仍要安装」:warn 级放行须用户确认(v3 §8.4「警告放行」+ 留痕由任务日志承担)。
|
|
719
|
+
const confirmInstall = async () => {
|
|
720
|
+
const c = installConfirm;
|
|
721
|
+
if (!c) return;
|
|
722
|
+
setInstallConfirm(null);
|
|
723
|
+
if (c.fromDialog) {
|
|
724
|
+
setSource('');
|
|
725
|
+
closeDialog();
|
|
726
|
+
}
|
|
727
|
+
await doInstallTask(c.source, c.extra ?? {});
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// 市场详情:懒加载 packs/<id>/manifest.json + README(fetchMarketPackDetail),弹窗展示 r2 徽标。
|
|
731
|
+
const doMarketDetail = async (pack) => {
|
|
732
|
+
setDetail({ pending: true, pack });
|
|
733
|
+
const r = await call('pack/market-detail', { pack });
|
|
734
|
+
if (!r.ok) { setDetail({ error: r.error, pack }); return; }
|
|
735
|
+
setDetail({
|
|
736
|
+
pack,
|
|
737
|
+
manifest: r.value.manifest,
|
|
738
|
+
icons: r.value.icons,
|
|
739
|
+
readme: r.value.readme ?? '',
|
|
740
|
+
r2: r.value.r2 ?? {},
|
|
741
|
+
badges: r.value.badges ?? [],
|
|
742
|
+
});
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// r2 徽标 → 本地化文案(结构化数据来自 core r2Badges,经 endpoint 透传;文案在 UI 层 i18n)。
|
|
746
|
+
const badgeText = (b) => {
|
|
747
|
+
if (b.kind === 'launcher-require') return t('market.r2.launcherRequire').replace('{id}', b.id).replace('{ver}', b.minVersion);
|
|
748
|
+
if (b.kind === 'launcher-conflict') return t('market.r2.launcherConflict').replace('{id}', b.id).replace('{reason}', b.reason || t('market.r2.noReason'));
|
|
749
|
+
if (b.kind === 'vendored') return t('market.r2.vendored').replace('{count}', String(b.count));
|
|
750
|
+
if (b.kind === 'dsh-versions') return t('market.r2.dshVersions').replace('{versions}', b.versions.join(', '));
|
|
751
|
+
return '';
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
const editResources = async () => {
|
|
755
|
+
const options = await call('pack/export-choices', { ...exportLocation(exportProfile), plugins: resources.plugins, profilePlugins: resources.profilePlugins });
|
|
756
|
+
if (!options.ok) return showErr(options.error);
|
|
757
|
+
const result = await chooseExportResources(options.value.candidates, options.value.units, resources, wholeHome);
|
|
758
|
+
if (result && selectedExport.current === exportProfile) setResources(result);
|
|
759
|
+
};
|
|
760
|
+
const doExportFromForm = async () => {
|
|
761
|
+
setResult({ pending: true });
|
|
762
|
+
const overrides = exportLocation(exportProfile);
|
|
763
|
+
for (const k of [...metadataFields, ...OUTPUT_FIELDS]) {
|
|
764
|
+
const v = (meta[k] ?? '').trim();
|
|
765
|
+
if (v) overrides[k] = v;
|
|
766
|
+
}
|
|
767
|
+
overrides.mode = mode;
|
|
768
|
+
overrides.content = contentLevel;
|
|
769
|
+
overrides.exportContent = {
|
|
770
|
+
...(wholeHome ? {data:!!exportContent.data} : {}),
|
|
771
|
+
preset: !!exportContent.preset,
|
|
772
|
+
instruction: !!exportContent.instruction,
|
|
773
|
+
};
|
|
774
|
+
// v5 r2:兼容性字段(dshVersions 枚举集 + launchers 兼容声明,两种形态都写 manifest)。
|
|
775
|
+
// 首个版本即首选(workspace-config v1 r2):未显式填「DSH 版本」时用集合首项作 dshVersion。
|
|
776
|
+
const versions = parseDshVersionsInput(dshVersionsText);
|
|
777
|
+
if (versions.length) {
|
|
778
|
+
overrides.dshVersions = versions;
|
|
779
|
+
if (!overrides.dshVersion) overrides.dshVersion = versions[0];
|
|
780
|
+
}
|
|
781
|
+
const launchers = buildLaunchersField();
|
|
782
|
+
if (Object.keys(launchers).length) overrides.launchers = launchers;
|
|
783
|
+
// v5 r2:vendoring 档位(auto/off/full;repo 形态不内嵌,不传)
|
|
784
|
+
if (mode === 'dspack') overrides.vendor = vendorMode;
|
|
785
|
+
// v5 r2:手动勾选的内嵌依赖(叠加在档位之上)
|
|
786
|
+
if (mode === 'dspack' && Object.keys(vendorSel).length) {
|
|
787
|
+
overrides.vendorCoords = { ...vendorSel };
|
|
788
|
+
}
|
|
789
|
+
const r = await call('pack/export', { ...overrides, ...resources });
|
|
790
|
+
if (!r.ok) return showErr(r.error);
|
|
791
|
+
showOk(t('result.taskStarted'));
|
|
792
|
+
watch(r.value.taskId);
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
// 导出页「上传到 GitHub」:切回聊天框并把发布指令直接发给 AI(走 session-scope 的 conversation.send)。
|
|
796
|
+
const doAiUpload = async () => {
|
|
797
|
+
if (!sendToChat) { setUpload({ ok: false, error: t('upload.noService') }); return; }
|
|
798
|
+
setUpload({ pending: true });
|
|
799
|
+
const parts = ['请帮我把整合包发布到 GitHub'];
|
|
800
|
+
if (wholeHome) parts.push('形态为全局目录(dshhome)');
|
|
801
|
+
else if (exportProfile) parts.push(`profile=${exportProfile}`);
|
|
802
|
+
if ((meta.name ?? '').trim()) parts.push(`name=${String(meta.name).trim()}`);
|
|
803
|
+
if ((meta.version ?? '').trim()) parts.push(`version=${String(meta.version).trim()}`);
|
|
804
|
+
const prompt = parts.join(',') + '。';
|
|
805
|
+
try {
|
|
806
|
+
await sendToChat(prompt);
|
|
807
|
+
setUpload({ ok: true, text: t('upload.sent') });
|
|
808
|
+
} catch (e) {
|
|
809
|
+
setUpload({ ok: false, error: `${t('upload.failed')}:${String(e?.message ?? e)}` });
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
// 「兼容 DSH 版本集」文本 → 去重去空数组(中英文逗号 / 分号 / 空白分隔)。
|
|
814
|
+
const parseDshVersionsInput = (text) =>
|
|
815
|
+
[...new Set(String(text ?? '').split(/[,,;;\s]+/).map((s) => s.trim()).filter(Boolean))];
|
|
816
|
+
|
|
817
|
+
// 启动器编辑状态 → manifest launchers 字段(简式糖:支持+版本 → "ver";支持 → true;冲突 → false / 全式带 reason)。
|
|
818
|
+
const buildLaunchersField = () => {
|
|
819
|
+
const out = {};
|
|
820
|
+
for (const [id, s] of Object.entries(launchersState)) {
|
|
821
|
+
if (!s || (s.mode !== 'support' && s.mode !== 'conflict')) continue;
|
|
822
|
+
if (s.mode === 'support') out[id] = (s.minVersion ?? '').trim() || true;
|
|
823
|
+
else out[id] = (s.reason ?? '').trim() ? { supported: false, reason: (s.reason ?? '').trim() } : false;
|
|
824
|
+
}
|
|
825
|
+
return out;
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
// manifest/.dshpkcfg 的 launchers 值 → 编辑状态(简式/全式都归一)。
|
|
829
|
+
const launchersValueToState = (value) => {
|
|
830
|
+
const out = {};
|
|
831
|
+
for (const [id, v] of Object.entries(value ?? {})) {
|
|
832
|
+
if (v === true) out[id] = { mode: 'support', minVersion: '', reason: '' };
|
|
833
|
+
else if (typeof v === 'string') out[id] = { mode: 'support', minVersion: v, reason: '' };
|
|
834
|
+
else if (v === false) out[id] = { mode: 'conflict', minVersion: '', reason: '' };
|
|
835
|
+
else if (v && typeof v === 'object') out[id] = { mode: v.supported === false ? 'conflict' : 'support', minVersion: typeof v.minVersion === 'string' ? v.minVersion : '', reason: typeof v.reason === 'string' ? v.reason : '' };
|
|
836
|
+
}
|
|
837
|
+
return out;
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
// 把 .dshpkcfg 回填进表单:空串跳过(保留表单默认值);无 config 则清空回填。
|
|
841
|
+
const applyConfig = (cfg) => {
|
|
842
|
+
const next = {};
|
|
843
|
+
for (const k of [...metadataFields, ...OUTPUT_FIELDS]) {
|
|
844
|
+
const v = cfg?.[k];
|
|
845
|
+
if (typeof v === 'string' && v.trim()) next[k] = v;
|
|
846
|
+
}
|
|
847
|
+
setMeta(next);
|
|
848
|
+
setResources(wholeHome ? {selection:cfg?.selection,profilePlugins:cfg?.profilePlugins} : {selection:cfg?.selection,plugins:cfg?.plugins});
|
|
849
|
+
setMode(!wholeHome && MODES.includes(cfg?.mode) ? cfg.mode : 'dspack');
|
|
850
|
+
setContentLevel(CONTENT_LEVELS.includes(cfg?.content) ? cfg.content : 'readme');
|
|
851
|
+
const ec = cfg?.exportContent;
|
|
852
|
+
setExportContent({
|
|
853
|
+
data: ec?.data === true,
|
|
854
|
+
preset: ec?.preset === true,
|
|
855
|
+
instruction: ec?.instruction === true,
|
|
856
|
+
});
|
|
857
|
+
// v5 r2 兼容性字段回填(数组 → 逗号文本;launchers 简式/全式 → 编辑状态;vendor 档位)
|
|
858
|
+
setDshVersionsText(Array.isArray(cfg?.dshVersions) ? cfg.dshVersions.join(', ') : '');
|
|
859
|
+
setLaunchersState(launchersValueToState(cfg?.launchers));
|
|
860
|
+
setVendorMode(['auto', 'off', 'full'].includes(cfg?.vendor) ? cfg.vendor : 'auto');
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
const loadConfig = async (name, silent = false) => {
|
|
864
|
+
const r = await call('pack/config-load', exportLocation(name));
|
|
865
|
+
if (selectedExport.current !== name) return;
|
|
866
|
+
if (!r.ok) return showErr(r.error);
|
|
867
|
+
setLoadedFor(name);
|
|
868
|
+
if (!r.value.config) {
|
|
869
|
+
applyConfig(null); // 切到无配置的 profile:清空表单残留
|
|
870
|
+
if (!silent) showOk(t('result.noCfg'));
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
applyConfig(r.value.config);
|
|
874
|
+
if (!silent) showOk(t('result.loaded'));
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
const doLoadConfig = () => { if (exportProfile) void loadConfig(exportProfile, false); };
|
|
878
|
+
|
|
879
|
+
const doSaveConfig = async () => {
|
|
880
|
+
if (!exportProfile) return;
|
|
881
|
+
setResult({ pending: true });
|
|
882
|
+
const cfg = {};
|
|
883
|
+
for (const k of [...metadataFields, ...OUTPUT_FIELDS]) cfg[k] = (meta[k] ?? '').trim();
|
|
884
|
+
Object.assign(cfg, resources);
|
|
885
|
+
cfg.mode = mode;
|
|
886
|
+
cfg.content = contentLevel;
|
|
887
|
+
cfg.exportContent = {
|
|
888
|
+
...(wholeHome ? {data:!!exportContent.data} : {}),
|
|
889
|
+
preset: !!exportContent.preset,
|
|
890
|
+
instruction: !!exportContent.instruction,
|
|
891
|
+
};
|
|
892
|
+
// v5 r2 兼容性字段持久化(.dshpkcfg 白名单已扩展)
|
|
893
|
+
const versions = parseDshVersionsInput(dshVersionsText);
|
|
894
|
+
if (versions.length) cfg.dshVersions = versions;
|
|
895
|
+
const launchers = buildLaunchersField();
|
|
896
|
+
if (Object.keys(launchers).length) cfg.launchers = launchers;
|
|
897
|
+
if (vendorMode !== 'auto') cfg.vendor = vendorMode; // auto 为缺省档,不落盘
|
|
898
|
+
const r = await call('pack/config-save', { ...exportLocation(exportProfile), ...cfg });
|
|
899
|
+
if (!r.ok) return showErr(r.error);
|
|
900
|
+
showOk(t('result.saved') + ' → ' + r.value.path);
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
// 切到导出 tab / 换 profile 时自动加载工作区配置(每个 profile 只自动加载一次;「读取」按钮可强制重读)。
|
|
904
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
905
|
+
useEffect(() => {
|
|
906
|
+
if (tab !== 'export' || !exportProfile || loadedFor === exportProfile) return;
|
|
907
|
+
void loadConfig(exportProfile, true);
|
|
908
|
+
}, [tab, exportProfile, loadedFor]);
|
|
909
|
+
|
|
910
|
+
// v5 r2:切到导出 tab(dspack 形态)/ 换 profile 时自动加载依赖清单(纯本地,无网络);
|
|
911
|
+
// 默认勾选「已内嵌」的依赖(装过 vendored 包 round-trip 保持内嵌);「刷新依赖」可强制重读。
|
|
912
|
+
const loadDeps = async (name, silent = false) => {
|
|
913
|
+
if (!name) return;
|
|
914
|
+
const r = await call('pack/dependencies', exportLocation(name));
|
|
915
|
+
if (selectedExport.current !== name) return;
|
|
916
|
+
if (!r.ok) {
|
|
917
|
+
if (!silent) showErr(r.error);
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
const list = r.value.deps ?? [];
|
|
921
|
+
setDeps(list);
|
|
922
|
+
setDepsFor(name);
|
|
923
|
+
const sel = {};
|
|
924
|
+
for (const d of list) if (d.vendored) sel[d.coord] = 'explicit';
|
|
925
|
+
setVendorSel(sel);
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
929
|
+
useEffect(() => {
|
|
930
|
+
if (tab !== 'export' || mode !== 'dspack' || !exportProfile || depsFor === exportProfile) return;
|
|
931
|
+
void loadDeps(exportProfile, true);
|
|
932
|
+
}, [tab, mode, exportProfile, depsFor]);
|
|
933
|
+
|
|
934
|
+
// 任务中心面板:展开期间轮询 task/list(600ms),收起即停止。
|
|
935
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
936
|
+
useEffect(() => {
|
|
937
|
+
if (!tasksOpen) return;
|
|
938
|
+
let stopped = false;
|
|
939
|
+
const load = async () => {
|
|
940
|
+
const r = await call('task/list', {});
|
|
941
|
+
if (stopped || !r.ok) return;
|
|
942
|
+
setTaskList(r.value.tasks ?? []);
|
|
943
|
+
};
|
|
944
|
+
void load();
|
|
945
|
+
const timer = setInterval(load, 600);
|
|
946
|
+
return () => { stopped = true; clearInterval(timer); };
|
|
947
|
+
}, [tasksOpen]);
|
|
948
|
+
|
|
949
|
+
const style = {
|
|
950
|
+
section: { display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 720, padding: '8px 0' },
|
|
951
|
+
tabs: { display: 'flex', gap: 4, borderBottom: '1px solid var(--dsw-alias-border-l2)', paddingBottom: 8 },
|
|
952
|
+
tab: {
|
|
953
|
+
height: 32, padding: '0 16px', borderRadius: 16, border: 'none', cursor: 'pointer',
|
|
954
|
+
fontSize: 13, lineHeight: '20px', background: 'transparent', color: 'var(--dsw-alias-label-secondary)', font: 'inherit',
|
|
955
|
+
},
|
|
956
|
+
tabActive: { background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-primary)', fontWeight: 600 },
|
|
957
|
+
group: { display: 'flex', flexDirection: 'column', gap: 6 },
|
|
958
|
+
groupTitle: { margin: '0', fontSize: 13, fontWeight: 600, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)' },
|
|
959
|
+
field: { display: 'flex', flexDirection: 'column', gap: 4 },
|
|
960
|
+
fieldLabel: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },
|
|
961
|
+
input: {
|
|
962
|
+
height: 32, padding: '4px 10px', borderRadius: 8, border: '1px solid var(--dsw-alias-border-l2)',
|
|
963
|
+
fontSize: 13, lineHeight: '20px', background: 'var(--dsw-alias-bg-layer-1)',
|
|
964
|
+
color: 'var(--dsw-alias-label-primary)', font: 'inherit', outline: 'none', boxSizing: 'border-box',
|
|
965
|
+
},
|
|
966
|
+
row: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' },
|
|
967
|
+
btn: {
|
|
968
|
+
height: 30, padding: '0 12px', borderRadius: 15, border: '1px solid var(--dsw-alias-border-l2)', cursor: 'pointer',
|
|
969
|
+
fontSize: 13, lineHeight: '18px', background: 'var(--dsw-alias-bg-layer-1)',
|
|
970
|
+
color: 'var(--dsw-alias-label-primary)', font: 'inherit',
|
|
971
|
+
width: 'fit-content', flex: '0 0 auto',
|
|
972
|
+
},
|
|
973
|
+
btnSmall: {
|
|
974
|
+
height: 26, padding: '0 10px', borderRadius: 13, border: '1px solid var(--dsw-alias-border-l2)',
|
|
975
|
+
cursor: 'pointer', fontSize: 12, lineHeight: '18px', background: 'var(--dsw-alias-bg-layer-1)',
|
|
976
|
+
color: 'var(--dsw-alias-label-primary)', font: 'inherit',
|
|
977
|
+
width: 'fit-content', flex: '0 0 auto',
|
|
978
|
+
},
|
|
979
|
+
list: { margin: 0, padding: 0, listStyle: 'none', display: 'flex', flexDirection: 'column', gap: 8 },
|
|
980
|
+
listItem: {
|
|
981
|
+
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8,
|
|
982
|
+
padding: '10px 12px', borderRadius: 10, border: '1px solid var(--dsw-alias-border-l2)',
|
|
983
|
+
background: 'var(--dsw-alias-bg-layer-1)',
|
|
984
|
+
},
|
|
985
|
+
listName: { fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)' },
|
|
986
|
+
line: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },
|
|
987
|
+
marketHead: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 },
|
|
988
|
+
refreshBtn: {
|
|
989
|
+
width: 26, height: 26, padding: 0, borderRadius: '50%',
|
|
990
|
+
border: '1px solid var(--dsw-alias-border-l2)', cursor: 'pointer',
|
|
991
|
+
background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-secondary)',
|
|
992
|
+
fontSize: 15, lineHeight: '18px', font: 'inherit',
|
|
993
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
994
|
+
flex: '0 0 auto',
|
|
995
|
+
},
|
|
996
|
+
sectionBox: { display: 'flex', flexDirection: 'column', gap: 8, paddingBottom: 14, marginBottom: 14, borderBottom: '1px solid var(--dsw-alias-border-l2)' },
|
|
997
|
+
sectionBoxLast: { display: 'flex', flexDirection: 'column', gap: 8 },
|
|
998
|
+
hint: { margin: '4px 0 0', fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },
|
|
999
|
+
ok: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-success)', whiteSpace: 'pre-wrap', wordBreak: 'break-all' },
|
|
1000
|
+
err: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-danger)', whiteSpace: 'pre-wrap', wordBreak: 'break-all' },
|
|
1001
|
+
// —— 切换确认弹窗 ——
|
|
1002
|
+
overlay: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.45)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 1000 },
|
|
1003
|
+
modal: {
|
|
1004
|
+
background: 'var(--dsw-alias-bg-layer-1)', borderRadius: 12, padding: '20px 22px',
|
|
1005
|
+
minWidth: 360, maxWidth: 440, boxShadow: '0 12px 40px rgba(0,0,0,0.45)',
|
|
1006
|
+
display: 'flex', flexDirection: 'column', gap: 14,
|
|
1007
|
+
},
|
|
1008
|
+
modalTitle: { margin: 0, fontSize: 15, fontWeight: 600, color: 'var(--dsw-alias-label-primary)', textAlign: 'center' },
|
|
1009
|
+
ticket: {
|
|
1010
|
+
position: 'relative', display: 'flex', alignItems: 'stretch',
|
|
1011
|
+
border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 10, background: 'var(--dsw-alias-bg-layer-1)',
|
|
1012
|
+
},
|
|
1013
|
+
ticketSide: { flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4, padding: '16px 10px', minWidth: 0 },
|
|
1014
|
+
ticketName: { fontSize: 18, fontWeight: 700, color: 'var(--dsw-alias-label-primary)', wordBreak: 'break-all', textAlign: 'center' },
|
|
1015
|
+
ticketRole: { fontSize: 12, color: 'var(--dsw-alias-label-tertiary)' },
|
|
1016
|
+
ticketLine: { width: 0, borderLeft: '2px dashed var(--dsw-alias-border-l2)', alignSelf: 'stretch' },
|
|
1017
|
+
ticketBadge: {
|
|
1018
|
+
position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%,-50%)',
|
|
1019
|
+
width: 28, height: 28, borderRadius: '50%',
|
|
1020
|
+
background: 'var(--dsw-alias-bg-layer-1)', border: '2px dashed var(--dsw-alias-border-l2)',
|
|
1021
|
+
color: 'var(--dsw-alias-label-secondary)', fontSize: 15, fontWeight: 700,
|
|
1022
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
1023
|
+
},
|
|
1024
|
+
warn: {
|
|
1025
|
+
display: 'flex', gap: 8, alignItems: 'flex-start', padding: '8px 10px', borderRadius: 8,
|
|
1026
|
+
border: '1px solid rgba(232,162,58,0.45)', background: 'rgba(232,162,58,0.10)',
|
|
1027
|
+
fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-primary)', wordBreak: 'break-word',
|
|
1028
|
+
},
|
|
1029
|
+
warnIcon: { flex: '0 0 auto', lineHeight: '18px', color: '#e8a23a', fontWeight: 700 },
|
|
1030
|
+
confirmBtns: { display: 'flex', justifyContent: 'flex-end', gap: 8 },
|
|
1031
|
+
logoTile: {
|
|
1032
|
+
width: 88, height: 88, borderRadius: 20, background: '#fff', color: '#4b7bec',
|
|
1033
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
1034
|
+
boxShadow: '0 4px 16px rgba(0,0,0,0.28)', flex: '0 0 auto',
|
|
1035
|
+
},
|
|
1036
|
+
btnPrimary: {
|
|
1037
|
+
height: 30, padding: '0 14px', borderRadius: 15, border: '1px solid #4b7bec', cursor: 'pointer',
|
|
1038
|
+
fontSize: 13, lineHeight: '18px', background: '#4b7bec', color: '#fff', fontWeight: 600, font: 'inherit',
|
|
1039
|
+
width: 'fit-content', flex: '0 0 auto',
|
|
1040
|
+
},
|
|
1041
|
+
// —— 任务中心内嵌面板 ——
|
|
1042
|
+
taskPanel: { display: 'flex', flexDirection: 'column', gap: 8, padding: '10px 12px', marginBottom: 12, borderRadius: 10, border: '1px solid var(--dsw-alias-border-l2)', background: 'var(--dsw-alias-bg-layer-1)' },
|
|
1043
|
+
taskCard: { display: 'flex', flexDirection: 'column', gap: 8, padding: '10px 12px', borderRadius: 10, border: '1px solid var(--dsw-alias-border-l2)', background: 'var(--dsw-alias-bg-layer-1)' },
|
|
1044
|
+
taskTitle: { fontSize: 13, fontWeight: 600, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)', wordBreak: 'break-all' },
|
|
1045
|
+
taskTimeline: { display: 'flex', flexWrap: 'wrap', gap: '6px 16px' },
|
|
1046
|
+
taskStep: { display: 'flex', alignItems: 'center', gap: 5, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },
|
|
1047
|
+
taskDot: { width: 14, height: 14, borderRadius: '50%', flex: '0 0 auto', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 10, lineHeight: 1, border: '1.5px solid var(--dsw-alias-border-l2)', color: 'transparent', background: 'transparent' },
|
|
1048
|
+
taskLog: { margin: 0, padding: '8px 10px', borderRadius: 8, border: '1px solid var(--dsw-alias-border-l2)', background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-secondary)', font: '12px/1.5 ui-monospace, Consolas, "Courier New", monospace', maxHeight: 160, overflow: 'auto', whiteSpace: 'pre-wrap', wordBreak: 'break-all' },
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
const fieldInput = (key) =>
|
|
1052
|
+
h('label', { key, style: style.field },
|
|
1053
|
+
h('span', { style: style.fieldLabel }, t('field.' + key)),
|
|
1054
|
+
h('input', {
|
|
1055
|
+
style: style.input, value: meta[key] ?? '',
|
|
1056
|
+
onInput: (e) => setMeta((m) => ({ ...m, [key]: e.target.value })),
|
|
1057
|
+
}),
|
|
1058
|
+
);
|
|
1059
|
+
|
|
1060
|
+
const renderManage = () => {
|
|
1061
|
+
const rows = profiles.map((p) =>
|
|
1062
|
+
h('li', { key: p.name, style: style.listItem },
|
|
1063
|
+
h('span', { style: style.listName }, p.name + (p.active ? `(${t('profile.active')})` : '')),
|
|
1064
|
+
h('div', { style: style.row },
|
|
1065
|
+
p.active ? null : h('button', { type: 'button', style: style.btnSmall, onClick: () => askSwitch(p.name) }, t('action.switch')),
|
|
1066
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => doExportProfile(p.name) }, t('action.export')),
|
|
1067
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => doDelete(p.name) }, t('action.delete')),
|
|
1068
|
+
),
|
|
1069
|
+
),
|
|
1070
|
+
);
|
|
1071
|
+
|
|
1072
|
+
return h('div', { style: { display: 'flex', flexDirection: 'column' } },
|
|
1073
|
+
// 区域 1:正在运行的整合包
|
|
1074
|
+
h('section', { key: 'running', style: style.sectionBox },
|
|
1075
|
+
h('h3', { style: style.groupTitle }, t('running.title')),
|
|
1076
|
+
h('p', { style: style.line }, t('running.profile') + (active ? active.name : t('market.none'))),
|
|
1077
|
+
h('div', { style: style.row },
|
|
1078
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc || !active, onClick: () => doExportProfile(active?.name) }, t('action.quickExport')),
|
|
1079
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc || !active, onClick: () => doOpenDir(active?.name) }, t('action.openDir')),
|
|
1080
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc, onClick: doOpenTasks }, t('action.tasks')),
|
|
1081
|
+
),
|
|
1082
|
+
),
|
|
1083
|
+
// 区域 2:创建整合包
|
|
1084
|
+
h('section', { key: 'create', style: style.sectionBox },
|
|
1085
|
+
h('h3', { style: style.groupTitle }, t('create.title')),
|
|
1086
|
+
h('div', { style: style.row },
|
|
1087
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc, onClick: () => openDialog('create') }, t('action.newEmpty')),
|
|
1088
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc, onClick: () => openDialog('import') }, t('action.import')),
|
|
1089
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc, onClick: () => { setTab('market'); void loadMarket(); } }, t('action.market')),
|
|
1090
|
+
),
|
|
1091
|
+
),
|
|
1092
|
+
// 区域 3:已安装的整合包
|
|
1093
|
+
h('section', { key: 'installed', style: style.sectionBoxLast },
|
|
1094
|
+
h('h3', { style: style.groupTitle }, t('installed.title')),
|
|
1095
|
+
profiles.length === 0 ? h('p', { style: style.line }, t('market.none')) : h('ul', { style: style.list }, rows),
|
|
1096
|
+
),
|
|
1097
|
+
);
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
const renderExport = () =>
|
|
1101
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 12 } },
|
|
1102
|
+
h('div', { style: style.group },
|
|
1103
|
+
h('div', { style: style.groupTitle }, t('group.meta')),
|
|
1104
|
+
...metadataFields.map(fieldInput),
|
|
1105
|
+
),
|
|
1106
|
+
h('div', { style: style.group },
|
|
1107
|
+
h('div', { style: style.groupTitle }, t('group.output')),
|
|
1108
|
+
...OUTPUT_FIELDS.map(fieldInput),
|
|
1109
|
+
h('label', { style: style.field },
|
|
1110
|
+
h('span', { style: style.fieldLabel }, t('field.profile')),
|
|
1111
|
+
h('select', { style: style.input, value: exportProfile, onChange: (e) => setExportProfile(e.target.value) },
|
|
1112
|
+
h('option', {value:HOME_EXPORT}, t('scope.home')),
|
|
1113
|
+
profiles.map((p) => h('option', { key: p.name, value: p.name }, p.name + (p.active ? `(${t('profile.active')})` : ''))),
|
|
1114
|
+
),
|
|
1115
|
+
),
|
|
1116
|
+
h('label', { style: style.field },
|
|
1117
|
+
h('span', { style: style.fieldLabel }, t('field.mode')),
|
|
1118
|
+
h('select', { style: style.input, value: mode, onChange: (e) => setMode(e.target.value) },
|
|
1119
|
+
(wholeHome ? ['dspack'] : MODES).map((m) => h('option', { key: m, value: m }, t('mode.' + m))),
|
|
1120
|
+
),
|
|
1121
|
+
),
|
|
1122
|
+
mode === 'repo'
|
|
1123
|
+
? h('label', { style: style.field },
|
|
1124
|
+
h('span', { style: style.fieldLabel }, t('field.content')),
|
|
1125
|
+
h('select', { style: style.input, value: contentLevel, onChange: (e) => setContentLevel(e.target.value) },
|
|
1126
|
+
CONTENT_LEVELS.map((c) => h('option', { key: c, value: c }, t('content.' + c))),
|
|
1127
|
+
),
|
|
1128
|
+
)
|
|
1129
|
+
: null,
|
|
1130
|
+
),
|
|
1131
|
+
h('div', { style: style.group },
|
|
1132
|
+
h('div', { style: style.groupTitle }, t('compat.title')),
|
|
1133
|
+
h('label', { style: style.field },
|
|
1134
|
+
h('span', { style: style.fieldLabel }, t('compat.dshVersions')),
|
|
1135
|
+
h('input', {
|
|
1136
|
+
style: style.input, value: dshVersionsText,
|
|
1137
|
+
placeholder: '0.1.1-rc.2, 0.1.0',
|
|
1138
|
+
list: 'dspack-dshversions',
|
|
1139
|
+
onChange: (e) => setDshVersionsText(e.target.value),
|
|
1140
|
+
}),
|
|
1141
|
+
installedDsh.length
|
|
1142
|
+
? h('datalist', { id: 'dspack-dshversions' },
|
|
1143
|
+
installedDsh.map((v) => h('option', { key: v, value: v })))
|
|
1144
|
+
: null,
|
|
1145
|
+
),
|
|
1146
|
+
h('p', { style: style.hint }, t('compat.dshVersionsHint')),
|
|
1147
|
+
h('div', { style: style.field },
|
|
1148
|
+
h('span', { style: style.fieldLabel }, t('compat.launchers')),
|
|
1149
|
+
...(launchersReg ?? LAUNCHER_IDS.map((id) => ({ id, name: id }))).map(({ id, name }) => {
|
|
1150
|
+
const st = launchersState[id] ?? { mode: 'none', minVersion: '', reason: '' };
|
|
1151
|
+
const setEntry = (patch) => setLaunchersState((s) => ({ ...s, [id]: { ...(s[id] ?? { minVersion: '', reason: '' }), ...patch } }));
|
|
1152
|
+
return h('div', { key: id, style: { ...style.row, flexWrap: 'nowrap' } },
|
|
1153
|
+
h('span', { style: { ...style.line, flex: '0 0 190px', wordBreak: 'break-all' } }, name && name !== id ? `${name}(${id})` : id),
|
|
1154
|
+
h('select', {
|
|
1155
|
+
style: { ...style.input, flex: '0 0 auto', width: 110 },
|
|
1156
|
+
value: st.mode,
|
|
1157
|
+
onChange: (e) => {
|
|
1158
|
+
const mode = e.target.value;
|
|
1159
|
+
if (mode === 'none') setLaunchersState((s) => { const n = { ...s }; delete n[id]; return n; });
|
|
1160
|
+
else setEntry({ mode });
|
|
1161
|
+
},
|
|
1162
|
+
},
|
|
1163
|
+
h('option', { value: 'none' }, t('launcher.none')),
|
|
1164
|
+
h('option', { value: 'support' }, t('launcher.support')),
|
|
1165
|
+
h('option', { value: 'conflict' }, t('launcher.conflict')),
|
|
1166
|
+
),
|
|
1167
|
+
st.mode === 'support'
|
|
1168
|
+
? h('input', {
|
|
1169
|
+
style: { ...style.input, flex: '0 1 170px' },
|
|
1170
|
+
placeholder: t('launcher.minVersion'),
|
|
1171
|
+
value: st.minVersion ?? '',
|
|
1172
|
+
onChange: (e) => setEntry({ minVersion: e.target.value }),
|
|
1173
|
+
})
|
|
1174
|
+
: null,
|
|
1175
|
+
st.mode === 'conflict'
|
|
1176
|
+
? h('input', {
|
|
1177
|
+
style: { ...style.input, flex: '1 1 auto', minWidth: 120 },
|
|
1178
|
+
placeholder: t('launcher.reason'),
|
|
1179
|
+
value: st.reason ?? '',
|
|
1180
|
+
onChange: (e) => setEntry({ reason: e.target.value }),
|
|
1181
|
+
})
|
|
1182
|
+
: null,
|
|
1183
|
+
);
|
|
1184
|
+
}),
|
|
1185
|
+
),
|
|
1186
|
+
),
|
|
1187
|
+
h('div', { style: style.group },
|
|
1188
|
+
h('div', { style: style.groupTitle }, t('group.content')),
|
|
1189
|
+
...(wholeHome ? ['preset','instruction','data'] : ['preset','instruction']).map((k) =>
|
|
1190
|
+
h('label', { key: k, style: style.row },
|
|
1191
|
+
h('input', {
|
|
1192
|
+
type: 'checkbox', checked: !!exportContent[k],
|
|
1193
|
+
style: { width: 16, height: 16, cursor: 'pointer', accentColor: '#4b7bec' },
|
|
1194
|
+
onChange: (e) => setExportContent((ec) => ({ ...ec, [k]: e.target.checked })),
|
|
1195
|
+
}),
|
|
1196
|
+
h('span', { style: style.line }, t('content.' + k)),
|
|
1197
|
+
),
|
|
1198
|
+
),
|
|
1199
|
+
),
|
|
1200
|
+
mode === 'dspack'
|
|
1201
|
+
? h('div', { style: style.group },
|
|
1202
|
+
h('div', { style: style.marketHead },
|
|
1203
|
+
h('div', { style: style.groupTitle },
|
|
1204
|
+
t('vendor.title'),
|
|
1205
|
+
Object.keys(vendorSel).length
|
|
1206
|
+
? h('span', { style: { ...style.line, marginLeft: 8 } }, `(${Object.keys(vendorSel).length} ${t('vendor.selected')})`)
|
|
1207
|
+
: null,
|
|
1208
|
+
),
|
|
1209
|
+
h('div', { style: style.row },
|
|
1210
|
+
h('select', {
|
|
1211
|
+
style: { ...style.input, width: 220 },
|
|
1212
|
+
value: vendorMode,
|
|
1213
|
+
title: t('vendor.mode'),
|
|
1214
|
+
onChange: (e) => setVendorMode(e.target.value),
|
|
1215
|
+
},
|
|
1216
|
+
h('option', { value: 'auto' }, t('vendor.mode.auto')),
|
|
1217
|
+
h('option', { value: 'off' }, t('vendor.mode.off')),
|
|
1218
|
+
h('option', { value: 'full' }, t('vendor.mode.full')),
|
|
1219
|
+
),
|
|
1220
|
+
h('button', {
|
|
1221
|
+
type: 'button', style: style.btnSmall, disabled: !rpc || !exportProfile,
|
|
1222
|
+
onClick: () => void loadDeps(exportProfile, false),
|
|
1223
|
+
}, t('vendor.reload')),
|
|
1224
|
+
),
|
|
1225
|
+
),
|
|
1226
|
+
h('p', { style: style.hint }, t('vendor.hint')),
|
|
1227
|
+
deps == null
|
|
1228
|
+
? h('p', { style: style.line }, '…')
|
|
1229
|
+
: deps.length === 0
|
|
1230
|
+
? h('p', { style: style.line }, t('vendor.none'))
|
|
1231
|
+
: h('ul', { style: style.list },
|
|
1232
|
+
deps.map((d) => h('li', { key: d.coord, style: style.listItem },
|
|
1233
|
+
h('label', { style: { display: 'flex', alignItems: 'center', gap: 10, cursor: 'pointer', minWidth: 0 } },
|
|
1234
|
+
h('input', {
|
|
1235
|
+
type: 'checkbox',
|
|
1236
|
+
checked: !!vendorSel[d.coord],
|
|
1237
|
+
disabled: !d.installed && !d.vendored,
|
|
1238
|
+
style: { width: 16, height: 16, cursor: d.installed || d.vendored ? 'pointer' : 'not-allowed', accentColor: '#4b7bec', flex: '0 0 auto' },
|
|
1239
|
+
onChange: (e) => setVendorSel((s) => {
|
|
1240
|
+
const next = { ...s };
|
|
1241
|
+
if (e.target.checked) next[d.coord] = 'explicit';
|
|
1242
|
+
else delete next[d.coord];
|
|
1243
|
+
return next;
|
|
1244
|
+
}),
|
|
1245
|
+
}),
|
|
1246
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 } },
|
|
1247
|
+
h('span', { style: style.listName }, `${d.pkgName}${d.version ? ` · ${d.version}` : ''}`),
|
|
1248
|
+
h('span', { style: style.line },
|
|
1249
|
+
t('vendor.kind.' + d.kind)
|
|
1250
|
+
+ (d.vendored ? ` · ${t('vendor.already')}` : '')
|
|
1251
|
+
+ (!d.installed && !d.vendored ? ` · ${t('vendor.notInstalled')}` : '')),
|
|
1252
|
+
),
|
|
1253
|
+
),
|
|
1254
|
+
)),
|
|
1255
|
+
),
|
|
1256
|
+
)
|
|
1257
|
+
: null,
|
|
1258
|
+
h('div', { style: style.row },
|
|
1259
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc || loadedFor !== exportProfile, onClick: doSaveConfig }, t('action.save')),
|
|
1260
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc, onClick: doLoadConfig }, t('action.load')),
|
|
1261
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc || loadedFor !== exportProfile, onClick: editResources }, t('action.editResources')),
|
|
1262
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc || loadedFor !== exportProfile, onClick: doExportFromForm }, t('action.export')),
|
|
1263
|
+
),
|
|
1264
|
+
h('div', { style: style.row },
|
|
1265
|
+
h('button', { type: 'button', style: style.btn, disabled: !sendToChat || upload?.pending, onClick: doAiUpload }, t('action.upload')),
|
|
1266
|
+
upload?.pending ? h('span', { style: style.line }, t('result.pending'))
|
|
1267
|
+
: upload?.ok ? h('span', { style: style.ok }, upload.text)
|
|
1268
|
+
: upload?.ok === false ? h('span', { style: style.err }, upload.error)
|
|
1269
|
+
: h('span', { style: style.hint }, t('upload.hint')),
|
|
1270
|
+
),
|
|
1271
|
+
);
|
|
1272
|
+
|
|
1273
|
+
const renderMarket = () => {
|
|
1274
|
+
const packs = market?.packs ?? [];
|
|
1275
|
+
let body;
|
|
1276
|
+
if (market === undefined) body = h('p', { style: style.line }, t('market.loading'));
|
|
1277
|
+
else if (market.error) body = h('p', { style: style.err }, `${t('market.error')}:${market.error}`);
|
|
1278
|
+
else if (packs.length === 0) body = h('p', { style: style.line }, t('market.empty'));
|
|
1279
|
+
else body = h('ul', { style: style.list },
|
|
1280
|
+
packs.map((p) => h('li', { key: (p.id || p.name) + '@' + (p.version ?? ''), style: style.listItem },
|
|
1281
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 2 } },
|
|
1282
|
+
h('span', { style: style.listName }, p.displayName || p.name),
|
|
1283
|
+
p.description ? h('span', { style: style.line }, p.description) : null,
|
|
1284
|
+
h('span', { style: style.line },
|
|
1285
|
+
`${p.author ? p.author + ' · ' : ''}${p.version || '?'}${p.dshVersion ? ' · DSH ' + p.dshVersion : ''}`
|
|
1286
|
+
// 索引派生标记(v5 r2):声明了 launchers 的包打标,详情弹窗里看完整兼容性徽标
|
|
1287
|
+
+ (p.launcherRestricted ? ' · ⚠ ' + t('market.launcherRestricted') : '')),
|
|
1288
|
+
),
|
|
1289
|
+
h('div', { style: style.row },
|
|
1290
|
+
h('button', { type: 'button', style: style.btnSmall, disabled: !rpc || detail?.pending, onClick: () => void doMarketDetail(p) }, t('market.detail')),
|
|
1291
|
+
h('button', { type: 'button', style: style.btnSmall, disabled: !rpc, onClick: () => doInstallFromMarket(p) }, t('action.install')),
|
|
1292
|
+
),
|
|
1293
|
+
)),
|
|
1294
|
+
);
|
|
1295
|
+
return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
1296
|
+
h('div', { style: style.marketHead },
|
|
1297
|
+
packs.length > 0 ? h('p', { style: style.line }, `市场共 ${packs.length} 个整合包`) : null,
|
|
1298
|
+
h('button', {
|
|
1299
|
+
type: 'button', style: style.refreshBtn, disabled: !rpc || market === undefined,
|
|
1300
|
+
title: t('action.refresh'), onClick: () => void loadMarket(),
|
|
1301
|
+
}, '↻'),
|
|
1302
|
+
),
|
|
1303
|
+
body,
|
|
1304
|
+
);
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
const renderLogo = () =>
|
|
1308
|
+
h('div', { style: style.logoTile },
|
|
1309
|
+
h('svg', { viewBox: '0 0 1024 1024', width: 52, height: 52, style: { display: 'block' } },
|
|
1310
|
+
h('path', { d: LOGO_PATH, fill: 'currentColor' }),
|
|
1311
|
+
),
|
|
1312
|
+
);
|
|
1313
|
+
|
|
1314
|
+
const renderAbout = () => {
|
|
1315
|
+
const updateLine = !update ? null : update.checking
|
|
1316
|
+
? h('p', { style: { ...style.line, margin: 0 } }, t('about.checking'))
|
|
1317
|
+
: update.error
|
|
1318
|
+
? h('p', { style: { ...style.err, margin: 0 } }, `${t('about.checkFailed')}:${update.error}`)
|
|
1319
|
+
: update.outdated
|
|
1320
|
+
? h('div', { style: { ...style.row, justifyContent: 'center' } },
|
|
1321
|
+
h('p', { style: { margin: 0, fontSize: 12, lineHeight: '18px', color: '#e8a23a', fontWeight: 600 } },
|
|
1322
|
+
t('about.newVersion').replace('{latest}', update.latest).replace('{current}', update.current)),
|
|
1323
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => openUrl(update.npmUrl || NPM_URL) }, t('about.viewNpm')),
|
|
1324
|
+
)
|
|
1325
|
+
: h('p', { style: { ...style.line, margin: 0 } }, `${t('about.upToDate')}(${update.latest})`);
|
|
1326
|
+
|
|
1327
|
+
return h('div', { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 12, padding: '24px 0' } },
|
|
1328
|
+
renderLogo(),
|
|
1329
|
+
h('div', { style: { fontSize: 16, fontWeight: 700, lineHeight: '24px', color: 'var(--dsw-alias-label-primary)' } }, MANAGER_PKG),
|
|
1330
|
+
h('p', { style: { ...style.line, margin: 0 } }, `${t('about.version')} ${VERSION}`),
|
|
1331
|
+
h('p', { style: { ...style.line, margin: 0, maxWidth: 440, textAlign: 'center' } }, t('about.desc')),
|
|
1332
|
+
h('p', { style: { ...style.line, margin: 0, maxWidth: 440, textAlign: 'center', fontStyle: 'italic', color: 'var(--dsw-alias-label-primary)' } }, t('about.philosophy')),
|
|
1333
|
+
h('div', { style: { ...style.row, justifyContent: 'center' } },
|
|
1334
|
+
h('button', { type: 'button', style: style.btn, onClick: () => doCheckUpdate() }, t('about.checkUpdate')),
|
|
1335
|
+
),
|
|
1336
|
+
updateLine,
|
|
1337
|
+
// —— 网络(代理设置:覆盖环境变量,保存即生效)——
|
|
1338
|
+
h('div', { style: { ...style.group, width: '100%', maxWidth: 440, paddingTop: 14, borderTop: '1px solid var(--dsw-alias-border-l2)' } },
|
|
1339
|
+
h('p', { style: style.groupTitle }, t('group.network')),
|
|
1340
|
+
h('div', { style: style.field },
|
|
1341
|
+
h('span', { style: style.fieldLabel }, t('field.proxyMode')),
|
|
1342
|
+
h('div', { style: style.row },
|
|
1343
|
+
['auto', 'direct', 'manual'].map((m) =>
|
|
1344
|
+
h('button', {
|
|
1345
|
+
key: m, type: 'button',
|
|
1346
|
+
style: proxyMode === m ? { ...style.tab, ...style.tabActive } : style.tab,
|
|
1347
|
+
onClick: () => setProxyMode(m),
|
|
1348
|
+
}, t('proxyMode.' + m)),
|
|
1349
|
+
),
|
|
1350
|
+
),
|
|
1351
|
+
),
|
|
1352
|
+
proxyMode === 'manual'
|
|
1353
|
+
? h('label', { style: style.field },
|
|
1354
|
+
h('span', { style: style.fieldLabel }, t('field.proxy')),
|
|
1355
|
+
h('input', {
|
|
1356
|
+
style: style.input, value: proxy,
|
|
1357
|
+
placeholder: 'http://127.0.0.1:7890',
|
|
1358
|
+
onInput: (e) => setProxy(e.target.value),
|
|
1359
|
+
}),
|
|
1360
|
+
)
|
|
1361
|
+
: null,
|
|
1362
|
+
h('p', { style: style.hint }, t('hint.proxy')),
|
|
1363
|
+
h('div', { style: style.row },
|
|
1364
|
+
h('button', { type: 'button', style: style.btn, disabled: !rpc, onClick: doSaveProxy }, t('action.save')),
|
|
1365
|
+
),
|
|
1366
|
+
),
|
|
1367
|
+
h('div', { style: { ...style.row, justifyContent: 'center' } },
|
|
1368
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => openUrl(AUTHOR_URL) }, `${t('about.author')} ${AUTHOR}`),
|
|
1369
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => openUrl(REPO_URL) }, t('about.repo')),
|
|
1370
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => openUrl(REPO_URL) }, `⭐ ${t('about.star')}`),
|
|
1371
|
+
),
|
|
1372
|
+
// —— 生态(DSH-PackForge 名下其它项目)——
|
|
1373
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8, width: '100%', maxWidth: 440, paddingTop: 14, borderTop: '1px solid var(--dsw-alias-border-l2)' } },
|
|
1374
|
+
h('p', { style: style.groupTitle }, t('about.ecosystem')),
|
|
1375
|
+
h('div', { style: { ...style.row, justifyContent: 'center' } },
|
|
1376
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => openUrl(SPEC_URL) }, t('about.ecosystem.spec')),
|
|
1377
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => openUrl(APP_URL) }, t('about.ecosystem.app')),
|
|
1378
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: () => openUrl(MARKET_URL) }, t('about.ecosystem.market')),
|
|
1379
|
+
),
|
|
1380
|
+
),
|
|
1381
|
+
// —— 版权说明 ——
|
|
1382
|
+
h('p', { style: { ...style.hint, margin: '4px 0 0', textAlign: 'center', maxWidth: 440 } }, t('about.copyright')),
|
|
1383
|
+
);
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
const content = tab === 'manage' ? renderManage() : tab === 'export' ? renderExport() : tab === 'market' ? renderMarket() : renderAbout();
|
|
1387
|
+
|
|
1388
|
+
const renderConfirm = () => {
|
|
1389
|
+
if (!confirm) return null;
|
|
1390
|
+
const warning = t('confirm.warning').replace('{pkg}', MANAGER_PKG);
|
|
1391
|
+
return h('div', { style: style.overlay, onClick: () => setConfirm(null) },
|
|
1392
|
+
h('div', { style: style.modal, onClick: (e) => e.stopPropagation() },
|
|
1393
|
+
h('h3', { style: style.modalTitle }, t('confirm.title')),
|
|
1394
|
+
h('div', { style: style.ticket },
|
|
1395
|
+
h('div', { style: style.ticketSide },
|
|
1396
|
+
h('span', { style: style.ticketName }, confirm.from),
|
|
1397
|
+
h('span', { style: style.ticketRole }, t('confirm.from')),
|
|
1398
|
+
),
|
|
1399
|
+
h('div', { style: style.ticketLine }),
|
|
1400
|
+
h('div', { style: style.ticketBadge }, '→'),
|
|
1401
|
+
h('div', { style: style.ticketSide },
|
|
1402
|
+
h('span', { style: style.ticketName }, confirm.to),
|
|
1403
|
+
h('span', { style: style.ticketRole }, t('confirm.to')),
|
|
1404
|
+
),
|
|
1405
|
+
),
|
|
1406
|
+
confirm.firstTime ? h('p', { style: style.hint }, t('confirm.firstTime')) : null,
|
|
1407
|
+
confirm.hasManager ? null : h('div', { style: style.warn },
|
|
1408
|
+
h('span', { style: style.warnIcon }, '!'),
|
|
1409
|
+
h('span', null, warning),
|
|
1410
|
+
),
|
|
1411
|
+
confirm.hasManager ? null : h('div', { style: style.group },
|
|
1412
|
+
h('span', { style: style.fieldLabel }, t('confirm.managerSource')),
|
|
1413
|
+
h('label', { key: 'npm', style: style.row },
|
|
1414
|
+
h('input', {
|
|
1415
|
+
type: 'radio', name: 'managerSource', checked: managerSource === 'npm',
|
|
1416
|
+
style: { width: 14, height: 14, cursor: 'pointer', accentColor: '#4b7bec' },
|
|
1417
|
+
onChange: () => setManagerSource('npm'),
|
|
1418
|
+
}),
|
|
1419
|
+
h('span', { style: style.line }, t('confirm.source.npm')),
|
|
1420
|
+
),
|
|
1421
|
+
h('label', { key: 'copy', style: style.row },
|
|
1422
|
+
h('input', {
|
|
1423
|
+
type: 'radio', name: 'managerSource', checked: managerSource === 'copy',
|
|
1424
|
+
style: { width: 14, height: 14, cursor: 'pointer', accentColor: '#4b7bec' },
|
|
1425
|
+
onChange: () => setManagerSource('copy'),
|
|
1426
|
+
}),
|
|
1427
|
+
h('span', { style: style.line }, t('confirm.source.copy')),
|
|
1428
|
+
),
|
|
1429
|
+
),
|
|
1430
|
+
h('p', { style: style.hint }, t('confirm.hintRestart')),
|
|
1431
|
+
h('div', { style: style.confirmBtns },
|
|
1432
|
+
h('button', { type: 'button', style: style.btn, onClick: () => setConfirm(null) }, t('confirm.cancel')),
|
|
1433
|
+
h('button', { type: 'button', style: style.btnPrimary, onClick: confirmSwitch }, t('confirm.ok')),
|
|
1434
|
+
),
|
|
1435
|
+
),
|
|
1436
|
+
);
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
// 创建/导入弹窗:收集名字(校验 kebab-case)或 .dspack 路径,错误就地展示。
|
|
1440
|
+
const renderDialog = () => {
|
|
1441
|
+
if (!dialog) return null;
|
|
1442
|
+
const isCreate = dialog === 'create';
|
|
1443
|
+
const value = isCreate ? newName : source;
|
|
1444
|
+
const submit = () => { if (!submitting) void (isCreate ? doCreate() : doImport()); };
|
|
1445
|
+
return h('div', { style: style.overlay, onClick: closeDialog },
|
|
1446
|
+
h('div', { style: style.modal, onClick: (e) => e.stopPropagation() },
|
|
1447
|
+
h('h3', { style: style.modalTitle }, isCreate ? t('dialog.createTitle') : t('dialog.importTitle')),
|
|
1448
|
+
h('label', { style: style.field },
|
|
1449
|
+
h('span', { style: style.fieldLabel }, isCreate ? t('field.newName') : t('field.source')),
|
|
1450
|
+
h('input', {
|
|
1451
|
+
style: style.input,
|
|
1452
|
+
value,
|
|
1453
|
+
autoFocus: true,
|
|
1454
|
+
placeholder: isCreate ? t('field.newName') : t('field.source'),
|
|
1455
|
+
onInput: (e) => {
|
|
1456
|
+
if (isCreate) setNewName(e.target.value); else setSource(e.target.value);
|
|
1457
|
+
if (fieldError) setFieldError('');
|
|
1458
|
+
},
|
|
1459
|
+
onKeyDown: (e) => { if (e.key === 'Enter') submit(); },
|
|
1460
|
+
}),
|
|
1461
|
+
),
|
|
1462
|
+
h('p', { style: style.hint }, isCreate ? t('hint.nameFormat') : t('hint.import')),
|
|
1463
|
+
fieldError ? h('p', { style: style.err }, fieldError) : null,
|
|
1464
|
+
h('div', { style: style.confirmBtns },
|
|
1465
|
+
h('button', { type: 'button', style: style.btn, disabled: submitting, onClick: closeDialog }, t('confirm.cancel')),
|
|
1466
|
+
h('button', { type: 'button', style: style.btnPrimary, disabled: !rpc || submitting, onClick: submit },
|
|
1467
|
+
submitting ? t('result.pending') : (isCreate ? t('action.create') : t('action.install'))),
|
|
1468
|
+
),
|
|
1469
|
+
),
|
|
1470
|
+
);
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1473
|
+
// —— 安装确认弹窗(v5 r2 §8.4 判定表第 4 行):pack/view 预检出 warn 级 launchers 警告时弹出 ——
|
|
1474
|
+
// 复用切换确认弹窗的 overlay / modal / warn 样式;取消 = 放弃安装,确认 = 照常安装(警告放行)。
|
|
1475
|
+
const renderInstallConfirm = () => {
|
|
1476
|
+
if (!installConfirm) return null;
|
|
1477
|
+
const warnings = installConfirm.warnings ?? [];
|
|
1478
|
+
return h('div', { style: style.overlay, onClick: () => setInstallConfirm(null) },
|
|
1479
|
+
h('div', { style: style.modal, onClick: (e) => e.stopPropagation() },
|
|
1480
|
+
h('h3', { style: style.modalTitle }, t('installConfirm.title')),
|
|
1481
|
+
h('p', { style: style.hint }, t('installConfirm.hint')),
|
|
1482
|
+
...warnings.map((w, i) =>
|
|
1483
|
+
h('div', { key: i, style: style.warn },
|
|
1484
|
+
h('span', { style: style.warnIcon }, '!'),
|
|
1485
|
+
h('span', null, w.message),
|
|
1486
|
+
)),
|
|
1487
|
+
h('div', { style: style.confirmBtns },
|
|
1488
|
+
h('button', { type: 'button', style: style.btn, onClick: () => setInstallConfirm(null) }, t('confirm.cancel')),
|
|
1489
|
+
h('button', { type: 'button', style: style.btnPrimary, onClick: confirmInstall }, t('installConfirm.ok')),
|
|
1490
|
+
),
|
|
1491
|
+
),
|
|
1492
|
+
);
|
|
1493
|
+
};
|
|
1494
|
+
|
|
1495
|
+
// —— 市场详情弹窗(v5 r2):懒加载 manifest 的兼容性徽标 + README ——
|
|
1496
|
+
// 徽标文案沿 style.line(冲突项复用 warn 警示框);README 复用任务日志的滚动样式。
|
|
1497
|
+
const renderDetail = () => {
|
|
1498
|
+
if (!detail) return null;
|
|
1499
|
+
const close = () => setDetail(null);
|
|
1500
|
+
const pack = detail.pack ?? {};
|
|
1501
|
+
return h('div', { style: style.overlay, onClick: close },
|
|
1502
|
+
h('div', { style: { ...style.modal, maxWidth: 560, maxHeight:'calc(100dvh - 240px)' }, onClick: (e) => e.stopPropagation() },
|
|
1503
|
+
h('h3', { style: style.modalTitle }, t('market.detailTitle')),
|
|
1504
|
+
detail.pending
|
|
1505
|
+
? h('p', { style: style.line }, t('market.loading'))
|
|
1506
|
+
: detail.error
|
|
1507
|
+
? h('p', { style: style.err }, `${t('market.error')}:${detail.error}`)
|
|
1508
|
+
: h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8, minWidth: 0, minHeight:0, overflowY:'auto' } },
|
|
1509
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 2 } },
|
|
1510
|
+
h('span', { style: style.listName }, pack.displayName || pack.name || detail.manifest?.name || ''),
|
|
1511
|
+
pack.description ? h('span', { style: style.line }, pack.description) : null,
|
|
1512
|
+
h('span', { style: style.line },
|
|
1513
|
+
`${pack.author ? pack.author + ' · ' : ''}${pack.version || '?'}${pack.dshVersion ? ' · DSH ' + pack.dshVersion : ''}`),
|
|
1514
|
+
),
|
|
1515
|
+
// v5 r2 兼容性徽标:需启动器 ≥ x / 声明冲突 / 内嵌 N 个依赖 / 兼容 DSH 版本集
|
|
1516
|
+
(detail.badges ?? []).length
|
|
1517
|
+
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
1518
|
+
detail.badges.map((b, i) => b.kind === 'launcher-conflict'
|
|
1519
|
+
? h('div', { key: i, style: style.warn },
|
|
1520
|
+
h('span', { style: style.warnIcon }, '!'),
|
|
1521
|
+
h('span', null, badgeText(b)))
|
|
1522
|
+
: h('p', { key: i, style: style.line }, '· ' + badgeText(b))))
|
|
1523
|
+
: h('p', { style: style.line }, t('market.r2.none')),
|
|
1524
|
+
marketResources(detail.manifest,detail.icons,t),
|
|
1525
|
+
detail.readme
|
|
1526
|
+
? h('pre', { style: { ...style.taskLog, maxHeight: 260 } }, detail.readme)
|
|
1527
|
+
: null,
|
|
1528
|
+
),
|
|
1529
|
+
h('div', { style: style.confirmBtns },
|
|
1530
|
+
h('button', { type: 'button', style: style.btn, onClick: close }, t('tasks.close')),
|
|
1531
|
+
detail.pending || detail.error ? null
|
|
1532
|
+
: h('button', {
|
|
1533
|
+
type: 'button', style: style.btnPrimary, disabled: !rpc,
|
|
1534
|
+
onClick: () => { const p = detail.pack; setDetail(null); void doInstallFromMarket(p); },
|
|
1535
|
+
}, t('action.install')),
|
|
1536
|
+
),
|
|
1537
|
+
),
|
|
1538
|
+
);
|
|
1539
|
+
};
|
|
1540
|
+
|
|
1541
|
+
// —— 任务中心内嵌面板:就地渲染内存里的任务(task/list 轮询),替代旧版独立 electron/WPF 小窗 ——
|
|
1542
|
+
const TASK_STATUS = {
|
|
1543
|
+
queued: ['排队中', '#e8a23a'],
|
|
1544
|
+
running: ['进行中', '#6ab7ff'],
|
|
1545
|
+
done: ['完成', '#2ea44f'],
|
|
1546
|
+
failed: ['失败', '#d3383a'],
|
|
1547
|
+
};
|
|
1548
|
+
const taskDotStyle = (status) =>
|
|
1549
|
+
status === 'done' ? { borderColor: '#2ea44f', background: '#2ea44f', color: '#fff' }
|
|
1550
|
+
: status === 'failed' ? { borderColor: '#d3383a', background: '#d3383a', color: '#fff' }
|
|
1551
|
+
: status === 'running' ? { borderColor: '#6ab7ff', color: '#6ab7ff' }
|
|
1552
|
+
: {};
|
|
1553
|
+
|
|
1554
|
+
const renderTasks = () => {
|
|
1555
|
+
const cards = taskList.map((t) => {
|
|
1556
|
+
const [stLabel, stColor] = TASK_STATUS[t.status] || ['?', '#9a9ba3'];
|
|
1557
|
+
const log = t.log || [];
|
|
1558
|
+
const stages = t.stages || [];
|
|
1559
|
+
return h('li', { key: t.id, style: style.taskCard },
|
|
1560
|
+
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } },
|
|
1561
|
+
h('span', { style: style.taskTitle }, t.title || '任务'),
|
|
1562
|
+
h('span', { style: { flex: '0 0 auto', fontSize: 12, fontWeight: 600, color: stColor } }, stLabel),
|
|
1563
|
+
),
|
|
1564
|
+
stages.length
|
|
1565
|
+
? h('div', { style: style.taskTimeline },
|
|
1566
|
+
stages.map((s) =>
|
|
1567
|
+
h('span', { key: s.id, style: style.taskStep },
|
|
1568
|
+
h('span', { style: { ...style.taskDot, ...taskDotStyle(s.status) } }, s.status === 'done' ? '✓' : s.status === 'failed' ? '✗' : ''),
|
|
1569
|
+
h('span', null, s.label),
|
|
1570
|
+
),
|
|
1571
|
+
),
|
|
1572
|
+
)
|
|
1573
|
+
: null,
|
|
1574
|
+
t.error ? h('p', { style: style.err }, '错误:' + t.error) : null,
|
|
1575
|
+
log.length
|
|
1576
|
+
? h('pre', { style: style.taskLog }, (t.logTruncated ? '…(已截断,仅保留最后 ' + log.length + ' 行)\n' : '') + log.join('\n'))
|
|
1577
|
+
: null,
|
|
1578
|
+
);
|
|
1579
|
+
});
|
|
1580
|
+
return h('div', { style: style.taskPanel },
|
|
1581
|
+
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } },
|
|
1582
|
+
h('h3', { style: style.groupTitle }, t('action.tasks')),
|
|
1583
|
+
h('button', { type: 'button', style: style.btnSmall, onClick: doOpenTasks, title: t('tasks.close') }, '✕'),
|
|
1584
|
+
),
|
|
1585
|
+
taskList.length === 0 ? h('p', { style: style.line }, t('tasks.empty')) : h('ul', { style: style.list }, cards),
|
|
1586
|
+
);
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
return h(Fragment, null,
|
|
1590
|
+
h('div', { style: style.section },
|
|
1591
|
+
h('div', { style: style.tabs },
|
|
1592
|
+
['manage', 'export', 'market', 'about'].map((id) => h('button', {
|
|
1593
|
+
key: id, type: 'button',
|
|
1594
|
+
style: tab === id ? { ...style.tab, ...style.tabActive } : style.tab,
|
|
1595
|
+
onClick: () => { setTab(id); if (id === 'market' && market === null) void loadMarket(); },
|
|
1596
|
+
}, t('tab.' + id))),
|
|
1597
|
+
),
|
|
1598
|
+
tasksOpen ? renderTasks() : null,
|
|
1599
|
+
content,
|
|
1600
|
+
tab === 'manage' ? h('p', { style: style.hint }, t('hint.restart')) : null,
|
|
1601
|
+
result
|
|
1602
|
+
? h('p', { style: result.ok === false ? style.err : style.ok },
|
|
1603
|
+
result.pending ? t('result.pending') : (result.text ?? result.error))
|
|
1604
|
+
: null,
|
|
1605
|
+
),
|
|
1606
|
+
renderConfirm(),
|
|
1607
|
+
renderDialog(),
|
|
1608
|
+
renderInstallConfirm(),
|
|
1609
|
+
renderDetail(),
|
|
1610
|
+
);
|
|
1611
|
+
}
|