cortico-world-fun 0.7.7 → 0.8.0
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/CHANGELOG.md +37 -0
- package/README.md +28 -28
- package/describe.json +124 -337
- package/dist/webui.js +491 -362
- package/package.json +5 -5
- package/src/ENV_PROMPT.md +15 -14
- package/src/config.js +52 -50
- package/src/definition.js +6 -48
- package/src/state.js +30 -8
- package/src/story-dm.js +63 -32
- package/src/story-examples.js +15 -0
- package/src/story-free.js +88 -22
- package/src/story-library.js +355 -316
- package/src/story-packs.js +753 -745
- package/src/story-panel.js +11 -4
- package/src/story-read.js +4 -4
- package/src/story-reliability.js +19 -3
- package/src/story-secrets.js +29 -0
- package/src/world.js +568 -511
- package/src/aquarium.js +0 -27
- package/src/branches.js +0 -62
- package/src/choices.js +0 -54
package/dist/webui.js
CHANGED
|
@@ -27,22 +27,36 @@ var ZH = {
|
|
|
27
27
|
storyGroupOptional: "可选设置",
|
|
28
28
|
settingsTab: "设置",
|
|
29
29
|
settingsTitle: "高级设置",
|
|
30
|
-
settingsIntro: "
|
|
31
|
-
settingsPartElsewhere: "
|
|
32
|
-
settingsElsewhereTitle: "
|
|
33
|
-
settingsWhereLength: "
|
|
30
|
+
settingsIntro: "主持方式和剧情图片来源在这里选择。宿主默认模式不会加载或显示外接密钥;外接接口与本机 ComfyUI 的设置仅在对应模式展开。",
|
|
31
|
+
settingsPartElsewhere: "其他高级选项",
|
|
32
|
+
settingsElsewhereTitle: "更多故事设置",
|
|
33
|
+
settingsWhereLength: "故事长度、文字通道、作者工具与自动游玩上限可在「配置 → 从0开始的肥鱼大冒险」的高级项调整。",
|
|
34
34
|
settingsWhereArtwork: "本地插画:「地点册 → 本地插画」;换浏览器或清缓存会没有,重新导入即可。",
|
|
35
|
-
settingsElsewhereNote: "
|
|
35
|
+
settingsElsewhereNote: "标有「高级」的配置项仍在配置页;地点、住所与画风:「地点册」;场所与故事分支:「故事工坊」。",
|
|
36
36
|
settingsKeyTitle: "文本主持密钥",
|
|
37
|
-
settingsKeySummary: "
|
|
38
|
-
settingsKeyHint: "
|
|
37
|
+
settingsKeySummary: "仅外接接口模式使用;API Key 只存本机 DPAPI 密文。",
|
|
38
|
+
settingsKeyHint: "地址与模型名按你的兼容接口填写;API Key 不写入配置或故事数据,只存本机 DPAPI 密文。切换到宿主默认后,本机密钥不会被读取。",
|
|
39
|
+
settingsDmMode: "主持方式",
|
|
40
|
+
settingsDmHost: "宿主默认(推荐)",
|
|
41
|
+
settingsDmExternal: "外接接口",
|
|
42
|
+
settingsDmUrl: "接口地址(HTTP(S))",
|
|
43
|
+
settingsDmModel: "模型名(可留空)",
|
|
44
|
+
settingsDmTest: "测试连接",
|
|
45
|
+
settingsDmTesting: "正在测试外接接口…",
|
|
46
|
+
settingsDmTestSuccess: "外接接口连接成功。",
|
|
47
|
+
settingsDmTestFailure: "外接接口测试失败;请检查设置后重试。",
|
|
48
|
+
settingsImageMode: "剧情图片来源",
|
|
49
|
+
settingsImageSourceOff: "关闭",
|
|
50
|
+
settingsImageSourceDelegate: "委派给生图工作室",
|
|
51
|
+
settingsImageSourceDirect: "本机 ComfyUI 直连",
|
|
52
|
+
settingsImageUrl: "ComfyUI loopback 根地址",
|
|
39
53
|
settingsImageManualTitle: "直连出图",
|
|
40
54
|
settingsImageManualSummary: "只在图片来源是本机 ComfyUI 时出现。",
|
|
41
55
|
settingsImageManualHint: "手动生成当前场景的一张图。委派来源不需要这一块:自动准备配图就够了。",
|
|
42
56
|
storyImageManual: "生成当前场景图片",
|
|
43
57
|
settingsAutoImage: "自动配图",
|
|
44
58
|
settingsAutoImageHint: "出游中、且总闸开着,才会自动准备委派参数。",
|
|
45
|
-
settingsAutoImageMasterOff: "
|
|
59
|
+
settingsAutoImageMasterOff: "剧情图片已关闭:在「剧情图片来源」中选择委派或本机直连即可开启。",
|
|
46
60
|
settingsAutoImageNoTrip: "有进行中的行程时才能自动准备配图。",
|
|
47
61
|
settingsAutoImageOn: "自动配图已打开:每到新的一处会准备参数。",
|
|
48
62
|
settingsAutoImageOff: "自动配图已关闭。",
|
|
@@ -56,8 +70,8 @@ var ZH = {
|
|
|
56
70
|
storyDmApiUnset: "未设置",
|
|
57
71
|
storyDmApiPending: "已输入,尚未保存",
|
|
58
72
|
storyDmApiClear: "清除密钥",
|
|
59
|
-
storyDmApiHint: "使用 OpenAI 兼容 POST /chat/completions。密钥只在本机用 Windows DPAPI CurrentUser
|
|
60
|
-
storyDmApiUnsupported: "此机器不支持私密密钥存储;当前仅 Windows 支持本机 DPAPI
|
|
73
|
+
storyDmApiHint: "使用 OpenAI 兼容 POST /chat/completions。密钥只在本机用 Windows DPAPI CurrentUser 加密保存,不交给宿主或其他插件,也不写进普通配置。换机器或重装需重填,随时可以清除。主持超时或失败会回退宿主一次并明确提示,手动游玩始终可用。",
|
|
74
|
+
storyDmApiUnsupported: "此机器不支持私密密钥存储;当前仅 Windows 支持本机 DPAPI 加密。可以切回宿主默认主持。",
|
|
61
75
|
storyImageTitle: "剧情图片生成",
|
|
62
76
|
storyImageWorkflowTitle: "自定义工作流(可选)",
|
|
63
77
|
storyImageWorkflowLabel: "工作流 JSON(留空用内置)",
|
|
@@ -90,8 +104,9 @@ var ZH = {
|
|
|
90
104
|
settingsClearFailure: "清除未获确认;请重试或读取设置核对。",
|
|
91
105
|
settingsDraft: "有未保存的设置输入",
|
|
92
106
|
settingsPartialDm: "密钥已保存,但自定义工作流没保存;请重试工作流,密钥不用重填。",
|
|
107
|
+
storyTitle: "故事手账",
|
|
93
108
|
storyCatalogTitle: "地点与故事",
|
|
94
|
-
storyCatalogIntro: "
|
|
109
|
+
storyCatalogIntro: "挑一张卡开始自由故事,或写下自己的开场。",
|
|
95
110
|
storyAuthorHint: "地点册管理住所、画风与封面;去哪儿管理可玩区域;这里的「编写故事」管理自己的故事包。",
|
|
96
111
|
storyEnabled: "已启用故事",
|
|
97
112
|
storyCustom: "自定义故事",
|
|
@@ -128,22 +143,36 @@ var EN = {
|
|
|
128
143
|
storyGroupOptional: "Optional settings",
|
|
129
144
|
settingsTab: "Settings",
|
|
130
145
|
settingsTitle: "Advanced settings",
|
|
131
|
-
settingsIntro: "
|
|
132
|
-
settingsPartElsewhere: "
|
|
133
|
-
settingsElsewhereTitle: "
|
|
134
|
-
settingsWhereLength: "Story length,
|
|
146
|
+
settingsIntro: "Choose the DM and story-image source here. Host default mode neither loads nor shows external credentials; external DM and local ComfyUI controls appear only in their selected modes.",
|
|
147
|
+
settingsPartElsewhere: "Other advanced options",
|
|
148
|
+
settingsElsewhereTitle: "More story settings",
|
|
149
|
+
settingsWhereLength: "Story length, text tools, author controls and autoplay limits are under Advanced in Configuration → Adventures of Fat Fish from Scratch.",
|
|
135
150
|
settingsWhereArtwork: "Local artwork: Place Book → Local artwork. It lives in this browser, so clearing site data removes it — import again.",
|
|
136
|
-
settingsElsewhereNote: "
|
|
151
|
+
settingsElsewhereNote: "Configuration items prefixed “Advanced” remain in the configuration page; places, home and style: Place Book; venues and story branches: Story Workshop.",
|
|
137
152
|
settingsKeyTitle: "Text DM key",
|
|
138
|
-
settingsKeySummary: "
|
|
139
|
-
settingsKeyHint: "
|
|
153
|
+
settingsKeySummary: "Used only for external DM; the API key is encrypted locally with DPAPI.",
|
|
154
|
+
settingsKeyHint: "Enter the endpoint and model for your compatible API. The API key never enters configuration or story data; only local DPAPI ciphertext is stored. Host-default mode does not read this key.",
|
|
155
|
+
settingsDmMode: "DM mode",
|
|
156
|
+
settingsDmHost: "Host default (recommended)",
|
|
157
|
+
settingsDmExternal: "External endpoint",
|
|
158
|
+
settingsDmUrl: "Endpoint URL (HTTP(S))",
|
|
159
|
+
settingsDmModel: "Model name (optional)",
|
|
160
|
+
settingsDmTest: "Test connection",
|
|
161
|
+
settingsDmTesting: "Testing external endpoint…",
|
|
162
|
+
settingsDmTestSuccess: "External endpoint connected.",
|
|
163
|
+
settingsDmTestFailure: "External endpoint test failed. Check the settings and retry.",
|
|
164
|
+
settingsImageMode: "Story image source",
|
|
165
|
+
settingsImageSourceOff: "Off",
|
|
166
|
+
settingsImageSourceDelegate: "Delegate to Image Studio",
|
|
167
|
+
settingsImageSourceDirect: "Direct local ComfyUI",
|
|
168
|
+
settingsImageUrl: "ComfyUI loopback root URL",
|
|
140
169
|
settingsImageManualTitle: "Direct image generation",
|
|
141
170
|
settingsImageManualSummary: "Only shown when the image source is local ComfyUI.",
|
|
142
171
|
settingsImageManualHint: "Generate one image for the current scene by hand. Delegation sources do not need this — automatic preparation is enough.",
|
|
143
172
|
storyImageManual: "Generate current scene image",
|
|
144
173
|
settingsAutoImage: "Auto images",
|
|
145
174
|
settingsAutoImageHint: "Parameters are prepared automatically only during a trip and with the master switch on.",
|
|
146
|
-
settingsAutoImageMasterOff: "
|
|
175
|
+
settingsAutoImageMasterOff: "Story images are off. Choose delegation or direct local generation under “Story image source” to turn them on.",
|
|
147
176
|
settingsAutoImageNoTrip: "Automatic preparation needs a trip in progress.",
|
|
148
177
|
settingsAutoImageOn: "Auto images on: parameters are prepared at each new spot.",
|
|
149
178
|
settingsAutoImageOff: "Auto images off.",
|
|
@@ -157,8 +186,8 @@ var EN = {
|
|
|
157
186
|
storyDmApiUnset: "Not set",
|
|
158
187
|
storyDmApiPending: "Entered, not saved",
|
|
159
188
|
storyDmApiClear: "Clear key",
|
|
160
|
-
storyDmApiHint: "Uses OpenAI-compatible POST /chat/completions. The key is encrypted on this machine with Windows DPAPI CurrentUser, never sent to the host or other plugins, and never written into ordinary configuration.
|
|
161
|
-
storyDmApiUnsupported: "Private key storage is unavailable on this machine; local DPAPI encryption currently requires Windows.
|
|
189
|
+
storyDmApiHint: "Uses OpenAI-compatible POST /chat/completions. The key is encrypted on this machine with Windows DPAPI CurrentUser, never sent to the host or other plugins, and never written into ordinary configuration. Re-enter after moving machines or reinstalling, and clear it at any time. External failures fall back to the host once with a visible notice; manual play remains available.",
|
|
190
|
+
storyDmApiUnsupported: "Private key storage is unavailable on this machine; local DPAPI encryption currently requires Windows. You can switch back to host-default DM.",
|
|
162
191
|
storyImageTitle: "Story image generation",
|
|
163
192
|
storyImageWorkflowTitle: "Custom workflow (optional)",
|
|
164
193
|
storyImageWorkflowLabel: "Workflow JSON (blank uses the built-in one)",
|
|
@@ -191,8 +220,9 @@ var EN = {
|
|
|
191
220
|
settingsClearFailure: "Key removal was not confirmed. Retry or read settings to check.",
|
|
192
221
|
settingsDraft: "Unsaved settings input",
|
|
193
222
|
settingsPartialDm: "The key was saved, but the custom workflow was not. Retry the workflow; the key need not be re-entered.",
|
|
223
|
+
storyTitle: "Story Journal",
|
|
194
224
|
storyCatalogTitle: "Places and stories",
|
|
195
|
-
storyCatalogIntro: "
|
|
225
|
+
storyCatalogIntro: "Pick a free-form story or write an opening of your own.",
|
|
196
226
|
storyAuthorHint: "The location book manages homes, art styles and covers; Places manages playable areas. “Write a story” here manages your own story packs.",
|
|
197
227
|
storyEnabled: "Enabled story",
|
|
198
228
|
storyCustom: "Custom story",
|
|
@@ -383,6 +413,11 @@ var CSS = `
|
|
|
383
413
|
.fun-story-file-note{margin:0;font-size:11.5px;color:var(--fs-dim)}
|
|
384
414
|
.fun-story-file-note[data-state=ok]{color:var(--fs-accent)}
|
|
385
415
|
.fun-story-file-note[data-state=error]{color:var(--fs-error)}
|
|
416
|
+
/* 地点编号对不上时的就地改绑(导入失败与作品卡共用) */
|
|
417
|
+
.fun-story-bind{margin:8px 0;padding:8px 10px;border:1px dashed var(--fs-line);border-radius:10px;background:color-mix(in srgb,var(--fs-accent) 5%,var(--fs-card))}
|
|
418
|
+
.fun-story-bind>.fun-story-note{margin:0 0 4px}
|
|
419
|
+
.fun-story-bind .fun-story-row{margin:0}
|
|
420
|
+
.fun-story-bind .fun-story-bind-place{max-width:100%}
|
|
386
421
|
@media(max-width:520px){.fun-story-group-content{padding-inline:9px}.fun-story-sticky-actions{bottom:4px;padding:8px}.fun-story-sticky-actions .fun-story-row{align-items:stretch}.fun-story-sticky-actions .fun-story-row>button{flex:1}.fun-story-sticky-actions .fun-story-sticky-status{width:100%;margin:0;text-align:center}}
|
|
387
422
|
/* 作品库:一个创建入口 + 作品卡;去掉右栏,正文收窄到 1040 居中 */
|
|
388
423
|
.fun-story-head{display:flex;justify-content:space-between;align-items:flex-start;gap:14px 18px;flex-wrap:wrap;padding-bottom:14px;margin-bottom:18px;border-bottom:1px solid var(--fs-line)}
|
|
@@ -1051,10 +1086,34 @@ function mountStories(ctx) {
|
|
|
1051
1086
|
const overwrite = el("input", { type: "checkbox", class: "fun-story-overwrite" });
|
|
1052
1087
|
const editorReport = feedback2();
|
|
1053
1088
|
const editorResult = el("div", { class: "fun-story-result" });
|
|
1089
|
+
const importBind = el("div", { class: "fun-story-bind fun-story-bind-import", hidden: true });
|
|
1090
|
+
let bindTarget = "";
|
|
1091
|
+
function hideImportBind() {
|
|
1092
|
+
importBind.hidden = true;
|
|
1093
|
+
importBind.replaceChildren();
|
|
1094
|
+
bindTarget = "";
|
|
1095
|
+
}
|
|
1096
|
+
function showImportBind(placeId) {
|
|
1097
|
+
const venues = lastData?.places ?? [];
|
|
1098
|
+
if (!venues.length) return;
|
|
1099
|
+
const select = el("select", { class: "fun-story-bind-place", "aria-label": "导入时绑定到的地点" });
|
|
1100
|
+
select.appendChild(el("option", { value: "" }, "选择要绑定到的地点"));
|
|
1101
|
+
for (const venue of venues) select.appendChild(el("option", { value: venue.id }, `${venue.name || venue.id} · ${venue.id}`));
|
|
1102
|
+
select.value = venues.some((venue) => venue.id === bindTarget) ? bindTarget : "";
|
|
1103
|
+
select.addEventListener("change", () => {
|
|
1104
|
+
bindTarget = select.value;
|
|
1105
|
+
});
|
|
1106
|
+
importBind.replaceChildren(
|
|
1107
|
+
el("p", { class: "fun-story-note" }, `包里写的地点编号「${placeId}」在地点册里没有。选一处现有地点,再点「导入故事包」,这次会直接把包绑过去。`),
|
|
1108
|
+
el("div", { class: "fun-story-row" }, select)
|
|
1109
|
+
);
|
|
1110
|
+
importBind.hidden = false;
|
|
1111
|
+
}
|
|
1054
1112
|
draft.addEventListener("input", () => {
|
|
1055
1113
|
draftEdits += 1;
|
|
1056
1114
|
if (!busy) editorReport.set();
|
|
1057
1115
|
editorResult.replaceChildren();
|
|
1116
|
+
hideImportBind();
|
|
1058
1117
|
updateDirty();
|
|
1059
1118
|
});
|
|
1060
1119
|
const editingLabel = el("p", { class: "fun-story-note fun-story-editing", role: "status" });
|
|
@@ -1081,7 +1140,10 @@ function mountStories(ctx) {
|
|
|
1081
1140
|
const edits = draftEdits;
|
|
1082
1141
|
const placeId = place.value;
|
|
1083
1142
|
const args = method === "template" ? placeId ? { placeId } : {} : { json };
|
|
1084
|
-
if (method === "import"
|
|
1143
|
+
if (method === "import") {
|
|
1144
|
+
if (overwrite.checked) args.replace = true;
|
|
1145
|
+
if (bindTarget) args.bindPlaceId = bindTarget;
|
|
1146
|
+
}
|
|
1085
1147
|
editorResult.replaceChildren();
|
|
1086
1148
|
void run(editorReport, pending, method, args, async (result) => {
|
|
1087
1149
|
const changed = draftEdits !== edits || draft.value !== json;
|
|
@@ -1102,13 +1164,17 @@ function mountStories(ctx) {
|
|
|
1102
1164
|
}
|
|
1103
1165
|
editorReport.set(result.ok ? changed || draft.value !== result.json ? "草稿已修改,保留当前内容。" : "模板已填入。" : "", result);
|
|
1104
1166
|
} else if (method === "validate") {
|
|
1105
|
-
editorReport.set(previous + (result.ok ? "校验通过。" : "校验未通过。"), result);
|
|
1167
|
+
editorReport.set(previous + (result.ok ? result.placeMissing ? "结构校验通过,但包里的地点在本地没有。" : "校验通过。" : "校验未通过。"), result);
|
|
1168
|
+
if (result.ok && result.placeMissing) showImportBind(result.pack?.placeId ?? "");
|
|
1106
1169
|
} else if (method === "preview") {
|
|
1107
1170
|
editorReport.set(previous + (result.ok ? "只读预览已生成。" : "预览失败。"), result);
|
|
1108
1171
|
if (result.ok) editorResult.appendChild(previewGraph(result));
|
|
1172
|
+
if (result.ok && result.placeMissing) showImportBind(result.placeId ?? "");
|
|
1109
1173
|
} else {
|
|
1110
1174
|
editorReport.set(previous + (result.ok ? `已导入${result.id ? ` · ${result.id}` : ""}。` : "导入失败。"), result);
|
|
1175
|
+
if (!result.ok && result.placeMissing) showImportBind(result.placeId ?? "");
|
|
1111
1176
|
if (result.ok) {
|
|
1177
|
+
hideImportBind();
|
|
1112
1178
|
if (!changed) jsonBaseline = json;
|
|
1113
1179
|
overwrite.checked = false;
|
|
1114
1180
|
updateDirty();
|
|
@@ -1253,6 +1319,7 @@ function mountStories(ctx) {
|
|
|
1253
1319
|
editAction("导入故事包", "import", "正在导入…"),
|
|
1254
1320
|
el("label", { class: "fun-story-field" }, overwrite, "覆盖同 ID 故事包")
|
|
1255
1321
|
),
|
|
1322
|
+
importBind,
|
|
1256
1323
|
editorReport.node,
|
|
1257
1324
|
editorResult
|
|
1258
1325
|
);
|
|
@@ -1363,6 +1430,31 @@ function mountStories(ctx) {
|
|
|
1363
1430
|
cancel.focus();
|
|
1364
1431
|
}, "fun-story-danger");
|
|
1365
1432
|
const warnings = pack.warnings?.length ? pack.warnings : pack.available === false ? ["绑定地点或区域当前不匹配。"] : [];
|
|
1433
|
+
const placeBind = pack.placeMissing ? (() => {
|
|
1434
|
+
const venues = lastData?.places ?? [];
|
|
1435
|
+
const select = el("select", { class: "fun-story-bind-place", "aria-label": `把「${title}」绑定到的地点` });
|
|
1436
|
+
select.appendChild(el("option", { value: "" }, "选择要绑定到的地点"));
|
|
1437
|
+
for (const venue of venues) select.appendChild(el("option", { value: venue.id }, `${venue.name || venue.id} · ${venue.id}`));
|
|
1438
|
+
const apply = pack.builtin ? null : packAction("绑定到此处", "bind", () => {
|
|
1439
|
+
if (!select.value) {
|
|
1440
|
+
report.set("先在下拉里选一处地点。");
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
const target = select.value;
|
|
1444
|
+
void run(report, "正在绑定…", "rebind", { id: pack.id, placeId: target }, async (result) => {
|
|
1445
|
+
report.set("", result);
|
|
1446
|
+
if (!result.ok) return;
|
|
1447
|
+
libraryReport.set(result.message || "已绑定。", result);
|
|
1448
|
+
await load();
|
|
1449
|
+
});
|
|
1450
|
+
});
|
|
1451
|
+
return el(
|
|
1452
|
+
"div",
|
|
1453
|
+
{ class: "fun-story-bind" },
|
|
1454
|
+
el("p", { class: "fun-story-note" }, `包里写的地点编号是「${pack.placeId}」,本地没有这处。`),
|
|
1455
|
+
apply && venues.length ? el("div", { class: "fun-story-row" }, select, apply) : null
|
|
1456
|
+
);
|
|
1457
|
+
})() : null;
|
|
1366
1458
|
const cover = el("div", { class: "fun-story-cover", "aria-hidden": "true" });
|
|
1367
1459
|
cover.innerHTML = venueArtwork(pack.placeId || "");
|
|
1368
1460
|
const body = el(
|
|
@@ -1380,6 +1472,7 @@ function mountStories(ctx) {
|
|
|
1380
1472
|
metadata ? el("p", { class: "fun-story-note" }, `作者:${metadata.author} · 类型:${metadata.genre} · ${metadata.participation === "duo" ? "双人" : "单人"} · 时长:${durationLabel}`) : el("p", { class: "fun-story-note" }, `时长未知 · ${pack.nodeCount} 个节点不用于估算时长`),
|
|
1381
1473
|
pack.description ? el("p", {}, pack.description) : null,
|
|
1382
1474
|
warnings.length ? el("div", { class: "fun-story-note" }, messageList(warnings)) : null,
|
|
1475
|
+
placeBind,
|
|
1383
1476
|
el(
|
|
1384
1477
|
"div",
|
|
1385
1478
|
{ class: "fun-story-row" },
|
|
@@ -1884,7 +1977,7 @@ function createStoryController(ctx, onChange = () => {
|
|
|
1884
1977
|
}
|
|
1885
1978
|
++requestVersion;
|
|
1886
1979
|
apply(snapshot);
|
|
1887
|
-
state.notice = method === "close" ? "这趟经历已收进回忆。" : "";
|
|
1980
|
+
state.notice = method === "close" ? "这趟经历已收进回忆。" : snapshot.lastSay?.note ?? "";
|
|
1888
1981
|
maybeResume();
|
|
1889
1982
|
} catch (error) {
|
|
1890
1983
|
if (alive()) await recover(error);
|
|
@@ -2304,7 +2397,8 @@ function mountPanel(root, ctx) {
|
|
|
2304
2397
|
navigate("author");
|
|
2305
2398
|
if (expand) authorPanel?.expand();
|
|
2306
2399
|
}
|
|
2307
|
-
let view = "
|
|
2400
|
+
let view = "stories";
|
|
2401
|
+
let freeNoticeAcknowledged = false;
|
|
2308
2402
|
let memoryFilter = "all";
|
|
2309
2403
|
let autoPreset = true;
|
|
2310
2404
|
let immersive = false;
|
|
@@ -2525,6 +2619,9 @@ function mountPanel(root, ctx) {
|
|
|
2525
2619
|
function stories(state) {
|
|
2526
2620
|
const snapshot = state.snapshot;
|
|
2527
2621
|
const all = list(snapshot.catalog);
|
|
2622
|
+
const freeStories = all.filter((story) => story.mode === "free" || story.formatVersion === 3);
|
|
2623
|
+
const featured = freeStories.slice(0, 4);
|
|
2624
|
+
const more = [...freeStories.slice(4), ...all.filter((story) => !freeStories.includes(story))];
|
|
2528
2625
|
const intro = node("div", { class: "sw-lead" }, node("h2", {}, t.storyCatalogTitle), node("p", {}, t.storyCatalogIntro));
|
|
2529
2626
|
const preset = node(
|
|
2530
2627
|
"section",
|
|
@@ -2549,21 +2646,88 @@ function mountPanel(root, ctx) {
|
|
|
2549
2646
|
),
|
|
2550
2647
|
note(snapshot.autonomy.available ? "可以随时接管。关闭窗口、切走页面或遇到错误时会暂停。" : text(snapshot.autonomy.reason, "自主游玩暂不可用,手动玩法不受影响。"))
|
|
2551
2648
|
);
|
|
2649
|
+
const freeNotice = snapshot.showFreeDefault && !freeNoticeAcknowledged ? node(
|
|
2650
|
+
"div",
|
|
2651
|
+
{ class: "sw-notice", role: "status" },
|
|
2652
|
+
note("自由故事已默认开启,可在高级里关掉。"),
|
|
2653
|
+
button("知道了", async () => {
|
|
2654
|
+
try {
|
|
2655
|
+
const result = await ownCall("ackFreeDefault", {});
|
|
2656
|
+
if (!result?.ok) throw new Error(result?.error || "没有保存提示状态。");
|
|
2657
|
+
freeNoticeAcknowledged = true;
|
|
2658
|
+
} catch (error) {
|
|
2659
|
+
localError = error.message;
|
|
2660
|
+
}
|
|
2661
|
+
render();
|
|
2662
|
+
}, { small: true })
|
|
2663
|
+
) : null;
|
|
2552
2664
|
return node(
|
|
2553
2665
|
"div",
|
|
2554
2666
|
{ class: "sw-stack" },
|
|
2555
2667
|
intro,
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
node("
|
|
2563
|
-
|
|
2668
|
+
featured.length ? node("div", { class: "sw-story-grid", "aria-label": "自由故事" }, featured.map((story) => storyCard(story, state))) : !more.length ? empty(t.storyEmptyTitle, t.storyEmptyBody) : null,
|
|
2669
|
+
freeNotice,
|
|
2670
|
+
snapshot.trip ? button("继续这趟故事", () => navigate("play"), { primary: true, key: "stories-continue" }) : null,
|
|
2671
|
+
partyEditor(snapshot),
|
|
2672
|
+
more.length ? trackedDetails(
|
|
2673
|
+
"more-stories",
|
|
2674
|
+
node("summary", {}, "更多故事"),
|
|
2675
|
+
preset,
|
|
2676
|
+
node("div", { class: "sw-story-grid" }, more.map((story) => storyCard(story, state)))
|
|
2677
|
+
) : null,
|
|
2678
|
+
trackedDetails(
|
|
2679
|
+
"story-authoring",
|
|
2680
|
+
node("summary", {}, t.storyWrite),
|
|
2681
|
+
note(t.storyAuthorHint),
|
|
2682
|
+
button(t.storyWrite, () => openAuthor(true), { size: "small", key: "stories-write" })
|
|
2564
2683
|
)
|
|
2565
2684
|
);
|
|
2566
2685
|
}
|
|
2686
|
+
function partyEditor(snapshot) {
|
|
2687
|
+
const input = node("textarea", { class: "sw-free-input", rows: "4", maxlength: "3000", "aria-label": "常驻小队名单" });
|
|
2688
|
+
input.value = list(snapshot.savedParty).map(({ who, tag }) => tag ? who + "|" + tag : who).join("\n");
|
|
2689
|
+
return trackedDetails(
|
|
2690
|
+
"story-party",
|
|
2691
|
+
node("summary", {}, "常驻小队"),
|
|
2692
|
+
note("每行一位:昵称|人设标签。改名单只影响下一次开局。"),
|
|
2693
|
+
input,
|
|
2694
|
+
button("保存小队", async () => {
|
|
2695
|
+
const party = input.value.split(/\r?\n/).map((line2) => {
|
|
2696
|
+
const [who, ...tags] = line2.split("|");
|
|
2697
|
+
return { who: who.trim(), tag: tags.join("|").trim() };
|
|
2698
|
+
}).filter(({ who }) => who);
|
|
2699
|
+
try {
|
|
2700
|
+
const result = await ownCall("saveParty", { party });
|
|
2701
|
+
if (!result?.ok) throw new Error(result?.error || "没有保存小队。");
|
|
2702
|
+
localError = "";
|
|
2703
|
+
localNotice = "常驻小队已保存。";
|
|
2704
|
+
await controller.refresh();
|
|
2705
|
+
} catch (error) {
|
|
2706
|
+
localError = error.message;
|
|
2707
|
+
render();
|
|
2708
|
+
}
|
|
2709
|
+
}, { key: "save-party", small: true })
|
|
2710
|
+
);
|
|
2711
|
+
}
|
|
2712
|
+
function freeLogEntry(entry) {
|
|
2713
|
+
return node(
|
|
2714
|
+
"li",
|
|
2715
|
+
{},
|
|
2716
|
+
node("small", {}, text(entry.who || entry.from, "这一回合")),
|
|
2717
|
+
list(entry.actions).length ? list(entry.actions).map(({ who, say }) => node("p", { class: "sw-free-say" }, who + ":" + say)) : entry.say ? node("p", { class: "sw-free-say" }, "「" + entry.say + "」") : null,
|
|
2718
|
+
node("p", { class: "sw-prose" }, text(entry.narration)),
|
|
2719
|
+
entry.unstructured ? note("本回合由纯文本接住。") : null
|
|
2720
|
+
);
|
|
2721
|
+
}
|
|
2722
|
+
function freeRedoButton(state, input, free, current) {
|
|
2723
|
+
if (!(Number(free.turn) > 0)) return null;
|
|
2724
|
+
return button("补充并重跑", async () => {
|
|
2725
|
+
const say = input.value.trim();
|
|
2726
|
+
if (!say || !canAct(state)) return;
|
|
2727
|
+
const confirmed = await askConfirm("补充并重跑?", "主持成功后,这份新输入会替代上一回合。已经花掉的模型调用不退。");
|
|
2728
|
+
if (confirmed && !disposed) await controller.mutate("say", { intent: "redo", say });
|
|
2729
|
+
}, { small: true, key: "free-redo", disabled: !canAct(state) || current.state === "draft" || Boolean(current.blocked) });
|
|
2730
|
+
}
|
|
2567
2731
|
function play(state) {
|
|
2568
2732
|
const current = state.snapshot?.trip;
|
|
2569
2733
|
if (!current) return empty("故事还没有开始", "先选一篇故事,确认后再出发。已结束的行程可以在回忆里翻看。", button("去看看故事", () => navigate("stories"), { primary: true, icon: "arrow", key: "empty-play" }));
|
|
@@ -2759,22 +2923,15 @@ function mountPanel(root, ctx) {
|
|
|
2759
2923
|
const reading = node("div", { class: "sw-reading", "data-focus": "play-reading" });
|
|
2760
2924
|
if (free.summary) reading.append(note(`到目前为止:${free.summary}`));
|
|
2761
2925
|
const log = list(free.log);
|
|
2762
|
-
if (!log.length) reading.append(node("p", { class: "sw-prose" }, "开场已经在那里了。说一句想做的事,故事就会往下走。"));
|
|
2926
|
+
if (!log.length) reading.append(node("p", { class: "sw-prose" }, text(current.opening, "开场已经在那里了。说一句想做的事,故事就会往下走。")));
|
|
2763
2927
|
else {
|
|
2764
|
-
const render2 = (entry) => node(
|
|
2765
|
-
"li",
|
|
2766
|
-
{},
|
|
2767
|
-
node("small", {}, text(entry.from, "这一回合")),
|
|
2768
|
-
entry.say ? node("p", { class: "sw-free-say" }, `「${text(entry.say)}」`) : null,
|
|
2769
|
-
node("p", { class: "sw-prose" }, text(entry.narration))
|
|
2770
|
-
);
|
|
2771
2928
|
const earlier = log.slice(0, -6);
|
|
2772
2929
|
if (earlier.length) reading.append(trackedDetails(
|
|
2773
2930
|
"free-earlier",
|
|
2774
2931
|
node("summary", {}, `更早的 ${earlier.length} 回合`),
|
|
2775
|
-
node("ol", { class: "sw-free-log" }, earlier.map(
|
|
2932
|
+
node("ol", { class: "sw-free-log" }, earlier.map(freeLogEntry))
|
|
2776
2933
|
));
|
|
2777
|
-
reading.append(node("ol", { class: "sw-free-log" }, log.slice(-6).map(
|
|
2934
|
+
reading.append(node("ol", { class: "sw-free-log" }, log.slice(-6).map(freeLogEntry)));
|
|
2778
2935
|
}
|
|
2779
2936
|
const chips = node("div", { class: "sw-story-meta" });
|
|
2780
2937
|
for (const [id, value] of Object.entries(free.facts ?? {})) chips.append(badge(`${id} · ${text(value)}`, true));
|
|
@@ -2783,7 +2940,7 @@ function mountPanel(root, ctx) {
|
|
|
2783
2940
|
if (chips.childNodes.length) reading.append(node("div", { class: "sw-free-state" }, node("div", { class: "sw-kicker" }, "正在起作用的状态"), chips));
|
|
2784
2941
|
if (list(current.blocked).length || current.blocked) reading.append(node("div", { class: "sw-notice sw-notice-error" }, icon("info"), node("p", {}, text(current.blocked))));
|
|
2785
2942
|
left.append(reading);
|
|
2786
|
-
const input = node("textarea", { class: "sw-free-input", rows: "2", placeholder: capped ? "
|
|
2943
|
+
const input = node("textarea", { class: "sw-free-input", rows: "2", maxlength: "1500", placeholder: capped ? "这段有点长了,要不要收进回忆?" : "这一回合你想做什么?", "aria-label": "这一回合做什么", disabled: isDraft || Boolean(current.blocked) });
|
|
2787
2944
|
const send = button("说这一句", async () => {
|
|
2788
2945
|
const say = input.value.trim();
|
|
2789
2946
|
if (!say || !canAct(state)) return;
|
|
@@ -2793,7 +2950,7 @@ function mountPanel(root, ctx) {
|
|
|
2793
2950
|
"div",
|
|
2794
2951
|
{ class: "sw-play-action sw-free-compose" },
|
|
2795
2952
|
input,
|
|
2796
|
-
actionRow(send, free.canContinue ? button(
|
|
2953
|
+
actionRow(send, freeRedoButton(state, input, free, current), free.canContinue ? button(
|
|
2797
2954
|
`再来一段 · 还能 ${text(free.segmentsLeft, 0)} 段`,
|
|
2798
2955
|
() => controller.continueSegment(),
|
|
2799
2956
|
{ primary: true, icon: "arrow", key: "free-segment", disabled: !canAct(state) || state.loading || state.recovering || Boolean(state.busy) }
|
|
@@ -2814,6 +2971,12 @@ function mountPanel(root, ctx) {
|
|
|
2814
2971
|
)
|
|
2815
2972
|
));
|
|
2816
2973
|
const right = node("aside", { class: "sw-stack sw-aside", "aria-label": "自由模式说明" });
|
|
2974
|
+
if (list(current.party).length) right.append(node(
|
|
2975
|
+
"section",
|
|
2976
|
+
{ class: "sw-card sw-card-pad" },
|
|
2977
|
+
node("strong", {}, "本局小队"),
|
|
2978
|
+
node("ul", {}, current.party.map(({ who, tag }) => node("li", {}, tag ? who + " · " + tag : who)))
|
|
2979
|
+
));
|
|
2817
2980
|
right.append(node(
|
|
2818
2981
|
"section",
|
|
2819
2982
|
{ class: "sw-card sw-card-pad" },
|
|
@@ -2967,6 +3130,7 @@ function mountPanel(root, ctx) {
|
|
|
2967
3130
|
node("p", {}, dm.proposal.narration),
|
|
2968
3131
|
node("p", {}, `建议选项:${label2}`)
|
|
2969
3132
|
),
|
|
3133
|
+
dm.proposal.receipt?.message ? node("p", { class: "sw-note sw-dm-receipt", role: "status" }, dm.proposal.receipt.message) : null,
|
|
2970
3134
|
button("明确采用这个选项", () => controller.applyDM(), { small: true, primary: true, disabled: !ownerTurn || isDraft || state.dmBusy || current.step !== "choose", key: "dm-apply" })
|
|
2971
3135
|
);
|
|
2972
3136
|
}
|
|
@@ -3022,7 +3186,8 @@ function mountPanel(root, ctx) {
|
|
|
3022
3186
|
"div",
|
|
3023
3187
|
{ class: "sw-imm-body" },
|
|
3024
3188
|
node("div", { class: "sw-kicker" }, free.ended ? "已收尾" : `第 ${text(free.segment, 1)} 段 · 还剩 ${turnsLeft} 回合`),
|
|
3025
|
-
node("p", { class: "sw-imm-lead" }, text(last?.narration, "开场已经在那里了。说一句想做的事,故事就会往下走。")),
|
|
3189
|
+
node("p", { class: "sw-imm-lead" }, text(last?.narration || current.opening, "开场已经在那里了。说一句想做的事,故事就会往下走。")),
|
|
3190
|
+
last?.unstructured ? note("本回合由纯文本接住。") : null,
|
|
3026
3191
|
last?.say ? node("p", { class: "sw-imm-ask" }, `你刚才说:「${text(last.say)}」`) : null,
|
|
3027
3192
|
free.summary ? note(`到目前为止:${free.summary}`) : null
|
|
3028
3193
|
));
|
|
@@ -3057,13 +3222,7 @@ function mountPanel(root, ctx) {
|
|
|
3057
3222
|
));
|
|
3058
3223
|
if (drawerOpen) {
|
|
3059
3224
|
const body = node("div", { class: "sw-drawer-body" });
|
|
3060
|
-
if (log.length) body.append(node("ol", { class: "sw-free-log" }, log.map(
|
|
3061
|
-
"li",
|
|
3062
|
-
{},
|
|
3063
|
-
node("small", {}, text(entry.from, "这一回合")),
|
|
3064
|
-
entry.say ? node("p", { class: "sw-free-say" }, `「${text(entry.say)}」`) : null,
|
|
3065
|
-
node("p", { class: "sw-prose" }, text(entry.narration))
|
|
3066
|
-
))));
|
|
3225
|
+
if (log.length) body.append(node("ol", { class: "sw-free-log" }, log.map(freeLogEntry)));
|
|
3067
3226
|
else body.append(note("还没有发生的回合。"));
|
|
3068
3227
|
wrap.append(node(
|
|
3069
3228
|
"div",
|
|
@@ -3239,7 +3398,16 @@ function mountPanel(root, ctx) {
|
|
|
3239
3398
|
workflow: "",
|
|
3240
3399
|
workflowTouched: false,
|
|
3241
3400
|
imagesEnabled: false,
|
|
3242
|
-
|
|
3401
|
+
dmEnabled: false,
|
|
3402
|
+
dmUrl: "",
|
|
3403
|
+
dmModel: "",
|
|
3404
|
+
imageMode: "delegate",
|
|
3405
|
+
imageUrl: "",
|
|
3406
|
+
dmModeTouched: false,
|
|
3407
|
+
dmUrlTouched: false,
|
|
3408
|
+
dmModelTouched: false,
|
|
3409
|
+
imageModeTouched: false,
|
|
3410
|
+
imageUrlTouched: false,
|
|
3243
3411
|
apiKey: { value: "", touched: false, revision: 0 }
|
|
3244
3412
|
};
|
|
3245
3413
|
const status = node("p", { class: "sw-note", role: "status", "aria-live": "polite" });
|
|
@@ -3247,6 +3415,76 @@ function mountPanel(root, ctx) {
|
|
|
3247
3415
|
const support = note("");
|
|
3248
3416
|
const saved = node("span", { class: "sw-badge", "data-settings-saved": "" });
|
|
3249
3417
|
const imageBadge = node("span", { class: "sw-badge sw-settings-state", "data-settings-image-state": "" });
|
|
3418
|
+
const dmMode = node(
|
|
3419
|
+
"select",
|
|
3420
|
+
{ "data-focus": "settings-dmMode", "aria-label": t.settingsDmMode },
|
|
3421
|
+
node("option", { value: "host" }, t.settingsDmHost),
|
|
3422
|
+
node("option", { value: "external" }, t.settingsDmExternal)
|
|
3423
|
+
);
|
|
3424
|
+
dmMode.addEventListener("change", () => {
|
|
3425
|
+
model.dmEnabled = dmMode.value === "external";
|
|
3426
|
+
model.dmModeTouched = true;
|
|
3427
|
+
++model.revision;
|
|
3428
|
+
paint();
|
|
3429
|
+
});
|
|
3430
|
+
const dmUrl = node("input", {
|
|
3431
|
+
type: "url",
|
|
3432
|
+
autocomplete: "off",
|
|
3433
|
+
spellcheck: "false",
|
|
3434
|
+
"data-focus": "settings-apiUrl",
|
|
3435
|
+
"aria-label": t.settingsDmUrl
|
|
3436
|
+
});
|
|
3437
|
+
dmUrl.addEventListener("input", () => {
|
|
3438
|
+
model.dmUrl = dmUrl.value;
|
|
3439
|
+
model.dmUrlTouched = true;
|
|
3440
|
+
++model.revision;
|
|
3441
|
+
paint();
|
|
3442
|
+
});
|
|
3443
|
+
const dmModel = node("input", {
|
|
3444
|
+
type: "text",
|
|
3445
|
+
autocomplete: "off",
|
|
3446
|
+
spellcheck: "false",
|
|
3447
|
+
"data-focus": "settings-model",
|
|
3448
|
+
"aria-label": t.settingsDmModel
|
|
3449
|
+
});
|
|
3450
|
+
dmModel.addEventListener("input", () => {
|
|
3451
|
+
model.dmModel = dmModel.value;
|
|
3452
|
+
model.dmModelTouched = true;
|
|
3453
|
+
++model.revision;
|
|
3454
|
+
paint();
|
|
3455
|
+
});
|
|
3456
|
+
const imageMode = node(
|
|
3457
|
+
"select",
|
|
3458
|
+
{ "data-focus": "settings-imageMode", "aria-label": t.settingsImageMode },
|
|
3459
|
+
node("option", { value: "off" }, t.settingsImageSourceOff),
|
|
3460
|
+
node("option", { value: "delegate" }, t.settingsImageSourceDelegate),
|
|
3461
|
+
node("option", { value: "comfyui" }, t.settingsImageSourceDirect)
|
|
3462
|
+
);
|
|
3463
|
+
imageMode.addEventListener("change", () => {
|
|
3464
|
+
model.imageMode = imageMode.value;
|
|
3465
|
+
model.imageModeTouched = true;
|
|
3466
|
+
model.imagesEnabled = model.imageMode !== "off";
|
|
3467
|
+
if (model.imageMode === "comfyui" && !model.imageUrl.trim()) {
|
|
3468
|
+
model.imageUrl = "http://127.0.0.1:8188";
|
|
3469
|
+
imageUrl.value = model.imageUrl;
|
|
3470
|
+
model.imageUrlTouched = true;
|
|
3471
|
+
}
|
|
3472
|
+
++model.revision;
|
|
3473
|
+
paint();
|
|
3474
|
+
});
|
|
3475
|
+
const imageUrl = node("input", {
|
|
3476
|
+
type: "url",
|
|
3477
|
+
autocomplete: "off",
|
|
3478
|
+
spellcheck: "false",
|
|
3479
|
+
"data-focus": "settings-imageUrl",
|
|
3480
|
+
"aria-label": t.settingsImageUrl
|
|
3481
|
+
});
|
|
3482
|
+
imageUrl.addEventListener("input", () => {
|
|
3483
|
+
model.imageUrl = imageUrl.value;
|
|
3484
|
+
model.imageUrlTouched = true;
|
|
3485
|
+
++model.revision;
|
|
3486
|
+
paint();
|
|
3487
|
+
});
|
|
3250
3488
|
const keyInput = node("input", {
|
|
3251
3489
|
type: "password",
|
|
3252
3490
|
autocomplete: "new-password",
|
|
@@ -3295,6 +3533,11 @@ function mountPanel(root, ctx) {
|
|
|
3295
3533
|
const save = button(t.settingsSave, async () => {
|
|
3296
3534
|
if (model.busy) return;
|
|
3297
3535
|
const args = {};
|
|
3536
|
+
if (model.dmModeTouched) args.dmEnabled = model.dmEnabled;
|
|
3537
|
+
if (model.dmUrlTouched) args.apiUrl = model.dmUrl.trim();
|
|
3538
|
+
if (model.dmModelTouched) args.model = model.dmModel.trim();
|
|
3539
|
+
if (model.imageModeTouched) args.imageMode = model.imageMode;
|
|
3540
|
+
if (model.imageUrlTouched || model.imageModeTouched && model.imageMode === "comfyui") args.imageSource = model.imageUrl.trim();
|
|
3298
3541
|
if (model.apiKey.touched) args.apiKey = model.apiKey.value.trim();
|
|
3299
3542
|
if (model.workflowTouched) {
|
|
3300
3543
|
args.workflow = model.workflow.trim();
|
|
@@ -3343,6 +3586,8 @@ function mountPanel(root, ctx) {
|
|
|
3343
3586
|
model.workflowTouched = false;
|
|
3344
3587
|
workflow.value = model.workflow = savedWorkflow;
|
|
3345
3588
|
}
|
|
3589
|
+
model.dmModeTouched = model.dmUrlTouched = model.dmModelTouched = false;
|
|
3590
|
+
model.imageModeTouched = model.imageUrlTouched = false;
|
|
3346
3591
|
status.textContent = t.settingsSaved;
|
|
3347
3592
|
if (revision === model.revision) error.textContent = "";
|
|
3348
3593
|
} catch {
|
|
@@ -3359,6 +3604,19 @@ function mountPanel(root, ctx) {
|
|
|
3359
3604
|
clearPrivate();
|
|
3360
3605
|
model.workflowTouched = false;
|
|
3361
3606
|
workflow.value = model.workflow = savedWorkflow;
|
|
3607
|
+
model.dmEnabled = savedSettings.dmEnabled;
|
|
3608
|
+
model.dmUrl = savedSettings.dmUrl;
|
|
3609
|
+
model.dmModel = savedSettings.dmModel;
|
|
3610
|
+
model.imageMode = savedSettings.imageMode;
|
|
3611
|
+
model.imageUrl = savedSettings.imageUrl;
|
|
3612
|
+
model.imagesEnabled = model.imageMode !== "off";
|
|
3613
|
+
model.dmModeTouched = model.dmUrlTouched = model.dmModelTouched = false;
|
|
3614
|
+
model.imageModeTouched = model.imageUrlTouched = false;
|
|
3615
|
+
dmMode.value = model.dmEnabled ? "external" : "host";
|
|
3616
|
+
dmUrl.value = model.dmUrl;
|
|
3617
|
+
dmModel.value = model.dmModel;
|
|
3618
|
+
imageMode.value = model.imageMode;
|
|
3619
|
+
imageUrl.value = model.imageUrl;
|
|
3362
3620
|
++model.revision;
|
|
3363
3621
|
error.textContent = "";
|
|
3364
3622
|
status.textContent = t.settingsCancelled;
|
|
@@ -3391,15 +3649,79 @@ function mountPanel(root, ctx) {
|
|
|
3391
3649
|
}
|
|
3392
3650
|
}, { danger: true, key: "settings-clear" });
|
|
3393
3651
|
const reload = button(t.settingsReload, () => void load(), { quiet: true, key: "settings-reload" });
|
|
3652
|
+
const testDm = button(t.settingsDmTest, async () => {
|
|
3653
|
+
if (model.busy || !model.dmEnabled || model.dmModeTouched || model.dmUrlTouched || model.dmModelTouched || model.apiKey.touched) return;
|
|
3654
|
+
model.busy = "test";
|
|
3655
|
+
status.textContent = t.settingsDmTesting;
|
|
3656
|
+
error.textContent = "";
|
|
3657
|
+
paint();
|
|
3658
|
+
try {
|
|
3659
|
+
const result = await ownCall("testStoryDm");
|
|
3660
|
+
if (disposed || ctx.signal?.aborted) return;
|
|
3661
|
+
status.textContent = result?.ok ? result.message || t.settingsDmTestSuccess : result?.error || t.settingsDmTestFailure;
|
|
3662
|
+
} catch {
|
|
3663
|
+
if (!disposed) status.textContent = t.settingsDmTestFailure;
|
|
3664
|
+
} finally {
|
|
3665
|
+
if (!disposed) {
|
|
3666
|
+
model.busy = "";
|
|
3667
|
+
paint();
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
}, { quiet: true, key: "settings-test-dm" });
|
|
3394
3671
|
let savedWorkflow = "";
|
|
3672
|
+
const savedSettings = { dmEnabled: false, dmUrl: "", dmModel: "", imageMode: "delegate", imageUrl: "" };
|
|
3395
3673
|
function applySafeView(result) {
|
|
3396
3674
|
if (typeof result.dm?.saved === "boolean") model.saved = result.dm.saved;
|
|
3397
3675
|
if (typeof result.dm?.supported === "boolean") model.supported = result.dm.supported;
|
|
3676
|
+
if (typeof result.dmEnabled === "boolean") {
|
|
3677
|
+
savedSettings.dmEnabled = result.dmEnabled;
|
|
3678
|
+
if (!model.dmModeTouched) {
|
|
3679
|
+
model.dmEnabled = result.dmEnabled;
|
|
3680
|
+
dmMode.value = result.dmEnabled ? "external" : "host";
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
if (typeof result.dmUrl === "string") {
|
|
3684
|
+
savedSettings.dmUrl = result.dmUrl;
|
|
3685
|
+
if (!model.dmUrlTouched) {
|
|
3686
|
+
model.dmUrl = result.dmUrl;
|
|
3687
|
+
dmUrl.value = result.dmUrl;
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
if (typeof result.dmModel === "string") {
|
|
3691
|
+
savedSettings.dmModel = result.dmModel;
|
|
3692
|
+
if (!model.dmModelTouched) {
|
|
3693
|
+
model.dmModel = result.dmModel;
|
|
3694
|
+
dmModel.value = result.dmModel;
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3398
3697
|
if (typeof result.imageWorkflow === "string") {
|
|
3399
3698
|
savedWorkflow = result.imageWorkflow;
|
|
3400
3699
|
if (!model.workflowTouched) workflow.value = model.workflow = savedWorkflow;
|
|
3401
3700
|
}
|
|
3402
|
-
|
|
3701
|
+
let isLoopback = false;
|
|
3702
|
+
try {
|
|
3703
|
+
const parsed = new URL(result.imageSource);
|
|
3704
|
+
isLoopback = /^https?:$/.test(parsed.protocol) && (parsed.hostname === "localhost" || parsed.hostname === "[::1]" || /^127\./.test(parsed.hostname)) && parsed.pathname === "/" && !parsed.username && !parsed.password && !parsed.search && !parsed.hash;
|
|
3705
|
+
} catch {
|
|
3706
|
+
}
|
|
3707
|
+
const inferredMode = result.imageMode ?? (result.imagesEnabled === false ? "off" : isLoopback ? "comfyui" : "delegate");
|
|
3708
|
+
if (["off", "delegate", "comfyui"].includes(inferredMode)) {
|
|
3709
|
+
savedSettings.imageMode = inferredMode;
|
|
3710
|
+
if (!model.imageModeTouched) {
|
|
3711
|
+
model.imageMode = inferredMode;
|
|
3712
|
+
imageMode.value = inferredMode;
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
const resolvedImageUrl = typeof result.imageUrl === "string" ? result.imageUrl : isLoopback ? result.imageSource : "";
|
|
3716
|
+
if (resolvedImageUrl) {
|
|
3717
|
+
savedSettings.imageUrl = resolvedImageUrl;
|
|
3718
|
+
if (!model.imageUrlTouched) {
|
|
3719
|
+
model.imageUrl = resolvedImageUrl;
|
|
3720
|
+
imageUrl.value = resolvedImageUrl;
|
|
3721
|
+
}
|
|
3722
|
+
}
|
|
3723
|
+
if (typeof result.imagesEnabled === "boolean") model.imagesEnabled = result.imagesEnabled;
|
|
3724
|
+
else model.imagesEnabled = model.imageMode !== "off";
|
|
3403
3725
|
}
|
|
3404
3726
|
function clearPrivate() {
|
|
3405
3727
|
model.apiKey.value = "";
|
|
@@ -3407,7 +3729,7 @@ function mountPanel(root, ctx) {
|
|
|
3407
3729
|
repaintKey();
|
|
3408
3730
|
}
|
|
3409
3731
|
function paint() {
|
|
3410
|
-
const dirty = model.apiKey.touched || model.workflowTouched;
|
|
3732
|
+
const dirty = model.dmModeTouched || model.dmUrlTouched || model.dmModelTouched || model.imageModeTouched || model.imageUrlTouched || model.apiKey.touched || model.workflowTouched;
|
|
3411
3733
|
saved.textContent = dirty ? t.storyDmApiPending : model.saved ? t.storyDmApiSaved : t.storyDmApiUnset;
|
|
3412
3734
|
support.textContent = model.supported ? "" : t.storyDmApiUnsupported;
|
|
3413
3735
|
save.disabled = Boolean(model.busy) || !model.loaded || !dirty;
|
|
@@ -3415,6 +3737,7 @@ function mountPanel(root, ctx) {
|
|
|
3415
3737
|
cancel.disabled = Boolean(model.busy) || !dirty;
|
|
3416
3738
|
reload.disabled = Boolean(model.busy);
|
|
3417
3739
|
keyInput.disabled = !model.supported;
|
|
3740
|
+
testDm.disabled = Boolean(model.busy) || !model.loaded || !model.dmEnabled || model.dmModeTouched || model.dmUrlTouched || model.dmModelTouched || model.apiKey.touched;
|
|
3418
3741
|
const hasWorkflow = Boolean(model.workflow.trim());
|
|
3419
3742
|
workflowBadge.textContent = hasWorkflow ? t.storyImageWorkflowOn : t.storyImageWorkflowOff;
|
|
3420
3743
|
workflowBadge.className = hasWorkflow ? "sw-badge sw-settings-state sw-settings-state-on" : "sw-badge sw-settings-state";
|
|
@@ -3422,12 +3745,21 @@ function mountPanel(root, ctx) {
|
|
|
3422
3745
|
imageBadge.className = model.imagesEnabled ? "sw-badge sw-settings-state sw-settings-state-on" : "sw-badge sw-settings-state";
|
|
3423
3746
|
manualButton.disabled = Boolean(model.busy) || imageBusy || !model.imagesEnabled;
|
|
3424
3747
|
manualButton.textContent = imageBusy ? t.storyImagePending : t.storyImageManual;
|
|
3425
|
-
|
|
3748
|
+
if (dmFieldsMounted !== model.dmEnabled) {
|
|
3749
|
+
dmFieldsMount.replaceChildren(...model.dmEnabled ? [dmFields] : []);
|
|
3750
|
+
dmFieldsMounted = model.dmEnabled;
|
|
3751
|
+
}
|
|
3752
|
+
const directImages = model.imageMode === "comfyui";
|
|
3753
|
+
if (imageFieldsMounted !== directImages) {
|
|
3754
|
+
imageFieldsMount.replaceChildren(...directImages ? [imageDirectCard] : []);
|
|
3755
|
+
imageFieldsMounted = directImages;
|
|
3756
|
+
}
|
|
3426
3757
|
container.setAttribute("aria-busy", String(Boolean(model.busy)));
|
|
3427
3758
|
}
|
|
3428
3759
|
function setImageState({ enabled, direct } = {}) {
|
|
3429
3760
|
if (typeof enabled === "boolean") model.imagesEnabled = enabled;
|
|
3430
|
-
if (typeof direct === "boolean") model.
|
|
3761
|
+
if (typeof direct === "boolean" && !model.imageModeTouched) model.imageMode = direct ? "comfyui" : model.imagesEnabled ? "delegate" : "off";
|
|
3762
|
+
imageMode.value = model.imageMode;
|
|
3431
3763
|
paint();
|
|
3432
3764
|
}
|
|
3433
3765
|
async function load() {
|
|
@@ -3453,8 +3785,11 @@ function mountPanel(root, ctx) {
|
|
|
3453
3785
|
}
|
|
3454
3786
|
}
|
|
3455
3787
|
}
|
|
3456
|
-
const
|
|
3457
|
-
|
|
3788
|
+
const dmFieldsMount = node("div", { class: "sw-settings-dm-fields" });
|
|
3789
|
+
let dmFieldsMounted = false;
|
|
3790
|
+
const imageFieldsMount = node("div", { class: "sw-settings-image-fields" });
|
|
3791
|
+
let imageFieldsMounted = false;
|
|
3792
|
+
const dmFields = node(
|
|
3458
3793
|
"section",
|
|
3459
3794
|
{ class: "sw-card sw-card-pad sw-private-settings-card" },
|
|
3460
3795
|
node(
|
|
@@ -3463,22 +3798,39 @@ function mountPanel(root, ctx) {
|
|
|
3463
3798
|
node("div", { class: "sw-settings-card-title" }, icon("settings"), node("div", {}, node("h3", {}, t.settingsKeyTitle), node("p", { class: "sw-card-summary" }, t.settingsKeySummary))),
|
|
3464
3799
|
saved
|
|
3465
3800
|
),
|
|
3801
|
+
node("label", { class: "sw-setting-field" }, t.settingsDmUrl, dmUrl),
|
|
3802
|
+
node("label", { class: "sw-setting-field" }, t.settingsDmModel, dmModel),
|
|
3466
3803
|
node("label", { class: "sw-setting-field" }, t.storyDmApiKey, keyInput),
|
|
3467
3804
|
note(t.settingsKeyHint),
|
|
3468
3805
|
support,
|
|
3469
|
-
node("details", { class: "sw-settings-help" }, node("summary", {}, t.storyDmHelpSummary), note(t.storyDmApiHint))
|
|
3806
|
+
node("details", { class: "sw-settings-help" }, node("summary", {}, t.storyDmHelpSummary), note(t.storyDmApiHint)),
|
|
3807
|
+
node("div", { class: "sw-settings-actions" }, actionRow(testDm, clear))
|
|
3470
3808
|
);
|
|
3471
|
-
const
|
|
3809
|
+
const imageUrlField = node("label", { class: "sw-setting-field" }, t.settingsImageUrl, imageUrl);
|
|
3810
|
+
const imageDirectCard = node(
|
|
3472
3811
|
"section",
|
|
3473
3812
|
{ class: "sw-card sw-card-pad sw-settings-manual" },
|
|
3474
3813
|
node("div", { class: "sw-settings-subhead" }, node("div", {}, node("h3", {}, t.settingsImageManualTitle), node("p", { class: "sw-card-summary" }, t.settingsImageManualSummary)), imageBadge),
|
|
3475
3814
|
node("p", { class: "sw-card-note" }, t.settingsImageManualHint),
|
|
3815
|
+
imageUrlField,
|
|
3476
3816
|
node("div", { class: "sw-settings-actions" }, actionRow(manualButton)),
|
|
3477
3817
|
imageOutput,
|
|
3478
3818
|
workflowBox
|
|
3479
3819
|
);
|
|
3480
|
-
|
|
3481
|
-
|
|
3820
|
+
const dmModeCard = node(
|
|
3821
|
+
"section",
|
|
3822
|
+
{ class: "sw-card sw-card-pad" },
|
|
3823
|
+
node("label", { class: "sw-setting-field" }, t.settingsDmMode, dmMode),
|
|
3824
|
+
dmFieldsMount
|
|
3825
|
+
);
|
|
3826
|
+
const imageModeCard = node(
|
|
3827
|
+
"section",
|
|
3828
|
+
{ class: "sw-card sw-card-pad" },
|
|
3829
|
+
node("label", { class: "sw-setting-field" }, t.settingsImageMode, imageMode),
|
|
3830
|
+
imageFieldsMount
|
|
3831
|
+
);
|
|
3832
|
+
const saveBar = node("div", { class: "sw-settings-actions" }, actionRow(save, cancel, reload));
|
|
3833
|
+
const container = node("div", { class: "sw-settings-stack sw-private-settings" }, dmModeCard, imageModeCard, saveBar, status, error);
|
|
3482
3834
|
paint();
|
|
3483
3835
|
return { node: container, load, clear: clearPrivate, setImageState };
|
|
3484
3836
|
}
|
|
@@ -3575,7 +3927,7 @@ function mountPanel(root, ctx) {
|
|
|
3575
3927
|
playScroll = { key: "", top: 0, atBottom: true };
|
|
3576
3928
|
}
|
|
3577
3929
|
top.replaceChildren(
|
|
3578
|
-
node("div", { class: "sw-brand" }, node("span", { class: "sw-logo" }, icon("fish")), node("div", {}, node("strong", {},
|
|
3930
|
+
node("div", { class: "sw-brand" }, node("span", { class: "sw-logo" }, icon("fish")), node("div", {}, node("strong", {}, t.storyTitle), node("small", {}, "把日常,慢慢过成故事"))),
|
|
3579
3931
|
node(
|
|
3580
3932
|
"div",
|
|
3581
3933
|
{ class: "sw-top-actions" },
|
|
@@ -4946,13 +5298,6 @@ function mountHome(ctx) {
|
|
|
4946
5298
|
el2(document2, "span", { class: "fhm-fine", text: "只接着逛;回不回家由你决定" })
|
|
4947
5299
|
));
|
|
4948
5300
|
}
|
|
4949
|
-
if (snapshot.wish) {
|
|
4950
|
-
const w = snapshot.wish;
|
|
4951
|
-
nodes.push(el2(document2, "p", {
|
|
4952
|
-
class: "fhm-wish",
|
|
4953
|
-
text: `心愿 · ${w.placeName}${w.target ? ` · ${w.target}` : ""}${w.reason ? `:${w.reason}` : ""}`
|
|
4954
|
-
}));
|
|
4955
|
-
}
|
|
4956
5301
|
return nodes;
|
|
4957
5302
|
}
|
|
4958
5303
|
function renderPlan() {
|
|
@@ -6562,11 +6907,6 @@ var CSS2 = `
|
|
|
6562
6907
|
.fun-draft{border:1px solid var(--f-line);border-left:3px solid var(--f-warm);border-radius:var(--radius-sm,6px);padding:12px 14px;margin-bottom:12px;background:var(--f-card)}
|
|
6563
6908
|
.fun-draft h3{margin:0 0 4px;font-size:15px;font-weight:600}
|
|
6564
6909
|
.fun-draft-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
|
|
6565
|
-
.fun-choice{border:1px solid var(--f-line);border-radius:var(--radius-sm,6px);padding:9px 11px;margin-top:9px;background:var(--f-soft)}
|
|
6566
|
-
.fun-choice-title{font-size:12px;font-weight:600}
|
|
6567
|
-
.fun-choice .fun-list{margin-top:4px}
|
|
6568
|
-
.fun-choice-note{font-size:11.5px;color:var(--f-dim);margin:7px 0 0;line-height:1.5}
|
|
6569
|
-
.fun-upcoming-wish{margin:-6px 0 12px;padding:8px 11px;border-radius:var(--radius-sm,6px);background:var(--f-soft);color:var(--f-dim);font-size:12px}
|
|
6570
6910
|
|
|
6571
6911
|
.fun-live{border:1px solid var(--f-line);border-left:3px solid var(--f-accent);border-radius:var(--radius-sm,6px);padding:9px 12px;margin-bottom:12px;background:var(--f-card)}
|
|
6572
6912
|
.fun-live-idle{border-left-color:var(--f-line)}
|
|
@@ -6684,7 +7024,7 @@ var CSS2 = `
|
|
|
6684
7024
|
.fun-ticket{position:relative;border-left:3px solid color-mix(in srgb,var(--f-accent) 55%,var(--f-line));margin-bottom:12px}
|
|
6685
7025
|
.fun-trip-detail{border-top:1px dashed var(--f-line);margin-top:12px;padding-top:4px}
|
|
6686
7026
|
.fun-trip-detail .fun-sec{margin-top:10px}.fun-trip-detail p{margin:4px 0;font-size:13px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
6687
|
-
.fun-
|
|
7027
|
+
.fun-visited-history{margin-top:14px}.fun-visited-history>summary{cursor:pointer;padding:8px 0;color:var(--f-dim)}
|
|
6688
7028
|
.fun-shelf-cabinet{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(180px,100%),1fr));gap:10px;margin-top:12px}
|
|
6689
7029
|
.fun-keepsake{border:1px solid var(--f-line);border-radius:10px;padding:12px;background:var(--f-soft);min-width:0}
|
|
6690
7030
|
.fun-keepsake>summary{cursor:pointer;line-height:1.7;overflow-wrap:anywhere}.fun-keepsake>summary strong{display:block;color:var(--f-ink);font-weight:600}
|
|
@@ -6694,7 +7034,7 @@ var CSS2 = `
|
|
|
6694
7034
|
.fun-feedback:empty{display:none}.fun-feedback{margin:10px 0}.fun-feedback .fun-err{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
|
|
6695
7035
|
.fun-loading{padding:18px;color:var(--f-dim);font-size:13px}.fun-empty{border:1px dashed var(--f-line);border-radius:var(--f-round);margin:10px 0;background:var(--f-soft)}
|
|
6696
7036
|
@media(max-width:420px){.fun{padding-inline:0}.fun-live,.fun-trip,.fun-form{padding:12px}.fun-stats{gap:12px}.fun-detail-cols,.fun-form-grid{grid-template-columns:1fr}.fun-detail-top{flex-wrap:wrap}.fun-trip-actions{flex-wrap:wrap}}
|
|
6697
|
-
.fun-art{display:block;color:color-mix(in srgb,var(--f-ink) 64%,var(--f-card));background:color-mix(in srgb,var(--f-accent) 5%,var(--f-card));border-radius:8px;margin-bottom:10px;overflow:hidden;pointer-events:none}.fun-art svg{display:block;width:100%;height:116px}.fun-art-detail svg{height:160px}.fun-icon{display:inline-flex;vertical-align:middle;flex:none;width:22px;height:22px;color:var(--f-dim);margin-right:5px}.fun-icon svg{width:100%;height:100%}.fun-keepsake>summary .fun-icon{width:32px;height:32px;margin-bottom:5px}.fun-recommendations{margin:18px 0 20px}.fun-recommendations h3{font-size:16px;margin:0 0 3px}.fun-recommend-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(218px,100%),1fr));gap:12px;margin-top:10px}.fun-recommend-card{padding:13px;border:1px solid var(--f-line);border-radius:var(--f-round);background:var(--f-card);cursor:pointer;transition:border-color .15s,background .15s}.fun-recommend-card:hover{border-color:var(--f-accent)}.fun-recommend-card:focus-visible{outline:2px solid var(--f-accent);outline-offset:3px}.fun-recommend-name{font-weight:650;font-size:15px}.fun-recommend-reason{margin-top:7px;color:var(--f-dim);font-size:12px}.fun-management{margin:16px 0;color:var(--f-dim);font-size:12px}.fun-management>summary{cursor:pointer;padding:6px 0}.fun-management .fun-bar{margin-top:8px}.fun-detail-actions{flex-wrap:wrap}.fun-detail-edit{border-color:var(--f-line);color:var(--f-dim)}.fun-album-filters{display:grid;grid-template-columns:minmax(160px,2fr) minmax(130px,1fr) minmax(130px,1fr);gap:8px;margin:14px 0}.fun-
|
|
7037
|
+
.fun-art{display:block;color:color-mix(in srgb,var(--f-ink) 64%,var(--f-card));background:color-mix(in srgb,var(--f-accent) 5%,var(--f-card));border-radius:8px;margin-bottom:10px;overflow:hidden;pointer-events:none}.fun-art svg{display:block;width:100%;height:116px}.fun-art-detail svg{height:160px}.fun-icon{display:inline-flex;vertical-align:middle;flex:none;width:22px;height:22px;color:var(--f-dim);margin-right:5px}.fun-icon svg{width:100%;height:100%}.fun-keepsake>summary .fun-icon{width:32px;height:32px;margin-bottom:5px}.fun-recommendations{margin:18px 0 20px}.fun-recommendations h3{font-size:16px;margin:0 0 3px}.fun-recommend-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(218px,100%),1fr));gap:12px;margin-top:10px}.fun-recommend-card{padding:13px;border:1px solid var(--f-line);border-radius:var(--f-round);background:var(--f-card);cursor:pointer;transition:border-color .15s,background .15s}.fun-recommend-card:hover{border-color:var(--f-accent)}.fun-recommend-card:focus-visible{outline:2px solid var(--f-accent);outline-offset:3px}.fun-recommend-name{font-weight:650;font-size:15px}.fun-recommend-reason{margin-top:7px;color:var(--f-dim);font-size:12px}.fun-management{margin:16px 0;color:var(--f-dim);font-size:12px}.fun-management>summary{cursor:pointer;padding:6px 0}.fun-management .fun-bar{margin-top:8px}.fun-detail-actions{flex-wrap:wrap}.fun-detail-edit{border-color:var(--f-line);color:var(--f-dim)}.fun-album-filters{display:grid;grid-template-columns:minmax(160px,2fr) minmax(130px,1fr) minmax(130px,1fr);gap:8px;margin:14px 0}.fun-link{background:transparent!important;color:var(--f-accent)!important;font-size:12px!important;min-height:30px!important}.fun-inspector{margin-top:10px;padding:12px;border:1px solid var(--f-line);border-radius:10px;background:var(--f-soft)}.fun-inspector h4{margin:0 0 4px}.fun-inline-status{font-size:12px;color:var(--f-dim);padding:8px 0}.fun-timeline{list-style:none;padding:0;margin:8px 0}.fun-timeline-block{border-left:2px solid var(--f-line);padding:0 0 12px 13px;margin-left:4px}.fun-timeline-block:last-child{padding-bottom:2px}.fun-timeline-area{font-size:13px;font-weight:600;margin-bottom:5px}.fun-timeline-row{display:grid;grid-template-columns:minmax(78px,auto) 1fr;gap:10px;font-size:12.5px;margin:5px 0;overflow-wrap:anywhere}.fun-timeline-time{color:var(--f-dim);font-size:11px;font-variant-numeric:tabular-nums}.fun-timeline-choice{border-left:2px solid color-mix(in srgb,var(--f-accent) 40%,var(--f-line));margin:5px 0 5px 10px;padding-left:8px}.fun-timeline-event{margin:6px 0}.fun-timeline-source{font-size:11px;color:var(--f-dim)}.fun-recommend-card,.fun-inspector,.fun-feedback,.fun-outing-result{animation:fun-appear .16s ease-out}@keyframes fun-appear{from{opacity:.4;transform:translateY(3px)}to{opacity:1;transform:translateY(0)}}.fun-trip-detail,.fun-detail,.fun-inspector{overflow-wrap:anywhere}.fun{--f-art-warm:color-mix(in srgb,#e9b97e 63%,var(--f-card));--f-art-mint:color-mix(in srgb,#79b7a6 62%,var(--f-card));--f-art-blue:color-mix(in srgb,#7cacc2 62%,var(--f-card));--f-art-pink:color-mix(in srgb,#ce91af 56%,var(--f-card))}@media(max-width:560px){.fun-album-filters{grid-template-columns:1fr}.fun-timeline-row{grid-template-columns:78px 1fr}.fun-art-detail svg{height:128px}}@media(prefers-reduced-motion:reduce){.fun *{transition:none!important;animation:none!important;scroll-behavior:auto!important}}
|
|
6698
7038
|
|
|
6699
7039
|
|
|
6700
7040
|
|
|
@@ -6780,20 +7120,7 @@ var CSS2 = `
|
|
|
6780
7120
|
.fun-ticket-date{display:flex;gap:8px;align-items:baseline;margin-bottom:6px}
|
|
6781
7121
|
.fun-ticket-date b{font:22px/1.2 Georgia,serif}
|
|
6782
7122
|
}
|
|
6783
|
-
/* 纪念册:主列 + 右侧心愿栏 */
|
|
6784
|
-
.fun-with-rail{display:grid;gap:20px}
|
|
6785
|
-
@media(min-width:960px){.fun-with-rail{grid-template-columns:minmax(0,1fr) 276px;align-items:start}}
|
|
6786
7123
|
.fun-book-main{min-width:0}
|
|
6787
|
-
.fun-rail{border:1px solid var(--f-line);border-radius:var(--f-round);padding:18px;background:var(--f-paper);min-width:0}
|
|
6788
|
-
.fun-rail h3{font-size:14px;letter-spacing:.03em;margin:0 0 10px}
|
|
6789
|
-
.fun-rail p{font-size:12px;line-height:1.85;color:var(--f-dim)}
|
|
6790
|
-
.fun-rail-wish p{font-size:12.5px;line-height:1.9;color:var(--f-ink);margin:0 0 10px;white-space:pre-line}
|
|
6791
|
-
.fun-rail-wish .fun-chip{display:inline-block;font-size:11px;line-height:1.6}
|
|
6792
|
-
.fun-rail-more{margin-top:10px!important;font-size:11.5px!important}
|
|
6793
|
-
.fun-rail .fun-quote{margin-top:18px;padding-top:16px;border-top:1px dashed var(--f-line);font-size:12px;line-height:1.95;color:var(--f-dim);white-space:pre-line}
|
|
6794
|
-
/* 没有右侧那一栏时(窄屏),摘要留在主列里,不要被 CSS 顺手藏掉。 */
|
|
6795
|
-
@media(min-width:960px){.fun-wish-summary{display:none}}
|
|
6796
|
-
@media(max-width:959px){.fun-rail{display:none}}
|
|
6797
7124
|
@media(max-width:640px){
|
|
6798
7125
|
.fun-album-filters{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
|
|
6799
7126
|
.fun-album-filters .fun-book-search{grid-column:1/-1}
|
|
@@ -6869,29 +7196,10 @@ function rememberFocus(container) {
|
|
|
6869
7196
|
}
|
|
6870
7197
|
};
|
|
6871
7198
|
}
|
|
6872
|
-
var routeStatus = { planned: "待出发", active: "行程中", between: "站间歇脚", completed: "已完成", cancelled: "已取消" };
|
|
6873
|
-
function routeSummary(route, trips = [], selectTrip) {
|
|
6874
|
-
const node2 = el(
|
|
6875
|
-
"section",
|
|
6876
|
-
{ class: "fun-route", "data-route-id": route.id, "aria-label": "联程记录" },
|
|
6877
|
-
el("strong", { text: `联程 · ${routeStatus[route.status] ?? "状态未知"}` }),
|
|
6878
|
-
el("div", { class: "fun-route-stops", text: (route.stops ?? []).map((stop) => stop.placeName || stop.placeId).join(" → ") })
|
|
6879
|
-
);
|
|
6880
|
-
const retained = (route.tripIds ?? []).map((id) => trips.find((trip) => trip.id === id)).filter(Boolean);
|
|
6881
|
-
if (selectTrip && retained.length) node2.appendChild(el("div", { class: "fun-route-stops" }, retained.map((trip) => el("button", {
|
|
6882
|
-
type: "button",
|
|
6883
|
-
class: "fun-link",
|
|
6884
|
-
"data-trip-id": trip.id,
|
|
6885
|
-
onclick: () => selectTrip(trip)
|
|
6886
|
-
}, `${trip.routeOrder ? `第 ${trip.routeOrder} 站 · ` : ""}${trip.placeName} · ${trip.day || "日期不详"}`))));
|
|
6887
|
-
if (selectTrip && (route.tripIds ?? []).length > retained.length) node2.appendChild(el("div", { class: "fun-note", text: "较早行程仅保留联程归属,详细记录已归档。" }));
|
|
6888
|
-
return node2;
|
|
6889
|
-
}
|
|
6890
7199
|
function tripDetails(trip) {
|
|
6891
7200
|
const detail = el("section", { class: "fun-trip-detail", "aria-label": `${trip.placeName}行程详情` });
|
|
6892
7201
|
if (trip.company) detail.appendChild(el("p", { text: `同行 · ${trip.company}` }));
|
|
6893
7202
|
if (trip.timelineTruncated) detail.appendChild(el("p", { class: "fun-note", text: "这趟记录较长,时间线保留进门与最近的活动;较早的逐项细节已省略。" }));
|
|
6894
|
-
if (trip.routeId) detail.appendChild(el("p", { class: "fun-note", text: `联程${trip.routeOrder ? ` · 第 ${trip.routeOrder} 站` : ""}`, "data-route-id": trip.routeId }));
|
|
6895
7203
|
const supplied = Array.isArray(trip.timeline) && trip.timeline.length > 0;
|
|
6896
7204
|
const timeline = supplied ? trip.timeline : [
|
|
6897
7205
|
...(trip.visited ?? []).map((area) => ({ kind: "area", text: typeof area === "string" ? area : area.area, area: typeof area === "string" ? area : area.area, at: null })),
|
|
@@ -7062,13 +7370,6 @@ function mountPlaces2(ctx) {
|
|
|
7062
7370
|
const restoreFocus = rememberFocus(body);
|
|
7063
7371
|
currentData = data;
|
|
7064
7372
|
body.replaceChildren(heading("今天,想去哪儿?", "有些地方适合热闹,有些地方适合慢慢待着。"));
|
|
7065
|
-
const pendingChoice = (choice) => choice ? el(
|
|
7066
|
-
"div",
|
|
7067
|
-
{ class: "fun-choice" },
|
|
7068
|
-
el("div", { class: "fun-choice-title", text: choice.prompt || "待选择事件" }),
|
|
7069
|
-
el("ul", { class: "fun-list" }, choice.options.map((option) => el("li", { text: option.label }))),
|
|
7070
|
-
el("p", { class: "fun-choice-note", text: "她可以选一项,也可以略过。" })
|
|
7071
|
-
) : null;
|
|
7072
7373
|
const draft = data.draft;
|
|
7073
7374
|
if (draft) {
|
|
7074
7375
|
const draftAction = (method, label2) => el("button", {
|
|
@@ -7082,7 +7383,6 @@ function mountPlaces2(ctx) {
|
|
|
7082
7383
|
el("h3", { text: `未逛完 · ${draft.placeName}` }),
|
|
7083
7384
|
el("div", { class: "fun-meta", text: `最后活动 ${draft.lastDay ? `${draft.lastDay} ` : ""}${draft.lastHm} · 逛了 ${draft.visited.length} 处` }),
|
|
7084
7385
|
el("div", { class: "fun-meta", text: draft.visited.length ? `逛过:${draft.visited.map((v) => v.area).join("、")}` : "还没逛到哪儿" }),
|
|
7085
|
-
pendingChoice(draft.pendingChoice),
|
|
7086
7386
|
draft.canResume === false ? el("div", { class: "fun-meta", text: "这处已不在地点清单中,可以按已有记录回家。" }) : null,
|
|
7087
7387
|
el("div", { class: "fun-draft-actions" }, draftAction("resume", "继续逛"), draftAction("closeDraft", "按已有记录回家"))
|
|
7088
7388
|
));
|
|
@@ -7108,8 +7408,7 @@ function mountPlaces2(ctx) {
|
|
|
7108
7408
|
s.photos.length ? el("div", { class: "fun-chips" }, s.photos.map((x) => el("span", { class: "fun-chip", text: `📷 ${x}` }))) : null,
|
|
7109
7409
|
s.ate && s.ate.length ? el("div", { class: "fun-chips" }, s.ate.map((x) => el("span", { class: "fun-chip fun-chip-ate", text: `${x.verb}了 ${x.item}` }))) : null,
|
|
7110
7410
|
s.events.length ? el("ul", { class: "fun-list" }, s.events.slice(-3).map((e) => el("li", { text: e }))) : null,
|
|
7111
|
-
venue ? el("div", { class: "fun-meta", text: leftText }) : null
|
|
7112
|
-
pendingChoice(s.pendingChoice)
|
|
7411
|
+
venue ? el("div", { class: "fun-meta", text: leftText }) : null
|
|
7113
7412
|
));
|
|
7114
7413
|
} else if (!draft) {
|
|
7115
7414
|
body.appendChild(el(
|
|
@@ -7126,8 +7425,6 @@ function mountPlaces2(ctx) {
|
|
|
7126
7425
|
tabindex: "-1",
|
|
7127
7426
|
text: notice.text
|
|
7128
7427
|
}));
|
|
7129
|
-
if (data.upcomingWish) body.appendChild(el("div", { class: "fun-upcoming-wish", text: data.upcomingWish }));
|
|
7130
|
-
if (data.route) body.appendChild(routeSummary(data.route));
|
|
7131
7428
|
const recommendBox = el("section", { class: "fun-recommendations", "aria-label": "此刻推荐" });
|
|
7132
7429
|
body.appendChild(recommendBox);
|
|
7133
7430
|
body.appendChild(el("div", { class: "fun-sec", text: "全部地方 · 找一处看看" }));
|
|
@@ -7201,7 +7498,7 @@ function mountPlaces2(ctx) {
|
|
|
7201
7498
|
hero.phase ? el("span", { class: "fun-chip", text: hero.phase }) : null
|
|
7202
7499
|
),
|
|
7203
7500
|
el("h3", { class: "fun-recommend-name", text: hero.name }),
|
|
7204
|
-
el("p", { class: "fun-recommend-reason", text: hero.
|
|
7501
|
+
el("p", { class: "fun-recommend-reason", text: hero.revisitReason || `${hero.hours.open}–${hero.hours.close} · ${hero.crowdLabel} · ${hero.stateLabel}` }),
|
|
7205
7502
|
el(
|
|
7206
7503
|
"div",
|
|
7207
7504
|
{ class: "fun-chips" },
|
|
@@ -7288,9 +7585,8 @@ function mountPlaces2(ctx) {
|
|
|
7288
7585
|
el("span", { class: `fun-card-state ${stateCls}`, text: p.stateLabel }),
|
|
7289
7586
|
el("span", { class: "fun-card-arrow", text: selected ? "⌃" : "⌄" })
|
|
7290
7587
|
),
|
|
7291
|
-
recommended ? el("div", { class: "fun-recommend-reason", text: p.
|
|
7588
|
+
recommended ? el("div", { class: "fun-recommend-reason", text: p.revisitReason || `${p.hours.open}–${p.hours.close} · ${p.crowdLabel} · ${p.phase || p.tags?.slice(0, 2).join(" / ") || "现在开着"}` }) : null,
|
|
7292
7589
|
recommended ? null : el("div", { class: "fun-card-desc", text: p.desc }),
|
|
7293
|
-
!recommended && p.wishReason ? el("div", { class: "fun-meta", text: p.wishReason }) : null,
|
|
7294
7590
|
!recommended && p.revisitReason ? el("div", { class: "fun-meta", text: p.revisitReason }) : null,
|
|
7295
7591
|
el(
|
|
7296
7592
|
"div",
|
|
@@ -7451,188 +7747,12 @@ function mountBook(ctx) {
|
|
|
7451
7747
|
let bookKeyword = "";
|
|
7452
7748
|
let bookPlace = "";
|
|
7453
7749
|
let bookDate = "";
|
|
7454
|
-
let wishFormOpen = false;
|
|
7455
7750
|
const expandedTrips = /* @__PURE__ */ new Set();
|
|
7456
7751
|
const status = feedback(box);
|
|
7457
7752
|
body.appendChild(el("div", { class: "fun-loading", role: "status", text: "正在翻开纪念册…" }));
|
|
7458
7753
|
const pending = /* @__PURE__ */ new Set();
|
|
7459
7754
|
const errors = /* @__PURE__ */ new Map();
|
|
7460
7755
|
let currentData = null;
|
|
7461
|
-
let wishDraft = { placeId: "", type: "", target: "", reason: "" };
|
|
7462
|
-
const wishPending = /* @__PURE__ */ new Set();
|
|
7463
|
-
const wishErrors = /* @__PURE__ */ new Map();
|
|
7464
|
-
const wishTypes = { visit: "去看看", area: "逛一处", phase: "在某个时段去", souvenir: "带回纪念品" };
|
|
7465
|
-
const renderWishes = (data) => {
|
|
7466
|
-
const places = data.places ?? [];
|
|
7467
|
-
const wishes = data.wishes ?? [];
|
|
7468
|
-
const adding = wishPending.has("add");
|
|
7469
|
-
const section = el("section", { class: "fun-wishes", "aria-label": "出游心愿" });
|
|
7470
|
-
section.appendChild(el(
|
|
7471
|
-
"div",
|
|
7472
|
-
{ class: "fun-bar" },
|
|
7473
|
-
el("span", { class: "fun-sec", text: "出游心愿" }),
|
|
7474
|
-
el("button", { type: "button", "aria-expanded": String(wishFormOpen), disabled: adding ? "disabled" : null, onclick: () => {
|
|
7475
|
-
wishFormOpen = !wishFormOpen;
|
|
7476
|
-
render(currentData);
|
|
7477
|
-
} }, wishFormOpen ? "收起表单" : "记个心愿")
|
|
7478
|
-
));
|
|
7479
|
-
const field = (label2, input) => el(
|
|
7480
|
-
"label",
|
|
7481
|
-
{ class: "fun-field" },
|
|
7482
|
-
el("span", { class: "fun-field-label", text: label2 }),
|
|
7483
|
-
input
|
|
7484
|
-
);
|
|
7485
|
-
const select = (className, placeholder, options, value) => {
|
|
7486
|
-
const input = el(
|
|
7487
|
-
"select",
|
|
7488
|
-
{ class: className, disabled: adding ? "disabled" : null },
|
|
7489
|
-
el("option", { value: "", text: placeholder }),
|
|
7490
|
-
options.map(([id, name]) => el("option", { value: id, text: name }))
|
|
7491
|
-
);
|
|
7492
|
-
input.value = value;
|
|
7493
|
-
return input;
|
|
7494
|
-
};
|
|
7495
|
-
const place = places.find((p) => p.id === wishDraft.placeId);
|
|
7496
|
-
const targets = place ? (wishDraft.type === "area" ? place.areas : wishDraft.type === "phase" ? place.phaseNames : wishDraft.type === "souvenir" ? place.souvenirs : []) ?? [] : [];
|
|
7497
|
-
const placeInput = select("fun-wish-place", "请选择地点", places.map((p) => [p.id, p.name]), wishDraft.placeId);
|
|
7498
|
-
const typeInput = select("fun-wish-type", "请选择心愿类型", Object.entries(wishTypes), wishDraft.type);
|
|
7499
|
-
const targetInput = select(
|
|
7500
|
-
"fun-wish-target",
|
|
7501
|
-
wishDraft.type === "visit" ? "去看看无需目标" : !place || !wishDraft.type ? "先选择地点和类型" : targets.length ? "请选择目标" : "此地点没有可选目标",
|
|
7502
|
-
targets.map((target) => [target, target]),
|
|
7503
|
-
wishDraft.target
|
|
7504
|
-
);
|
|
7505
|
-
targetInput.disabled = adding || !targets.length;
|
|
7506
|
-
const reasonInput = el("input", { class: "fun-wish-reason", type: "text", placeholder: "可选,记下为什么想去", disabled: adding ? "disabled" : null });
|
|
7507
|
-
reasonInput.value = wishDraft.reason;
|
|
7508
|
-
placeInput.addEventListener("change", () => {
|
|
7509
|
-
wishDraft.placeId = placeInput.value;
|
|
7510
|
-
wishDraft.target = "";
|
|
7511
|
-
wishErrors.delete("add");
|
|
7512
|
-
render(currentData);
|
|
7513
|
-
});
|
|
7514
|
-
typeInput.addEventListener("change", () => {
|
|
7515
|
-
wishDraft.type = typeInput.value;
|
|
7516
|
-
wishDraft.target = "";
|
|
7517
|
-
wishErrors.delete("add");
|
|
7518
|
-
render(currentData);
|
|
7519
|
-
});
|
|
7520
|
-
targetInput.addEventListener("change", () => {
|
|
7521
|
-
wishDraft.target = targetInput.value;
|
|
7522
|
-
});
|
|
7523
|
-
reasonInput.addEventListener("input", () => {
|
|
7524
|
-
wishDraft.reason = reasonInput.value;
|
|
7525
|
-
});
|
|
7526
|
-
const errorNode = el("div", { class: "fun-form-error", role: "alert", text: wishErrors.get("add") ?? "" });
|
|
7527
|
-
const save = async () => {
|
|
7528
|
-
if (wishPending.has("add")) return;
|
|
7529
|
-
const payload = {
|
|
7530
|
-
action: "add",
|
|
7531
|
-
placeId: placeInput.value,
|
|
7532
|
-
type: typeInput.value,
|
|
7533
|
-
target: typeInput.value === "visit" ? "" : targetInput.value,
|
|
7534
|
-
reason: reasonInput.value.trim()
|
|
7535
|
-
};
|
|
7536
|
-
const chosenPlace = (currentData.places ?? []).find((p) => p.id === payload.placeId);
|
|
7537
|
-
const validTargets = chosenPlace ? (payload.type === "area" ? chosenPlace.areas : payload.type === "phase" ? chosenPlace.phaseNames : chosenPlace.souvenirs) ?? [] : [];
|
|
7538
|
-
if (!chosenPlace || !Object.hasOwn(wishTypes, payload.type) || payload.type !== "visit" && !validTargets.includes(payload.target)) {
|
|
7539
|
-
const message = "请选择地点、心愿类型及对应目标。";
|
|
7540
|
-
wishErrors.set("add", message);
|
|
7541
|
-
errorNode.textContent = message;
|
|
7542
|
-
return;
|
|
7543
|
-
}
|
|
7544
|
-
wishDraft = { placeId: payload.placeId, type: payload.type, target: payload.target, reason: reasonInput.value };
|
|
7545
|
-
await changeWish("add", payload, data);
|
|
7546
|
-
};
|
|
7547
|
-
if (wishFormOpen) section.appendChild(el(
|
|
7548
|
-
"div",
|
|
7549
|
-
{ class: "fun-form fun-wish-form" },
|
|
7550
|
-
el("div", { class: "fun-form-note", text: "由你选择想去的地方,按保存才记下心愿;心愿不保证立即出发。" }),
|
|
7551
|
-
el("div", { class: "fun-form-grid" }, field("地点", placeInput), field("心愿类型", typeInput), field("目标", targetInput)),
|
|
7552
|
-
field("缘由(可选)", reasonInput),
|
|
7553
|
-
errorNode,
|
|
7554
|
-
el("button", { class: "fun-btn-primary", type: "button", disabled: adding ? "disabled" : null, onclick: save }, adding ? "保存中…" : "保存心愿")
|
|
7555
|
-
));
|
|
7556
|
-
if (!wishes.length) section.appendChild(el("div", { class: "fun-note", text: "还没有出游心愿,想好了再记下。" }));
|
|
7557
|
-
const statusNames = { active: "待实现", paused: "已暂缓", completed: "已实现", cancelled: "已取消" };
|
|
7558
|
-
const history = el("details", {
|
|
7559
|
-
class: "fun-wish-history",
|
|
7560
|
-
open: wishes.some((w) => w.status !== "active" && (wishErrors.has(`wish:${w.id}`) || wishPending.has(`wish:${w.id}`))) ? "open" : null
|
|
7561
|
-
}, el("summary", { text: `已实现、暂缓与取消(${wishes.filter((w) => w.status !== "active").length})` }));
|
|
7562
|
-
for (const wish of wishes) {
|
|
7563
|
-
const key = `wish:${wish.id}`;
|
|
7564
|
-
const busy = wishPending.has(key);
|
|
7565
|
-
const state = wish.status;
|
|
7566
|
-
const actions = el("div", { class: "fun-trip-actions" });
|
|
7567
|
-
if (state === "active" || state === "paused") {
|
|
7568
|
-
actions.appendChild(el("button", {
|
|
7569
|
-
type: "button",
|
|
7570
|
-
disabled: busy ? "disabled" : null,
|
|
7571
|
-
onclick: () => changeWish(key, { action: state === "paused" ? "resume" : "pause", id: wish.id }, data)
|
|
7572
|
-
}, state === "paused" ? "恢复" : "暂缓"));
|
|
7573
|
-
actions.appendChild(el("button", {
|
|
7574
|
-
type: "button",
|
|
7575
|
-
disabled: busy ? "disabled" : null,
|
|
7576
|
-
onclick: () => changeWish(key, { action: "cancel", id: wish.id }, data)
|
|
7577
|
-
}, "取消"));
|
|
7578
|
-
}
|
|
7579
|
-
if (busy) actions.appendChild(el("span", { class: "fun-dim", text: "保存中…" }));
|
|
7580
|
-
if (wishErrors.has(key)) actions.appendChild(el("span", { class: "fun-trip-error", role: "alert", text: wishErrors.get(key) }));
|
|
7581
|
-
(state === "active" ? section : history).appendChild(el(
|
|
7582
|
-
"div",
|
|
7583
|
-
{ class: "fun-wish fun-trip" },
|
|
7584
|
-
el(
|
|
7585
|
-
"div",
|
|
7586
|
-
{ class: "fun-trip-head" },
|
|
7587
|
-
el("span", { class: "fun-trip-name", text: wish.placeName ?? places.find((p) => p.id === wish.placeId)?.name ?? wish.placeId }),
|
|
7588
|
-
el("span", { class: "fun-wish-status fun-dim", text: statusNames[state] ?? state ?? "状态未知" })
|
|
7589
|
-
),
|
|
7590
|
-
el("div", { class: "fun-trip-sum", text: `${wishTypes[wish.type] ?? wish.type}${wish.target ? ` · ${wish.target}` : ""}` }),
|
|
7591
|
-
wish.reason ? el("div", { class: "fun-wish-note fun-note", text: `缘由:${wish.reason}` }) : null,
|
|
7592
|
-
actions
|
|
7593
|
-
));
|
|
7594
|
-
}
|
|
7595
|
-
if (wishes.some((w) => w.status !== "active")) section.appendChild(history);
|
|
7596
|
-
body.appendChild(section);
|
|
7597
|
-
};
|
|
7598
|
-
const changeWish = async (key, payload, data) => {
|
|
7599
|
-
if (wishPending.has(key)) return;
|
|
7600
|
-
wishPending.add(key);
|
|
7601
|
-
wishErrors.delete(key);
|
|
7602
|
-
render(currentData ?? data);
|
|
7603
|
-
let saved = false;
|
|
7604
|
-
try {
|
|
7605
|
-
const result = await ctx.invoke("wish", [payload]);
|
|
7606
|
-
if (!result?.ok) throw new Error(result?.error ?? "心愿保存失败");
|
|
7607
|
-
saved = true;
|
|
7608
|
-
if (key === "add") {
|
|
7609
|
-
wishDraft = { placeId: "", type: "", target: "", reason: "" };
|
|
7610
|
-
wishFormOpen = false;
|
|
7611
|
-
}
|
|
7612
|
-
await load(true);
|
|
7613
|
-
} catch (error) {
|
|
7614
|
-
wishErrors.set(key, `${saved ? "已保存,但列表刷新失败:" : ""}${error?.message ?? String(error)}`);
|
|
7615
|
-
if (key === "add") wishFormOpen = true;
|
|
7616
|
-
} finally {
|
|
7617
|
-
wishPending.delete(key);
|
|
7618
|
-
render(currentData ?? data);
|
|
7619
|
-
}
|
|
7620
|
-
};
|
|
7621
|
-
const bookRail = (activeWishes) => el(
|
|
7622
|
-
"aside",
|
|
7623
|
-
{ class: "fun-rail fun-book-rail", "aria-label": "下次想去" },
|
|
7624
|
-
el("h3", { text: "下次想去" }),
|
|
7625
|
-
activeWishes.length ? [
|
|
7626
|
-
el(
|
|
7627
|
-
"div",
|
|
7628
|
-
{ class: "fun-rail-wish" },
|
|
7629
|
-
el("p", { text: activeWishes[0].reason || `${wishTypes[activeWishes[0].type] ?? "想去"}${activeWishes[0].target ? ` · ${activeWishes[0].target}` : ""},${activeWishes[0].placeName ?? activeWishes[0].placeId}` }),
|
|
7630
|
-
el("span", { class: "fun-chip", text: `${activeWishes[0].placeName ?? activeWishes[0].placeId} · ${wishTypes[activeWishes[0].type] ?? activeWishes[0].type}` })
|
|
7631
|
-
),
|
|
7632
|
-
activeWishes.length > 1 ? el("p", { class: "fun-rail-more", text: `另外还记着 ${activeWishes.length - 1} 个心愿,去「心愿」页签里看。` }) : null
|
|
7633
|
-
] : el("p", { text: "还没有记下的心愿。在「心愿」页签里记一个,她出门时会顺路想着。" }),
|
|
7634
|
-
el("div", { class: "fun-quote", text: "心愿只作提醒。\n什么时候出门,由她决定。" })
|
|
7635
|
-
);
|
|
7636
7756
|
const render = (data) => {
|
|
7637
7757
|
const restoreFocus = rememberFocus(body);
|
|
7638
7758
|
currentData = data;
|
|
@@ -7651,7 +7771,7 @@ function mountBook(ctx) {
|
|
|
7651
7771
|
el("div", { class: "fun-trip-sum", text: data.trips[0].summary })
|
|
7652
7772
|
));
|
|
7653
7773
|
const tabs = el("nav", { class: "fun-tabs", "aria-label": "纪念册分类" });
|
|
7654
|
-
for (const [id, label2] of [["all", "全部行程"], ["kept", "珍藏"]
|
|
7774
|
+
for (const [id, label2] of [["all", "全部行程"], ["kept", "珍藏"]]) tabs.appendChild(el("button", {
|
|
7655
7775
|
type: "button",
|
|
7656
7776
|
"aria-pressed": String(bookTab === id),
|
|
7657
7777
|
onclick: () => {
|
|
@@ -7659,12 +7779,6 @@ function mountBook(ctx) {
|
|
|
7659
7779
|
render(currentData);
|
|
7660
7780
|
}
|
|
7661
7781
|
}, label2));
|
|
7662
|
-
if (bookTab === "wishes") {
|
|
7663
|
-
body.appendChild(tabs);
|
|
7664
|
-
renderWishes(data);
|
|
7665
|
-
restoreFocus();
|
|
7666
|
-
return;
|
|
7667
|
-
}
|
|
7668
7782
|
if (!data.total && !(data.keepsakeCount > 0)) {
|
|
7669
7783
|
body.appendChild(tabs);
|
|
7670
7784
|
body.appendChild(el("div", { class: "fun-empty", text: "纪念册还是空的——她收一次摊,这里就有一趟。" }));
|
|
@@ -7682,21 +7796,12 @@ function mountBook(ctx) {
|
|
|
7682
7796
|
));
|
|
7683
7797
|
if (data.mostVisited?.length) body.appendChild(el(
|
|
7684
7798
|
"details",
|
|
7685
|
-
{ class: "fun-
|
|
7799
|
+
{ class: "fun-visited-history" },
|
|
7686
7800
|
el("summary", { text: "常去的" }),
|
|
7687
7801
|
el("div", { class: "fun-chips" }, data.mostVisited.slice(0, 8).map((m) => el("span", { class: "fun-chip", text: `${m.name} ×${m.times}` })))
|
|
7688
7802
|
));
|
|
7689
|
-
const activeWishes = (data.wishes ?? []).filter((w) => w.status === "active");
|
|
7690
|
-
if (activeWishes.length) body.appendChild(el(
|
|
7691
|
-
"div",
|
|
7692
|
-
{ class: "fun-note fun-wish-summary" },
|
|
7693
|
-
`记着 ${activeWishes.length} 个心愿:${activeWishes.slice(0, 3).map((w) => w.placeName ?? w.placeId).join("、")}${activeWishes.length > 3 ? " 等" : ""}。什么时候出门,由她决定。`
|
|
7694
|
-
));
|
|
7695
|
-
const layout = el("div", { class: "fun-with-rail" });
|
|
7696
7803
|
const main = el("div", { class: "fun-book-main" });
|
|
7697
|
-
|
|
7698
|
-
layout.appendChild(bookRail(activeWishes));
|
|
7699
|
-
body.appendChild(layout);
|
|
7804
|
+
body.appendChild(main);
|
|
7700
7805
|
main.appendChild(tabs);
|
|
7701
7806
|
const search = el("input", { class: "fun-book-search", type: "search", placeholder: "搜地点、同行人、日期、备注或沿途回忆", value: bookKeyword, "aria-label": "搜索纪念册", "data-focus-key": "book-search" });
|
|
7702
7807
|
const placeOptions = new Map((data.trips ?? []).map((trip) => [trip.placeId, trip.placeName]));
|
|
@@ -7740,12 +7845,9 @@ function mountBook(ctx) {
|
|
|
7740
7845
|
if (bookPlace && trip.placeId !== bookPlace) return false;
|
|
7741
7846
|
if (bookDate && (trip.day || "unknown") !== bookDate) return false;
|
|
7742
7847
|
if (!keyword) return true;
|
|
7743
|
-
|
|
7744
|
-
const linked = route ? allTrips.filter((member) => (route.tripIds ?? []).includes(member.id)) : [];
|
|
7745
|
-
const linkedText = route ? [(route.stops ?? []).map((stop) => stop.placeName).join(" "), ...linked.map(textFor)].join(" ").toLowerCase() : "";
|
|
7746
|
-
return textFor(trip).includes(keyword) || linkedText.includes(keyword);
|
|
7848
|
+
return textFor(trip).includes(keyword);
|
|
7747
7849
|
});
|
|
7748
|
-
if (keyword || bookPlace || bookDate) results.appendChild(el("div", { class: "fun-note", role: "status", text: "找到 " + trips.length + "
|
|
7850
|
+
if (keyword || bookPlace || bookDate) results.appendChild(el("div", { class: "fun-note", role: "status", text: "找到 " + trips.length + " 趟行程。" }));
|
|
7749
7851
|
const appendTrip = (trip, parent) => {
|
|
7750
7852
|
const open = expandedTrips.has(trip.id);
|
|
7751
7853
|
const toggleKeep = async () => {
|
|
@@ -7786,7 +7888,6 @@ function mountBook(ctx) {
|
|
|
7786
7888
|
),
|
|
7787
7889
|
el("div", { class: "fun-trip-sum", text: trip.summary }),
|
|
7788
7890
|
trip.company ? el("div", { class: "fun-trip-extras", text: `同行 · ${trip.company}` }) : null,
|
|
7789
|
-
trip.routeOrder ? el("div", { class: "fun-note", text: "联程 · 第 " + trip.routeOrder + " 站" }) : null,
|
|
7790
7891
|
el(
|
|
7791
7892
|
"div",
|
|
7792
7893
|
{ class: "fun-trip-actions" },
|
|
@@ -7804,37 +7905,13 @@ function mountBook(ctx) {
|
|
|
7804
7905
|
if (open) card.querySelector(".fun-ticket-main").appendChild(tripDetails(trip));
|
|
7805
7906
|
parent.appendChild(card);
|
|
7806
7907
|
};
|
|
7807
|
-
const drawnRoutes = /* @__PURE__ */ new Set();
|
|
7808
7908
|
let previousDay = null;
|
|
7809
7909
|
for (const trip of trips) {
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
drawnRoutes.add(route.id);
|
|
7814
|
-
const group = el("section", { class: "fun-route-group", "data-route-id": route.id });
|
|
7815
|
-
group.appendChild(routeSummary(route, allTrips, (selected) => {
|
|
7816
|
-
expandedTrips.add(selected.id);
|
|
7817
|
-
bookKeyword = "";
|
|
7818
|
-
bookPlace = "";
|
|
7819
|
-
bookDate = "";
|
|
7820
|
-
bookTab = "all";
|
|
7821
|
-
render(currentData);
|
|
7822
|
-
[...body.querySelectorAll(".fun-detail-toggle")].find((button2) => button2.getAttribute("data-trip-id") === selected.id)?.focus?.();
|
|
7823
|
-
}));
|
|
7824
|
-
const members = (route.tripIds ?? []).map((id) => trips.find((member) => member.id === id)).filter(Boolean);
|
|
7825
|
-
for (const member of members) {
|
|
7826
|
-
group.appendChild(el("div", { class: "fun-date", text: member.day || "日期不详" }));
|
|
7827
|
-
appendTrip(member, group);
|
|
7828
|
-
}
|
|
7829
|
-
results.appendChild(group);
|
|
7830
|
-
previousDay = null;
|
|
7831
|
-
} else {
|
|
7832
|
-
if (trip.day !== previousDay) {
|
|
7833
|
-
results.appendChild(el("div", { class: "fun-date", text: trip.day || "日期不详" }));
|
|
7834
|
-
previousDay = trip.day;
|
|
7835
|
-
}
|
|
7836
|
-
appendTrip(trip, results);
|
|
7910
|
+
if (trip.day !== previousDay) {
|
|
7911
|
+
results.appendChild(el("div", { class: "fun-date", text: trip.day || "日期不详" }));
|
|
7912
|
+
previousDay = trip.day;
|
|
7837
7913
|
}
|
|
7914
|
+
appendTrip(trip, results);
|
|
7838
7915
|
}
|
|
7839
7916
|
if (!trips.length) results.appendChild(el("div", { class: "fun-empty", text: bookKeyword || bookPlace || bookDate ? "没有匹配的行程,试试其他地点、日期或搜索词。" : bookTab === "kept" ? "还没有珍藏的行程。" : "还没有可回看的行程。" }));
|
|
7840
7917
|
};
|
|
@@ -7982,17 +8059,69 @@ function mountShelf(ctx) {
|
|
|
7982
8059
|
void load();
|
|
7983
8060
|
return { refresh: load };
|
|
7984
8061
|
}
|
|
8062
|
+
function mergedPanel(ctx, sections, initial = 0) {
|
|
8063
|
+
const doc = ctx.root.ownerDocument;
|
|
8064
|
+
const nav = doc.createElement("div");
|
|
8065
|
+
nav.className = "fun-panel-tabs";
|
|
8066
|
+
nav.setAttribute("role", "tablist");
|
|
8067
|
+
const panes = sections.map((section, index) => {
|
|
8068
|
+
const pane = doc.createElement("section");
|
|
8069
|
+
pane.hidden = index !== initial;
|
|
8070
|
+
pane.setAttribute("role", "tabpanel");
|
|
8071
|
+
const button2 = doc.createElement("button");
|
|
8072
|
+
button2.type = "button";
|
|
8073
|
+
button2.textContent = section.title;
|
|
8074
|
+
button2.setAttribute("role", "tab");
|
|
8075
|
+
button2.setAttribute("aria-selected", index === initial ? "true" : "false");
|
|
8076
|
+
button2.addEventListener("click", () => {
|
|
8077
|
+
sections.forEach((_, i) => {
|
|
8078
|
+
panes[i].hidden = i !== index;
|
|
8079
|
+
nav.children[i].setAttribute("aria-selected", i === index ? "true" : "false");
|
|
8080
|
+
});
|
|
8081
|
+
});
|
|
8082
|
+
nav.appendChild(button2);
|
|
8083
|
+
ctx.root.appendChild(pane);
|
|
8084
|
+
const childCtx = { ...ctx, root: pane, invoke: (method, args = []) => ctx.invoke(method, [...args, { __panelSource: section.source }]) };
|
|
8085
|
+
section.mount(childCtx);
|
|
8086
|
+
return pane;
|
|
8087
|
+
});
|
|
8088
|
+
ctx.root.prepend(nav);
|
|
8089
|
+
}
|
|
8090
|
+
function mountOuting(ctx) {
|
|
8091
|
+
mergedPanel(ctx, [
|
|
8092
|
+
{ title: "此刻去逛", source: "places", mount: mountPlaces2 },
|
|
8093
|
+
{ title: "地点册", source: "locations", mount: mountPlaces }
|
|
8094
|
+
]);
|
|
8095
|
+
}
|
|
8096
|
+
function mountJournal(ctx) {
|
|
8097
|
+
mergedPanel(ctx, [
|
|
8098
|
+
{ title: "行程手账", source: "book", mount: mountBook },
|
|
8099
|
+
{ title: "珍藏柜", source: "shelf", mount: mountShelf }
|
|
8100
|
+
]);
|
|
8101
|
+
}
|
|
8102
|
+
function mountStoryJournal(ctx) {
|
|
8103
|
+
const doc = ctx.root.ownerDocument;
|
|
8104
|
+
const main = doc.createElement("section");
|
|
8105
|
+
const more = doc.createElement("details");
|
|
8106
|
+
more.className = "fun-more-stories";
|
|
8107
|
+
const summary = doc.createElement("summary");
|
|
8108
|
+
summary.textContent = "更多故事";
|
|
8109
|
+
const authors = doc.createElement("div");
|
|
8110
|
+
more.append(summary, authors);
|
|
8111
|
+
ctx.root.replaceChildren(main, more);
|
|
8112
|
+
mountFishStory({ ...ctx, root: main });
|
|
8113
|
+
mountStories({ ...ctx, root: authors });
|
|
8114
|
+
}
|
|
8115
|
+
var testMounts = { home: mountHome, places: mountPlaces2, locations: mountPlaces, story: mountFishStory, stories: mountStories, book: mountBook, shelf: mountShelf };
|
|
7985
8116
|
var webui_default = {
|
|
7986
8117
|
panels: {
|
|
7987
8118
|
home: { mount: mountHome },
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
locations: { mount: mountPlaces },
|
|
7992
|
-
story: { mount: mountFishStory },
|
|
7993
|
-
stories: { mount: mountStories }
|
|
8119
|
+
outing: { mount: mountOuting },
|
|
8120
|
+
story: { mount: mountStoryJournal },
|
|
8121
|
+
journal: { mount: mountJournal }
|
|
7994
8122
|
}
|
|
7995
8123
|
};
|
|
7996
8124
|
export {
|
|
7997
|
-
webui_default as default
|
|
8125
|
+
webui_default as default,
|
|
8126
|
+
testMounts
|
|
7998
8127
|
};
|