@logictan/dsh-easyrewrite 2.7.0 → 2.7.2
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/lib/client.js +333 -444
- package/package.json +12 -1
package/lib/client.js
CHANGED
|
@@ -10,6 +10,7 @@ window.__ModuleLoader__.load({
|
|
|
10
10
|
factory: function (require) {
|
|
11
11
|
var React = require("react");
|
|
12
12
|
var Primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
13
|
+
var UI = require("@logictan/dsh-plugins-shared-client");
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* 取第一个可用的图标导出。
|
|
@@ -1592,7 +1593,7 @@ window.__ModuleLoader__.load({
|
|
|
1592
1593
|
errNoBoundary: "该消息之前没有可截断的闭合回合边界(截断/首条消息无法撤回或编辑)",
|
|
1593
1594
|
errTurnOpen: "该消息所在回合尚未结束,请等待回复完成后再操作",
|
|
1594
1595
|
errGeneric: "操作失败,请重试",
|
|
1595
|
-
resetNotice: "
|
|
1596
|
+
resetNotice: "该消息之前没有可保留的历史,已重置——修改后的内容将作为新对话的第一条发出",
|
|
1596
1597
|
turnOpenNotice: "回复仍在生成中,请等待回复完成后再撤回。",
|
|
1597
1598
|
sectionUpdate: "更新",
|
|
1598
1599
|
currentVersion: "当前版本",
|
|
@@ -1685,7 +1686,7 @@ window.__ModuleLoader__.load({
|
|
|
1685
1686
|
errNoBoundary: "No truncation boundary before this message (first/truncated message cannot be recalled or edited)",
|
|
1686
1687
|
errTurnOpen: "This message's turn is still running; wait for the reply to finish",
|
|
1687
1688
|
errGeneric: "Operation failed, please retry",
|
|
1688
|
-
resetNotice: "
|
|
1689
|
+
resetNotice: "There is no earlier history to keep, so the conversation was reset — your edit will be sent as the first message of a new conversation",
|
|
1689
1690
|
turnOpenNotice: "A reply is still being generated. Please wait for it to finish before recalling.",
|
|
1690
1691
|
sectionUpdate: "Update",
|
|
1691
1692
|
currentVersion: "Current version",
|
|
@@ -1778,7 +1779,7 @@ window.__ModuleLoader__.load({
|
|
|
1778
1779
|
errNoBoundary: "このメッセージの前に切り詰め境界がありません(切り詰め後・最初のメッセージは撤回/編集できません)",
|
|
1779
1780
|
errTurnOpen: "このメッセージのターンはまだ終了していません。返信完了後にお試しください",
|
|
1780
1781
|
errGeneric: "操作に失敗しました。もう一度お試しください",
|
|
1781
|
-
resetNotice: "
|
|
1782
|
+
resetNotice: "このメッセージより前の履歴がないためリセットしました——編集内容は新しい会話の最初のメッセージとして送信されます",
|
|
1782
1783
|
turnOpenNotice: "返信がまだ生成中です。返信が完了してから取り消してください",
|
|
1783
1784
|
sectionUpdate: "更新",
|
|
1784
1785
|
currentVersion: "現在のバージョン",
|
|
@@ -1851,19 +1852,7 @@ window.__ModuleLoader__.load({
|
|
|
1851
1852
|
/** 设置卡片:注册进 plugins.row.config(设置 → 插件 → 插件配置)。
|
|
1852
1853
|
* 插件页对每个配置项渲染两次:view==='summary' 取行标题下的一行摘要,view==='page' 取完整表单。 */
|
|
1853
1854
|
function EasyRewriteSettingsCard(props) {
|
|
1854
|
-
/**
|
|
1855
|
-
* 是否由外部容器提供卡片外壳。
|
|
1856
|
-
*
|
|
1857
|
-
* 0.1.7 的插件页(plugins.item)自己画行外壳、标题取自插槽 label,卡片再画一层头部
|
|
1858
|
-
* 就成了嵌套折叠;旧插槽 settings.plugin.item 没有外壳,卡片必须自画。由挂载方经
|
|
1859
|
-
* inject 面传入,默认 false,保持旧行为。
|
|
1860
|
-
*/
|
|
1861
|
-
var embedded = !!(props && props.embedded);
|
|
1862
1855
|
var L = useUILocaleDict();
|
|
1863
|
-
// embedded 时头部不渲染,但「展开时检查更新」这类 side effect 仍要照跑,故初始即展开。
|
|
1864
|
-
var openState = React.useState(embedded);
|
|
1865
|
-
var open = openState[0];
|
|
1866
|
-
var setOpen = openState[1];
|
|
1867
1856
|
// 控件状态(初始化自 localStorage)
|
|
1868
1857
|
var sRewrite = React.useState(rewriteOnClick());
|
|
1869
1858
|
var rewrite = sRewrite[0];
|
|
@@ -1948,10 +1937,10 @@ window.__ModuleLoader__.load({
|
|
|
1948
1937
|
}
|
|
1949
1938
|
}).catch(function () { setUpdateUpdating(false); setUpdateMsg(L.updateFailed); });
|
|
1950
1939
|
}
|
|
1951
|
-
//
|
|
1952
|
-
//
|
|
1940
|
+
// 卡片加载时无感触发一次检查(5 分钟节流,防频繁刷新刷请求);
|
|
1941
|
+
// 每日检查开关开启时,即使不打开也会按天自动检测
|
|
1953
1942
|
React.useEffect(function () {
|
|
1954
|
-
if (
|
|
1943
|
+
if (props && props.view === "summary") return;
|
|
1955
1944
|
var now = Date.now();
|
|
1956
1945
|
var lastCheck = 0;
|
|
1957
1946
|
try { lastCheck = parseInt(localStorage.getItem("dsh-easyrewrite:lastUpdateCheckTs") || "0", 10) || 0; } catch (e) { /* ignore */ }
|
|
@@ -1959,7 +1948,7 @@ window.__ModuleLoader__.load({
|
|
|
1959
1948
|
try { localStorage.setItem("dsh-easyrewrite:lastUpdateCheckTs", String(now)); } catch (e) { /* ignore */ }
|
|
1960
1949
|
if (!updateVer) setUpdateVer("…");
|
|
1961
1950
|
doCheckUpdate();
|
|
1962
|
-
}, [
|
|
1951
|
+
}, [props && props.view]);
|
|
1963
1952
|
// 每日检测:开关开启时每天首次触发一次(不依赖展开)
|
|
1964
1953
|
React.useEffect(function () {
|
|
1965
1954
|
var autoOn = getBool("dsh-easyrewrite:autoCheckUpdate", false);
|
|
@@ -2025,417 +2014,331 @@ window.__ModuleLoader__.load({
|
|
|
2025
2014
|
var origImg = sOrigImg[0];
|
|
2026
2015
|
var setOrigImg = sOrigImg[1];
|
|
2027
2016
|
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
};
|
|
2036
|
-
var cardOpenStyle = { background: "var(--dsw-alias-bg-layer-2)", borderColor: "var(--dsw-alias-label-dimmed)" };
|
|
2037
|
-
var headStyle = {
|
|
2038
|
-
appearance: "none",
|
|
2039
|
-
width: "100%",
|
|
2040
|
-
font: "inherit",
|
|
2041
|
-
color: "inherit",
|
|
2042
|
-
textAlign: "left",
|
|
2043
|
-
cursor: "pointer",
|
|
2044
|
-
background: "transparent",
|
|
2045
|
-
border: "none",
|
|
2046
|
-
borderRadius: "12px",
|
|
2047
|
-
display: "flex",
|
|
2048
|
-
alignItems: "center",
|
|
2049
|
-
gap: "12px",
|
|
2050
|
-
padding: "14px 16px"
|
|
2051
|
-
};
|
|
2052
|
-
var headTextStyle = { display: "flex", flexDirection: "column", flex: "1", minWidth: "0", gap: "4px" };
|
|
2053
|
-
var titleStyle = { color: "var(--dsw-alias-label-primary)", fontSize: "15px", fontWeight: 600, lineHeight: "1.4" };
|
|
2054
|
-
var subStyle = { color: "var(--dsw-alias-label-tertiary)", fontSize: "13px", lineHeight: "1.5" };
|
|
2055
|
-
var chevronStyle = { color: "var(--dsw-alias-label-tertiary)", flex: "none", transition: "transform .16s", transform: "rotate(90deg)" };
|
|
2056
|
-
var chevronOpenStyle = { transform: "rotate(270deg)" };
|
|
2057
|
-
var bodyStyle = {
|
|
2058
|
-
borderTop: "1px solid var(--dsw-alias-border-l2)",
|
|
2059
|
-
margin: "0 16px",
|
|
2060
|
-
paddingTop: "14px",
|
|
2061
|
-
paddingBottom: "8px",
|
|
2062
|
-
display: "flex",
|
|
2063
|
-
flexDirection: "column",
|
|
2064
|
-
gap: "16px"
|
|
2065
|
-
};
|
|
2066
|
-
// 大项分组:组内 10px,组间 16px(bodyStyle gap);每级缩进 4 空格(16px)
|
|
2067
|
-
var sectionStyle = { display: "flex", flexDirection: "column", gap: "10px", paddingLeft: "16px" };
|
|
2068
|
-
var groupTitleStyle = {
|
|
2069
|
-
fontSize: "14px",
|
|
2070
|
-
fontWeight: 600,
|
|
2071
|
-
color: "var(--dsw-alias-label-primary)",
|
|
2072
|
-
letterSpacing: "0.02em",
|
|
2073
|
-
lineHeight: "1.6"
|
|
2074
|
-
};
|
|
2075
|
-
var rowStyle = { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "12px", paddingLeft: "16px" };
|
|
2076
|
-
var labelStyle = { fontSize: "13px", color: "var(--dsw-alias-label-primary)" };
|
|
2077
|
-
var hintStyle = { fontSize: "11px", color: "var(--dsw-alias-label-tertiary)" };
|
|
2078
|
-
var groupStyle = { display: "flex", flexDirection: "column", gap: "6px", paddingLeft: "16px" };
|
|
2079
|
-
var inputStyle = {
|
|
2080
|
-
width: "90px",
|
|
2081
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(128,128,128,0.3))",
|
|
2082
|
-
borderRadius: "8px",
|
|
2083
|
-
padding: "4px 8px",
|
|
2084
|
-
fontSize: "13px",
|
|
2085
|
-
background: "var(--dsw-alias-bg-base)",
|
|
2086
|
-
color: "var(--dsw-alias-label-primary)"
|
|
2087
|
-
};
|
|
2088
|
-
var disabledInputStyle = Object.assign({}, inputStyle, { opacity: 0.45, cursor: "not-allowed" });
|
|
2089
|
-
function switchRow(label, value, onChange, extraHint, disabled) {
|
|
2090
|
-
// 圆形勾选框:选中 = 白底黑勾(与确认胶囊同设计语言);未选中 = 灰色圆环
|
|
2091
|
-
var checkSize = 20;
|
|
2092
|
-
var checkStyle = {
|
|
2093
|
-
width: checkSize,
|
|
2094
|
-
height: checkSize,
|
|
2095
|
-
borderRadius: "50%",
|
|
2096
|
-
border: "2px solid " + (value ? "#ffffff" : "var(--dsw-alias-border-l2, rgba(128,128,128,0.45))"),
|
|
2097
|
-
background: value ? "#ffffff" : "transparent",
|
|
2098
|
-
display: "flex",
|
|
2099
|
-
alignItems: "center",
|
|
2100
|
-
justifyContent: "center",
|
|
2101
|
-
color: value ? "#000000" : "transparent",
|
|
2102
|
-
fontSize: "13px",
|
|
2103
|
-
lineHeight: "13px",
|
|
2104
|
-
cursor: "pointer",
|
|
2105
|
-
flex: "none",
|
|
2106
|
-
margin: "0 2px",
|
|
2107
|
-
transition: "border-color .15s, background .15s, color .15s",
|
|
2108
|
-
userSelect: "none",
|
|
2109
|
-
boxSizing: "border-box"
|
|
2110
|
-
};
|
|
2111
|
-
return React.createElement("div", {
|
|
2112
|
-
style: Object.assign({}, rowStyle, disabled ? { opacity: 0.45, cursor: "not-allowed" } : null),
|
|
2113
|
-
"data-dsh-easyrewrite": "switch-row",
|
|
2114
|
-
title: disabled ? (extraHint || "") : undefined
|
|
2115
|
-
},
|
|
2116
|
-
React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "2px", flex: "1", minWidth: "0" } },
|
|
2117
|
-
React.createElement("span", { style: labelStyle }, label),
|
|
2118
|
-
extraHint ? React.createElement("span", { style: hintStyle }, extraHint) : null
|
|
2119
|
-
),
|
|
2120
|
-
React.createElement("div", {
|
|
2121
|
-
role: "checkbox",
|
|
2122
|
-
"aria-checked": !!value,
|
|
2123
|
-
"aria-disabled": disabled || undefined,
|
|
2124
|
-
style: Object.assign({}, checkStyle, disabled ? { cursor: "not-allowed" } : null),
|
|
2125
|
-
onClick: function (e) { e.stopPropagation(); if (disabled) return; onChange(!value); }
|
|
2126
|
-
}, value ? React.createElement(IconCheckOutline, null) : null)
|
|
2017
|
+
if (props && props.view === "summary") return L.subtitle;
|
|
2018
|
+
|
|
2019
|
+
function sectionHead(title) {
|
|
2020
|
+
return React.createElement(
|
|
2021
|
+
"div",
|
|
2022
|
+
{ key: "head-" + title, className: "dsp-card-title", style: { fontSize: "14px", fontWeight: 600, marginTop: "8px" } },
|
|
2023
|
+
title,
|
|
2127
2024
|
);
|
|
2128
2025
|
}
|
|
2129
|
-
|
|
2130
|
-
function
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
};
|
|
2153
|
-
return React.createElement("div", { style: segStyle, role: "radiogroup" },
|
|
2154
|
-
React.createElement("div", { style: thumbStyle, "data-dsh-easyrewrite": "seg-thumb" }),
|
|
2155
|
-
options.map(function (opt) {
|
|
2156
|
-
var sel = value === opt[0];
|
|
2157
|
-
return React.createElement("div", {
|
|
2158
|
-
key: opt[0],
|
|
2159
|
-
role: "radio",
|
|
2160
|
-
"aria-checked": sel,
|
|
2161
|
-
style: {
|
|
2162
|
-
position: "relative",
|
|
2163
|
-
zIndex: 2,
|
|
2164
|
-
flex: "1",
|
|
2165
|
-
padding: "3px 10px",
|
|
2166
|
-
textAlign: "center",
|
|
2167
|
-
fontSize: "13px",
|
|
2168
|
-
lineHeight: "20px",
|
|
2169
|
-
cursor: "pointer",
|
|
2170
|
-
borderRadius: "999px",
|
|
2171
|
-
color: sel ? "var(--dsw-alias-label-primary)" : "var(--dsw-alias-label-secondary)",
|
|
2172
|
-
transition: "color .15s",
|
|
2173
|
-
whiteSpace: "nowrap",
|
|
2174
|
-
userSelect: "none"
|
|
2175
|
-
},
|
|
2176
|
-
onClick: function () { onChange(opt[0]); }
|
|
2177
|
-
}, opt[1]);
|
|
2178
|
-
})
|
|
2026
|
+
|
|
2027
|
+
function sectionDivider(key) {
|
|
2028
|
+
return React.createElement("hr", {
|
|
2029
|
+
key: key,
|
|
2030
|
+
style: { border: "none", borderTop: "1px solid var(--dsw-alias-border-l2)", margin: "8px 0" },
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
function renderSwitch(label, value, onChange, extraHint, disabled) {
|
|
2035
|
+
return React.createElement(
|
|
2036
|
+
UI.Field,
|
|
2037
|
+
{
|
|
2038
|
+
key: label,
|
|
2039
|
+
inline: true,
|
|
2040
|
+
label: label,
|
|
2041
|
+
hint: extraHint || undefined,
|
|
2042
|
+
},
|
|
2043
|
+
React.createElement(UI.Switch, {
|
|
2044
|
+
checked: !!value,
|
|
2045
|
+
disabled: !!disabled,
|
|
2046
|
+
label: label,
|
|
2047
|
+
onCheckedChange: onChange,
|
|
2048
|
+
}),
|
|
2179
2049
|
);
|
|
2180
2050
|
}
|
|
2181
2051
|
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2052
|
+
var children = [
|
|
2053
|
+
// —— 编辑 ——
|
|
2054
|
+
sectionHead(L.sectionEdit),
|
|
2055
|
+
renderSwitch(L.rewrite, rewrite, function (v) { setRewrite(v); setBool("dsh-easyrewrite:rewriteOnClick", v); }),
|
|
2056
|
+
renderSwitch(L.editOffShowRecall, showRecall, function (v) {
|
|
2057
|
+
setShowRecall(v); setBool("dsh-easyrewrite:editOffShowRecall", v);
|
|
2058
|
+
}, rewrite ? L.lockedHint : null, rewrite),
|
|
2059
|
+
React.createElement(
|
|
2060
|
+
UI.Field,
|
|
2061
|
+
{
|
|
2062
|
+
key: "edit-width",
|
|
2063
|
+
label: L.editWidth,
|
|
2064
|
+
},
|
|
2065
|
+
React.createElement(UI.Segmented, {
|
|
2066
|
+
label: L.editWidth,
|
|
2067
|
+
value: widthMode,
|
|
2068
|
+
options: [
|
|
2069
|
+
{ value: "compact", label: L.wCompact },
|
|
2070
|
+
{ value: "standard", label: L.wStandard },
|
|
2071
|
+
{ value: "extended", label: L.wExtended },
|
|
2072
|
+
{ value: "custom", label: L.wCustom },
|
|
2073
|
+
],
|
|
2074
|
+
onChange: function (v) { setWidthMode(v); setSetting("dsh-easyrewrite:editWidth", v); },
|
|
2075
|
+
}),
|
|
2076
|
+
),
|
|
2077
|
+
React.createElement(
|
|
2078
|
+
UI.Field,
|
|
2079
|
+
{
|
|
2080
|
+
key: "custom-width",
|
|
2081
|
+
inline: true,
|
|
2082
|
+
label: L.customWidth,
|
|
2083
|
+
},
|
|
2084
|
+
React.createElement(UI.NumberField, {
|
|
2085
|
+
min: 100,
|
|
2086
|
+
max: 1200,
|
|
2087
|
+
disabled: widthMode !== "custom",
|
|
2088
|
+
placeholder: L.placeholderCustom,
|
|
2089
|
+
value: customW,
|
|
2090
|
+
onValueChange: function (v) {
|
|
2091
|
+
setCustomW(v);
|
|
2092
|
+
setSetting("dsh-easyrewrite:editWidthCustom", v);
|
|
2093
|
+
},
|
|
2094
|
+
}),
|
|
2095
|
+
),
|
|
2096
|
+
|
|
2097
|
+
sectionDivider("div-recall"),
|
|
2098
|
+
|
|
2099
|
+
// —— 撤回 ——
|
|
2100
|
+
sectionHead(L.sectionRecall),
|
|
2101
|
+
renderSwitch(L.recallConfirm, confirmCapsule, function (v) { setConfirmCapsule(v); setBool("dsh-easyrewrite:recallConfirm", v); }),
|
|
2102
|
+
renderSwitch(L.showOriginalImages, origImg, function (v) { setOrigImg(v); setBool("dsh-easyrewrite:showOriginalImages", v); }),
|
|
2103
|
+
React.createElement(
|
|
2104
|
+
UI.Field,
|
|
2105
|
+
{
|
|
2106
|
+
key: "visual-mode",
|
|
2107
|
+
label: L.visualMode,
|
|
2108
|
+
},
|
|
2109
|
+
React.createElement(UI.Segmented, {
|
|
2110
|
+
label: L.visualMode,
|
|
2111
|
+
value: visual,
|
|
2112
|
+
options: [
|
|
2113
|
+
{ value: "simple", label: L.visualSimple },
|
|
2114
|
+
{ value: "minimal", label: L.visualMinimal },
|
|
2115
|
+
{ value: "info", label: L.visualInfo },
|
|
2116
|
+
],
|
|
2117
|
+
onChange: function (v) { setVisual(v); setSetting("dsh-easyrewrite:visualMode", v); },
|
|
2118
|
+
}),
|
|
2119
|
+
),
|
|
2120
|
+
renderSwitch(L.statOnlyUser, statOnly, function (v) { setStatOnly(v); setBool("dsh-easyrewrite:statOnlyUser", v); }),
|
|
2121
|
+
renderSwitch(L.hotkeyEnable, hotkeyOn, function (v) {
|
|
2122
|
+
setHotkeyOn(v);
|
|
2123
|
+
setHotkeyEnabledSetting(v);
|
|
2124
|
+
if (!v) setRecording(false);
|
|
2125
|
+
}, L.hotkeyHint),
|
|
2126
|
+
React.createElement(
|
|
2127
|
+
UI.Field,
|
|
2128
|
+
{
|
|
2129
|
+
key: "hotkey-field",
|
|
2130
|
+
inline: true,
|
|
2131
|
+
label: L.hotkey + ":" + (hotkey ? formatHotkey(hotkey) : L.hotkeyNone),
|
|
2132
|
+
hint: recording ? L.hotkeyRecording : (hotkey ? undefined : L.hotkeyHint),
|
|
2133
|
+
error: hotkeyInvalid ? L.hotkeyInvalid : undefined,
|
|
2134
|
+
},
|
|
2135
|
+
React.createElement(
|
|
2136
|
+
UI.Button,
|
|
2137
|
+
{
|
|
2138
|
+
variant: "secondary",
|
|
2139
|
+
size: "sm",
|
|
2140
|
+
disabled: !hotkeyOn,
|
|
2141
|
+
onClick: function () { setHotkeyInvalid(false); setRecording(!recording); },
|
|
2142
|
+
},
|
|
2143
|
+
recording ? L.hotkeyRecording : L.hotkeyRecord,
|
|
2217
2144
|
),
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2145
|
+
),
|
|
2146
|
+
|
|
2147
|
+
sectionDivider("div-composer"),
|
|
2148
|
+
|
|
2149
|
+
// —— 回填 ——
|
|
2150
|
+
sectionHead(L.sectionComposer),
|
|
2151
|
+
React.createElement(
|
|
2152
|
+
UI.Field,
|
|
2153
|
+
{
|
|
2154
|
+
key: "conflict-mode",
|
|
2155
|
+
label: L.conflictMode,
|
|
2156
|
+
hint: conflict === "merge" ? L.conflictMerge : L.conflictOverwrite,
|
|
2157
|
+
},
|
|
2158
|
+
React.createElement(UI.Segmented, {
|
|
2159
|
+
label: L.conflictMode,
|
|
2160
|
+
value: conflict,
|
|
2161
|
+
options: [
|
|
2162
|
+
{ value: "overwrite", label: L.conflictOverwriteShort },
|
|
2163
|
+
{ value: "merge", label: L.conflictMergeShort },
|
|
2164
|
+
],
|
|
2165
|
+
onChange: function (v) { setConflict(v); setSetting("dsh-easyrewrite:conflictMode", v); },
|
|
2166
|
+
}),
|
|
2167
|
+
),
|
|
2168
|
+
|
|
2169
|
+
sectionDivider("div-versions"),
|
|
2170
|
+
|
|
2171
|
+
// —— 版本 ——
|
|
2172
|
+
sectionHead(L.sectionVersions),
|
|
2173
|
+
React.createElement(
|
|
2174
|
+
"div",
|
|
2175
|
+
{ key: "versions-group", style: { display: "flex", flexDirection: "column", gap: "6px" } },
|
|
2176
|
+
(function () {
|
|
2177
|
+
var families = listVersionFamilies(props.ctxSessions);
|
|
2178
|
+
if (families.length === 0) return React.createElement("span", { className: "dsp-field-hint" }, L.versionFamilyNone);
|
|
2179
|
+
var snap = null;
|
|
2180
|
+
try { snap = props.ctxSessions.list.getSnapshot(); } catch (e) { /* ignore */ }
|
|
2181
|
+
var metaOf = function (vid) { return (snap && snap.byId && snap.byId[vid]) || {}; };
|
|
2182
|
+
var famName = function (fam) {
|
|
2183
|
+
var best = null, bt = -1;
|
|
2184
|
+
fam.versions.forEach(function (vid) {
|
|
2185
|
+
var m = metaOf(vid); var tt = m.updatedAt || 0;
|
|
2186
|
+
if (tt >= bt) { bt = tt; best = m.title || null; }
|
|
2187
|
+
});
|
|
2188
|
+
return best || (fam.versions.length + " " + L.versionCount);
|
|
2189
|
+
};
|
|
2190
|
+
var fmtStamp = function (tsv) {
|
|
2191
|
+
if (!tsv) return "—";
|
|
2192
|
+
var dd = new Date(tsv);
|
|
2193
|
+
var p2 = function (x) { return (x < 10 ? "0" : "") + x; };
|
|
2194
|
+
return dd.getFullYear() + "-" + p2(dd.getMonth() + 1) + "-" + p2(dd.getDate()) + " " + p2(dd.getHours()) + ":" + p2(dd.getMinutes());
|
|
2195
|
+
};
|
|
2196
|
+
var chev = function (openState) {
|
|
2197
|
+
return React.createElement("svg", {
|
|
2198
|
+
width: "16", height: "16", viewBox: "0 0 24 24",
|
|
2199
|
+
style: { flex: "none", display: "block", color: "var(--dsw-alias-label-tertiary)", transform: openState ? "rotate(90deg)" : "rotate(0deg)", transition: "transform .12s" }
|
|
2200
|
+
}, React.createElement("path", { d: "M9 6l6 6-6 6", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
2201
|
+
};
|
|
2202
|
+
var rowHead = { display: "flex", alignItems: "center", gap: "8px", padding: "4px 8px", borderRadius: "6px" };
|
|
2203
|
+
var hdrRow = { display: "flex", alignItems: "center", gap: "6px", cursor: "pointer", padding: "4px 0" };
|
|
2204
|
+
return React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "4px" } },
|
|
2205
|
+
React.createElement("div", { style: hdrRow, onClick: function () { setHistOpen(!histOpen); } },
|
|
2206
|
+
chev(histOpen),
|
|
2207
|
+
React.createElement("span", { style: { fontSize: "13px", color: "var(--dsw-alias-label-secondary)" } }, L.versionHistory),
|
|
2208
|
+
React.createElement("span", { style: { marginLeft: "auto" } }, React.createElement(UI.Tag, { mono: true }, families.length + ""))
|
|
2241
2209
|
),
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
color: "var(--dsw-alias-label-secondary)",
|
|
2250
|
-
borderRadius: "6px",
|
|
2251
|
-
padding: "3px 10px",
|
|
2252
|
-
fontSize: "12px",
|
|
2253
|
-
cursor: hotkeyOn ? "pointer" : "not-allowed",
|
|
2254
|
-
fontFamily: "inherit",
|
|
2255
|
-
flex: "none",
|
|
2256
|
-
opacity: hotkeyOn ? 1 : 0.45
|
|
2257
|
-
},
|
|
2258
|
-
onClick: function () { setHotkeyInvalid(false); setRecording(!recording); }
|
|
2259
|
-
}, recording ? L.hotkeyRecording : L.hotkeyRecord)
|
|
2260
|
-
)
|
|
2261
|
-
),
|
|
2262
|
-
// —— 回填 ——
|
|
2263
|
-
React.createElement("div", { style: sectionStyle },
|
|
2264
|
-
React.createElement("span", { style: groupTitleStyle }, L.sectionComposer),
|
|
2265
|
-
// 回填冲突模式
|
|
2266
|
-
React.createElement("div", { style: groupStyle },
|
|
2267
|
-
React.createElement("span", { style: labelStyle }, L.conflictMode),
|
|
2268
|
-
segmentedGroup([["overwrite", L.conflictOverwriteShort], ["merge", L.conflictMergeShort]], conflict, function (v) { setConflict(v); setSetting("dsh-easyrewrite:conflictMode", v); }),
|
|
2269
|
-
React.createElement("span", { style: hintStyle }, conflict === "merge" ? L.conflictMerge : L.conflictOverwrite)
|
|
2270
|
-
)
|
|
2271
|
-
),
|
|
2272
|
-
// —— 版本 ——
|
|
2273
|
-
React.createElement("div", { style: sectionStyle },
|
|
2274
|
-
React.createElement("span", { style: groupTitleStyle }, L.sectionVersions),
|
|
2275
|
-
// 版本历史(三层折叠):总开关默认收起 → 按对话名的家族折叠项 → 条目显最后对话时间
|
|
2276
|
-
// (官方无归档恢复入口,此处保留恢复并打开;review #6 后家族来自官方 lineage)
|
|
2277
|
-
React.createElement("div", { style: groupStyle },
|
|
2278
|
-
(function () {
|
|
2279
|
-
var families = listVersionFamilies(props.ctxSessions);
|
|
2280
|
-
if (families.length === 0) return React.createElement("span", { style: hintStyle }, L.versionFamilyNone);
|
|
2281
|
-
var snap = null;
|
|
2282
|
-
try { snap = props.ctxSessions.list.getSnapshot(); } catch (e) { /* ignore */ }
|
|
2283
|
-
var metaOf = function (vid) { return (snap && snap.byId && snap.byId[vid]) || {}; };
|
|
2284
|
-
var famName = function (fam) {
|
|
2285
|
-
var best = null, bt = -1;
|
|
2286
|
-
fam.versions.forEach(function (vid) {
|
|
2287
|
-
var m = metaOf(vid); var tt = m.updatedAt || 0;
|
|
2288
|
-
if (tt >= bt) { bt = tt; best = m.title || null; }
|
|
2289
|
-
});
|
|
2290
|
-
return best || (fam.versions.length + " " + L.versionCount);
|
|
2291
|
-
};
|
|
2292
|
-
var fmtStamp = function (tsv) {
|
|
2293
|
-
if (!tsv) return "—";
|
|
2294
|
-
var dd = new Date(tsv);
|
|
2295
|
-
var p2 = function (x) { return (x < 10 ? "0" : "") + x; };
|
|
2296
|
-
return dd.getFullYear() + "-" + p2(dd.getMonth() + 1) + "-" + p2(dd.getDate()) + " " + p2(dd.getHours()) + ":" + p2(dd.getMinutes());
|
|
2297
|
-
};
|
|
2298
|
-
// 折叠箭头:SVG 描边(官方图标同风格),像素级对齐、无字距
|
|
2299
|
-
var chev = function (openState) {
|
|
2300
|
-
return React.createElement("svg", {
|
|
2301
|
-
width: "18", height: "18", viewBox: "0 0 24 24",
|
|
2302
|
-
style: { flex: "none", display: "block", color: "var(--dsw-alias-label-tertiary)", transform: openState ? "rotate(90deg)" : "rotate(0deg)", transition: "transform .12s" }
|
|
2303
|
-
}, React.createElement("path", { d: "M9 6l6 6-6 6", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
2304
|
-
};
|
|
2305
|
-
var rowHead = { display: "flex", alignItems: "center", gap: "6px", padding: "5px 4px", cursor: "pointer", borderRadius: "6px" };
|
|
2306
|
-
var hdrRow = { display: "flex", alignItems: "center", cursor: "pointer" }; // 无 gap:SVG 箭头紧贴文字
|
|
2307
|
-
// 层1:版本历史总折叠(默认收起)
|
|
2308
|
-
return React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "2px" } },
|
|
2309
|
-
React.createElement("div", { style: hdrRow, onClick: function () { setHistOpen(!histOpen); } },
|
|
2310
|
-
chev(histOpen),
|
|
2311
|
-
React.createElement("span", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary)" } }, L.versionHistory),
|
|
2312
|
-
React.createElement("span", { style: { fontSize: "11px", color: "var(--dsw-alias-label-tertiary)", marginLeft: "auto" } }, families.length + "")
|
|
2210
|
+
histOpen ? families.map(function (fam) {
|
|
2211
|
+
var famOpen = !!famOpenMap[fam.rootId];
|
|
2212
|
+
return React.createElement("div", { key: fam.rootId, style: { display: "flex", flexDirection: "column", gap: "2px", padding: "2px 0 2px 14px", borderTop: "1px solid var(--dsw-alias-border-l2)" } },
|
|
2213
|
+
React.createElement("div", { style: hdrRow, onClick: function () { var nm = {}; for (var ok2 in famOpenMap) nm[ok2] = famOpenMap[ok2]; nm[fam.rootId] = !famOpen; setFamOpenMap(nm); } },
|
|
2214
|
+
chev(famOpen),
|
|
2215
|
+
React.createElement("span", { style: { fontSize: "13px", color: "var(--dsw-alias-label-primary)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: "1" } }, famName(fam)),
|
|
2216
|
+
React.createElement("span", { style: { marginLeft: "auto" } }, React.createElement(UI.Tag, null, fam.versions.length + " " + L.versionCount))
|
|
2313
2217
|
),
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
React.createElement("
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
headers: { "content-type": "application/json" },
|
|
2334
|
-
body: JSON.stringify({ sessionId: vid }),
|
|
2335
|
-
keepalive: true
|
|
2336
|
-
}).then(function () {
|
|
2337
|
-
if (typeof props.openSession === "function") props.openSession(vid);
|
|
2338
|
-
}).catch(function () { /* ignore */ });
|
|
2339
|
-
}
|
|
2340
|
-
}, L.versionRestoreOpen)
|
|
2341
|
-
);
|
|
2342
|
-
}) : null
|
|
2218
|
+
famOpen ? fam.versions.map(function (vid, vi) {
|
|
2219
|
+
return React.createElement("div", { key: vid, style: rowHead },
|
|
2220
|
+
React.createElement("span", { style: { fontSize: "12px", color: "var(--dsw-alias-label-tertiary)", fontVariantNumeric: "tabular-nums", flex: "none", width: "28px" } }, "v" + (vi + 1)),
|
|
2221
|
+
React.createElement("span", { style: { fontSize: "12px", color: "var(--dsw-alias-label-tertiary)", fontVariantNumeric: "tabular-nums", flex: "1" } }, fmtStamp(metaOf(vid).updatedAt)),
|
|
2222
|
+
React.createElement(UI.Button, {
|
|
2223
|
+
variant: "secondary",
|
|
2224
|
+
size: "sm",
|
|
2225
|
+
onClick: function (ev) {
|
|
2226
|
+
ev.stopPropagation();
|
|
2227
|
+
fetch("/bubble/unarchive", {
|
|
2228
|
+
method: "POST",
|
|
2229
|
+
headers: { "content-type": "application/json" },
|
|
2230
|
+
body: JSON.stringify({ sessionId: vid }),
|
|
2231
|
+
keepalive: true
|
|
2232
|
+
}).then(function () {
|
|
2233
|
+
if (typeof props.openSession === "function") props.openSession(vid);
|
|
2234
|
+
}).catch(function () { /* ignore */ });
|
|
2235
|
+
}
|
|
2236
|
+
}, L.versionRestoreOpen)
|
|
2343
2237
|
);
|
|
2344
2238
|
}) : null
|
|
2345
2239
|
);
|
|
2346
|
-
})
|
|
2347
|
-
)
|
|
2240
|
+
}) : null
|
|
2241
|
+
);
|
|
2242
|
+
})()
|
|
2243
|
+
),
|
|
2244
|
+
|
|
2245
|
+
sectionDivider("div-update"),
|
|
2246
|
+
|
|
2247
|
+
// —— 更新 ——
|
|
2248
|
+
sectionHead(L.sectionUpdate),
|
|
2249
|
+
React.createElement(
|
|
2250
|
+
"div",
|
|
2251
|
+
{ key: "updates-group", style: { display: "flex", flexDirection: "column", gap: "10px" } },
|
|
2252
|
+
React.createElement(
|
|
2253
|
+
UI.Field,
|
|
2254
|
+
{
|
|
2255
|
+
key: "check-update-field",
|
|
2256
|
+
inline: true,
|
|
2257
|
+
label: L.currentVersion + ":" + (updateVer || "…"),
|
|
2258
|
+
hint: updateMsg || undefined,
|
|
2259
|
+
},
|
|
2260
|
+
React.createElement(UI.Button, {
|
|
2261
|
+
variant: "secondary",
|
|
2262
|
+
size: "sm",
|
|
2263
|
+
loading: updateChecking,
|
|
2264
|
+
onClick: function () { doCheckUpdate(); },
|
|
2265
|
+
}, updateChecking ? L.checking : L.checkUpdate),
|
|
2348
2266
|
),
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
React.createElement("
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
React.createElement(
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
)
|
|
2363
|
-
)
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
React.createElement("button", {
|
|
2394
|
-
type: "button",
|
|
2395
|
-
style: {
|
|
2396
|
-
appearance: "none",
|
|
2397
|
-
border: "none",
|
|
2398
|
-
background: "var(--dsw-static-deepseek-500, #4d6bfe)",
|
|
2399
|
-
color: "#ffffff",
|
|
2400
|
-
borderRadius: "6px",
|
|
2401
|
-
padding: "3px 12px",
|
|
2402
|
-
fontSize: "12px",
|
|
2403
|
-
cursor: "pointer",
|
|
2404
|
-
fontFamily: "inherit",
|
|
2405
|
-
flex: "none"
|
|
2406
|
-
},
|
|
2407
|
-
onClick: function () { doUpdatePlugin(); }
|
|
2408
|
-
}, updateUpdating ? L.updating : L.updateNow)
|
|
2409
|
-
) : null,
|
|
2410
|
-
switchRow(L.autoCheckUpdate, autoCheckOn, function (v) {
|
|
2411
|
-
setAutoCheckOn(v);
|
|
2412
|
-
setBool("dsh-easyrewrite:autoCheckUpdate", v);
|
|
2413
|
-
})
|
|
2267
|
+
(function () {
|
|
2268
|
+
if (!dshVer) return null;
|
|
2269
|
+
if (cmpDsh(dshVer, MIN_DSH_VERSION) < 0) return React.createElement(
|
|
2270
|
+
UI.Banner,
|
|
2271
|
+
{ key: "dsh-low", kind: "warn" },
|
|
2272
|
+
React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "4px", width: "100%" } },
|
|
2273
|
+
React.createElement("span", null, L.dshLowWarning.replace("{cur}", dshVer).replace("{min}", MIN_DSH_VERSION)),
|
|
2274
|
+
React.createElement("div", { style: { display: "flex", alignItems: "center", gap: "6px" } },
|
|
2275
|
+
React.createElement("code", { style: { fontSize: "11px", flex: "1", minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, "npm install -g @deepseek-ai/dsh@" + MIN_DSH_VERSION),
|
|
2276
|
+
React.createElement(UI.Button, {
|
|
2277
|
+
variant: "secondary",
|
|
2278
|
+
size: "sm",
|
|
2279
|
+
onClick: function () { try { legacyCopy("npm install -g @deepseek-ai/dsh@" + MIN_DSH_VERSION); } catch (e) {} },
|
|
2280
|
+
}, L.copyUpgradeCmd)
|
|
2281
|
+
)
|
|
2282
|
+
)
|
|
2283
|
+
);
|
|
2284
|
+
if (cmpDsh(MAX_TESTED_DSH_VERSION, dshVer) < 0) return React.createElement(UI.Banner, { key: "dsh-new", kind: "info" }, L.dshNewNotice.replace("{cur}", dshVer));
|
|
2285
|
+
return null;
|
|
2286
|
+
})(),
|
|
2287
|
+
!remindClosed && !getBool("dsh-easyrewrite:autoCheckUpdate", false) ? React.createElement(
|
|
2288
|
+
UI.Banner,
|
|
2289
|
+
{ key: "remind", kind: "info" },
|
|
2290
|
+
React.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" } },
|
|
2291
|
+
React.createElement("span", { style: { flex: "1", minWidth: 0 } }, L.suggestAutoCheck),
|
|
2292
|
+
React.createElement(UI.Button, {
|
|
2293
|
+
variant: "primary",
|
|
2294
|
+
size: "sm",
|
|
2295
|
+
onClick: function () {
|
|
2296
|
+
setBool("dsh-easyrewrite:autoCheckUpdate", true);
|
|
2297
|
+
setBool("dsh-easyrewrite:autoCheckReminded", true);
|
|
2298
|
+
setAutoCheckOn(true);
|
|
2299
|
+
setRemindClosed(true);
|
|
2300
|
+
},
|
|
2301
|
+
}, L.enableNow),
|
|
2302
|
+
React.createElement(UI.Button, {
|
|
2303
|
+
variant: "ghost",
|
|
2304
|
+
size: "sm",
|
|
2305
|
+
title: L.remindIgnore,
|
|
2306
|
+
onClick: function () {
|
|
2307
|
+
setBool("dsh-easyrewrite:autoCheckReminded", true);
|
|
2308
|
+
setRemindClosed(true);
|
|
2309
|
+
},
|
|
2310
|
+
}, L.remindIgnore)
|
|
2414
2311
|
)
|
|
2415
|
-
),
|
|
2416
|
-
React.createElement(
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
React.createElement("span", { style: subStyle }, L.subtitle)
|
|
2434
|
-
),
|
|
2435
|
-
React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", style: Object.assign({}, chevronStyle, open ? chevronOpenStyle : null) },
|
|
2436
|
-
React.createElement("path", { d: "M9 6l6 6-6 6", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }))
|
|
2312
|
+
) : null,
|
|
2313
|
+
updateAvailableVer ? React.createElement(
|
|
2314
|
+
UI.Banner,
|
|
2315
|
+
{ key: "update-avail", kind: "ok" },
|
|
2316
|
+
React.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" } },
|
|
2317
|
+
React.createElement("span", { style: { flex: "1" } }, L.newVersion.replace("{ver}", updateAvailableVer)),
|
|
2318
|
+
React.createElement(UI.Button, {
|
|
2319
|
+
variant: "primary",
|
|
2320
|
+
size: "sm",
|
|
2321
|
+
loading: updateUpdating,
|
|
2322
|
+
onClick: function () { doUpdatePlugin(); },
|
|
2323
|
+
}, updateUpdating ? L.updating : L.updateNow)
|
|
2324
|
+
)
|
|
2325
|
+
) : null,
|
|
2326
|
+
renderSwitch(L.autoCheckUpdate, autoCheckOn, function (v) {
|
|
2327
|
+
setAutoCheckOn(v);
|
|
2328
|
+
setBool("dsh-easyrewrite:autoCheckUpdate", v);
|
|
2329
|
+
}),
|
|
2437
2330
|
),
|
|
2438
|
-
|
|
2331
|
+
|
|
2332
|
+
React.createElement("span", { key: "instant-hint", className: "dsp-field-hint" }, L.instant),
|
|
2333
|
+
];
|
|
2334
|
+
|
|
2335
|
+
return React.createElement(
|
|
2336
|
+
UI.SettingsCard,
|
|
2337
|
+
{
|
|
2338
|
+
title: L.title,
|
|
2339
|
+
description: L.subtitle,
|
|
2340
|
+
},
|
|
2341
|
+
children,
|
|
2439
2342
|
);
|
|
2440
2343
|
}
|
|
2441
2344
|
|
|
@@ -2498,20 +2401,19 @@ window.__ModuleLoader__.load({
|
|
|
2498
2401
|
}
|
|
2499
2402
|
|
|
2500
2403
|
/** 极限场景重置(首条消息/截断会话首条,无前置闭合边界,无法 fork):
|
|
2501
|
-
*
|
|
2502
|
-
*
|
|
2503
|
-
* - 全新会话首条(无家族):归档当前 → 回到空白新对话(官方 project() 检测归档即回 hero)。
|
|
2404
|
+
* 归档当前会话 → 在所属工作区打开空白新会话;编辑模式经 resume 机制把修改后的文本
|
|
2405
|
+
* 作为新会话的**第一条**自动发出(DESIGN §2.3:目标消息之前没有历史,新对话即修改稿本身)。
|
|
2504
2406
|
* @param mode - "recall" | "edit"
|
|
2505
2407
|
* @param text - edit 模式的修改后文本
|
|
2506
2408
|
* @param props - 组件 inject 面
|
|
2507
2409
|
*/
|
|
2508
2410
|
function resetConversation(sessionId, mode, text, props, imageIds, selOverride, stagedDraft) {
|
|
2509
2411
|
log("info", "reset", "首条消息重置对话", { sessionId: sessionId, mode: mode });
|
|
2510
|
-
// v2.1.1
|
|
2412
|
+
// v2.1.1:新会话发送前需要恢复当前模型/挡位
|
|
2511
2413
|
// v2.2:气泡编辑 chip 的本地选择优先(selOverride),撤回键路径不传 → 原语义
|
|
2512
2414
|
var msel = selOverride || (props.modelSel ? props.modelSel.capture(sessionId) : null);
|
|
2513
2415
|
writePending(sessionId, null);
|
|
2514
|
-
// 1)
|
|
2416
|
+
// 1) 归档当前会话(project() 检测 current 归档 → 自动回 hero;新会话随后被打开)
|
|
2515
2417
|
try {
|
|
2516
2418
|
var archiver = typeof props.archiveSession === "function"
|
|
2517
2419
|
? props.archiveSession
|
|
@@ -2524,26 +2426,10 @@ window.__ModuleLoader__.load({
|
|
|
2524
2426
|
log("warn", "reset", "归档能力不可用", { sessionId: sessionId });
|
|
2525
2427
|
}
|
|
2526
2428
|
} catch (e) { /* ignore */ }
|
|
2527
|
-
// 2)
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
var parentId = fam && fam.versions.length >= 2 && fam.index > 0 ? fam.versions[fam.index - 1] : null;
|
|
2532
|
-
if (parentId) {
|
|
2533
|
-
if (mode === "edit" && typeof text === "string") {
|
|
2534
|
-
try { localStorage.setItem("dsh-easyrewrite:resume-send:" + parentId, JSON.stringify({ draftText: text, t: Date.now(), imageIds: imageIds || [], sel: msel, stagedDraft: stagedDraft || null })); } catch (e) { /* ignore */ }
|
|
2535
|
-
}
|
|
2536
|
-
var doOpenParent = function () {
|
|
2537
|
-
safeOpenSession(parentId, props);
|
|
2538
|
-
};
|
|
2539
|
-
if (typeof props.restoreSession === "function") {
|
|
2540
|
-
try { props.restoreSession(parentId).then(doOpenParent, doOpenParent); return; } catch (e) { /* fallthrough */ }
|
|
2541
|
-
}
|
|
2542
|
-
doOpenParent();
|
|
2543
|
-
return;
|
|
2544
|
-
}
|
|
2545
|
-
} catch (e) { /* ignore */ }
|
|
2546
|
-
// 3) 场景 1:全新会话首条 → 无缝打开空白新会话(编辑模式经 resume 自动发送编辑文本)
|
|
2429
|
+
// 2) 打开空白新会话(编辑模式经 resume 自动发送编辑文本)
|
|
2430
|
+
// 目标消息之前没有任何历史 → 新对话 = 修改后的消息本身(DESIGN §2.3)。
|
|
2431
|
+
// 此前这里先走「家族父版本」分支,把修改后的文本**追加到父版本历史末尾**:
|
|
2432
|
+
// 首条消息的编辑于是变成「整段旧历史 + 修改稿」,与 §2.3 的截断语义相反。
|
|
2547
2433
|
try {
|
|
2548
2434
|
var wsId = null;
|
|
2549
2435
|
if (props.ctxWorkspaces && typeof props.ctxWorkspaces.list === "object" && typeof props.ctxWorkspaces.list.getSnapshot === "function") {
|
|
@@ -2557,7 +2443,7 @@ window.__ModuleLoader__.load({
|
|
|
2557
2443
|
}
|
|
2558
2444
|
}
|
|
2559
2445
|
}
|
|
2560
|
-
log("info", "reset", "
|
|
2446
|
+
log("info", "reset", "空白新会话:工作区定位", { sessionId: sessionId, wsId: wsId, hasConnect: !!(ctxUiWorkspaceRef && typeof ctxUiWorkspaceRef.connectWorkspace === "function") });
|
|
2561
2447
|
var wsConnector = (ctxUiWorkspaceRef && typeof ctxUiWorkspaceRef.connectWorkspace === "function") ? ctxUiWorkspaceRef : ((props.ctxWorkspaces && typeof props.ctxWorkspaces.connectWorkspace === "function") ? props.ctxWorkspaces : null);
|
|
2562
2448
|
if (wsId && wsConnector) {
|
|
2563
2449
|
wsConnector.connectWorkspace(wsId).then(function (newId) {
|
|
@@ -2572,7 +2458,7 @@ window.__ModuleLoader__.load({
|
|
|
2572
2458
|
}
|
|
2573
2459
|
} catch (e) { /* ignore */ }
|
|
2574
2460
|
// 兜底:归档已生效,官方自动回 hero
|
|
2575
|
-
log("
|
|
2461
|
+
log("warn", "reset", "无可用的空白新会话通道(已归档,回 hero)", { sessionId: sessionId, mode: mode, wsId: wsId });
|
|
2576
2462
|
}
|
|
2577
2463
|
|
|
2578
2464
|
/** 版本翻页器 < X >:撤回/编辑重发产生的版本家族切换(官方 assistant-actions 操作区)。
|
|
@@ -4087,7 +3973,10 @@ window.__ModuleLoader__.load({
|
|
|
4087
3973
|
} catch (eDbg) { /* ignore */ }
|
|
4088
3974
|
try { ctxConversationRef = ctx.conversation; } catch (e) { ctxConversationRef = null; }
|
|
4089
3975
|
try { ctxUiConversationRef = (typeof ctx.get === "function") ? (ctx.get("uiConversation") || null) : null; } catch (eUic) { ctxUiConversationRef = null; }
|
|
4090
|
-
|
|
3976
|
+
// 注意:uiWorkspace 不在本插件的 inject 清单内,`ctx.uiWorkspace` 抛错(见下方
|
|
3977
|
+
// invokeOpenSession 的 try/catch);此前把它放在 || 左侧,抛错被 catch 吞掉,导致
|
|
3978
|
+
// ctx.get("uiWorkspace") 永远不可达、ctxUiWorkspaceRef 恒为 null(空白新会话通道自 2.6.0 起失效)。
|
|
3979
|
+
try { ctxUiWorkspaceRef = (typeof ctx.get === "function") ? (ctx.get("uiWorkspace") || null) : null; } catch (eUiw) { ctxUiWorkspaceRef = null; }
|
|
4091
3980
|
function invokeOpenSession(id) {
|
|
4092
3981
|
try {
|
|
4093
3982
|
if (ctx.uiWorkspace && typeof ctx.uiWorkspace.openSession === "function") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logictan/dsh-easyrewrite",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "DSH Web内目前最无感的消息撤回、重编辑插件,原版体验,兼容性强,功能简单可开关,设置丰富,现代化轻量ui框架。The most seamless message recall & re-edit plugin for DSH Web — native experience, strong compatibility, simple toggles, rich settings, modern lightweight UI. DSH Web で最もシームレスなメッセージ撤回・再編集プラグイン——ネイティブ体験、高い互換性、シンプルなトグル、充実した設定、モダンで軽量な UI。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"patch": "./cordis.patch.yml"
|
|
15
15
|
},
|
|
16
16
|
"client": {
|
|
17
|
+
"external": [
|
|
18
|
+
"@logictan/dsh-plugins-shared-client"
|
|
19
|
+
],
|
|
17
20
|
"inject": [
|
|
18
21
|
"slots",
|
|
19
22
|
"sessions",
|
|
@@ -63,9 +66,17 @@
|
|
|
63
66
|
"prepare": "node build.mjs",
|
|
64
67
|
"prepack": "node build.mjs"
|
|
65
68
|
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"@logictan/dsh-plugins-shared-client": "^0.1.0"
|
|
71
|
+
},
|
|
66
72
|
"repository": {
|
|
67
73
|
"type": "git",
|
|
68
74
|
"url": "git+https://github.com/dale0525/dsh-plugins.git",
|
|
69
75
|
"directory": "packages/dsh-easyrewrite"
|
|
76
|
+
},
|
|
77
|
+
"peerDependenciesMeta": {
|
|
78
|
+
"@logictan/dsh-plugins-shared-client": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
70
81
|
}
|
|
71
82
|
}
|