dsh-crossterm 0.3.33 → 0.3.34

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/client/client.js CHANGED
@@ -181,6 +181,10 @@ window.__ModuleLoader__.load({
181
181
 
182
182
  const onToggleCloud = async () => {
183
183
  const running = Boolean((status && status.cloud && status.cloud.running) || false);
184
+ if (!(status && status.cloud && status.cloud.configured)) {
185
+ setMsg("这台机器还没连接云端:先按 README「云端配置」配好网盘授权(baidu-app.json + baidu-auth.json)");
186
+ return;
187
+ }
184
188
  setBusy("cloud");
185
189
  setMsg(running ? "正在关闭云同步…" : "正在开启云同步…");
186
190
  try {
@@ -241,7 +245,9 @@ window.__ModuleLoader__.load({
241
245
  "span",
242
246
  null,
243
247
  status
244
- ? `${(cloud.provider && cloud.provider.name) || "云端"} · ${cloud.root || "—"}${cloud.running ? "(同步中)" : "(未同步)"}`
248
+ ? cloud.configured
249
+ ? `${(cloud.provider && cloud.provider.name) || "云端"} · ${cloud.root || "—"}${cloud.running ? "(同步中)" : "(未同步)"}`
250
+ : "未连接(还没配置云盘)"
245
251
  : "—",
246
252
  ),
247
253
  status
@@ -254,8 +260,12 @@ window.__ModuleLoader__.load({
254
260
  void onToggleCloud();
255
261
  },
256
262
  disabled: busy !== "",
257
- title: cloud.running ? "点击关闭云同步" : "点击开启云同步",
258
- "aria-label": cloud.running ? "云同步开启中" : "云同步已关闭",
263
+ title: !cloud.configured
264
+ ? "还没配置云盘,点击查看说明"
265
+ : cloud.running
266
+ ? "点击关闭云同步"
267
+ : "点击开启云同步",
268
+ "aria-label": !cloud.configured ? "云盘未配置" : cloud.running ? "云同步开启中" : "云同步已关闭",
259
269
  },
260
270
  h("span", { style: cloud.running ? S.knobOn : S.knobOff }),
261
271
  )
package/lib/bus.js CHANGED
@@ -22,7 +22,7 @@ import os from 'node:os'
22
22
  import path from 'node:path'
23
23
  import crypto from 'node:crypto'
24
24
 
25
- export const VERSION = '0.3.33'
25
+ export const VERSION = '0.3.34'
26
26
 
27
27
  /** DSH 的家目录:与宿主其它状态(sessions / profiles)同一个根,多终端天然共享 */
28
28
  export function dshHome() {
package/lib/web.js CHANGED
@@ -79,10 +79,14 @@ function installMode(spec) {
79
79
 
80
80
  /** 云端用哪家网盘:现在只接了百度,靠凭证文件认;以后加别家在这里扩展 */
81
81
  function cloudProvider(cfg) {
82
- if (!cfg) return { id: '', name: '' }
83
- if (cfg.baiduAppFile) return { id: 'baidu', name: '百度网盘' }
84
- if (cfg.cloudRoot) return { id: 'custom', name: '自定义云端' }
85
- return { id: '', name: '' }
82
+ if (!cfg) return { id: '', name: '', configured: false }
83
+ // readConfig 会把 baiduAppFile / baiduAuthFile 补成默认路径(非空字符串),
84
+ // 所以「配置了路径」不等于「已经授权」——必须两个凭证文件真的存在才算连上云端。
85
+ const exists = (file) => Boolean(file) && fs.existsSync(file)
86
+ if (exists(cfg.baiduAppFile) && exists(cfg.baiduAuthFile)) {
87
+ return { id: 'baidu', name: '百度网盘', configured: true }
88
+ }
89
+ return { id: 'none', name: '未连接', configured: false }
86
90
  }
87
91
 
88
92
  /** 语义化版本比较:只比 主.次.补(忽略预发布尾巴),a>b 返回正数 */
@@ -159,6 +163,7 @@ function statusOf(term) {
159
163
  /* ignore */
160
164
  }
161
165
  const cloud = term.cloud
166
+ const provider = cloudProvider(cfg)
162
167
  return {
163
168
  ok: true,
164
169
  version: VERSION,
@@ -169,11 +174,13 @@ function statusOf(term) {
169
174
  workspace: cfg.workspace || '',
170
175
  install: { profile: (info && info.name) || '', spec: (info && info.spec) || '', mode },
171
176
  cloud: {
172
- enabled: cfg.cloudEnabled === true,
173
- running: Boolean(cloud && cloud.running),
174
- root: cfg.cloudRoot || '',
177
+ // 没配云盘时不要把默认路径当成「已连接的云端」显示出来
178
+ configured: provider.configured,
179
+ enabled: cfg.cloudEnabled === true && provider.configured,
180
+ running: provider.configured && Boolean(cloud && cloud.running),
181
+ root: provider.configured ? cfg.cloudRoot || '' : '',
175
182
  intervalMs: cfg.cloudIntervalMs || 0,
176
- provider: cloudProvider(cfg),
183
+ provider,
177
184
  },
178
185
  chains,
179
186
  }
@@ -220,6 +227,15 @@ export function registerWeb(ctx, term, log) {
220
227
  path: '/crossterm/api/cloud/start',
221
228
  handler: (req, res) => {
222
229
  try {
230
+ const before = statusOf(term).cloud
231
+ if (!before.configured) {
232
+ json(res, 200, {
233
+ ok: false,
234
+ message: '这台机器还没连接云盘:先配置自己的网盘授权(需要 baidu-app.json + baidu-auth.json),配置步骤见 README「云端配置」',
235
+ cloud: before,
236
+ })
237
+ return
238
+ }
223
239
  term.enableCloud()
224
240
  json(res, 200, { ok: true, message: '云同步已开启', cloud: statusOf(term).cloud })
225
241
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-crossterm",
3
- "version": "0.3.33",
3
+ "version": "0.3.34",
4
4
  "description": "DSH 跨终端互联:同一账号下的多个 DSH 终端/进程互发邮件与文件(主题内联、正文落盘,收件方自己读)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",