mirror of
https://github.com/yexi-by/dsh-unrestricted.git
synced 2026-11-28 02:30:22 +08:00
精简:移除重复的插件更新器
This commit is contained in:
1 parent
35e3e7d9bc
commit
1b4d8b9205
18 files changed
+223
-1467
No files matched your search
+184
-515
@@ -10,7 +10,6 @@ window.__ModuleLoader__.load({
|
||||
//#region src/client/controller.ts
|
||||
const RPC_CHANNEL = "/dsh-unrestricted";
|
||||
const SETTINGS_NS = "unrestricted";
|
||||
const DEFAULT_VERSION = "0.2.6";
|
||||
/** Human-readable error text for the banner. */
|
||||
function messageOf(error) {
|
||||
return error instanceof Error ? error.message : String(error);
|
||||
@@ -28,11 +27,6 @@ window.__ModuleLoader__.load({
|
||||
writable: false,
|
||||
settingsStatus: "loading",
|
||||
status: null,
|
||||
update: {
|
||||
state: "idle",
|
||||
currentVersion: DEFAULT_VERSION,
|
||||
restartRequired: false
|
||||
},
|
||||
previews: {},
|
||||
busy: false
|
||||
};
|
||||
@@ -56,7 +50,6 @@ window.__ModuleLoader__.load({
|
||||
writable: settingsSnapshot.writable,
|
||||
settingsStatus: settingsSnapshot.status,
|
||||
status: snapshot.status,
|
||||
update: snapshot.update,
|
||||
previews: snapshot.previews,
|
||||
busy: pendingOperations > 0,
|
||||
message: snapshot.message
|
||||
@@ -92,14 +85,9 @@ window.__ModuleLoader__.load({
|
||||
const status = await call(endpoint, {});
|
||||
if (generation !== statusGeneration) return;
|
||||
if (clearPreviews) invalidatePreviews();
|
||||
const nextUpdate = status.update !== void 0 && (snapshot.update.state === "idle" || status.update.state !== "idle") ? status.update : {
|
||||
...snapshot.update,
|
||||
currentVersion: status.version ?? snapshot.update.currentVersion
|
||||
};
|
||||
snapshot = {
|
||||
...snapshot,
|
||||
status,
|
||||
update: nextUpdate,
|
||||
message: void 0
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -174,75 +162,6 @@ window.__ModuleLoader__.load({
|
||||
}
|
||||
publish();
|
||||
}
|
||||
/**
|
||||
* Check whether a newer version is available from GitHub or the local source directory.
|
||||
* @param force - bypass in-flight reuse and force a fresh check.
|
||||
*/
|
||||
async function checkUpdate(force = false) {
|
||||
if (snapshot.update.state === "checking" || snapshot.update.state === "updating") return;
|
||||
snapshot = {
|
||||
...snapshot,
|
||||
update: {
|
||||
...snapshot.update,
|
||||
state: "checking",
|
||||
errorCode: void 0,
|
||||
errorDetail: void 0
|
||||
}
|
||||
};
|
||||
publish();
|
||||
try {
|
||||
const update = await call("check-update", { force });
|
||||
snapshot = {
|
||||
...snapshot,
|
||||
update
|
||||
};
|
||||
} catch (error) {
|
||||
snapshot = {
|
||||
...snapshot,
|
||||
update: {
|
||||
...snapshot.update,
|
||||
state: "failed",
|
||||
errorCode: "update-check-failed",
|
||||
errorDetail: messageOf(error)
|
||||
}
|
||||
};
|
||||
}
|
||||
publish();
|
||||
}
|
||||
/**
|
||||
* Download and install the latest version into the active profile.
|
||||
*/
|
||||
async function performUpdate() {
|
||||
if (snapshot.update.state === "updating") return;
|
||||
snapshot = {
|
||||
...snapshot,
|
||||
update: {
|
||||
...snapshot.update,
|
||||
state: "updating",
|
||||
errorCode: void 0,
|
||||
errorDetail: void 0
|
||||
}
|
||||
};
|
||||
publish();
|
||||
try {
|
||||
const update = await call("perform-update", { targetTag: snapshot.update.latestTag });
|
||||
snapshot = {
|
||||
...snapshot,
|
||||
update
|
||||
};
|
||||
} catch (error) {
|
||||
snapshot = {
|
||||
...snapshot,
|
||||
update: {
|
||||
...snapshot.update,
|
||||
state: "failed",
|
||||
errorCode: "update-install-failed",
|
||||
errorDetail: messageOf(error)
|
||||
}
|
||||
};
|
||||
}
|
||||
publish();
|
||||
}
|
||||
ctx.effect(() => settings.subscribe(publish), "dsh-unrestricted: settings mirror");
|
||||
ctx.effect(() => ctx.remote.$on("settings/document-updated", (namespace) => {
|
||||
if (namespace === void 0 || namespace === SETTINGS_NS) refresh(true);
|
||||
@@ -254,9 +173,7 @@ window.__ModuleLoader__.load({
|
||||
setEnabled,
|
||||
recheck,
|
||||
refresh: () => refresh(true),
|
||||
loadPreview,
|
||||
checkUpdate,
|
||||
performUpdate
|
||||
loadPreview
|
||||
}) };
|
||||
}
|
||||
//#endregion
|
||||
@@ -305,33 +222,10 @@ window.__ModuleLoader__.load({
|
||||
settingsLoading: "正在读取配置…",
|
||||
operationFailed: "操作失败:",
|
||||
issuePersona: "未检测到预设角色前缀段落,已自动保留原版提示词",
|
||||
updateTitle: "版本与更新",
|
||||
currentVersion: "当前版本",
|
||||
latestVersion: "最新版本",
|
||||
installSource: "安装方式",
|
||||
sourceGithub: "GitHub 仓库",
|
||||
sourceFile: "本地目录 (file:)",
|
||||
sourceRegistry: "软件包镜像",
|
||||
sourceUnknown: "当前 Profile",
|
||||
updateIdle: "尚未检查更新",
|
||||
updateChecking: "正在检查更新…",
|
||||
updateUpToDate: "已是最新版本",
|
||||
updateAvailable: "发现新版本",
|
||||
updateInstalling: "正在下载并安装更新,请稍候…",
|
||||
updateInstalled: "已安装新版本,重启 DSH Web 或桌面端后生效",
|
||||
updateBadge: "可更新",
|
||||
updateRestartBadge: "待重启生效",
|
||||
checkUpdate: "检查更新",
|
||||
installUpdate: "立即更新",
|
||||
viewRelease: "发布说明",
|
||||
errorRpcDisconnected: "无法连接宿主服务,请确认 DSH 正在运行后刷新重试。",
|
||||
errorUnsupportedPreset: "不支持该预设模式的提示词预览。",
|
||||
errorMissingPersona: "当前预设未包含角色前缀段落,已自动保留原版提示词。",
|
||||
errorPreviewFailed: "生成提示词预览失败,请稍后刷新重试。",
|
||||
errorUpdateCheckFailed: "检查更新失败,请确认网络连接正常后重试。",
|
||||
errorUpdateNoProfile: "当前运行环境未绑定可管理的 Profile 目录,无法执行自动更新。",
|
||||
errorUpdateFileOutdated: "当前通过本地目录 (file:) 安装,且本地目录版本低于远端最新版本,请先更新本地源码目录后再点更新。",
|
||||
errorUpdateInstallFailed: "安装更新失败:"
|
||||
errorPreviewFailed: "生成提示词预览失败,请稍后刷新重试。"
|
||||
};
|
||||
/** English dictionary checked against the Chinese key set. */
|
||||
const en = {
|
||||
@@ -376,33 +270,10 @@ window.__ModuleLoader__.load({
|
||||
settingsLoading: "Loading configuration…",
|
||||
operationFailed: "Operation failed: ",
|
||||
issuePersona: "Preset persona section not found — stock prompt kept",
|
||||
updateTitle: "Version & Updates",
|
||||
currentVersion: "Current version",
|
||||
latestVersion: "Latest version",
|
||||
installSource: "Install source",
|
||||
sourceGithub: "GitHub repository",
|
||||
sourceFile: "Local directory (file:)",
|
||||
sourceRegistry: "Package registry",
|
||||
sourceUnknown: "Active profile",
|
||||
updateIdle: "Not checked yet",
|
||||
updateChecking: "Checking for updates…",
|
||||
updateUpToDate: "Up to date",
|
||||
updateAvailable: "Update available",
|
||||
updateInstalling: "Downloading and installing update…",
|
||||
updateInstalled: "Update installed — restart DSH Web or Desktop to apply",
|
||||
updateBadge: "Update available",
|
||||
updateRestartBadge: "Restart to apply",
|
||||
checkUpdate: "Check for updates",
|
||||
installUpdate: "Update now",
|
||||
viewRelease: "Release notes",
|
||||
errorRpcDisconnected: "Cannot reach the host service. Please verify DSH is running and refresh.",
|
||||
errorUnsupportedPreset: "Prompt preview is not supported for this preset.",
|
||||
errorMissingPersona: "The preset is missing a persona prefix section; the stock prompt is kept.",
|
||||
errorPreviewFailed: "Could not assemble the prompt preview. Please try refreshing.",
|
||||
errorUpdateCheckFailed: "Could not check for updates. Please verify your network connection and try again.",
|
||||
errorUpdateNoProfile: "This runtime does not expose a managed profile directory for self-update.",
|
||||
errorUpdateFileOutdated: "Installed from a local file: directory whose version is older than the latest release. Update the local directory first.",
|
||||
errorUpdateInstallFailed: "Failed to install update: "
|
||||
errorPreviewFailed: "Could not assemble the prompt preview. Please try refreshing."
|
||||
};
|
||||
/** Dictionary namespace owned by this plugin. */
|
||||
const NS = "settings.unrestricted";
|
||||
@@ -638,50 +509,6 @@ window.__ModuleLoader__.load({
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.dsh-unrestricted-metaGrid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 10px 14px;
|
||||
margin: 0;
|
||||
border: 1px solid var(--dsw-alias-border-l2);
|
||||
border-radius: var(--dsw-radius-lg, 10px);
|
||||
padding: 11px 14px;
|
||||
background: var(--dsw-alias-bg-layer-2);
|
||||
}
|
||||
|
||||
.dsh-unrestricted-metaItem {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.dsh-unrestricted-metaItem dt {
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
}
|
||||
|
||||
.dsh-unrestricted-metaItem dd {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
line-height: 19px;
|
||||
font-weight: 500;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.dsh-unrestricted-link {
|
||||
color: var(--dsw-alias-state-business-primary);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.dsh-unrestricted-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.dsh-unrestricted-card {
|
||||
padding: 14px;
|
||||
@@ -705,10 +532,9 @@ window.__ModuleLoader__.load({
|
||||
//#endregion
|
||||
//#region src/client/UnrestrictedCard.tsx
|
||||
/**
|
||||
* The unrestricted settings view and plugin-detail badge:
|
||||
* The unrestricted settings view:
|
||||
* - Master toggle card with native Switch, status Tag, and scope boundary notes
|
||||
* - Per-preset coverage list with StateDot, Tag, preview drawer, and one-click copy
|
||||
* - Version & Updates card with automatic release check and one-click self-update
|
||||
*/
|
||||
/** Mode rows in display order, with their locale label and description keys. */
|
||||
const MODE_ROWS = [
|
||||
@@ -781,68 +607,16 @@ window.__ModuleLoader__.load({
|
||||
const detail = entry.preview?.reason ?? entry.message;
|
||||
return detail !== void 0 && detail.trim() !== "" ? `${t("previewUnavailable")}${detail}` : t("errorPreviewFailed");
|
||||
}
|
||||
/** Friendly localized text for update errors. */
|
||||
function localizeUpdateError(update, t) {
|
||||
switch (update.errorCode) {
|
||||
case "update-check-failed": return t("errorUpdateCheckFailed");
|
||||
case "update-no-profile": return t("errorUpdateNoProfile");
|
||||
case "update-file-source-outdated": return t("errorUpdateFileOutdated");
|
||||
case "update-install-failed": return `${t("errorUpdateInstallFailed")}${update.errorDetail ?? ""}`;
|
||||
default: return update.errorDetail !== void 0 && update.errorDetail !== "" ? `${t("operationFailed")}${update.errorDetail}` : t("errorUpdateCheckFailed");
|
||||
}
|
||||
}
|
||||
/** Friendly label for the installation source. */
|
||||
function installSourceLabel(source, t) {
|
||||
switch (source) {
|
||||
case "github": return t("sourceGithub");
|
||||
case "file": return t("sourceFile");
|
||||
case "registry": return t("sourceRegistry");
|
||||
default: return t("sourceUnknown");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Badge shown in the Plugin Manager detail header when an update is available
|
||||
* or waiting for a restart.
|
||||
*/
|
||||
function UnrestrictedDetailBadge(props) {
|
||||
const { subject, t, checkUpdate } = props;
|
||||
const update = props.useView((snapshot) => snapshot.update);
|
||||
const isTargetBundle = subject.kind === "bundle" && subject.pkg.name === "dsh-unrestricted";
|
||||
(0, react.useEffect)(() => {
|
||||
if (isTargetBundle && update.state === "idle") checkUpdate(false);
|
||||
}, [
|
||||
isTargetBundle,
|
||||
update.state,
|
||||
checkUpdate
|
||||
]);
|
||||
if (!isTargetBundle) return null;
|
||||
if (update.state === "available") {
|
||||
const versionSuffix = update.latestVersion !== void 0 ? ` v${update.latestVersion}` : "";
|
||||
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: "info",
|
||||
children: `${t("updateBadge")}${versionSuffix}`
|
||||
});
|
||||
}
|
||||
if (update.state === "updated" || update.restartRequired === true) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: "success",
|
||||
children: t("updateRestartBadge")
|
||||
});
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Render the unrestricted configuration cards.
|
||||
*/
|
||||
function UnrestrictedCard(props) {
|
||||
const { t, loadPreview, checkUpdate } = props;
|
||||
const { t, loadPreview } = props;
|
||||
const view = props.useView((snapshot) => snapshot);
|
||||
const status = view.status;
|
||||
const update = view.update;
|
||||
const [openPreview, setOpenPreview] = (0, react.useState)(null);
|
||||
const [copiedPreset, setCopiedPreset] = (0, react.useState)(null);
|
||||
const openEntry = openPreview === null ? void 0 : view.previews[openPreview];
|
||||
(0, react.useEffect)(() => {
|
||||
if (update.state === "idle") checkUpdate(false);
|
||||
}, [update.state, checkUpdate]);
|
||||
(0, react.useEffect)(() => {
|
||||
if (openPreview !== null && openEntry === void 0) loadPreview(openPreview);
|
||||
}, [
|
||||
@@ -879,294 +653,195 @@ window.__ModuleLoader__.load({
|
||||
return key !== void 0 ? t(key) : issue;
|
||||
}).join(";");
|
||||
}
|
||||
const updateBusy = update.state === "checking" || update.state === "updating";
|
||||
const updateTagTone = update.state === "available" ? "info" : update.state === "updated" ? "success" : update.state === "failed" ? "danger" : "neutral";
|
||||
const updateTagKey = update.state === "checking" ? "updateChecking" : update.state === "updating" ? "updateInstalling" : update.state === "available" ? "updateAvailable" : update.state === "updated" ? "updateRestartBadge" : update.state === "up-to-date" ? "updateUpToDate" : "updateIdle";
|
||||
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-root",
|
||||
"aria-busy": view.busy || updateBusy,
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
||||
className: "dsh-unrestricted-card",
|
||||
"aria-labelledby": "dsh-unrestricted-main-title",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-header",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-headerTitle",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
||||
id: "dsh-unrestricted-main-title",
|
||||
className: "dsh-unrestricted-title",
|
||||
children: t("title")
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: summaryTone,
|
||||
children: t(summaryKey)
|
||||
})]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-headerControls",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
||||
className: "dsh-unrestricted-switchLabel",
|
||||
children: t("toggle")
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
|
||||
checked: view.enabled,
|
||||
disabled: !view.writable || view.settingsStatus !== "ready" || view.busy,
|
||||
label: t("toggle"),
|
||||
onChange: (checked) => {
|
||||
props.setEnabled(checked);
|
||||
}
|
||||
})]
|
||||
"aria-busy": view.busy,
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
||||
className: "dsh-unrestricted-card",
|
||||
"aria-labelledby": "dsh-unrestricted-main-title",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-header",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-headerTitle",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
||||
id: "dsh-unrestricted-main-title",
|
||||
className: "dsh-unrestricted-title",
|
||||
children: t("title")
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: summaryTone,
|
||||
children: t(summaryKey)
|
||||
})]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-description",
|
||||
children: t("description")
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("scopeNote")
|
||||
}),
|
||||
view.settingsStatus === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
role: "status",
|
||||
children: t("settingsLoading")
|
||||
}),
|
||||
view.settingsStatus === "unavailable" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "info",
|
||||
role: "status",
|
||||
children: t("settingsUnavailable")
|
||||
}),
|
||||
view.message !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "error",
|
||||
role: "alert",
|
||||
children: localizeBannerError(view.message, t)
|
||||
})
|
||||
]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
||||
className: "dsh-unrestricted-card",
|
||||
"aria-labelledby": "dsh-unrestricted-modes-title",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-header",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-headerTitle",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
|
||||
id: "dsh-unrestricted-modes-title",
|
||||
className: "dsh-unrestricted-subtitle",
|
||||
children: t("statusTitle")
|
||||
})
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-headerControls",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: "outline",
|
||||
size: "sm",
|
||||
disabled: view.busy,
|
||||
onClick: () => {
|
||||
props.refresh();
|
||||
},
|
||||
children: t("refresh")
|
||||
})
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-headerControls",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
||||
className: "dsh-unrestricted-switchLabel",
|
||||
children: t("toggle")
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
|
||||
checked: view.enabled,
|
||||
disabled: !view.writable || view.settingsStatus !== "ready" || view.busy,
|
||||
label: t("toggle"),
|
||||
onChange: (checked) => {
|
||||
props.setEnabled(checked);
|
||||
}
|
||||
})]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("statusSubtitle")
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
||||
className: "dsh-unrestricted-modes",
|
||||
children: MODE_ROWS.map((row) => {
|
||||
const mode = status?.modes[row.id];
|
||||
const entry = view.previews[row.id];
|
||||
const isOpen = openPreview === row.id;
|
||||
const previewText = entry?.preview?.text;
|
||||
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
||||
className: "dsh-unrestricted-mode",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-modeMain",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-modeInfo",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-modeHeading",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: dotStateOf(mode) }),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
||||
className: "dsh-unrestricted-modeName",
|
||||
children: t(row.labelKey)
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: "outline",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
||||
className: "dsh-unrestricted-mono",
|
||||
children: t(row.presetKey)
|
||||
})
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: modeTagTone(mode),
|
||||
children: t(stateKey(mode))
|
||||
})
|
||||
]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-modeDesc",
|
||||
children: t(row.descKey)
|
||||
})]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-headerControls",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: isOpen ? "toolbar" : "outline",
|
||||
size: "sm",
|
||||
onClick: () => {
|
||||
togglePreview(row.id);
|
||||
},
|
||||
children: t(isOpen ? "hidePreview" : "showPreview")
|
||||
})
|
||||
})]
|
||||
}),
|
||||
mode !== void 0 && mode.issues.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-issues",
|
||||
children: formatIssues(mode.issues)
|
||||
}),
|
||||
isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-preview",
|
||||
children: entry === void 0 || entry.status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
role: "status",
|
||||
children: t("previewLoading")
|
||||
}) : entry.status === "failed" || entry.preview?.available === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "error",
|
||||
role: "alert",
|
||||
children: localizePreviewError(entry, t)
|
||||
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-previewHeader",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
||||
className: "dsh-unrestricted-previewMeta",
|
||||
children: [
|
||||
entry.preview?.lines,
|
||||
" ",
|
||||
t("previewSize"),
|
||||
entry.preview?.bytes !== void 0 && ` · ${(0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(entry.preview.bytes)}`,
|
||||
entry.preview?.source !== void 0 && ` · ${t(entry.preview.source === "live" ? "previewSourceLive" : "previewSourceStanding")}`
|
||||
]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: "ghost",
|
||||
size: "sm",
|
||||
onClick: () => {
|
||||
handleCopyPreview(row.id, previewText);
|
||||
},
|
||||
children: t(copiedPreset === row.id ? "copiedPreview" : "copyPreview")
|
||||
})]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
||||
className: "dsh-unrestricted-previewText",
|
||||
children: previewText
|
||||
})] })
|
||||
})
|
||||
]
|
||||
}, row.id);
|
||||
})]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-description",
|
||||
children: t("description")
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("scopeNote")
|
||||
}),
|
||||
view.settingsStatus === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
role: "status",
|
||||
children: t("settingsLoading")
|
||||
}),
|
||||
view.settingsStatus === "unavailable" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "info",
|
||||
role: "status",
|
||||
children: t("settingsUnavailable")
|
||||
}),
|
||||
view.message !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "error",
|
||||
role: "alert",
|
||||
children: localizeBannerError(view.message, t)
|
||||
})
|
||||
]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
||||
className: "dsh-unrestricted-card",
|
||||
"aria-labelledby": "dsh-unrestricted-modes-title",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-header",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-headerTitle",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
|
||||
id: "dsh-unrestricted-modes-title",
|
||||
className: "dsh-unrestricted-subtitle",
|
||||
children: t("statusTitle")
|
||||
})
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("subagentNote")
|
||||
})
|
||||
]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
||||
className: "dsh-unrestricted-card",
|
||||
"aria-labelledby": "dsh-unrestricted-update-title",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-header",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-headerTitle",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
|
||||
id: "dsh-unrestricted-update-title",
|
||||
className: "dsh-unrestricted-subtitle",
|
||||
children: t("updateTitle")
|
||||
}), update.state !== "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: updateTagTone,
|
||||
children: update.state === "available" && update.latestVersion !== void 0 ? `${t("updateAvailable")} v${update.latestVersion}` : t(updateTagKey)
|
||||
})]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-headerControls",
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-headerControls",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: "outline",
|
||||
size: "sm",
|
||||
disabled: view.busy,
|
||||
onClick: () => {
|
||||
props.refresh();
|
||||
},
|
||||
children: t("refresh")
|
||||
})
|
||||
})]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("statusSubtitle")
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
||||
className: "dsh-unrestricted-modes",
|
||||
children: MODE_ROWS.map((row) => {
|
||||
const mode = status?.modes[row.id];
|
||||
const entry = view.previews[row.id];
|
||||
const isOpen = openPreview === row.id;
|
||||
const previewText = entry?.preview?.text;
|
||||
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
||||
className: "dsh-unrestricted-mode",
|
||||
children: [
|
||||
update.releaseUrl !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
||||
className: "dsh-unrestricted-link",
|
||||
href: update.releaseUrl,
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
children: t("viewRelease")
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-modeMain",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-modeInfo",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-modeHeading",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: dotStateOf(mode) }),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
||||
className: "dsh-unrestricted-modeName",
|
||||
children: t(row.labelKey)
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: "outline",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
||||
className: "dsh-unrestricted-mono",
|
||||
children: t(row.presetKey)
|
||||
})
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
||||
tone: modeTagTone(mode),
|
||||
children: t(stateKey(mode))
|
||||
})
|
||||
]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-modeDesc",
|
||||
children: t(row.descKey)
|
||||
})]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-headerControls",
|
||||
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: isOpen ? "toolbar" : "outline",
|
||||
size: "sm",
|
||||
onClick: () => {
|
||||
togglePreview(row.id);
|
||||
},
|
||||
children: t(isOpen ? "hidePreview" : "showPreview")
|
||||
})
|
||||
})]
|
||||
}),
|
||||
update.state === "available" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: "primary",
|
||||
size: "sm",
|
||||
disabled: updateBusy,
|
||||
onClick: () => {
|
||||
props.performUpdate();
|
||||
},
|
||||
children: update.latestVersion !== void 0 ? `${t("installUpdate")} (v${update.latestVersion})` : t("installUpdate")
|
||||
mode !== void 0 && mode.issues.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-issues",
|
||||
children: formatIssues(mode.issues)
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: "outline",
|
||||
size: "sm",
|
||||
disabled: updateBusy,
|
||||
onClick: () => {
|
||||
props.checkUpdate(true);
|
||||
},
|
||||
children: t("checkUpdate")
|
||||
isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
||||
className: "dsh-unrestricted-preview",
|
||||
children: entry === void 0 || entry.status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
role: "status",
|
||||
children: t("previewLoading")
|
||||
}) : entry.status === "failed" || entry.preview?.available === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "error",
|
||||
role: "alert",
|
||||
children: localizePreviewError(entry, t)
|
||||
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-previewHeader",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
||||
className: "dsh-unrestricted-previewMeta",
|
||||
children: [
|
||||
entry.preview?.lines,
|
||||
" ",
|
||||
t("previewSize"),
|
||||
entry.preview?.bytes !== void 0 && ` · ${(0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(entry.preview.bytes)}`,
|
||||
entry.preview?.source !== void 0 && ` · ${t(entry.preview.source === "live" ? "previewSourceLive" : "previewSourceStanding")}`
|
||||
]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
||||
variant: "ghost",
|
||||
size: "sm",
|
||||
onClick: () => {
|
||||
handleCopyPreview(row.id, previewText);
|
||||
},
|
||||
children: t(copiedPreset === row.id ? "copiedPreview" : "copyPreview")
|
||||
})]
|
||||
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
||||
className: "dsh-unrestricted-previewText",
|
||||
children: previewText
|
||||
})] })
|
||||
})
|
||||
]
|
||||
})]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dl", {
|
||||
className: "dsh-unrestricted-metaGrid",
|
||||
children: [
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-metaItem",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("currentVersion") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
|
||||
className: "dsh-unrestricted-mono",
|
||||
children: `v${update.currentVersion}`
|
||||
})]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-metaItem",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("latestVersion") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
|
||||
className: "dsh-unrestricted-mono",
|
||||
children: update.latestVersion !== void 0 ? `v${update.latestVersion}` : "—"
|
||||
})]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
||||
className: "dsh-unrestricted-metaItem",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("installSource") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
|
||||
title: update.dependencySpec,
|
||||
children: installSourceLabel(update.installSource, t)
|
||||
})]
|
||||
})
|
||||
]
|
||||
}),
|
||||
update.state === "updating" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "info",
|
||||
role: "status",
|
||||
children: t("updateInstalling")
|
||||
}),
|
||||
(update.state === "updated" || update.restartRequired === true) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "success",
|
||||
role: "status",
|
||||
children: t("updateInstalled")
|
||||
}),
|
||||
update.state === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-banner",
|
||||
"data-tone": "error",
|
||||
role: "alert",
|
||||
children: localizeUpdateError(update, t)
|
||||
}, row.id);
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("subagentNote")
|
||||
})
|
||||
]
|
||||
})]
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
@@ -1179,7 +854,7 @@ window.__ModuleLoader__.load({
|
||||
"remote",
|
||||
"configForms"
|
||||
];
|
||||
/** 注册本插件的配置卡片与详情页更新徽标。 */
|
||||
/** 注册本插件的配置卡片。 */
|
||||
function apply(ctx) {
|
||||
ensureStyles();
|
||||
ctx.effect(() => ctx.locale.register(NS, {
|
||||
@@ -1193,12 +868,6 @@ window.__ModuleLoader__.load({
|
||||
locale: NS,
|
||||
inject: () => controller.face()
|
||||
}, UnrestrictedCard));
|
||||
ctx.slots.inject("plugins.detail.badge", () => ctx.slots.register({
|
||||
name: "plugins.detail.badge",
|
||||
id: "dsh-unrestricted:update-badge",
|
||||
locale: NS,
|
||||
inject: () => controller.face()
|
||||
}, UnrestrictedDetailBadge));
|
||||
}
|
||||
//#endregion
|
||||
exports.apply = apply;
|
||||
|
||||
Reference in new issue
Block a user