dsh-mac-pet 0.9.3 → 0.9.4
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 +1 -1
- package/lib/client.js +16 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
- **DSH Pet 桥接插件**(包名 `dsh-mac-pet`):订阅 Agent 会话事件,提供 HTTP/状态 Socket 兼容接口、用户级命令 Socket,以及安装桌宠引导和桌宠会话跳转;无插件设置项
|
|
32
32
|
|
|
33
33
|
旧名称和数据位置保留必要的兼容处理。安装脚本会清理旧版 `MoodBall.app`。
|
|
34
|
-
当前源码对应的桌面 App 版本为 **v0.9.4**,桥接插件版本为 **v0.9.
|
|
34
|
+
当前源码对应的桌面 App 版本为 **v0.9.4**,桥接插件版本为 **v0.9.4**。已发布的 `DSH-Pet.app.zip` 安装包可从 [GitHub Releases](https://github.com/sundusk/dsh-mac-pet/releases/latest) 下载;安装脚本也会自动获取最新发布的安装包。
|
|
35
35
|
|
|
36
36
|
一切配置都在 app 的设置面板里完成。新版设置面板包含六个页面:「桌宠外观」「交互与提醒」「快捷键」「宠物管理」「Harness 连接」和「关于与更新」。
|
|
37
37
|
|
package/lib/client.js
CHANGED
|
@@ -24,21 +24,26 @@ function apply(ctx) {
|
|
|
24
24
|
// The desktop shell spawns its Host locally and exclusively forwards this origin to it.
|
|
25
25
|
const localDesktop = window.location?.protocol === 'dsh-app:' && window.location?.hostname === 'app'
|
|
26
26
|
&& typeof window.dshDesktopBoot?.ready === 'function'
|
|
27
|
-
let
|
|
27
|
+
let detection = { status: 'unknown', checking: false, checked: false }
|
|
28
28
|
let stopped = false
|
|
29
29
|
let requestId = 0
|
|
30
30
|
const listeners = new Set()
|
|
31
31
|
const subscribe = listener => { listeners.add(listener); return () => listeners.delete(listener) }
|
|
32
|
-
const refreshStatus = async () => {
|
|
32
|
+
const refreshStatus = async (manual = false) => {
|
|
33
|
+
if (detection.checking) return
|
|
33
34
|
const current = ++requestId
|
|
35
|
+
if (manual) {
|
|
36
|
+
detection = { ...detection, checking: true, checked: false }
|
|
37
|
+
for (const listener of listeners) listener()
|
|
38
|
+
}
|
|
34
39
|
let next = 'unknown'
|
|
35
40
|
try {
|
|
36
41
|
const response = await fetch(new URL('api/dsh-pet/install-status', document.baseURI).href, { cache: 'no-store', headers: { accept: 'application/json' } })
|
|
37
42
|
const payload = response.ok ? await response.json() : null
|
|
38
43
|
if (['installed', 'not-found'].includes(payload?.status)) next = payload.status
|
|
39
44
|
} catch { /* Keep the installation entry available when detection fails. */ }
|
|
40
|
-
if (stopped || current !== requestId || next ===
|
|
41
|
-
|
|
45
|
+
if (stopped || current !== requestId || (!manual && next === detection.status)) return
|
|
46
|
+
detection = { status: next, checking: false, checked: manual }
|
|
42
47
|
for (const listener of listeners) listener()
|
|
43
48
|
}
|
|
44
49
|
|
|
@@ -54,7 +59,7 @@ function apply(ctx) {
|
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
function InstallPage() {
|
|
57
|
-
const status = React.useSyncExternalStore(subscribe, () =>
|
|
62
|
+
const { status, checking, checked } = React.useSyncExternalStore(subscribe, () => detection)
|
|
58
63
|
const hostLabel = status === 'installed' ? '已检测到 DSH Pet' : status === 'not-found' ? '未检测到 DSH Pet' : '无法确认'
|
|
59
64
|
const section = { marginTop: '28px' }
|
|
60
65
|
return h('main', { style: { height: '100%', overflow: 'auto', boxSizing: 'border-box', color: 'var(--dsw-alias-label-primary)', background: 'var(--dsw-alias-bg-base)' } },
|
|
@@ -71,12 +76,14 @@ function apply(ctx) {
|
|
|
71
76
|
h('li', null, '将 DSH Pet.app 拖入「应用程序」文件夹,然后打开。'),
|
|
72
77
|
h('li', null, '在桌宠的「设置」→「Harness 连接」中检查连接状态。'),
|
|
73
78
|
h('li', null, '如果 Harness 提示需要重启才能加载插件,请在当前任务完成后重启。')),
|
|
74
|
-
h('p', null, '首次打开时,如果 macOS
|
|
79
|
+
h('p', null, '首次打开时,如果 macOS 提示无法验证开发者,请打开「系统设置」→「隐私与安全性」,向下找到 DSH Pet,点击「仍要打开」,并在提示中确认打开。')),
|
|
75
80
|
h('section', { style: section },
|
|
76
81
|
h('h2', { style: { fontSize: '16px' } }, '安装状态'),
|
|
77
|
-
h('p', { role: 'status' }, `${localDesktop ? '本机' : 'Harness 所在设备'}:${hostLabel}。`),
|
|
82
|
+
h('p', { role: 'status' }, checking ? '正在检测…' : `${checked ? '检测完成。' : ''}${localDesktop ? '本机' : 'Harness 所在设备'}:${hostLabel}。`),
|
|
78
83
|
localDesktop ? null : h('p', null, '无法确认你当前使用的设备是否就是 Harness 所在设备,请在本机检查 DSH Pet 是否已安装。'),
|
|
79
|
-
h('button', { type: 'button', onClick: () => { void refreshStatus() } }, '重新检测')
|
|
84
|
+
h('button', { type: 'button', disabled: checking, onClick: () => { void refreshStatus(true) } }, checking ? '检测中…' : '重新检测'),
|
|
85
|
+
status === 'installed' && !checking && typeof scope.layout?.selectPanel === 'function'
|
|
86
|
+
? h('button', { type: 'button', style: { marginLeft: '12px' }, onClick: () => scope.layout.selectPanel(null) }, '完成,返回会话') : null)))
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
scope.slots.inject('main', () => scope.slots.register({ name: 'main', key: panelId }, InstallPage))
|
|
@@ -85,7 +92,7 @@ function apply(ctx) {
|
|
|
85
92
|
const panelInfo = scope.layout?.panelInfo
|
|
86
93
|
const canTrackPanel = typeof panelInfo?.getSnapshot === 'function' && typeof panelInfo?.subscribe === 'function'
|
|
87
94
|
const update = () => {
|
|
88
|
-
const visible = !localDesktop ||
|
|
95
|
+
const visible = !localDesktop || detection.status !== 'installed' || !canTrackPanel || panelInfo.getSnapshot().activePanelId === panelId
|
|
89
96
|
if (visible && unregister === undefined) unregister = scope.slots.register({ name: 'sidebar.panellist', id: panelId, order: 90, label: '安装桌宠' }, InstallIcon)
|
|
90
97
|
else if (!visible && unregister !== undefined) { unregister(); unregister = undefined }
|
|
91
98
|
}
|
package/package.json
CHANGED