@tianacloud/dsh-remote 0.2.4 → 0.2.5
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/package.json +1 -1
- package/web-src/shell-ui.js +26 -9
package/package.json
CHANGED
package/web-src/shell-ui.js
CHANGED
|
@@ -10,6 +10,7 @@ const SHELL_STYLES = ':root{color-scheme:light dark;--dsh-bg-l:#f1f5f9;--dsh-bg-
|
|
|
10
10
|
'.dsh-shell-tabs{display:flex;gap:8px;flex-wrap:wrap}.dsh-shell-tab{padding:6px 12px;border-radius:8px;font-size:13px;font-weight:500;cursor:pointer;border:1px solid var(--dsh-border);background:transparent;color:var(--dsh-muted)}.dsh-shell-tab[aria-selected="true"]{background:#2563eb;border-color:#2563eb;color:#fff}' +
|
|
11
11
|
'.dsh-shell-codebox{display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:10px;min-width:0;max-width:100%;box-sizing:border-box;background:var(--dsh-code);border:1px solid var(--dsh-border)}' +
|
|
12
12
|
'.dsh-shell-code{flex:1;min-width:0;overflow-x:auto;white-space:nowrap;font:13px ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}' +
|
|
13
|
+
'#dsh-remote-key-cmd{white-space:normal;overflow-wrap:anywhere}' +
|
|
13
14
|
'.dsh-shell-btn{padding:9px 14px;border-radius:9px;font-size:13px;font-weight:500;cursor:pointer;border:1px solid var(--dsh-border);background:transparent;color:var(--dsh-text);white-space:nowrap}.dsh-shell-btn-primary{background:#2563eb;border-color:#2563eb;color:#fff}.dsh-shell-btn:hover{filter:brightness(1.06)}' +
|
|
14
15
|
'.dsh-shell-input-row{display:flex;gap:8px;align-items:center}.dsh-shell-input{flex:1;min-width:0;padding:11px 13px;border-radius:9px;border:1px solid var(--dsh-border);background:var(--dsh-code);color:var(--dsh-text);font:13px ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}' +
|
|
15
16
|
'.dsh-shell-err{padding:10px 12px;border-radius:9px;font-size:13px;line-height:1.45;background:rgba(220,38,38,.14);border:1px solid rgba(248,113,113,.45);color:#ef4444}' +
|
|
@@ -22,6 +23,7 @@ const SHELL_STYLES = ':root{color-scheme:light dark;--dsh-bg-l:#f1f5f9;--dsh-bg-
|
|
|
22
23
|
'@media (max-width:560px){#dsh-remote-shell{padding:14px}.dsh-shell-card{padding:20px}}';
|
|
23
24
|
|
|
24
25
|
const PAIRING_KEY_PATTERN = /^(?:dshk1_)?[A-Za-z0-9_-]{43}$/u;
|
|
26
|
+
export const KEY_VIEW_COMMAND = 'npx --yes @tianacloud/dsh-remote@latest key';
|
|
25
27
|
|
|
26
28
|
export function validatePairingKeyInput(raw) {
|
|
27
29
|
const trimmed = String(raw ?? '').trim();
|
|
@@ -47,6 +49,23 @@ function el(tag, props, ...children) {
|
|
|
47
49
|
return node;
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
function makeCopyButton(getText, { id, primary = false } = {}) {
|
|
53
|
+
const btn = el('button', {
|
|
54
|
+
id: id ?? '', type: 'button', className: `dsh-shell-btn${primary ? ' dsh-shell-btn-primary' : ''}`,
|
|
55
|
+
textContent: '复制命令',
|
|
56
|
+
});
|
|
57
|
+
let reset;
|
|
58
|
+
btn.addEventListener('click', async () => {
|
|
59
|
+
clearTimeout(reset);
|
|
60
|
+
try {
|
|
61
|
+
await navigator.clipboard.writeText(getText());
|
|
62
|
+
btn.textContent = '已复制';
|
|
63
|
+
reset = setTimeout(() => { btn.textContent = '复制命令'; }, 1800);
|
|
64
|
+
} catch { btn.textContent = '请手动复制'; }
|
|
65
|
+
});
|
|
66
|
+
return btn;
|
|
67
|
+
}
|
|
68
|
+
|
|
50
69
|
function ensureShellStyles() {
|
|
51
70
|
if (typeof document === 'undefined') return;
|
|
52
71
|
if (!document.querySelector('meta[name="color-scheme"]')) {
|
|
@@ -130,14 +149,7 @@ export function createShellUI(rootEl) {
|
|
|
130
149
|
tabButtons[key] = btn;
|
|
131
150
|
tabs.append(btn);
|
|
132
151
|
}
|
|
133
|
-
const copyBtn =
|
|
134
|
-
copyBtn.addEventListener('click', async () => {
|
|
135
|
-
try {
|
|
136
|
-
await navigator.clipboard.writeText(osCommands[activeOs].cmd);
|
|
137
|
-
copyBtn.textContent = '已复制';
|
|
138
|
-
setTimeout(() => { copyBtn.textContent = '复制命令'; }, 1800);
|
|
139
|
-
} catch { copyBtn.textContent = '请手动复制'; }
|
|
140
|
-
});
|
|
152
|
+
const copyBtn = makeCopyButton(() => osCommands[activeOs].cmd, { id: 'dsh-remote-copy-cmd', primary: true });
|
|
141
153
|
const codeBox = el('div', { className: 'dsh-shell-codebox' }, codeEl, copyBtn);
|
|
142
154
|
waitStatusEl = el('span', { textContent: '正在等待你的电脑完成配置并上线…(上线后自动进入解锁页)' });
|
|
143
155
|
const waitBar = el('div', { className: 'dsh-shell-wait', id: 'dsh-remote-onboarding-wait' }, el('span', { className: 'dsh-shell-pulse' }), waitStatusEl);
|
|
@@ -209,8 +221,13 @@ export function createShellUI(rootEl) {
|
|
|
209
221
|
const rememberLabel = el('label', { className: 'dsh-shell-check' }, rememberBox, '在此受信任浏览器记住密钥(取消勾选后密钥仅驻留当前页面内存,刷新或关闭标签页立即销毁)');
|
|
210
222
|
const hint = el('div', { className: 'dsh-shell-sub', style: 'font-size:12px;', textContent: '密钥仅在浏览器与你的电脑之间进行端到端加密校验,Tiana 云端无法解密任何内容。可从刚运行的 connect 剪贴板粘贴,或在本地 DSH 侧栏「Tiana Remote」复制。' });
|
|
211
223
|
const submitBtn = el('button', { id: 'dsh-remote-e2ee-submit', type: 'submit', className: 'dsh-shell-btn dsh-shell-btn-primary', textContent: '解锁并进入工作台' });
|
|
224
|
+
const keyHint = el('p', { className: 'dsh-shell-sub', textContent: '忘记或需要查看当前配对密钥?在本地主机终端运行:' });
|
|
225
|
+
const keyBox = el('div', { className: 'dsh-shell-codebox' },
|
|
226
|
+
el('code', { id: 'dsh-remote-key-cmd', className: 'dsh-shell-code', textContent: KEY_VIEW_COMMAND }),
|
|
227
|
+
makeCopyButton(() => KEY_VIEW_COMMAND, { id: 'dsh-remote-copy-key-cmd' }),
|
|
228
|
+
);
|
|
212
229
|
|
|
213
|
-
const form = el('form', { style: 'display:grid;gap:12px;' }, errBox, el('div', { className: 'dsh-shell-input-row' }, input, toggleBtn), validationEl, rememberLabel, hint, submitBtn);
|
|
230
|
+
const form = el('form', { style: 'display:grid;gap:12px;' }, errBox, el('div', { className: 'dsh-shell-input-row' }, input, toggleBtn), validationEl, rememberLabel, hint, submitBtn, keyHint, keyBox);
|
|
214
231
|
form.addEventListener('submit', (e) => {
|
|
215
232
|
e.preventDefault();
|
|
216
233
|
const check = updateValidation();
|