vanspod 0.4.6 → 0.4.7
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/README.md +4 -4
- package/dist/lifecyclePage.js +95 -19
- package/dist/page.js +5 -21
- package/dist/powerMenuView.js +78 -0
- package/dist/start.js +21 -29
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/pagePrototype.js +0 -528
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ npm run dist
|
|
|
38
38
|
npm pack --pack-destination dist
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.4.
|
|
41
|
+
exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.4.7.tgz`;可在 Windows 用 `npm install -g <套件路徑>` 安裝測試。圖片、favicon、系統匣與移除腳本均包含在發佈產物中。更新 logo 後執行 `powershell.exe -NoProfile -File scripts/build-icon.ps1` 重建多尺寸 Windows icon。
|
|
42
42
|
|
|
43
43
|
exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vanspod`](https://www.npmjs.com/package/vanspod) 套件。更新時不要執行完整移除,否則會清除課堂資料。
|
|
44
44
|
|
|
@@ -46,12 +46,12 @@ exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vans
|
|
|
46
46
|
|
|
47
47
|
一般 push 不發佈;推送 `v*` tag 會在 Windows runner 安裝 Node.js 24、檢查型別、執行測試、打包並驗證 exe/npm 生命週期,全部通過後才建立 GitHub Release,最後發佈 npm 套件。學生從 Release 下載 `VansPod.exe`,同頁提供 `SHA256SUMS.txt`。
|
|
48
48
|
|
|
49
|
-
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.
|
|
49
|
+
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.7` 為例:
|
|
50
50
|
|
|
51
51
|
```powershell
|
|
52
52
|
git push origin master
|
|
53
|
-
git tag -a v0.4.
|
|
54
|
-
git push origin v0.4.
|
|
53
|
+
git tag -a v0.4.7 -m "VansPod 0.4.7"
|
|
54
|
+
git push origin v0.4.7
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
|
package/dist/lifecyclePage.js
CHANGED
|
@@ -2,42 +2,118 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lifecyclePage = lifecyclePage;
|
|
4
4
|
const versionUpdateView_1 = require("./versionUpdateView");
|
|
5
|
+
const TRASH_ICON = `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3"/></svg>`;
|
|
6
|
+
// 完整移除的確認對話框:先列出會刪除/會保留,實際路徑由管理 API 的預覽填入。
|
|
7
|
+
const REMOVE_DIALOG = `<div class="power-modal" hidden><div class="power-dialog" role="dialog" aria-modal="true" aria-labelledby="power-remove-title"><h3 id="power-remove-title">移除 VansPod?</h3><p class="power-warn">只在不再使用這台電腦上課時移除。更新版本不需要移除,否則會清掉課堂資料。</p><p class="power-warn" data-uninstall-interruptions hidden></p><div class="power-split"><div class="drop"><h4>會刪除</h4><ul><li>課堂憑證(API Key)</li><li>偏好與模式記憶</li><li>日誌與暫存檔</li><li>VansPod 程式本身</li></ul></div><div class="keep"><h4>會保留</h4><ul><li>學生專案與作品</li><li>Node、Git、VS Code</li><li>個人設定</li></ul></div></div><details class="power-paths"><summary>查看實際路徑</summary><pre data-uninstall-preview>讀取中…</pre></details><div class="power-confirm" data-power-modal-confirm hidden></div><div class="power-actions"><button type="button" class="quiet" data-power-modal-close>取消</button><button type="button" class="danger" data-lifecycle-confirm="uninstall">${TRASH_ICON}<span>確認移除</span></button></div></div></div><!-- /power-modal -->`;
|
|
5
8
|
function lifecyclePage(html, token) {
|
|
6
|
-
const
|
|
9
|
+
const stop = `<button type="button" class="power-stop" data-lifecycle="stop">結束 VansPod</button>`;
|
|
10
|
+
const remove = `<button type="button" class="power-remove" data-lifecycle="uninstall">移除 VansPod…</button>`;
|
|
7
11
|
const script = `<script>
|
|
8
12
|
(function () {
|
|
9
13
|
var token = ${JSON.stringify(token)};
|
|
14
|
+
var toggle = document.querySelector('[data-power-toggle]');
|
|
15
|
+
var message = document.querySelector('[data-lifecycle-message]');
|
|
16
|
+
var modal = document.querySelector('.power-modal');
|
|
10
17
|
async function request(action, body) {
|
|
11
18
|
var response = await fetch('/_vanspod/' + action, {method: body ? 'POST' : 'GET', headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json'}, body: body ? JSON.stringify(body) : undefined});
|
|
12
19
|
if (!response.ok) throw new Error('無法完成操作,請重新開啟 VansPod。');
|
|
13
20
|
return response.json();
|
|
14
21
|
}
|
|
22
|
+
// 訊息寫在面板裡;不是成功訊息時,電源鈕亮黃點提醒學生打開看。
|
|
23
|
+
function say(text, ok) {
|
|
24
|
+
message.textContent = text || '';
|
|
25
|
+
message.classList.toggle('ok', !!ok);
|
|
26
|
+
toggle.classList.toggle('has-message', !!text && !ok);
|
|
27
|
+
}
|
|
28
|
+
// 中斷安裝或模型回答前,在面板/對話框裡再問一次,預設停在「取消」。
|
|
29
|
+
// 面板或對話框被關掉時當作取消,按鈕才不會一直停在停用。
|
|
30
|
+
var pending = null;
|
|
31
|
+
function cancelPending(records) {
|
|
32
|
+
if (pending && records.some(function (record) { return record.target.hidden; })) pending(false);
|
|
33
|
+
}
|
|
34
|
+
var watchHidden = new MutationObserver(cancelPending);
|
|
35
|
+
watchHidden.observe(document.getElementById('power-panel'), {attributes: true, attributeFilter: ['hidden']});
|
|
36
|
+
watchHidden.observe(modal, {attributes: true, attributeFilter: ['hidden']});
|
|
37
|
+
function ask(box, text, label) {
|
|
38
|
+
return new Promise(function (resolve) {
|
|
39
|
+
box.textContent = '';
|
|
40
|
+
var question = document.createElement('p'); question.textContent = text;
|
|
41
|
+
var actions = document.createElement('div'); actions.className = 'power-actions';
|
|
42
|
+
var cancel = document.createElement('button'); cancel.type = 'button'; cancel.className = 'quiet'; cancel.textContent = '取消';
|
|
43
|
+
var go = document.createElement('button'); go.type = 'button'; go.className = 'danger'; go.textContent = label;
|
|
44
|
+
actions.append(cancel, go); box.append(question, actions); box.hidden = false; cancel.focus();
|
|
45
|
+
function done(value) { pending = null; box.hidden = true; box.textContent = ''; resolve(value); }
|
|
46
|
+
pending = done;
|
|
47
|
+
cancel.onclick = function () { done(false); };
|
|
48
|
+
go.onclick = function () { done(true); };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async function run(action, body, box, label) {
|
|
52
|
+
var result = await request(action, body);
|
|
53
|
+
if (!result.confirmation) return result;
|
|
54
|
+
if (!(await ask(box, result.message, label))) return null;
|
|
55
|
+
return request(action, Object.assign({}, body, {confirmed: true, interruptConfirmed: true}));
|
|
56
|
+
}
|
|
57
|
+
function setModal(open) {
|
|
58
|
+
if (modal.hidden === !open) return;
|
|
59
|
+
modal.hidden = !open;
|
|
60
|
+
if (open) modal.querySelector('[data-power-modal-close]').focus();
|
|
61
|
+
else document.querySelector('[data-lifecycle="uninstall"]').focus();
|
|
62
|
+
}
|
|
63
|
+
// 預覽回來前不能確認:學生要先看到會刪除什麼、會中止哪些工作。
|
|
64
|
+
async function openRemoval() {
|
|
65
|
+
var paths = modal.querySelector('[data-uninstall-preview]');
|
|
66
|
+
var interruptions = modal.querySelector('[data-uninstall-interruptions]');
|
|
67
|
+
var confirm = modal.querySelector('[data-lifecycle-confirm="uninstall"]');
|
|
68
|
+
paths.textContent = '讀取中…';
|
|
69
|
+
interruptions.hidden = true;
|
|
70
|
+
confirm.disabled = true;
|
|
71
|
+
setModal(true);
|
|
72
|
+
var preview = await request('uninstall-preview');
|
|
73
|
+
if (!preview.ok) { setModal(false); say(preview.message); return; }
|
|
74
|
+
paths.textContent = preview.message;
|
|
75
|
+
interruptions.textContent = preview.interruptions || '';
|
|
76
|
+
interruptions.hidden = !preview.interruptions;
|
|
77
|
+
confirm.disabled = false;
|
|
78
|
+
}
|
|
79
|
+
async function remove() {
|
|
80
|
+
var result = await run('uninstall', {confirmed: true}, modal.querySelector('[data-power-modal-confirm]'), '仍要移除');
|
|
81
|
+
if (!result) return;
|
|
82
|
+
setModal(false);
|
|
83
|
+
say(result.message || '操作未完成,請重試。', result.ok);
|
|
84
|
+
}
|
|
85
|
+
async function stop() {
|
|
86
|
+
var result = await run('stop', {confirmed: false}, document.querySelector('[data-power-confirm]'), '仍要結束');
|
|
87
|
+
if (!result) return;
|
|
88
|
+
say(result.message || (result.ok ? 'VansPod 已結束,可關閉此分頁。' : '操作未完成,請重試。'), result.ok);
|
|
89
|
+
if (result.ok) document.querySelector('.power-head').textContent = 'VansPod 已結束';
|
|
90
|
+
}
|
|
15
91
|
document.addEventListener('click', async function (event) {
|
|
16
|
-
var
|
|
92
|
+
var target = event.target;
|
|
93
|
+
if (!target || !target.closest) return;
|
|
94
|
+
if (target.closest('[data-power-modal-close]') || target === modal) { setModal(false); return; }
|
|
95
|
+
var button = target.closest('[data-lifecycle], [data-lifecycle-confirm]');
|
|
17
96
|
if (!button) return;
|
|
18
|
-
var message = document.querySelector('[data-lifecycle-message]');
|
|
19
97
|
button.disabled = true;
|
|
20
98
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!preview.ok) { message.textContent = preview.message; return; }
|
|
26
|
-
confirmed = window.confirm(preview.message + '\\n\\n確定完整移除 VansPod?');
|
|
27
|
-
if (!confirmed) return;
|
|
28
|
-
}
|
|
29
|
-
var result = await request(action, {confirmed: confirmed});
|
|
30
|
-
if (result.confirmation && window.confirm(result.message)) result = await request(action, {confirmed: true, interruptConfirmed: true});
|
|
31
|
-
message.textContent = result.message || (result.ok ? 'VansPod 已結束,可關閉此分頁。' : '操作未完成,請重試。');
|
|
32
|
-
} catch (error) { message.textContent = error.message; }
|
|
99
|
+
if (button.dataset.lifecycle === 'stop') await stop();
|
|
100
|
+
else if (button.dataset.lifecycle === 'uninstall') await openRemoval();
|
|
101
|
+
else await remove();
|
|
102
|
+
} catch (error) { setModal(false); say(error.message); }
|
|
33
103
|
finally { button.disabled = false; }
|
|
34
104
|
});
|
|
105
|
+
document.addEventListener('keydown', function (event) {
|
|
106
|
+
if (event.key === 'Escape' && !modal.hidden) setModal(false);
|
|
107
|
+
});
|
|
35
108
|
request('status').then(function (status) {
|
|
36
|
-
if (status.startupError) {
|
|
37
|
-
if (status.trayError) {
|
|
38
|
-
if (status.launchVersion && status.launchVersion !== status.version)
|
|
109
|
+
if (status.startupError) { say(status.startupError); return; }
|
|
110
|
+
if (status.trayError) { say('右下角的系統匣圖示無法顯示,VansPod 仍在背景執行。要結束時請用側欄底部的電源鈕。'); return; }
|
|
111
|
+
if (status.launchVersion && status.launchVersion !== status.version) say('目前執行版本 ' + status.version + ',本次開啟版本 ' + status.launchVersion + '。換版請先結束 VansPod。');
|
|
39
112
|
}).catch(function () {});
|
|
40
113
|
})();
|
|
41
114
|
</script>`;
|
|
42
|
-
return html
|
|
115
|
+
return html
|
|
116
|
+
.replace(/<form method="post" action="\/stop">[\s\S]*?<\/form>/, stop)
|
|
117
|
+
.replace("<!-- /power-panel -->", `${remove}<!-- /power-panel -->`)
|
|
118
|
+
.replace("</body>", `${REMOVE_DIALOG}${script}${(0, versionUpdateView_1.versionUpdateScript)(token)}</body>`);
|
|
43
119
|
}
|
package/dist/page.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.modelStatus = modelStatus;
|
|
4
4
|
exports.environmentStageText = environmentStageText;
|
|
5
5
|
exports.environmentStatus = environmentStatus;
|
|
6
|
-
exports.classroomBlocks = classroomBlocks;
|
|
7
6
|
exports.renderPage = renderPage;
|
|
8
7
|
exports.renderInspectorPage = renderInspectorPage;
|
|
9
8
|
const version_1 = require("./version");
|
|
@@ -20,6 +19,7 @@ const classroomApp_1 = require("./classroomApp");
|
|
|
20
19
|
const promptCapture_1 = require("./promptCapture");
|
|
21
20
|
const inspectorView_1 = require("./inspectorView");
|
|
22
21
|
const versionUpdateView_1 = require("./versionUpdateView");
|
|
22
|
+
const powerMenuView_1 = require("./powerMenuView");
|
|
23
23
|
const courseCatalog_1 = require("./courseCatalog");
|
|
24
24
|
const PRODUCT = "VansPod";
|
|
25
25
|
const VERSION = `v${version_1.VERSION}`;
|
|
@@ -312,9 +312,6 @@ function catalogTable(view) {
|
|
|
312
312
|
const snippetBlock = snippets ? `<h3>本課片段</h3>${snippets}` : "";
|
|
313
313
|
return `${head}${table}${snippetBlock}`;
|
|
314
314
|
}
|
|
315
|
-
function stopForm() {
|
|
316
|
-
return `<form method="post" action="/stop"><button type="submit" class="stop">停止</button></form>`;
|
|
317
|
-
}
|
|
318
315
|
function tile(title, body, wide = false) {
|
|
319
316
|
return `<section class="tile${wide ? " wide" : ""}"><h2>${title}</h2>${body}</section>`;
|
|
320
317
|
}
|
|
@@ -608,19 +605,6 @@ function appearanceScript() {
|
|
|
608
605
|
});
|
|
609
606
|
`;
|
|
610
607
|
}
|
|
611
|
-
function classroomBlocks(view) {
|
|
612
|
-
return {
|
|
613
|
-
status: statusWord(view),
|
|
614
|
-
notices: notices(view),
|
|
615
|
-
connect: connectInner(view),
|
|
616
|
-
folder: folderInner(view),
|
|
617
|
-
model: modelInner(view),
|
|
618
|
-
environment: environmentInner(view),
|
|
619
|
-
command: commandInner(view),
|
|
620
|
-
catalog: catalogTable(view),
|
|
621
|
-
stop: stopForm(),
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
608
|
const SIDE_PAGES = [
|
|
625
609
|
{
|
|
626
610
|
id: "settings",
|
|
@@ -639,7 +623,7 @@ const BRAND = `<div class="brand"><div class="logo-badge"><img src="/brand-logo.
|
|
|
639
623
|
/** 兩頁共用的側欄:行動版頂列、抽屜遮罩、選單與外觀切換。 */
|
|
640
624
|
function sideMenu(current) {
|
|
641
625
|
const items = SIDE_PAGES.map((page) => `<a class="side-item" href="${page.href}"${page.id === current ? ' aria-current="page"' : ""}>${page.icon}<span>${page.label}</span></a>`).join("");
|
|
642
|
-
return `<div class="mobile-top"><button type="button" class="menu-toggle" aria-label="開啟選單" aria-expanded="false" aria-controls="side-menu"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 7h16M4 12h16M4 17h16"/></svg></button>${BRAND}</div><button type="button" class="drawer-scrim" aria-label="關閉選單"></button><header class="bar" id="side-menu">${BRAND}<nav aria-label="選單">${items}</nav><div class="side-foot"><button type="button" data-appearance-toggle aria-label="切換外觀"></button>${versionUpdateView_1.UPDATE_BUTTON}</div></header>`;
|
|
626
|
+
return `<div class="mobile-top"><button type="button" class="menu-toggle" aria-label="開啟選單" aria-expanded="false" aria-controls="side-menu"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 7h16M4 12h16M4 17h16"/></svg></button>${BRAND}</div><button type="button" class="drawer-scrim" aria-label="關閉選單"></button><header class="bar" id="side-menu">${BRAND}<nav aria-label="選單">${items}</nav><div class="side-foot"><button type="button" data-appearance-toggle aria-label="切換外觀"></button>${versionUpdateView_1.UPDATE_BUTTON}${(0, powerMenuView_1.powerMenu)(VERSION)}</div></header>`;
|
|
643
627
|
}
|
|
644
628
|
/** 兩頁共用的頁殼版面:側欄、行動版抽屜。 */
|
|
645
629
|
const SHELL_LAYOUT_STYLES = `
|
|
@@ -657,6 +641,7 @@ const SHELL_LAYOUT_STYLES = `
|
|
|
657
641
|
.side-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
658
642
|
.side-item svg { width: 18px; height: 18px; flex-shrink: 0; }
|
|
659
643
|
${versionUpdateView_1.VERSION_UPDATE_STYLES}
|
|
644
|
+
${powerMenuView_1.POWER_MENU_STYLES}
|
|
660
645
|
.mobile-top, .drawer-scrim, .menu-toggle { display: none; }
|
|
661
646
|
main { justify-self: center; width: min(52rem, 100%); }
|
|
662
647
|
@media (max-width: 760px) {
|
|
@@ -718,7 +703,6 @@ function basePage(view) {
|
|
|
718
703
|
${tile("環境", environmentInner(view))}
|
|
719
704
|
${tile("指令", commandInner(view), true)}
|
|
720
705
|
${tile("課程", catalogTable(view), true)}
|
|
721
|
-
${tile("離開", stopForm(), true)}
|
|
722
706
|
</div>
|
|
723
707
|
</main>
|
|
724
708
|
</body>
|
|
@@ -1114,7 +1098,7 @@ function renderPage(view) {
|
|
|
1114
1098
|
main button.connection-clear:hover:not(:disabled) { color: light-dark(#b91c1c, #f87171); }
|
|
1115
1099
|
${classroomUpdate_1.classroomUpdateStyles}
|
|
1116
1100
|
</style>
|
|
1117
|
-
<script>${drawerScript()}${installProgress_1.installProgressScript}${environmentProgress_1.environmentProgressScript}${snippetCopyScript()}${courseSectionScript()}${connectionMascot_1.connectionMascotScript}${classroomUpdate_1.classroomUpdateScript}${settingsActions_1.settingsActionsScript}${modelStatus_1.modelStatusScript}
|
|
1101
|
+
<script>${drawerScript()}${powerMenuView_1.powerMenuScript}${installProgress_1.installProgressScript}${environmentProgress_1.environmentProgressScript}${snippetCopyScript()}${courseSectionScript()}${connectionMascot_1.connectionMascotScript}${classroomUpdate_1.classroomUpdateScript}${settingsActions_1.settingsActionsScript}${modelStatus_1.modelStatusScript}
|
|
1118
1102
|
</script>`;
|
|
1119
1103
|
return html.replace("</body>", `${extra}</body>`);
|
|
1120
1104
|
}
|
|
@@ -1186,7 +1170,7 @@ function renderInspectorPage(view) {
|
|
|
1186
1170
|
${inspectorView_1.INSPECTOR_STYLES}
|
|
1187
1171
|
</style>
|
|
1188
1172
|
${headPatrol.sheet}
|
|
1189
|
-
<script>${drawerScript()}${connectionMascot_1.connectionMascotScript}${headPatrol.script}${recorderActionsScript}${(0, inspectorView_1.inspectorScript)()}</script>
|
|
1173
|
+
<script>${drawerScript()}${powerMenuView_1.powerMenuScript}${connectionMascot_1.connectionMascotScript}${headPatrol.script}${recorderActionsScript}${(0, inspectorView_1.inspectorScript)()}</script>
|
|
1190
1174
|
</body>
|
|
1191
1175
|
</html>`;
|
|
1192
1176
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 側欄底部最右邊的電源鈕(原型 F)。只放 icon,點了先開面板說明後果,不會直接結束。
|
|
3
|
+
// 面板裡的「結束」是 /stop 表單;有管理 API 時由 lifecyclePage 換成生命週期按鈕並加上完整移除。
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.powerMenuScript = exports.POWER_MENU_STYLES = void 0;
|
|
6
|
+
exports.powerMenu = powerMenu;
|
|
7
|
+
const POWER_ICON = `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 3v8"/><path d="M6.3 6.8a8 8 0 1 0 11.4 0"/></svg>`;
|
|
8
|
+
function powerMenu(version) {
|
|
9
|
+
return `<div class="power-menu"><button type="button" class="power-toggle" data-power-toggle aria-label="結束或移除 VansPod" title="結束 VansPod" aria-haspopup="dialog" aria-expanded="false" aria-controls="power-panel">${POWER_ICON}<span class="power-dot" aria-hidden="true"></span></button><div class="power-panel" id="power-panel" role="dialog" aria-label="結束 VansPod" hidden><div class="power-head"><span class="power-live" aria-hidden="true"></span><strong>VansPod ${version} 執行中</strong></div><p class="power-message" role="status" data-lifecycle-message></p><p class="power-note">下課時再結束。課堂連線會中斷,各工具設定恢復原狀;課堂資料保留,下次開啟可接續。</p><div class="power-confirm" data-power-confirm hidden></div><div class="power-actions"><button type="button" class="quiet" data-power-close>取消</button><form method="post" action="/stop"><button type="submit" class="power-stop">結束 VansPod</button></form></div><!-- /power-panel --></div></div>`;
|
|
10
|
+
}
|
|
11
|
+
exports.POWER_MENU_STYLES = `
|
|
12
|
+
.bar .side-foot { position: relative; }
|
|
13
|
+
.power-menu { margin-left: auto; padding-left: 10px; border-left: 1px solid var(--line); display: flex; }
|
|
14
|
+
.power-toggle { position: relative; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; min-height: 2.75rem; flex: 0 0 auto; padding: 0; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
|
|
15
|
+
.power-toggle svg { width: 1.2rem; height: 1.2rem; }
|
|
16
|
+
.power-toggle:hover, .power-toggle[aria-expanded="true"] { color: light-dark(#b91c1c, #f87171); border-color: light-dark(rgba(185, 28, 28, 0.35), rgba(248, 113, 113, 0.35)); background: light-dark(rgba(185, 28, 28, 0.05), rgba(248, 113, 113, 0.08)); }
|
|
17
|
+
.power-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
18
|
+
.power-dot { display: none; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 999px; background: #f59e0b; box-shadow: 0 0 0 2px var(--bg); }
|
|
19
|
+
.power-toggle.has-message .power-dot { display: block; }
|
|
20
|
+
.power-panel { position: absolute; left: 0; bottom: calc(100% + 10px); z-index: 50; width: min(300px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--tile); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25); color: var(--text); font-size: 13px; }
|
|
21
|
+
.power-panel[hidden] { display: none; }
|
|
22
|
+
.power-head { display: flex; align-items: center; gap: 8px; }
|
|
23
|
+
.power-live { width: 8px; height: 8px; border-radius: 999px; background: light-dark(#10a37f, #4ecb9d); box-shadow: 0 0 0 3px light-dark(rgba(16, 163, 127, 0.15), rgba(78, 203, 157, 0.15)); }
|
|
24
|
+
.power-note { color: var(--muted); line-height: 1.6; }
|
|
25
|
+
.power-message:empty { display: none; }
|
|
26
|
+
.power-message { padding: 10px 12px; border-radius: 10px; background: light-dark(#fff7ed, #3b3024); color: light-dark(#9a3412, #fed7aa); line-height: 1.6; white-space: pre-line; }
|
|
27
|
+
.power-message.ok { background: light-dark(rgba(16, 163, 127, 0.10), rgba(78, 203, 157, 0.13)); color: light-dark(#0a7d5c, #4ecb9d); }
|
|
28
|
+
.power-confirm { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 10px; border: 1px solid light-dark(rgba(185, 28, 28, 0.30), rgba(248, 113, 113, 0.30)); background: light-dark(rgba(185, 28, 28, 0.04), rgba(248, 113, 113, 0.06)); line-height: 1.6; white-space: pre-line; }
|
|
29
|
+
.power-confirm[hidden] { display: none; }
|
|
30
|
+
.power-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
31
|
+
.power-panel button, .power-dialog button { min-height: 34px; padding: 8px 16px; border-radius: 999px; border: 1px solid transparent; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 500; }
|
|
32
|
+
.power-panel button.quiet, .power-dialog button.quiet { background: transparent; color: var(--text); border-color: var(--line); }
|
|
33
|
+
.power-panel button.danger, .power-dialog button.danger { display: inline-flex; align-items: center; gap: 6px; background: light-dark(#b91c1c, #f87171); color: light-dark(#ffffff, #1c1c1e); }
|
|
34
|
+
.power-dialog button.danger svg { width: 15px; height: 15px; }
|
|
35
|
+
.power-panel .power-remove { width: 100%; min-height: 0; padding: 10px 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--muted); font-size: 12px; text-align: left; }
|
|
36
|
+
.power-panel .power-remove:hover { color: light-dark(#b91c1c, #f87171); }
|
|
37
|
+
.power-modal { position: fixed; inset: 0; z-index: 96; display: grid; place-items: center; padding: 24px; background: light-dark(rgba(20, 20, 20, 0.32), rgba(0, 0, 0, 0.52)); }
|
|
38
|
+
.power-modal[hidden] { display: none; }
|
|
39
|
+
.power-dialog { width: min(34rem, 100%); max-height: calc(100dvh - 48px); overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--tile); color: var(--text); font-size: 13px; }
|
|
40
|
+
.power-dialog > h3 { margin: 0; font-size: 18px; font-weight: 600; }
|
|
41
|
+
.power-warn { padding: 10px 12px; border-radius: 10px; background: light-dark(#fff7ed, #3b3024); color: light-dark(#9a3412, #fed7aa); line-height: 1.6; }
|
|
42
|
+
.power-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
|
43
|
+
.power-split > div { padding: 10px 12px; border-radius: 10px; background: var(--input); }
|
|
44
|
+
.power-split h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; }
|
|
45
|
+
.power-split .drop h4 { color: light-dark(#b91c1c, #f87171); }
|
|
46
|
+
.power-split .keep h4 { color: light-dark(#0a7d5c, #4ecb9d); }
|
|
47
|
+
.power-split ul { margin: 0; padding-left: 18px; line-height: 1.7; }
|
|
48
|
+
.power-paths summary { width: fit-content; cursor: pointer; color: var(--muted); font-size: 12px; }
|
|
49
|
+
.power-paths pre { margin: 6px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--input); font-size: 12px; line-height: 1.6; }
|
|
50
|
+
@media (max-width: 40rem) { .power-split { grid-template-columns: 1fr; } }
|
|
51
|
+
@media (max-width: 760px) { .power-panel { width: 100%; } }`;
|
|
52
|
+
/** 面板開關:點電源鈕切換,取消/Esc/點面板外關閉。完整移除的對話框開著時不收面板。 */
|
|
53
|
+
exports.powerMenuScript = `
|
|
54
|
+
(function () {
|
|
55
|
+
var toggle = document.querySelector("[data-power-toggle]");
|
|
56
|
+
var panel = document.getElementById("power-panel");
|
|
57
|
+
if (!toggle || !panel) return;
|
|
58
|
+
function setOpen(open) {
|
|
59
|
+
panel.hidden = !open;
|
|
60
|
+
toggle.setAttribute("aria-expanded", open ? "true" : "false");
|
|
61
|
+
if (open) panel.querySelector("[data-power-close]").focus();
|
|
62
|
+
}
|
|
63
|
+
document.addEventListener("click", function (event) {
|
|
64
|
+
var target = event.target;
|
|
65
|
+
if (!target || !target.closest) return;
|
|
66
|
+
if (target.closest("[data-power-toggle]")) { setOpen(panel.hidden); return; }
|
|
67
|
+
if (target.closest("[data-power-close]")) { setOpen(false); toggle.focus(); return; }
|
|
68
|
+
if (!panel.hidden && !target.closest(".power-menu") && !target.closest(".power-modal")) setOpen(false);
|
|
69
|
+
});
|
|
70
|
+
document.addEventListener("keydown", function (event) {
|
|
71
|
+
if (event.key !== "Escape" || panel.hidden) return;
|
|
72
|
+
var modal = document.querySelector(".power-modal");
|
|
73
|
+
if (modal && !modal.hidden) return;
|
|
74
|
+
setOpen(false);
|
|
75
|
+
toggle.focus();
|
|
76
|
+
});
|
|
77
|
+
})();
|
|
78
|
+
`;
|
package/dist/start.js
CHANGED
|
@@ -21,7 +21,6 @@ const commandRunner_1 = require("./commandRunner");
|
|
|
21
21
|
const windowsEnvironment_1 = require("./windowsEnvironment");
|
|
22
22
|
const windowsEnvironmentSystem_1 = require("./windowsEnvironmentSystem");
|
|
23
23
|
const exitGuard_1 = require("./exitGuard");
|
|
24
|
-
const pagePrototype_1 = require("./pagePrototype");
|
|
25
24
|
const routeFiles_1 = require("./routeFiles");
|
|
26
25
|
const responsesChat_1 = require("./responsesChat");
|
|
27
26
|
const adapterSettings_1 = require("./adapterSettings");
|
|
@@ -444,18 +443,13 @@ async function main(instance) {
|
|
|
444
443
|
}
|
|
445
444
|
const parsed = new URL(req.url ?? "/", `http://127.0.0.1:${port}`);
|
|
446
445
|
const pathname = parsed.pathname;
|
|
447
|
-
const goHome = (
|
|
446
|
+
const goHome = () => {
|
|
448
447
|
if (req.headers["x-classroom-settings"] === "1") {
|
|
449
448
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
|
|
450
449
|
const html = (0, page_1.renderPage)(app.pageView());
|
|
451
450
|
res.end(instance ? (0, lifecyclePage_1.lifecyclePage)(html, instance.token) : html);
|
|
452
451
|
return;
|
|
453
452
|
}
|
|
454
|
-
const variant = params?.get("prototype_variant") ?? "";
|
|
455
|
-
if (process.env.NODE_ENV !== "production" && (0, pagePrototype_1.isPrototypeVariant)(variant)) {
|
|
456
|
-
redirect(res, `/?variant=${variant}`);
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
453
|
redirect(res);
|
|
460
454
|
};
|
|
461
455
|
try {
|
|
@@ -486,7 +480,8 @@ async function main(instance) {
|
|
|
486
480
|
return;
|
|
487
481
|
}
|
|
488
482
|
if (req.method === "GET" && pathname === "/_vanspod/uninstall-preview") {
|
|
489
|
-
|
|
483
|
+
const interruptions = (0, exitGuard_1.removalInterruptions)(exitWork());
|
|
484
|
+
reply({ ok: true, message: `${await (0, removal_1.removalPreview)()}${interruptions}`, interruptions: interruptions.trim() });
|
|
490
485
|
return;
|
|
491
486
|
}
|
|
492
487
|
if (req.method === "POST" && (pathname === "/_vanspod/stop" || pathname === "/_vanspod/uninstall")) {
|
|
@@ -573,10 +568,7 @@ async function main(instance) {
|
|
|
573
568
|
// 版本更新後重新啟動時,舊分頁一拿到首頁就重新整理頁面;
|
|
574
569
|
// 等 Classroom Connection 恢復、Course Catalog 載入後才給頁面,免得課程安裝停在尚未載入的狀態。
|
|
575
570
|
await startupSettled;
|
|
576
|
-
const
|
|
577
|
-
const html = process.env.NODE_ENV !== "production" && (0, pagePrototype_1.isPrototypeVariant)(variant)
|
|
578
|
-
? (0, pagePrototype_1.renderPrototypePage)(app.pageView(), variant)
|
|
579
|
-
: (0, page_1.renderPage)(app.pageView());
|
|
571
|
+
const html = (0, page_1.renderPage)(app.pageView());
|
|
580
572
|
res.writeHead(200, {
|
|
581
573
|
"Content-Type": "text/html; charset=utf-8",
|
|
582
574
|
"Cache-Control": "no-store",
|
|
@@ -596,7 +588,7 @@ async function main(instance) {
|
|
|
596
588
|
if (req.method === "POST" && pathname === "/redeem") {
|
|
597
589
|
const params = new URLSearchParams(await readBody(req));
|
|
598
590
|
await app.redeem(params.get("invite_code") ?? "", params.get("nickname") ?? "");
|
|
599
|
-
goHome(
|
|
591
|
+
goHome();
|
|
600
592
|
return;
|
|
601
593
|
}
|
|
602
594
|
if (req.method === "POST" && pathname === "/pick-folder") {
|
|
@@ -604,7 +596,7 @@ async function main(instance) {
|
|
|
604
596
|
const picked = await (0, folderPicker_1.pickProjectFolder)();
|
|
605
597
|
if (picked)
|
|
606
598
|
await app.setProjectFolder(picked);
|
|
607
|
-
goHome(
|
|
599
|
+
goHome();
|
|
608
600
|
return;
|
|
609
601
|
}
|
|
610
602
|
if (req.method === "POST" && pathname === "/project-folder") {
|
|
@@ -616,7 +608,7 @@ async function main(instance) {
|
|
|
616
608
|
else {
|
|
617
609
|
app.rejectProjectFolder();
|
|
618
610
|
}
|
|
619
|
-
goHome(
|
|
611
|
+
goHome();
|
|
620
612
|
return;
|
|
621
613
|
}
|
|
622
614
|
if (req.method === "POST" && pathname === "/prepare") {
|
|
@@ -628,7 +620,7 @@ async function main(instance) {
|
|
|
628
620
|
res.end((0, page_1.renderPage)(view));
|
|
629
621
|
return;
|
|
630
622
|
}
|
|
631
|
-
goHome(
|
|
623
|
+
goHome();
|
|
632
624
|
return;
|
|
633
625
|
}
|
|
634
626
|
if (req.method === "POST" && pathname === "/confirm") {
|
|
@@ -640,7 +632,7 @@ async function main(instance) {
|
|
|
640
632
|
res.end(JSON.stringify({ succeeded: view.commandSucceeded, aborted: view.commandAborted === true, output: view.commandOutput ?? "", installedActionIds: view.installedActionIds ?? [] }));
|
|
641
633
|
return;
|
|
642
634
|
}
|
|
643
|
-
goHome(
|
|
635
|
+
goHome();
|
|
644
636
|
return;
|
|
645
637
|
}
|
|
646
638
|
if (req.method === "POST" && pathname === "/cancel") {
|
|
@@ -652,7 +644,7 @@ async function main(instance) {
|
|
|
652
644
|
res.end(JSON.stringify({ canceled }));
|
|
653
645
|
return;
|
|
654
646
|
}
|
|
655
|
-
goHome(
|
|
647
|
+
goHome();
|
|
656
648
|
return;
|
|
657
649
|
}
|
|
658
650
|
if (req.method === "POST" && pathname === "/abort-install") {
|
|
@@ -663,25 +655,25 @@ async function main(instance) {
|
|
|
663
655
|
res.end(JSON.stringify({ aborted: true }));
|
|
664
656
|
return;
|
|
665
657
|
}
|
|
666
|
-
goHome(
|
|
658
|
+
goHome();
|
|
667
659
|
return;
|
|
668
660
|
}
|
|
669
661
|
if (req.method === "POST" && pathname === "/environment-check") {
|
|
670
662
|
const params = new URLSearchParams(await readBody(req));
|
|
671
663
|
await app.checkEnvironment();
|
|
672
|
-
goHome(
|
|
664
|
+
goHome();
|
|
673
665
|
return;
|
|
674
666
|
}
|
|
675
667
|
if (req.method === "POST" && pathname === "/environment-log") {
|
|
676
668
|
const params = new URLSearchParams(await readBody(req));
|
|
677
669
|
await app.openEnvironmentLog();
|
|
678
|
-
goHome(
|
|
670
|
+
goHome();
|
|
679
671
|
return;
|
|
680
672
|
}
|
|
681
673
|
if (req.method === "POST" && pathname === "/open-vscode") {
|
|
682
674
|
const params = new URLSearchParams(await readBody(req));
|
|
683
675
|
await app.openVsCode().catch(() => { });
|
|
684
|
-
goHome(
|
|
676
|
+
goHome();
|
|
685
677
|
return;
|
|
686
678
|
}
|
|
687
679
|
if (req.method === "POST" && pathname === "/environment") {
|
|
@@ -693,13 +685,13 @@ async function main(instance) {
|
|
|
693
685
|
// 背景安裝:請求立刻回來,頁面輪詢 /environment-status。commandRunning 在 confirmEnvironment 同步開頭就設好,
|
|
694
686
|
// 轉回首頁時已顯示進行中,exit guard、版本更新與移除也照常看得到這次安裝。
|
|
695
687
|
void app.confirmEnvironment().catch(() => { });
|
|
696
|
-
goHome(
|
|
688
|
+
goHome();
|
|
697
689
|
return;
|
|
698
690
|
}
|
|
699
691
|
if (req.method === "POST" && pathname === "/copy") {
|
|
700
692
|
const params = new URLSearchParams(await readBody(req));
|
|
701
693
|
await app.copyKey();
|
|
702
|
-
goHome(
|
|
694
|
+
goHome();
|
|
703
695
|
return;
|
|
704
696
|
}
|
|
705
697
|
if (req.method === "POST" && pathname === "/copy-snippet") {
|
|
@@ -712,7 +704,7 @@ async function main(instance) {
|
|
|
712
704
|
if (req.method === "POST" && pathname === "/clear") {
|
|
713
705
|
const params = new URLSearchParams(await readBody(req));
|
|
714
706
|
await app.clearConnection();
|
|
715
|
-
goHome(
|
|
707
|
+
goHome();
|
|
716
708
|
return;
|
|
717
709
|
}
|
|
718
710
|
if (req.method === "POST" && pathname === "/switch") {
|
|
@@ -727,7 +719,7 @@ async function main(instance) {
|
|
|
727
719
|
}
|
|
728
720
|
await app.setSwitch(mode, client ?? undefined);
|
|
729
721
|
}
|
|
730
|
-
goHome(
|
|
722
|
+
goHome();
|
|
731
723
|
return;
|
|
732
724
|
}
|
|
733
725
|
if (req.method === "POST" && pathname === "/adapter") {
|
|
@@ -739,14 +731,14 @@ async function main(instance) {
|
|
|
739
731
|
return;
|
|
740
732
|
}
|
|
741
733
|
await app.setAdapter(client, params.get("adapter") ?? "");
|
|
742
|
-
goHome(
|
|
734
|
+
goHome();
|
|
743
735
|
return;
|
|
744
736
|
}
|
|
745
737
|
if (req.method === "POST" && pathname === "/reload") {
|
|
746
738
|
const params = new URLSearchParams(await readBody(req));
|
|
747
739
|
await app.reloadCatalog();
|
|
748
740
|
await app.reloadAllowlist();
|
|
749
|
-
goHome(
|
|
741
|
+
goHome();
|
|
750
742
|
return;
|
|
751
743
|
}
|
|
752
744
|
if ((req.method === "POST" || req.method === "PUT") &&
|
|
@@ -803,7 +795,7 @@ async function main(instance) {
|
|
|
803
795
|
}
|
|
804
796
|
const params = new URLSearchParams(await readBody(req));
|
|
805
797
|
await app.stop();
|
|
806
|
-
goHome(
|
|
798
|
+
goHome();
|
|
807
799
|
return;
|
|
808
800
|
}
|
|
809
801
|
if (req.method === "POST" && pathname === "/close") {
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
package/dist/pagePrototype.js
DELETED
|
@@ -1,528 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROTOTYPE_VARIANTS = void 0;
|
|
4
|
-
exports.isPrototypeVariant = isPrototypeVariant;
|
|
5
|
-
exports.renderPrototypePage = renderPrototypePage;
|
|
6
|
-
const page_1 = require("./page");
|
|
7
|
-
const PRODUCT = "VansPod";
|
|
8
|
-
exports.PROTOTYPE_VARIANTS = ["A", "B", "C", "D"];
|
|
9
|
-
const VARIANT_NAME = {
|
|
10
|
-
A: "側欄控制台",
|
|
11
|
-
B: "設定清單",
|
|
12
|
-
C: "工作區",
|
|
13
|
-
D: "原本",
|
|
14
|
-
};
|
|
15
|
-
const SECTIONS = [
|
|
16
|
-
{ id: "connect", label: "連線" },
|
|
17
|
-
{ id: "folder", label: "資料夾" },
|
|
18
|
-
{ id: "model", label: "模型" },
|
|
19
|
-
{ id: "environment", label: "環境" },
|
|
20
|
-
{ id: "command", label: "指令" },
|
|
21
|
-
{ id: "catalog", label: "課程" },
|
|
22
|
-
];
|
|
23
|
-
function isPrototypeVariant(value) {
|
|
24
|
-
return exports.PROTOTYPE_VARIANTS.includes(value);
|
|
25
|
-
}
|
|
26
|
-
function stamp(html, variant) {
|
|
27
|
-
if (!variant)
|
|
28
|
-
return html;
|
|
29
|
-
return html.replaceAll(/<form\b([^>]*)>/g, `<form$1><input type="hidden" name="prototype_variant" value="${variant}">`);
|
|
30
|
-
}
|
|
31
|
-
function stateText(view) {
|
|
32
|
-
return JSON.stringify({
|
|
33
|
-
connected: view.connected,
|
|
34
|
-
mode: view.mode,
|
|
35
|
-
modelId: view.modelId ?? null,
|
|
36
|
-
classLabel: view.classLabel ?? null,
|
|
37
|
-
detail: view.detail,
|
|
38
|
-
notice: view.notice ?? null,
|
|
39
|
-
projectFolder: view.projectFolder ?? null,
|
|
40
|
-
installAvailable: view.installAvailable,
|
|
41
|
-
commandRunning: view.commandRunning,
|
|
42
|
-
pendingCommand: view.pendingCommand ?? null,
|
|
43
|
-
catalogError: view.catalogError ?? null,
|
|
44
|
-
actions: view.catalog?.actions.length ?? 0,
|
|
45
|
-
snippets: view.catalog?.snippets?.length ?? 0,
|
|
46
|
-
tools: view.tools.map((tool) => ({
|
|
47
|
-
id: tool.id,
|
|
48
|
-
readiness: tool.readiness,
|
|
49
|
-
selected: tool.selected,
|
|
50
|
-
})),
|
|
51
|
-
mustRestart: view.mustRestart ?? [],
|
|
52
|
-
}, null, 2);
|
|
53
|
-
}
|
|
54
|
-
const CSS = `
|
|
55
|
-
:root {
|
|
56
|
-
color-scheme: light dark;
|
|
57
|
-
--bg: light-dark(#ffffff, #212121);
|
|
58
|
-
--rail: light-dark(#f9f9f9, #171717);
|
|
59
|
-
--surface: light-dark(#ffffff, #262626);
|
|
60
|
-
--raised: light-dark(#f4f4f4, #303030);
|
|
61
|
-
--border: light-dark(#e6e6e6, #3d3d3d);
|
|
62
|
-
--border-soft: light-dark(#f0f0f0, #333333);
|
|
63
|
-
--text: light-dark(#0d0d0d, #ececec);
|
|
64
|
-
--muted: light-dark(#6e6e6e, #a6a6a6);
|
|
65
|
-
--faint: light-dark(#707070, #9a9a9a);
|
|
66
|
-
--accent: light-dark(#0d0d0d, #ececec);
|
|
67
|
-
--accent-hover: light-dark(#3d3d3d, #ffffff);
|
|
68
|
-
--accent-ink: light-dark(#ffffff, #0d0d0d);
|
|
69
|
-
--accent-soft: light-dark(rgba(13, 13, 13, 0.06), rgba(255, 255, 255, 0.09));
|
|
70
|
-
--accent-ring: light-dark(rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.38));
|
|
71
|
-
--green: light-dark(#0a7d5c, #4ecb9d);
|
|
72
|
-
--green-soft: light-dark(rgba(16, 163, 127, 0.10), rgba(78, 203, 157, 0.13));
|
|
73
|
-
--red: light-dark(#b91c1c, #f87171);
|
|
74
|
-
--red-soft: light-dark(rgba(185, 28, 28, 0.09), rgba(248, 113, 113, 0.13));
|
|
75
|
-
--amber: light-dark(#9a4a08, #fbbf24);
|
|
76
|
-
--glass-rail: light-dark(rgba(249, 249, 249, 0.66), rgba(23, 23, 23, 0.62));
|
|
77
|
-
--radius: 12px;
|
|
78
|
-
--radius-sm: 8px;
|
|
79
|
-
--radius-pill: 999px;
|
|
80
|
-
--font-ui: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
|
|
81
|
-
--font-code: ui-monospace, "Cascadia Code", Consolas, monospace;
|
|
82
|
-
}
|
|
83
|
-
:root[data-theme="light"] { color-scheme: light; }
|
|
84
|
-
:root[data-theme="dark"] { color-scheme: dark; }
|
|
85
|
-
* { box-sizing: border-box; }
|
|
86
|
-
html, body { margin: 0; min-height: 100%; }
|
|
87
|
-
body {
|
|
88
|
-
background: transparent;
|
|
89
|
-
color: var(--text);
|
|
90
|
-
font-family: var(--font-ui);
|
|
91
|
-
font-size: 14px;
|
|
92
|
-
line-height: 1.5;
|
|
93
|
-
}
|
|
94
|
-
body::before {
|
|
95
|
-
content: "";
|
|
96
|
-
position: fixed;
|
|
97
|
-
inset: -20%;
|
|
98
|
-
z-index: -1;
|
|
99
|
-
pointer-events: none;
|
|
100
|
-
background:
|
|
101
|
-
radial-gradient(42% 38% at 12% 6%, light-dark(rgba(164, 196, 255, 0.42), rgba(96, 130, 200, 0.16)), transparent 70%),
|
|
102
|
-
radial-gradient(46% 42% at 88% 18%, light-dark(rgba(168, 226, 197, 0.38), rgba(88, 160, 130, 0.13)), transparent 70%),
|
|
103
|
-
radial-gradient(40% 36% at 70% 92%, light-dark(rgba(255, 224, 194, 0.30), rgba(180, 140, 100, 0.08)), transparent 72%),
|
|
104
|
-
var(--bg);
|
|
105
|
-
filter: blur(70px);
|
|
106
|
-
}
|
|
107
|
-
button, input { font: inherit; color: inherit; }
|
|
108
|
-
button { cursor: pointer; }
|
|
109
|
-
button:disabled { opacity: 0.55; cursor: default; }
|
|
110
|
-
h1, h2, h3, p { margin: 0; }
|
|
111
|
-
pre, code { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-code); font-size: 12px; }
|
|
112
|
-
.hint, .empty, .mode-line { color: var(--muted); font-size: 13px; }
|
|
113
|
-
.error, .restart { color: var(--red); font-size: 13px; }
|
|
114
|
-
.running { color: var(--green); font-weight: 600; font-size: 13px; }
|
|
115
|
-
.detail, .notice, .class-label { font-size: 14px; }
|
|
116
|
-
.proto button:not(.nav-item):not(.theme-btn) {
|
|
117
|
-
display: inline-flex;
|
|
118
|
-
align-items: center;
|
|
119
|
-
justify-content: center;
|
|
120
|
-
min-height: 34px;
|
|
121
|
-
padding: 8px 16px;
|
|
122
|
-
border: 1px solid transparent;
|
|
123
|
-
border-radius: var(--radius-pill);
|
|
124
|
-
background: var(--accent);
|
|
125
|
-
color: var(--accent-ink);
|
|
126
|
-
font-size: 13px;
|
|
127
|
-
font-weight: 500;
|
|
128
|
-
}
|
|
129
|
-
.proto button.quiet {
|
|
130
|
-
background: var(--bg);
|
|
131
|
-
color: var(--text);
|
|
132
|
-
border-color: var(--border);
|
|
133
|
-
}
|
|
134
|
-
.proto button.stop {
|
|
135
|
-
background: transparent;
|
|
136
|
-
color: var(--red);
|
|
137
|
-
border-color: transparent;
|
|
138
|
-
}
|
|
139
|
-
.proto .modes {
|
|
140
|
-
display: flex;
|
|
141
|
-
gap: 2px;
|
|
142
|
-
padding: 2px;
|
|
143
|
-
border-radius: var(--radius-pill);
|
|
144
|
-
background: var(--raised);
|
|
145
|
-
border: 1px solid var(--border);
|
|
146
|
-
}
|
|
147
|
-
.proto .modes button {
|
|
148
|
-
flex: 1;
|
|
149
|
-
background: transparent;
|
|
150
|
-
color: var(--muted);
|
|
151
|
-
border-color: transparent;
|
|
152
|
-
}
|
|
153
|
-
.proto .modes button.on {
|
|
154
|
-
background: var(--accent);
|
|
155
|
-
color: var(--accent-ink);
|
|
156
|
-
}
|
|
157
|
-
.proto input:not([type="checkbox"]):not([type="hidden"]) {
|
|
158
|
-
width: 100%;
|
|
159
|
-
min-height: 34px;
|
|
160
|
-
border: 1px solid var(--border);
|
|
161
|
-
border-radius: var(--radius-sm);
|
|
162
|
-
background: var(--bg);
|
|
163
|
-
padding: 0 10px;
|
|
164
|
-
font-size: 13px;
|
|
165
|
-
}
|
|
166
|
-
.proto label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
|
|
167
|
-
.proto form.stack, .proto .tools { display: flex; flex-direction: column; gap: 10px; }
|
|
168
|
-
.proto .tool { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
|
|
169
|
-
.proto .tool em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 12px; }
|
|
170
|
-
.proto table { width: 100%; border-collapse: collapse; }
|
|
171
|
-
.proto th, .proto td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border-soft); }
|
|
172
|
-
.proto th { font-size: 12px; font-weight: 500; color: var(--muted); }
|
|
173
|
-
.proto .choices { display: flex; gap: 8px; align-items: center; }
|
|
174
|
-
.proto .pending, .proto pre {
|
|
175
|
-
margin: 0;
|
|
176
|
-
padding: 12px;
|
|
177
|
-
background: var(--raised);
|
|
178
|
-
border: 1px solid var(--border-soft);
|
|
179
|
-
border-radius: var(--radius-sm);
|
|
180
|
-
}
|
|
181
|
-
.badge {
|
|
182
|
-
display: inline-flex;
|
|
183
|
-
align-items: center;
|
|
184
|
-
min-height: 22px;
|
|
185
|
-
padding: 0 8px;
|
|
186
|
-
border-radius: var(--radius-pill);
|
|
187
|
-
background: var(--green-soft);
|
|
188
|
-
color: var(--green);
|
|
189
|
-
font-size: 12px;
|
|
190
|
-
font-weight: 600;
|
|
191
|
-
}
|
|
192
|
-
.badge.off { background: var(--raised); color: var(--muted); }
|
|
193
|
-
.brand-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
|
194
|
-
.mark {
|
|
195
|
-
width: 26px; height: 26px; border-radius: 6px; overflow: hidden; flex: 0 0 auto;
|
|
196
|
-
border: 1px solid var(--border); background: var(--surface);
|
|
197
|
-
}
|
|
198
|
-
.mark img { width: 100%; height: 100%; object-fit: contain; }
|
|
199
|
-
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: 0; }
|
|
200
|
-
.theme-btn {
|
|
201
|
-
width: 34px; height: 34px; padding: 0; border-radius: 999px;
|
|
202
|
-
background: var(--surface); color: var(--text); border: 1px solid var(--border);
|
|
203
|
-
}
|
|
204
|
-
.notices { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 18px; max-width: 70ch; }
|
|
205
|
-
|
|
206
|
-
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
|
|
207
|
-
.sidebar {
|
|
208
|
-
position: sticky; top: 0; height: 100dvh;
|
|
209
|
-
display: flex; flex-direction: column; gap: 4px;
|
|
210
|
-
padding: 18px 14px;
|
|
211
|
-
border-right: 1px solid var(--border);
|
|
212
|
-
background: var(--glass-rail);
|
|
213
|
-
backdrop-filter: saturate(1.6) blur(22px);
|
|
214
|
-
}
|
|
215
|
-
.sidebar nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
|
|
216
|
-
.nav-item {
|
|
217
|
-
display: flex; align-items: center; width: 100%;
|
|
218
|
-
padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
|
|
219
|
-
background: none; color: var(--muted); font-size: 13px; font-weight: 500;
|
|
220
|
-
text-align: left;
|
|
221
|
-
}
|
|
222
|
-
.nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
|
|
223
|
-
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
|
|
224
|
-
.main { min-width: 0; }
|
|
225
|
-
.main-inner { max-width: 980px; margin: 0 auto; padding: 32px 36px 96px; }
|
|
226
|
-
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
|
|
227
|
-
.page-head h2 { font-size: 20px; font-weight: 600; }
|
|
228
|
-
.panel { display: none; }
|
|
229
|
-
.panel.on { display: block; }
|
|
230
|
-
|
|
231
|
-
.sheet { max-width: 880px; margin: 0 auto; padding: 28px 28px 120px; }
|
|
232
|
-
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
|
|
233
|
-
.set-list { margin-top: 12px; border-top: 1px solid var(--border); }
|
|
234
|
-
.set-row {
|
|
235
|
-
display: grid;
|
|
236
|
-
grid-template-columns: 180px minmax(0, 1fr);
|
|
237
|
-
gap: 20px;
|
|
238
|
-
padding: 18px 0;
|
|
239
|
-
border-bottom: 1px solid var(--border);
|
|
240
|
-
}
|
|
241
|
-
.set-label h2 { font-size: 14px; font-weight: 600; }
|
|
242
|
-
.set-label p { margin-top: 4px; color: var(--muted); font-size: 12px; }
|
|
243
|
-
.sheet-block { padding: 22px 0 8px; }
|
|
244
|
-
.sheet-block h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
|
|
245
|
-
|
|
246
|
-
.workspace { min-height: 100dvh; display: flex; flex-direction: column; }
|
|
247
|
-
.topbar {
|
|
248
|
-
display: flex; align-items: center; justify-content: space-between; gap: 12px;
|
|
249
|
-
padding: 14px 20px; border-bottom: 1px solid var(--border);
|
|
250
|
-
background: var(--glass-rail); backdrop-filter: saturate(1.6) blur(22px);
|
|
251
|
-
position: sticky; top: 0;
|
|
252
|
-
}
|
|
253
|
-
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0; flex: 1; }
|
|
254
|
-
.rail-actions { border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
|
|
255
|
-
.rail-actions section { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); }
|
|
256
|
-
.rail-actions h2 { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
|
|
257
|
-
.detail { padding: 20px 24px 110px; min-width: 0; }
|
|
258
|
-
.detail h2 { font-size: 12px; font-weight: 500; color: var(--muted); margin: 18px 0 8px; }
|
|
259
|
-
.detail h2:first-child { margin-top: 0; }
|
|
260
|
-
.terminal { background: var(--rail); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 180px; }
|
|
261
|
-
|
|
262
|
-
.proto-bar {
|
|
263
|
-
position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
|
|
264
|
-
z-index: 80; width: min(440px, calc(100% - 24px));
|
|
265
|
-
display: flex; flex-direction: column; gap: 6px; align-items: center;
|
|
266
|
-
}
|
|
267
|
-
.proto-state {
|
|
268
|
-
width: 100%; max-height: 88px; overflow: auto; margin: 0;
|
|
269
|
-
padding: 8px 10px; border-radius: 10px;
|
|
270
|
-
background: #111; color: #f4f4f4; border: 2px solid #f5c518;
|
|
271
|
-
font-size: 10px; line-height: 1.35;
|
|
272
|
-
}
|
|
273
|
-
.proto-pill {
|
|
274
|
-
display: flex; align-items: center; gap: 8px;
|
|
275
|
-
padding: 6px 8px; border-radius: 999px;
|
|
276
|
-
background: #111; color: #fff; border: 2px solid #f5c518;
|
|
277
|
-
box-shadow: 0 8px 24px rgba(0,0,0,0.28);
|
|
278
|
-
}
|
|
279
|
-
.proto-pill button {
|
|
280
|
-
width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 999px;
|
|
281
|
-
background: #f5c518; color: #111; border: 0; font-weight: 700;
|
|
282
|
-
align-self: auto;
|
|
283
|
-
}
|
|
284
|
-
.proto-pill span { font-size: 13px; font-weight: 600; min-width: 9rem; text-align: center; }
|
|
285
|
-
@media (max-width: 760px) {
|
|
286
|
-
.shell, .split, .set-row { grid-template-columns: 1fr; }
|
|
287
|
-
.sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
|
|
288
|
-
.rail-actions { border-right: 0; border-bottom: 1px solid var(--border); }
|
|
289
|
-
.main-inner, .sheet { padding-inline: 16px; }
|
|
290
|
-
}
|
|
291
|
-
@media (prefers-reduced-motion: reduce) {
|
|
292
|
-
* { transition: none !important; }
|
|
293
|
-
}
|
|
294
|
-
`;
|
|
295
|
-
function themeButton() {
|
|
296
|
-
return `<button type="button" class="theme-btn" data-appearance-toggle aria-label="切換外觀">◐</button>`;
|
|
297
|
-
}
|
|
298
|
-
function brand() {
|
|
299
|
-
return `<div class="brand-row">
|
|
300
|
-
<div class="mark"><img src="/brand-logo.png" alt=""></div>
|
|
301
|
-
<div class="brand-name">${PRODUCT}</div>
|
|
302
|
-
</div>`;
|
|
303
|
-
}
|
|
304
|
-
function badge(status, connected) {
|
|
305
|
-
return `<span class="badge${connected ? "" : " off"}">${status}</span>`;
|
|
306
|
-
}
|
|
307
|
-
function switcher(variant, state) {
|
|
308
|
-
const index = exports.PROTOTYPE_VARIANTS.indexOf(variant);
|
|
309
|
-
const prev = exports.PROTOTYPE_VARIANTS[(index + exports.PROTOTYPE_VARIANTS.length - 1) % exports.PROTOTYPE_VARIANTS.length];
|
|
310
|
-
const next = exports.PROTOTYPE_VARIANTS[(index + 1) % exports.PROTOTYPE_VARIANTS.length];
|
|
311
|
-
return `<div class="proto-bar" data-proto-bar>
|
|
312
|
-
<pre class="proto-state">${state.replaceAll("<", "<")}</pre>
|
|
313
|
-
<div class="proto-pill">
|
|
314
|
-
<button type="button" data-proto-go="${prev}" aria-label="上一個版本">‹</button>
|
|
315
|
-
<span>${variant} · ${VARIANT_NAME[variant]}</span>
|
|
316
|
-
<button type="button" data-proto-go="${next}" aria-label="下一個版本">›</button>
|
|
317
|
-
</div>
|
|
318
|
-
</div>`;
|
|
319
|
-
}
|
|
320
|
-
function variantA(blocks, view, variant) {
|
|
321
|
-
const nav = SECTIONS.map((section, index) => `<button type="button" class="nav-item${index === 0 ? " active" : ""}" data-nav="${section.id}">${section.label}</button>`).join("");
|
|
322
|
-
const panels = SECTIONS.map((section, index) => {
|
|
323
|
-
const body = stamp(blocks[section.id], variant);
|
|
324
|
-
return `<section class="panel${index === 0 ? " on" : ""}" data-panel="${section.id}">${body}</section>`;
|
|
325
|
-
}).join("");
|
|
326
|
-
return `<div class="shell">
|
|
327
|
-
<aside class="sidebar">
|
|
328
|
-
${brand()}
|
|
329
|
-
<nav aria-label="區段">${nav}</nav>
|
|
330
|
-
<div class="sidebar-foot">
|
|
331
|
-
${badge(blocks.status, view.connected)}
|
|
332
|
-
${stamp(blocks.stop, variant)}
|
|
333
|
-
${themeButton()}
|
|
334
|
-
</div>
|
|
335
|
-
</aside>
|
|
336
|
-
<main class="main">
|
|
337
|
-
<div class="main-inner">
|
|
338
|
-
<div class="page-head">
|
|
339
|
-
<h2 data-page-title>連線</h2>
|
|
340
|
-
${badge(blocks.status, view.connected)}
|
|
341
|
-
</div>
|
|
342
|
-
<div class="notices">${blocks.notices}</div>
|
|
343
|
-
${panels}
|
|
344
|
-
</div>
|
|
345
|
-
</main>
|
|
346
|
-
</div>`;
|
|
347
|
-
}
|
|
348
|
-
function variantB(blocks, view, variant) {
|
|
349
|
-
const rows = [
|
|
350
|
-
["連線", "邀請碼、暱稱,或複製已兌換的 key。", blocks.connect],
|
|
351
|
-
["資料夾", "安裝課程檔案時寫入的專案路徑。", blocks.folder],
|
|
352
|
-
["模型", "Classroom 與 Native 的切換。", blocks.model],
|
|
353
|
-
["環境", "這台電腦還缺哪些工具。", blocks.environment],
|
|
354
|
-
];
|
|
355
|
-
const list = rows
|
|
356
|
-
.map(([title, hint, body]) => `<section class="set-row">
|
|
357
|
-
<div class="set-label"><h2>${title}</h2><p>${hint}</p></div>
|
|
358
|
-
<div class="set-control">${stamp(body, variant)}</div>
|
|
359
|
-
</section>`)
|
|
360
|
-
.join("");
|
|
361
|
-
return `<div class="sheet">
|
|
362
|
-
<header class="sheet-head">
|
|
363
|
-
${brand()}
|
|
364
|
-
<div class="brand-row">${badge(blocks.status, view.connected)}${themeButton()}</div>
|
|
365
|
-
</header>
|
|
366
|
-
<div class="notices">${blocks.notices}</div>
|
|
367
|
-
<div class="set-list">${list}</div>
|
|
368
|
-
<section class="sheet-block">
|
|
369
|
-
<h2>指令</h2>
|
|
370
|
-
${stamp(blocks.command, variant)}
|
|
371
|
-
</section>
|
|
372
|
-
<section class="sheet-block">
|
|
373
|
-
<h2>課程</h2>
|
|
374
|
-
${stamp(blocks.catalog, variant)}
|
|
375
|
-
</section>
|
|
376
|
-
<section class="sheet-block">${stamp(blocks.stop, variant)}</section>
|
|
377
|
-
</div>`;
|
|
378
|
-
}
|
|
379
|
-
function variantC(blocks, view, variant) {
|
|
380
|
-
const rail = [
|
|
381
|
-
["連線", blocks.connect],
|
|
382
|
-
["資料夾", blocks.folder],
|
|
383
|
-
["模型", blocks.model],
|
|
384
|
-
["環境", blocks.environment],
|
|
385
|
-
]
|
|
386
|
-
.map(([title, body]) => `<section><h2>${title}</h2>${stamp(body, variant)}</section>`)
|
|
387
|
-
.join("");
|
|
388
|
-
return `<div class="workspace">
|
|
389
|
-
<header class="topbar">
|
|
390
|
-
${brand()}
|
|
391
|
-
<div class="brand-row">${badge(blocks.status, view.connected)}${themeButton()}${stamp(blocks.stop, variant)}</div>
|
|
392
|
-
</header>
|
|
393
|
-
<div class="notices" style="padding: 12px 20px 0;">${blocks.notices}</div>
|
|
394
|
-
<div class="split">
|
|
395
|
-
<div class="rail-actions">${rail}</div>
|
|
396
|
-
<div class="detail">
|
|
397
|
-
<h2>指令</h2>
|
|
398
|
-
<div class="terminal">${stamp(blocks.command, variant)}</div>
|
|
399
|
-
<h2>課程</h2>
|
|
400
|
-
${stamp(blocks.catalog, variant)}
|
|
401
|
-
</div>
|
|
402
|
-
</div>
|
|
403
|
-
</div>`;
|
|
404
|
-
}
|
|
405
|
-
function clientScript(variant) {
|
|
406
|
-
return `
|
|
407
|
-
var appearanceKey = "classroom-appearance";
|
|
408
|
-
function systemDark() {
|
|
409
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
410
|
-
}
|
|
411
|
-
function paintTheme() {
|
|
412
|
-
var stored = null;
|
|
413
|
-
try { stored = localStorage.getItem(appearanceKey); } catch (error) {}
|
|
414
|
-
var appearance = stored === "light" || stored === "dark" ? stored : (systemDark() ? "dark" : "light");
|
|
415
|
-
document.documentElement.dataset.theme = appearance;
|
|
416
|
-
var button = document.querySelector("[data-appearance-toggle]");
|
|
417
|
-
if (button) button.setAttribute("aria-label", appearance === "dark" ? "切換到淺色" : "切換到深色");
|
|
418
|
-
}
|
|
419
|
-
paintTheme();
|
|
420
|
-
document.addEventListener("click", function (event) {
|
|
421
|
-
var target = event.target;
|
|
422
|
-
if (!target || !target.closest) return;
|
|
423
|
-
if (target.closest("[data-appearance-toggle]")) {
|
|
424
|
-
var current = document.documentElement.dataset.theme === "dark" ? "dark" : "light";
|
|
425
|
-
var next = current === "dark" ? "light" : "dark";
|
|
426
|
-
try { localStorage.setItem(appearanceKey, next); } catch (error) {}
|
|
427
|
-
paintTheme();
|
|
428
|
-
}
|
|
429
|
-
var jump = target.closest("[data-proto-go]");
|
|
430
|
-
if (jump) {
|
|
431
|
-
var url = new URL(location.href);
|
|
432
|
-
url.searchParams.set("variant", jump.getAttribute("data-proto-go"));
|
|
433
|
-
location.assign(url.pathname + url.search + url.hash);
|
|
434
|
-
}
|
|
435
|
-
var nav = target.closest("[data-nav]");
|
|
436
|
-
if (nav) {
|
|
437
|
-
var id = nav.getAttribute("data-nav");
|
|
438
|
-
document.querySelectorAll("[data-nav]").forEach(function (item) {
|
|
439
|
-
item.classList.toggle("active", item.getAttribute("data-nav") === id);
|
|
440
|
-
});
|
|
441
|
-
document.querySelectorAll("[data-panel]").forEach(function (panel) {
|
|
442
|
-
panel.classList.toggle("on", panel.getAttribute("data-panel") === id);
|
|
443
|
-
});
|
|
444
|
-
var title = document.querySelector("[data-page-title]");
|
|
445
|
-
if (title) title.textContent = nav.textContent;
|
|
446
|
-
history.replaceState(null, "", "#" + id);
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
var first = (location.hash || "#connect").slice(1);
|
|
450
|
-
var start = document.querySelector('[data-nav="' + first + '"]');
|
|
451
|
-
if (start) start.click();
|
|
452
|
-
window.addEventListener("keydown", function (event) {
|
|
453
|
-
var tag = event.target && event.target.tagName;
|
|
454
|
-
if (tag === "INPUT" || tag === "TEXTAREA" || (event.target && event.target.isContentEditable)) return;
|
|
455
|
-
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
456
|
-
var order = ${JSON.stringify(exports.PROTOTYPE_VARIANTS)};
|
|
457
|
-
var current = ${JSON.stringify(variant)};
|
|
458
|
-
var index = order.indexOf(current);
|
|
459
|
-
var step = event.key === "ArrowRight" ? 1 : -1;
|
|
460
|
-
var next = order[(index + step + order.length) % order.length];
|
|
461
|
-
var url = new URL(location.href);
|
|
462
|
-
url.searchParams.set("variant", next);
|
|
463
|
-
location.assign(url.pathname + url.search);
|
|
464
|
-
});
|
|
465
|
-
window.addEventListener("pagehide", function () {
|
|
466
|
-
navigator.sendBeacon("/close");
|
|
467
|
-
});
|
|
468
|
-
`;
|
|
469
|
-
}
|
|
470
|
-
function variantD(view) {
|
|
471
|
-
const html = stamp((0, page_1.renderPage)(view), "D");
|
|
472
|
-
const bar = `<style>
|
|
473
|
-
.proto-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 80; width: min(440px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 6px; align-items: center; }
|
|
474
|
-
.proto-state { width: 100%; max-height: 88px; overflow: auto; margin: 0; padding: 8px 10px; border-radius: 10px; background: #111; color: #f4f4f4; border: 2px solid #f5c518; font-size: 10px; line-height: 1.35; }
|
|
475
|
-
.proto-pill { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 999px; background: #111; color: #fff; border: 2px solid #f5c518; box-shadow: 0 8px 24px rgba(0,0,0,0.28); }
|
|
476
|
-
.proto-pill button { width: 32px; height: 32px; min-height: 32px; padding: 0; border: 0; border-radius: 999px; background: #f5c518; color: #111; font-weight: 700; }
|
|
477
|
-
.proto-pill span { font-size: 13px; font-weight: 600; min-width: 9rem; text-align: center; }
|
|
478
|
-
</style>
|
|
479
|
-
${switcher("D", stateText(view))}
|
|
480
|
-
<script>
|
|
481
|
-
document.addEventListener("click", function (event) {
|
|
482
|
-
var target = event.target;
|
|
483
|
-
if (!target || !target.closest) return;
|
|
484
|
-
var jump = target.closest("[data-proto-go]");
|
|
485
|
-
if (!jump) return;
|
|
486
|
-
var url = new URL(location.href);
|
|
487
|
-
url.searchParams.set("variant", jump.getAttribute("data-proto-go"));
|
|
488
|
-
location.assign(url.pathname + url.search);
|
|
489
|
-
});
|
|
490
|
-
window.addEventListener("keydown", function (event) {
|
|
491
|
-
var tag = event.target && event.target.tagName;
|
|
492
|
-
if (tag === "INPUT" || tag === "TEXTAREA" || (event.target && event.target.isContentEditable)) return;
|
|
493
|
-
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
494
|
-
var order = ${JSON.stringify(exports.PROTOTYPE_VARIANTS)};
|
|
495
|
-
var index = order.indexOf("D");
|
|
496
|
-
var step = event.key === "ArrowRight" ? 1 : -1;
|
|
497
|
-
var next = order[(index + step + order.length) % order.length];
|
|
498
|
-
var url = new URL(location.href);
|
|
499
|
-
url.searchParams.set("variant", next);
|
|
500
|
-
location.assign(url.pathname + url.search);
|
|
501
|
-
});
|
|
502
|
-
</script>`;
|
|
503
|
-
return html.replace("</body>", `${bar}</body>`);
|
|
504
|
-
}
|
|
505
|
-
function renderPrototypePage(view, variant) {
|
|
506
|
-
if (variant === "D")
|
|
507
|
-
return variantD(view);
|
|
508
|
-
const blocks = (0, page_1.classroomBlocks)(view);
|
|
509
|
-
const body = variant === "A"
|
|
510
|
-
? variantA(blocks, view, variant)
|
|
511
|
-
: variant === "B"
|
|
512
|
-
? variantB(blocks, view, variant)
|
|
513
|
-
: variantC(blocks, view, variant);
|
|
514
|
-
return `<!DOCTYPE html>
|
|
515
|
-
<html lang="zh-Hant">
|
|
516
|
-
<head>
|
|
517
|
-
<meta charset="utf-8">
|
|
518
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
519
|
-
<title>${PRODUCT}</title>
|
|
520
|
-
<style>${CSS}</style>
|
|
521
|
-
</head>
|
|
522
|
-
<body>
|
|
523
|
-
<div class="proto">${body}</div>
|
|
524
|
-
${switcher(variant, stateText(view))}
|
|
525
|
-
<script>${clientScript(variant)}</script>
|
|
526
|
-
</body>
|
|
527
|
-
</html>`;
|
|
528
|
-
}
|