@vibedev-si/dsh-island 0.1.0 → 0.3.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/client.js CHANGED
@@ -68,6 +68,7 @@ window.__ModuleLoader__.load({
68
68
 
69
69
  const CSS = `
70
70
  .vdi { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 0; color: var(--dsw-alias-label-primary); font-size: 14px; line-height: 22px; }
71
+ .vdi--native { display: block; max-width: 860px; }
71
72
  .vdi * { box-sizing: border-box; }
72
73
  .vdi__nav { display: flex; flex-direction: column; gap: 1px; padding: 4px 8px 4px 0; }
73
74
  .vdi__nav button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 13px; color: var(--dsw-alias-label-secondary); text-align: left; cursor: pointer; }
@@ -520,8 +521,8 @@ window.__ModuleLoader__.load({
520
521
  { id: 'pages', title: '岛上页面', icon: 'layers' },
521
522
  { id: 'sessions', title: 'VibeDev 会话', icon: 'chat' },
522
523
  { id: 'todos', title: '待办', icon: 'list' },
523
- { id: 'clipboard', title: '剪贴板', icon: 'clipboard' },
524
- { id: 'screenshot', title: '截图', icon: 'crop' },
524
+ { id: 'clipboard', title: '剪贴板', icon: 'clipboard', needs: 'clipboard' },
525
+ { id: 'screenshot', title: '截图', icon: 'crop', needs: 'screenshot' },
525
526
  { id: 'messages', title: '消息', icon: 'mail' },
526
527
  { id: 'translation', title: '翻译', icon: 'translate' },
527
528
  { id: 'about', title: '关于', icon: 'info' },
@@ -892,12 +893,116 @@ window.__ModuleLoader__.load({
892
893
  )
893
894
  }
894
895
 
896
+ function useIslandControl(setError) {
897
+ const [busy, setBusy] = React.useState(false)
898
+ const control = React.useCallback(
899
+ async (action) => {
900
+ setBusy(true)
901
+ try {
902
+ statusStore.set(await postJson(CONTROL_URL, { action }))
903
+ setError(undefined)
904
+ } catch (cause) {
905
+ setError(String(cause?.message ?? cause))
906
+ } finally {
907
+ setBusy(false)
908
+ }
909
+ },
910
+ [setError],
911
+ )
912
+ return [control, busy]
913
+ }
914
+
915
+ function IslandStatusCard({ status, children }) {
916
+ const running = status?.running === true
917
+ const uptime = () => {
918
+ if (!running || status?.startedAt === undefined) return '—'
919
+ const elapsed = Date.now() - new Date(status.startedAt).getTime()
920
+ if (!Number.isFinite(elapsed) || elapsed < 0) return '—'
921
+ const minutes = Math.floor(elapsed / 60000)
922
+ if (minutes < 60) return `${minutes} 分钟`
923
+ return `${Math.floor(minutes / 60)} 小时 ${minutes % 60} 分`
924
+ }
925
+ // 插件此刻送到小岛上的:只说数目,不写会话标题(设置页可能被别人看到)。小岛自己的待办、音乐、消息插件不知道。
926
+ const surface = (() => {
927
+ const sent = status?.surface
928
+ if (!running) return '—'
929
+ if (sent?.state === 'approval') return `${sent.approvals} 项等你批准`
930
+ if (sent?.state === 'running') return `${sent.running} 个会话在运行`
931
+ return '空闲'
932
+ })()
933
+ const fact = (label, text) => h('div', { key: label }, h('dt', null, label), h('dd', null, text))
934
+
935
+ return h(
936
+ 'div',
937
+ { className: 'vdi-ov' },
938
+ h(
939
+ 'div',
940
+ { className: 'vdi-ov__card' },
941
+ h(
942
+ 'div',
943
+ { className: 'vdi-status' },
944
+ h('span', {
945
+ className: `vdi-dot${running ? ' vdi-dot--ok' : status?.configured === false ? ' vdi-dot--bad' : ''}`,
946
+ }),
947
+ h('span', { className: 'vdi-status__text' }, running ? '运行中' : '已停止'),
948
+ ),
949
+ h(
950
+ 'dl',
951
+ { className: 'vdi-facts' },
952
+ fact('版本', status?.version ?? '—'),
953
+ fact('通信', '标准输入输出'),
954
+ fact('已运行', uptime()),
955
+ fact('小岛上', surface),
956
+ ),
957
+ children,
958
+ status?.lastError === undefined ? null : h('div', { className: 'vdi-error' }, status.lastError),
959
+ ),
960
+ )
961
+ }
962
+
963
+ function NativeSettingsPage({ status }) {
964
+ const canOpen = status?.nativeSettings === true
965
+ const [error, setError] = React.useState(undefined)
966
+ const [control, busy] = useIslandControl(setError)
967
+ return h(
968
+ 'div',
969
+ { className: 'vdi vdi--native' },
970
+ h('style', null, CSS),
971
+ h(IslandStatusCard, { status }),
972
+ h(
973
+ 'div',
974
+ { className: 'vdi-status__actions', style: { marginTop: 14 } },
975
+ h(
976
+ 'button',
977
+ {
978
+ className: 'vdi-btn',
979
+ type: 'button',
980
+ disabled: busy || !canOpen,
981
+ onClick: () => void control('open-native-settings'),
982
+ },
983
+ busy ? '正在打开…' : '打开设置',
984
+ ),
985
+ ),
986
+ error === undefined ? null : h('div', { className: 'vdi-error', role: 'alert' }, `无法打开设置:${error}`),
987
+ )
988
+ }
989
+
895
990
  function IslandSettingsPage(props) {
896
- const [section, setSection] = React.useState(props?.initialSection ?? 'overview')
897
991
  const status = useIslandStatus(props?.initialStatus)
898
- const [settings, setSettings] = React.useState(props?.initialSettings)
992
+ // 插件列表里只渲染一行摘要。
993
+ if (props?.view === 'summary') {
994
+ return h('span', { className: 'vdi-status__meta' }, status?.running === true ? '岛屿运行中' : '岛屿已停止')
995
+ }
996
+ if (status?.nativeSettingsExpected === true || (status?.running === true && status.nativeSettings === true))
997
+ return h(NativeSettingsPage, { status })
998
+ return h(LegacySettingsPage, { ...props, status })
999
+ }
1000
+
1001
+ function LegacySettingsPage({ initialSection, initialSettings, initialChangelog, status }) {
1002
+ const [section, setSection] = React.useState(initialSection ?? 'overview')
1003
+ const [settings, setSettings] = React.useState(initialSettings)
899
1004
  const [error, setError] = React.useState(undefined)
900
- const [busy, setBusy] = React.useState(false)
1005
+ const [control, busy] = useIslandControl(setError)
901
1006
 
902
1007
  React.useEffect(() => {
903
1008
  let alive = true
@@ -937,18 +1042,6 @@ window.__ModuleLoader__.load({
937
1042
  [save, settings],
938
1043
  )
939
1044
 
940
- const control = React.useCallback(async (action) => {
941
- setBusy(true)
942
- try {
943
- statusStore.set(await postJson(CONTROL_URL, { action }))
944
- setError(undefined)
945
- } catch (cause) {
946
- setError(String(cause?.message ?? cause))
947
- } finally {
948
- setBusy(false)
949
- }
950
- }, [])
951
-
952
1045
  // 恢复默认设置:宿主改完之后马上把新的设置读回来,不等下一次轮询。
953
1046
  const resetSettings = React.useCallback(async () => {
954
1047
  await control('reset-settings')
@@ -959,12 +1052,6 @@ window.__ModuleLoader__.load({
959
1052
  }
960
1053
  }, [control])
961
1054
 
962
- // 插件列表里只渲染一行摘要。放在所有 hook 之后:hook 的调用顺序不能随视图变。
963
- if (props?.view === 'summary') {
964
- const running = status?.running === true
965
- return h('span', { className: 'vdi-status__meta' }, running ? '岛屿运行中' : '岛屿已停止')
966
- }
967
-
968
1055
  const value = (path, fallback) => {
969
1056
  const found = getAt(settings, path)
970
1057
  return found === undefined ? fallback : found
@@ -977,6 +1064,13 @@ window.__ModuleLoader__.load({
977
1064
  return `⚠ 注册失败:${entry.error ?? '被占用'}`
978
1065
  }
979
1066
  const withNote = (...parts) => parts.filter((part) => part !== undefined && part !== '').join(' · ')
1067
+ /** 这个系统上的小岛有没有某项要靠系统接口的功能(宿主的 features.js);还不知道时当作有。 */
1068
+ const has = (feature) => !Array.isArray(status?.features) || status.features.includes(feature)
1069
+ /** 岛屿自己的数据目录(待办、笔记、截图):Tauri 按标识 com.vibedev.island 放在系统的应用数据目录里。 */
1070
+ const islandDataDir =
1071
+ status?.platform === 'darwin'
1072
+ ? '~/Library/Application Support/com.vibedev.island'
1073
+ : '%APPDATA%/com.vibedev.island'
980
1074
 
981
1075
  const PRESET_FIELDS = [
982
1076
  'taskTextColor',
@@ -1030,80 +1124,41 @@ window.__ModuleLoader__.load({
1030
1124
  const running = status?.running === true
1031
1125
  const ready = settings !== undefined
1032
1126
 
1033
- const uptime = () => {
1034
- if (!running || status?.startedAt === undefined) return '—'
1035
- const elapsed = Date.now() - new Date(status.startedAt).getTime()
1036
- if (!Number.isFinite(elapsed) || elapsed < 0) return '—'
1037
- const minutes = Math.floor(elapsed / 60000)
1038
- if (minutes < 60) return `${minutes} 分钟`
1039
- return `${Math.floor(minutes / 60)} 小时 ${minutes % 60} 分`
1040
- }
1041
-
1042
- // 插件此刻送到小岛上的:只说数目,不写会话标题(设置页可能被别人看到)。小岛自己的待办、音乐、消息插件不知道。
1043
- const surface = (() => {
1044
- const sent = status?.surface
1045
- if (!running) return '—'
1046
- if (sent?.state === 'approval') return `${sent.approvals} 项等你批准`
1047
- if (sent?.state === 'running') return `${sent.running} 个会话在运行`
1048
- return '空闲'
1049
- })()
1050
-
1051
1127
  const overview = () => [
1052
1128
  h(
1053
- 'div',
1054
- { className: 'vdi-ov', key: 'ov' },
1129
+ IslandStatusCard,
1130
+ { status, key: 'ov' },
1055
1131
  h(
1056
1132
  'div',
1057
- { className: 'vdi-ov__card' },
1058
- h(
1059
- 'div',
1060
- { className: 'vdi-status' },
1061
- h('span', {
1062
- className: `vdi-dot${running ? ' vdi-dot--ok' : status?.configured === false ? ' vdi-dot--bad' : ''}`,
1063
- }),
1064
- h('span', { className: 'vdi-status__text' }, running ? '运行中' : '已停止'),
1065
- ),
1066
- h(
1067
- 'dl',
1068
- { className: 'vdi-facts' },
1069
- fact('版本', status?.version ?? '—'),
1070
- fact('通信', '标准输入输出'),
1071
- fact('已运行', uptime()),
1072
- fact('小岛上', surface),
1073
- ),
1133
+ { className: 'vdi-status__actions', style: { marginTop: 14 } },
1134
+ running
1135
+ ? h(
1136
+ 'button',
1137
+ { className: 'vdi-btn', type: 'button', disabled: busy, onClick: () => void control('stop') },
1138
+ '停止',
1139
+ )
1140
+ : h(
1141
+ 'button',
1142
+ {
1143
+ className: 'vdi-btn vdi-btn--primary',
1144
+ type: 'button',
1145
+ disabled: busy || status?.configured === false,
1146
+ onClick: () => void control('start'),
1147
+ },
1148
+ '启动小岛',
1149
+ ),
1074
1150
  h(
1075
- 'div',
1076
- { className: 'vdi-status__actions', style: { marginTop: 14 } },
1077
- running
1078
- ? h(
1079
- 'button',
1080
- { className: 'vdi-btn', type: 'button', disabled: busy, onClick: () => void control('stop') },
1081
- '停止',
1082
- )
1083
- : h(
1084
- 'button',
1085
- {
1086
- className: 'vdi-btn vdi-btn--primary',
1087
- type: 'button',
1088
- disabled: busy || status?.configured === false,
1089
- onClick: () => void control('start'),
1090
- },
1091
- '启动小岛',
1092
- ),
1093
- h(
1094
- 'button',
1095
- { className: 'vdi-btn', type: 'button', disabled: busy, onClick: () => void control('open-logs') },
1096
- '打开日志目录',
1097
- ),
1151
+ 'button',
1152
+ { className: 'vdi-btn', type: 'button', disabled: busy, onClick: () => void control('open-logs') },
1153
+ '打开日志目录',
1098
1154
  ),
1099
- status?.lastError === undefined ? null : h('div', { className: 'vdi-error' }, status.lastError),
1100
1155
  ),
1101
1156
  ),
1102
1157
  h(
1103
1158
  Group,
1104
1159
  { title: '各功能状态', key: 'features', desc: '某项出问题时会在这里提示。' },
1105
- statusRow('QQ 通知', ...qqChip(status?.qq?.status)),
1106
- statusRow('微信提醒', ...(status?.wechat?.summary?.chip ?? NO_CHIP)),
1160
+ has('qqNotifications') ? statusRow('QQ 通知', ...qqChip(status?.qq?.status)) : null,
1161
+ has('wechat') ? statusRow('微信提醒', ...(status?.wechat?.summary?.chip ?? NO_CHIP)) : null,
1107
1162
  statusRow(
1108
1163
  '翻译',
1109
1164
  ...(status?.translation?.available === undefined
@@ -1113,14 +1168,17 @@ window.__ModuleLoader__.load({
1113
1168
  : ['用本地密钥', 'warn']),
1114
1169
  ),
1115
1170
  statusRow('QQ 邮箱', ...mailChip(status?.mail)),
1116
- statusRow(
1117
- 'WebView2',
1118
- ...(typeof status?.webview2 === 'string'
1119
- ? [status.webview2, 'ok']
1120
- : status?.running === true
1121
- ? ['没读到版本', 'warn']
1122
- : NO_CHIP),
1123
- ),
1171
+ // WebView2 只在 Windows 上有。
1172
+ status?.platform === 'darwin'
1173
+ ? null
1174
+ : statusRow(
1175
+ 'WebView2',
1176
+ ...(typeof status?.webview2 === 'string'
1177
+ ? [status.webview2, 'ok']
1178
+ : status?.running === true
1179
+ ? ['没读到版本', 'warn']
1180
+ : NO_CHIP),
1181
+ ),
1124
1182
  ),
1125
1183
  h(
1126
1184
  Group,
@@ -1130,7 +1188,6 @@ window.__ModuleLoader__.load({
1130
1188
  ),
1131
1189
  ]
1132
1190
 
1133
- const fact = (label, text) => h('div', { key: label }, h('dt', null, label), h('dd', null, text))
1134
1191
  const statusRow = (label, text, tone) =>
1135
1192
  h(Row, { key: label, label }, h('span', { className: `vdi-chip vdi-chip--${tone}` }, text))
1136
1193
  const infoRow = (label, text, desc) =>
@@ -1428,18 +1485,20 @@ window.__ModuleLoader__.load({
1428
1485
  onChange: (next) => update('behavior.autoTuckSeconds', next),
1429
1486
  }),
1430
1487
  ),
1431
- h(
1432
- Row,
1433
- {
1434
- label: '全屏时保持安静',
1435
- desc: '前台是盖住小岛那块屏的全屏程序(游戏、全屏视频)时:鼠标经过不展开、不弹消息横幅、不出翻译按钮,等你批准的操作直接交给 VibeDev。',
1436
- },
1437
- h(Toggle, {
1438
- label: '全屏时保持安静',
1439
- checked: value('behavior.quietInFullscreen', true) === true,
1440
- onChange: (next) => update('behavior.quietInFullscreen', next),
1441
- }),
1442
- ),
1488
+ has('fullscreen')
1489
+ ? h(
1490
+ Row,
1491
+ {
1492
+ label: '全屏时保持安静',
1493
+ desc: '前台是盖住小岛那块屏的全屏程序(游戏、全屏视频)时:鼠标经过不展开、不弹消息横幅、不出翻译按钮,等你批准的操作直接交给 VibeDev。',
1494
+ },
1495
+ h(Toggle, {
1496
+ label: '全屏时保持安静',
1497
+ checked: value('behavior.quietInFullscreen', true) === true,
1498
+ onChange: (next) => update('behavior.quietInFullscreen', next),
1499
+ }),
1500
+ )
1501
+ : null,
1443
1502
  ),
1444
1503
  h(
1445
1504
  Group,
@@ -1472,40 +1531,42 @@ window.__ModuleLoader__.load({
1472
1531
  }),
1473
1532
  ),
1474
1533
  ),
1475
- h(
1476
- Group,
1477
- {
1478
- title: '快捷键',
1479
- key: 'hotkeys',
1480
- desc: '两个都可以不设;不设就不占用任何组合键。',
1481
- },
1482
- h(
1483
- Row,
1484
- {
1485
- label: '显示或隐藏小岛',
1486
- desc: withNote('把小岛藏起来,再按一次叫回来。', shortcutNote('toggleIsland')),
1487
- },
1488
- h(ShortcutField, {
1489
- label: '显示或隐藏小岛',
1490
- value: value('behavior.toggleShortcut', ''),
1491
- optional: true,
1492
- onChange: (next) => update('behavior.toggleShortcut', next),
1493
- }),
1494
- ),
1495
- h(
1496
- Row,
1497
- {
1498
- label: '展开到 VibeDev 会话',
1499
- desc: withNote('把小岛叫出来,并打开会话那一页。', shortcutNote('openSessions')),
1500
- },
1501
- h(ShortcutField, {
1502
- label: '展开到 VibeDev 会话',
1503
- value: value('behavior.sessionsShortcut', ''),
1504
- optional: true,
1505
- onChange: (next) => update('behavior.sessionsShortcut', next),
1506
- }),
1507
- ),
1508
- ),
1534
+ has('shortcuts')
1535
+ ? h(
1536
+ Group,
1537
+ {
1538
+ title: '快捷键',
1539
+ key: 'hotkeys',
1540
+ desc: '两个都可以不设;不设就不占用任何组合键。',
1541
+ },
1542
+ h(
1543
+ Row,
1544
+ {
1545
+ label: '显示或隐藏小岛',
1546
+ desc: withNote('把小岛藏起来,再按一次叫回来。', shortcutNote('toggleIsland')),
1547
+ },
1548
+ h(ShortcutField, {
1549
+ label: '显示或隐藏小岛',
1550
+ value: value('behavior.toggleShortcut', ''),
1551
+ optional: true,
1552
+ onChange: (next) => update('behavior.toggleShortcut', next),
1553
+ }),
1554
+ ),
1555
+ h(
1556
+ Row,
1557
+ {
1558
+ label: '展开到 VibeDev 会话',
1559
+ desc: withNote('把小岛叫出来,并打开会话那一页。', shortcutNote('openSessions')),
1560
+ },
1561
+ h(ShortcutField, {
1562
+ label: '展开到 VibeDev 会话',
1563
+ value: value('behavior.sessionsShortcut', ''),
1564
+ optional: true,
1565
+ onChange: (next) => update('behavior.sessionsShortcut', next),
1566
+ }),
1567
+ ),
1568
+ )
1569
+ : null,
1509
1570
  ],
1510
1571
 
1511
1572
  pages: () => {
@@ -1545,14 +1606,18 @@ window.__ModuleLoader__.load({
1545
1606
  )
1546
1607
  })
1547
1608
  }
1548
- const order = value('pages.order', TAB_PAGES)
1609
+ // 这个系统上没有的页面(音乐、剪贴板)不列出来;它们在设置里的位置原样留着。
1610
+ const pageAvailable = (id) => (id === 'music' ? has('media') : id === 'clipboard' ? has('clipboard') : true)
1611
+ const savedOrder = value('pages.order', TAB_PAGES)
1612
+ const order = savedOrder.filter(pageAvailable)
1613
+ const unavailable = savedOrder.filter((id) => !pageAvailable(id))
1549
1614
  const hidden = value('pages.hidden', NO_EVENTS)
1550
1615
  const shown = order.filter((id) => !hidden.includes(id))
1551
- const move = (id, step) => update('pages.order', movePage(order, id, step))
1616
+ const move = (id, step) => update('pages.order', [...movePage(order, id, step), ...unavailable])
1552
1617
  const setShown = (id, visible) => update('pages.hidden', setPageShown(hidden, id, visible))
1553
1618
  const openOn = value('pages.openOn', 'last')
1554
1619
  const openOnLabels = { last: '上次停留的那一页', ...PAGE_LABELS }
1555
- const openOnChoices = ['last', ...TAB_PAGES]
1620
+ const openOnChoices = ['last', ...TAB_PAGES.filter(pageAvailable)]
1556
1621
  return [
1557
1622
  h(
1558
1623
  Group,
@@ -1769,53 +1834,57 @@ window.__ModuleLoader__.load({
1769
1834
  onChange: (next) => update('sessions.doneNotifyMinSeconds', next),
1770
1835
  }),
1771
1836
  ),
1772
- h(
1773
- Row,
1774
- { label: '通知时播放提示音', desc: '任务完成时岛屿响一下。它不会抢走你正在用的窗口的焦点。' },
1775
- h(Toggle, {
1776
- label: '通知时播放提示音',
1777
- checked: value('sessions.notifySound', true) === true,
1778
- onChange: (next) => update('sessions.notifySound', next),
1779
- }),
1780
- ),
1781
- h(
1782
- Row,
1783
- { label: '提示音', dim: value('sessions.notifySound', true) !== true },
1784
- h(Select, {
1785
- label: '提示音',
1786
- options: SOUND_CHOICES.map(([, label]) => label),
1787
- value: (SOUND_CHOICES.find(([id]) => id === value('sessions.sound', 'exclamation')) ??
1788
- SOUND_CHOICES[0])[1],
1789
- onChange: (option) =>
1790
- update(
1791
- 'sessions.sound',
1792
- (SOUND_CHOICES.find(([, label]) => label === option) ?? SOUND_CHOICES[0])[0],
1837
+ ...(has('sound')
1838
+ ? [
1839
+ h(
1840
+ Row,
1841
+ { label: '通知时播放提示音', desc: '任务完成时岛屿响一下。它不会抢走你正在用的窗口的焦点。' },
1842
+ h(Toggle, {
1843
+ label: '通知时播放提示音',
1844
+ checked: value('sessions.notifySound', true) === true,
1845
+ onChange: (next) => update('sessions.notifySound', next),
1846
+ }),
1793
1847
  ),
1794
- }),
1795
- ),
1796
- h(
1797
- Row,
1798
- { label: '音量', dim: value('sessions.notifySound', true) !== true },
1799
- h(Slider, {
1800
- label: '音量',
1801
- value: value('sessions.soundVolume', 100),
1802
- min: 0,
1803
- max: 100,
1804
- step: 5,
1805
- unit: '%',
1806
- onChange: (next) => update('sessions.soundVolume', next),
1807
- }),
1808
- h(
1809
- 'button',
1810
- {
1811
- className: 'vdi-btn',
1812
- type: 'button',
1813
- disabled: busy || !running,
1814
- onClick: () => void control('sound-test'),
1815
- },
1816
- '试听',
1817
- ),
1818
- ),
1848
+ h(
1849
+ Row,
1850
+ { label: '提示音', dim: value('sessions.notifySound', true) !== true },
1851
+ h(Select, {
1852
+ label: '提示音',
1853
+ options: SOUND_CHOICES.map(([, label]) => label),
1854
+ value: (SOUND_CHOICES.find(([id]) => id === value('sessions.sound', 'exclamation')) ??
1855
+ SOUND_CHOICES[0])[1],
1856
+ onChange: (option) =>
1857
+ update(
1858
+ 'sessions.sound',
1859
+ (SOUND_CHOICES.find(([, label]) => label === option) ?? SOUND_CHOICES[0])[0],
1860
+ ),
1861
+ }),
1862
+ ),
1863
+ h(
1864
+ Row,
1865
+ { label: '音量', dim: value('sessions.notifySound', true) !== true },
1866
+ h(Slider, {
1867
+ label: '音量',
1868
+ value: value('sessions.soundVolume', 100),
1869
+ min: 0,
1870
+ max: 100,
1871
+ step: 5,
1872
+ unit: '%',
1873
+ onChange: (next) => update('sessions.soundVolume', next),
1874
+ }),
1875
+ h(
1876
+ 'button',
1877
+ {
1878
+ className: 'vdi-btn',
1879
+ type: 'button',
1880
+ disabled: busy || !running,
1881
+ onClick: () => void control('sound-test'),
1882
+ },
1883
+ '试听',
1884
+ ),
1885
+ ),
1886
+ ]
1887
+ : NO_EVENTS),
1819
1888
  h(
1820
1889
  Row,
1821
1890
  { label: '运行中的会话显示成任务', desc: '折叠条上显示一条「运行中」的任务,不编造百分比。' },
@@ -1932,7 +2001,7 @@ window.__ModuleLoader__.load({
1932
2001
  h(
1933
2002
  Row,
1934
2003
  { label: '待办与笔记', desc: '清单、当天笔记和归档存在同一个 JSON 文件里。' },
1935
- h(PathInput, { label: '待办与笔记', value: '%APPDATA%/com.vibedev.island/data/todos.json' }),
2004
+ h(PathInput, { label: '待办与笔记', value: `${islandDataDir}/data/todos.json` }),
1936
2005
  ),
1937
2006
  h(
1938
2007
  Row,
@@ -2102,132 +2171,144 @@ window.__ModuleLoader__.load({
2102
2171
  ],
2103
2172
 
2104
2173
  messages: () => [
2105
- h(
2106
- Group,
2107
- { title: '消息接收', key: 'receive' },
2108
- h(
2109
- Row,
2110
- { label: 'QQ 通知', desc: '读取 Windows 通知中心里的 QQ 消息。' },
2111
- h(Toggle, {
2112
- label: 'QQ 通知',
2113
- checked: value('messages.qq', true) === true,
2114
- onChange: (next) => update('messages.qq', next),
2115
- }),
2116
- ),
2117
- // QQ 通知要 Windows 授权才能读;状态由岛屿回报,按状态给对应按钮。
2118
- (() => {
2119
- const qq = status?.qq
2120
- const state = qq?.status
2121
- const label =
2122
- {
2123
- listening: '已授权,正在接收',
2124
- waiting: '等待 QQ 通知',
2125
- disabled: '已关闭',
2126
- permissionRequired: '还没授权',
2127
- permissionDenied: '已被拒绝,需要去系统设置里打开',
2128
- error: '出错了',
2129
- }[state] ?? (status?.running === true ? '读取中…' : '岛屿未运行')
2130
- const needsGrant = state === 'permissionRequired' || state === 'error'
2131
- const needsSettings = state === 'permissionDenied'
2132
- return h(
2133
- Row,
2134
- { label: '通知读取权限', desc: qq?.error ? `${label}:${qq.error}` : label },
2135
- needsGrant
2136
- ? h(
2137
- 'button',
2138
- {
2139
- className: 'vdi-btn',
2140
- type: 'button',
2141
- disabled: busy,
2142
- onClick: () => void control('qq-request-access'),
2143
- },
2144
- '申请授权',
2145
- )
2146
- : needsSettings
2147
- ? h(
2148
- 'button',
2174
+ has('qqNotifications') || has('wechat')
2175
+ ? h(
2176
+ Group,
2177
+ { title: '消息接收', key: 'receive' },
2178
+ ...(has('qqNotifications')
2179
+ ? [
2180
+ h(
2181
+ Row,
2182
+ { label: 'QQ 通知', desc: '读取 Windows 通知中心里的 QQ 消息。' },
2183
+ h(Toggle, {
2184
+ label: 'QQ 通知',
2185
+ checked: value('messages.qq', true) === true,
2186
+ onChange: (next) => update('messages.qq', next),
2187
+ }),
2188
+ ),
2189
+ // QQ 通知要 Windows 授权才能读;状态由岛屿回报,按状态给对应按钮。
2190
+ (() => {
2191
+ const qq = status?.qq
2192
+ const state = qq?.status
2193
+ const label =
2194
+ {
2195
+ listening: '已授权,正在接收',
2196
+ waiting: '等待 QQ 通知',
2197
+ disabled: '已关闭',
2198
+ permissionRequired: '还没授权',
2199
+ permissionDenied: '已被拒绝,需要去系统设置里打开',
2200
+ error: '出错了',
2201
+ }[state] ?? (status?.running === true ? '读取中…' : '岛屿未运行')
2202
+ const needsGrant = state === 'permissionRequired' || state === 'error'
2203
+ const needsSettings = state === 'permissionDenied'
2204
+ return h(
2205
+ Row,
2206
+ { label: '通知读取权限', desc: qq?.error ? `${label}:${qq.error}` : label },
2207
+ needsGrant
2208
+ ? h(
2209
+ 'button',
2210
+ {
2211
+ className: 'vdi-btn',
2212
+ type: 'button',
2213
+ disabled: busy,
2214
+ onClick: () => void control('qq-request-access'),
2215
+ },
2216
+ '申请授权',
2217
+ )
2218
+ : needsSettings
2219
+ ? h(
2220
+ 'button',
2221
+ {
2222
+ className: 'vdi-btn',
2223
+ type: 'button',
2224
+ disabled: busy,
2225
+ onClick: () => void control('qq-open-settings'),
2226
+ },
2227
+ '打开系统设置',
2228
+ )
2229
+ : h('span', { className: 'vdi-info' }, state === 'listening' ? '正常' : '—'),
2230
+ )
2231
+ })(),
2232
+ ]
2233
+ : NO_EVENTS),
2234
+ ...(has('wechat')
2235
+ ? [
2236
+ h(
2237
+ Row,
2149
2238
  {
2150
- className: 'vdi-btn',
2151
- type: 'button',
2152
- disabled: busy,
2153
- onClick: () => void control('qq-open-settings'),
2239
+ label: '微信提醒',
2240
+ // 没连上时把原因带出来(比如没找到微信)。
2241
+ desc: ['微信托盘图标闪烁时提醒。', status?.wechat?.summary?.connection]
2242
+ .filter(Boolean)
2243
+ .join(' '),
2154
2244
  },
2155
- '打开系统设置',
2156
- )
2157
- : h('span', { className: 'vdi-info' }, state === 'listening' ? '正常' : '—'),
2245
+ h(Toggle, {
2246
+ label: '微信提醒',
2247
+ checked: value('messages.wechat', false) === true,
2248
+ onChange: (next) => update('messages.wechat', next),
2249
+ }),
2250
+ ),
2251
+ // 下面两项只在微信提醒开着时有意义;第二项只在第一项开着时有意义。
2252
+ ...(value('messages.wechat', false) === true
2253
+ ? [
2254
+ h(
2255
+ Row,
2256
+ {
2257
+ key: 'wechat-details',
2258
+ label: '显示联系人和消息内容',
2259
+ desc:
2260
+ '默认只知道微信有新消息。打开后,小岛会把正在运行的微信里控制辅助功能的一个字节从 0 改成 1,' +
2261
+ '微信就像开着读屏软件一样公开界面,这样才读得到会话列表里是谁、说了什么,点提醒还能直接进那个聊天。' +
2262
+ '只改内存:关掉这个开关或退出小岛时改回,微信重启后会再改一次。' +
2263
+ '这不是微信公开支持的做法:微信会多占一些 CPU 和内存,安全软件可能拦截,腾讯也可能把它当成异常行为。',
2264
+ },
2265
+ h(Toggle, {
2266
+ label: '显示联系人和消息内容',
2267
+ checked: value('messages.wechatDetails', false) === true,
2268
+ onChange: (next) => update('messages.wechatDetails', next),
2269
+ }),
2270
+ ),
2271
+ ...(value('messages.wechatDetails', false) === true
2272
+ ? [
2273
+ h(
2274
+ Row,
2275
+ {
2276
+ key: 'wechat-details-state',
2277
+ label: '读取状态',
2278
+ desc: status?.wechat?.summary?.details ?? '正在读取…',
2279
+ },
2280
+ h('span', { className: 'vdi-info' }, status?.wechat?.exposeStatus ? '见说明' : '—'),
2281
+ ),
2282
+ h(
2283
+ Row,
2284
+ {
2285
+ key: 'wechat-hide-taskbar',
2286
+ label: '微信最小化时不占任务栏',
2287
+ desc:
2288
+ '建议打开。微信关进托盘后读不到会话列表,最小化才读得到。打开后,最小化的微信不显示任务栏按钮,' +
2289
+ '看起来和关进托盘一样;从托盘或提醒里打开微信时按钮会回来。所以请用最小化代替关闭。',
2290
+ },
2291
+ h(Toggle, {
2292
+ label: '微信最小化时不占任务栏',
2293
+ checked: value('messages.wechatHideTaskbar', false) === true,
2294
+ onChange: (next) => update('messages.wechatHideTaskbar', next),
2295
+ }),
2296
+ ),
2297
+ ]
2298
+ : NO_EVENTS),
2299
+ ]
2300
+ : NO_EVENTS),
2301
+ ]
2302
+ : NO_EVENTS),
2158
2303
  )
2159
- })(),
2160
- h(
2161
- Row,
2162
- {
2163
- label: '微信提醒',
2164
- // 没连上时把原因带出来(比如没找到微信)。
2165
- desc: ['微信托盘图标闪烁时提醒。', status?.wechat?.summary?.connection].filter(Boolean).join(' '),
2166
- },
2167
- h(Toggle, {
2168
- label: '微信提醒',
2169
- checked: value('messages.wechat', false) === true,
2170
- onChange: (next) => update('messages.wechat', next),
2171
- }),
2172
- ),
2173
- // 下面两项只在微信提醒开着时有意义;第二项只在第一项开着时有意义。
2174
- ...(value('messages.wechat', false) === true
2175
- ? [
2176
- h(
2177
- Row,
2178
- {
2179
- key: 'wechat-details',
2180
- label: '显示联系人和消息内容',
2181
- desc:
2182
- '默认只知道微信有新消息。打开后,小岛会把正在运行的微信里控制辅助功能的一个字节从 0 改成 1,' +
2183
- '微信就像开着读屏软件一样公开界面,这样才读得到会话列表里是谁、说了什么,点提醒还能直接进那个聊天。' +
2184
- '只改内存:关掉这个开关或退出小岛时改回,微信重启后会再改一次。' +
2185
- '这不是微信公开支持的做法:微信会多占一些 CPU 和内存,安全软件可能拦截,腾讯也可能把它当成异常行为。',
2186
- },
2187
- h(Toggle, {
2188
- label: '显示联系人和消息内容',
2189
- checked: value('messages.wechatDetails', false) === true,
2190
- onChange: (next) => update('messages.wechatDetails', next),
2191
- }),
2192
- ),
2193
- ...(value('messages.wechatDetails', false) === true
2194
- ? [
2195
- h(
2196
- Row,
2197
- {
2198
- key: 'wechat-details-state',
2199
- label: '读取状态',
2200
- desc: status?.wechat?.summary?.details ?? '正在读取…',
2201
- },
2202
- h('span', { className: 'vdi-info' }, status?.wechat?.exposeStatus ? '见说明' : '—'),
2203
- ),
2204
- h(
2205
- Row,
2206
- {
2207
- key: 'wechat-hide-taskbar',
2208
- label: '微信最小化时不占任务栏',
2209
- desc:
2210
- '建议打开。微信关进托盘后读不到会话列表,最小化才读得到。打开后,最小化的微信不显示任务栏按钮,' +
2211
- '看起来和关进托盘一样;从托盘或提醒里打开微信时按钮会回来。所以请用最小化代替关闭。',
2212
- },
2213
- h(Toggle, {
2214
- label: '微信最小化时不占任务栏',
2215
- checked: value('messages.wechatHideTaskbar', false) === true,
2216
- onChange: (next) => update('messages.wechatHideTaskbar', next),
2217
- }),
2218
- ),
2219
- ]
2220
- : NO_EVENTS),
2221
- ]
2222
- : NO_EVENTS),
2223
- ),
2304
+ : null,
2224
2305
  h(
2225
2306
  Group,
2226
2307
  { title: '邮箱', key: 'mail' },
2227
2308
  infoRow(
2228
2309
  'QQ 邮箱',
2229
2310
  '在岛屿上连接',
2230
- '账号和授权码在岛屿的「消息」页里填写,授权码保存在 Windows 凭据管理器里。',
2311
+ `账号和授权码在岛屿的「消息」页里填写,授权码保存在${status?.platform === 'darwin' ? '系统钥匙串' : ' Windows 凭据管理器'}里。`,
2231
2312
  ),
2232
2313
  ),
2233
2314
  h(
@@ -2277,7 +2358,10 @@ window.__ModuleLoader__.load({
2277
2358
  label: '翻译选中的文字',
2278
2359
  desc:
2279
2360
  '选中一段外文,把鼠标移到小岛上,展开的小岛最上面会出现「翻译」按钮,点一下在小岛下面打开译文;' +
2280
- `选着文字按 ${value('translation.shortcut', 'Ctrl+Alt+T')} 也会直接翻译它。标题、列表、代码块和表格照原样排版。` +
2361
+ (has('shortcuts')
2362
+ ? `选着文字按 ${value('translation.shortcut', 'Ctrl+Alt+T')} 也会直接翻译它。`
2363
+ : '') +
2364
+ '标题、列表、代码块和表格照原样排版。' +
2281
2365
  '选中的文字只留在本机内存里,点了翻译才发给翻译服务。',
2282
2366
  },
2283
2367
  h(Toggle, {
@@ -2286,23 +2370,25 @@ window.__ModuleLoader__.load({
2286
2370
  onChange: (next) => update('translation.selection', next),
2287
2371
  }),
2288
2372
  ),
2289
- h(
2290
- Row,
2291
- {
2292
- label: '也读取其它应用里选中的文字',
2293
- dim: value('translation.selection', true) !== true,
2294
- desc:
2295
- 'VibeDev 里选中的文字直接就能读到。其它应用要经 Windows 的无障碍接口去问:只读,不碰剪贴板、不模拟按键,密码框不读。' +
2296
- '浏览器、VS Code 这类程序被这样问过之后会打开自己的无障碍支持,可能多占一些内存,所以默认关闭。' +
2297
- '关着时,在其它应用里先复制(Ctrl+C),再把鼠标移到小岛上,也会出现翻译按钮。',
2298
- },
2299
- h(Toggle, {
2300
- label: '也读取其它应用里选中的文字',
2301
- checked: value('translation.readOtherApps', false) === true,
2302
- disabled: value('translation.selection', true) !== true,
2303
- onChange: (next) => update('translation.readOtherApps', next),
2304
- }),
2305
- ),
2373
+ has('readOtherApps')
2374
+ ? h(
2375
+ Row,
2376
+ {
2377
+ label: '也读取其它应用里选中的文字',
2378
+ dim: value('translation.selection', true) !== true,
2379
+ desc:
2380
+ 'VibeDev 里选中的文字直接就能读到。其它应用要经 Windows 的无障碍接口去问:只读,不碰剪贴板、不模拟按键,密码框不读。' +
2381
+ '浏览器、VS Code 这类程序被这样问过之后会打开自己的无障碍支持,可能多占一些内存,所以默认关闭。' +
2382
+ '关着时,在其它应用里先复制(Ctrl+C),再把鼠标移到小岛上,也会出现翻译按钮。',
2383
+ },
2384
+ h(Toggle, {
2385
+ label: '也读取其它应用里选中的文字',
2386
+ checked: value('translation.readOtherApps', false) === true,
2387
+ disabled: value('translation.selection', true) !== true,
2388
+ onChange: (next) => update('translation.readOtherApps', next),
2389
+ }),
2390
+ )
2391
+ : null,
2306
2392
  ),
2307
2393
  h(
2308
2394
  Group,
@@ -2312,7 +2398,10 @@ window.__ModuleLoader__.load({
2312
2398
  {
2313
2399
  label: '翻译面板',
2314
2400
  desc:
2315
- `没选文字时按 ${value('translation.shortcut', 'Ctrl+Alt+T')} 打开翻译面板:可以直接打字,或按 Tab 填入刚复制的内容,回车翻译。` +
2401
+ (has('shortcuts')
2402
+ ? `没选文字时按 ${value('translation.shortcut', 'Ctrl+Alt+T')} 打开翻译面板:`
2403
+ : '打开翻译面板:') +
2404
+ '可以直接打字,或按 Tab 填入刚复制的内容,回车翻译。' +
2316
2405
  '小岛展开后右上角的「文」字按钮也能打开它。',
2317
2406
  },
2318
2407
  h(
@@ -2372,15 +2461,17 @@ window.__ModuleLoader__.load({
2372
2461
  busy ? '翻译中…' : '翻译一句试试',
2373
2462
  ),
2374
2463
  ),
2375
- h(
2376
- Row,
2377
- { label: '快捷键', desc: shortcutNote('translation') },
2378
- h(ShortcutField, {
2379
- label: '翻译快捷键',
2380
- value: value('translation.shortcut', 'Ctrl+Alt+T'),
2381
- onChange: (next) => update('translation.shortcut', next),
2382
- }),
2383
- ),
2464
+ has('shortcuts')
2465
+ ? h(
2466
+ Row,
2467
+ { label: '快捷键', desc: shortcutNote('translation') },
2468
+ h(ShortcutField, {
2469
+ label: '翻译快捷键',
2470
+ value: value('translation.shortcut', 'Ctrl+Alt+T'),
2471
+ onChange: (next) => update('translation.shortcut', next),
2472
+ }),
2473
+ )
2474
+ : null,
2384
2475
  ),
2385
2476
  ],
2386
2477
 
@@ -2395,7 +2486,7 @@ window.__ModuleLoader__.load({
2395
2486
  ),
2396
2487
  infoRow('协议版本', status?.protocol === undefined ? '—' : String(status.protocol)),
2397
2488
  ),
2398
- h(Group, { title: '更新记录', key: 'changelog' }, h(Changelog, { initial: props?.initialChangelog })),
2489
+ h(Group, { title: '更新记录', key: 'changelog' }, h(Changelog, { initial: initialChangelog })),
2399
2490
  h(
2400
2491
  Group,
2401
2492
  { title: '数据', key: 'data' },
@@ -2410,7 +2501,7 @@ window.__ModuleLoader__.load({
2410
2501
  h(
2411
2502
  Row,
2412
2503
  { label: '数据目录', desc: '待办、笔记和归档。' },
2413
- h(PathInput, { label: '数据目录', value: '%APPDATA%/com.vibedev.island/data' }),
2504
+ h(PathInput, { label: '数据目录', value: `${islandDataDir}/data` }),
2414
2505
  ),
2415
2506
  h(
2416
2507
  Row,
@@ -2435,7 +2526,7 @@ window.__ModuleLoader__.load({
2435
2526
  label: '导出诊断信息',
2436
2527
  desc:
2437
2528
  status?.diagnosticsPath === undefined
2438
- ? '把版本、WebView2、各项状态、设置和最近 200 行日志写进一个文本文件,在资源管理器里选中它。日志里可能有会话标题,发给别人前看一眼;密钥不在里面。'
2529
+ ? '把版本、运行状态、设置和最近 200 行日志写入文本文件。日志可能含会话标题,请在转发前检查。'
2439
2530
  : `已导出:${status.diagnosticsPath}`,
2440
2531
  },
2441
2532
  h(
@@ -2453,14 +2544,20 @@ window.__ModuleLoader__.load({
2453
2544
  h(
2454
2545
  Group,
2455
2546
  { title: '许可与致谢', key: 'license' },
2456
- infoRow('小岛', 'MIT', '基于 fly-island(flyl1u,MIT)改造。'),
2547
+ infoRow('小岛', 'MIT', '原生界面和截图助手的版权与许可见随包声明。'),
2457
2548
  h(Row, { label: '第三方许可' }, null),
2458
2549
  h(ThirdParty, null),
2459
2550
  ),
2460
2551
  ],
2461
2552
  }
2462
2553
 
2463
- const active = sections[section] ?? sections.overview
2554
+ // 这个系统上没有的功能,分区不给入口;停在那里时回到概览。
2555
+ const sectionShown = (id) => {
2556
+ const needs = SECTIONS.find((item) => item.id === id)?.needs
2557
+ return needs === undefined || has(needs)
2558
+ }
2559
+ const shownSection = sectionShown(section) ? section : 'overview'
2560
+ const active = sections[shownSection] ?? sections.overview
2464
2561
  const titles = {
2465
2562
  overview: '概览',
2466
2563
  appearance: '外观',
@@ -2495,13 +2592,13 @@ window.__ModuleLoader__.load({
2495
2592
  h(
2496
2593
  'nav',
2497
2594
  { className: 'vdi__nav', 'aria-label': '设置分区' },
2498
- SECTIONS.map((item) =>
2595
+ SECTIONS.filter((item) => sectionShown(item.id)).map((item) =>
2499
2596
  h(
2500
2597
  'button',
2501
2598
  {
2502
2599
  key: item.id,
2503
2600
  type: 'button',
2504
- 'aria-current': item.id === section ? 'true' : 'false',
2601
+ 'aria-current': item.id === shownSection ? 'true' : 'false',
2505
2602
  onClick: () => setSection(item.id),
2506
2603
  },
2507
2604
  h(Icon, { name: item.icon }),
@@ -2512,7 +2609,7 @@ window.__ModuleLoader__.load({
2512
2609
  h(
2513
2610
  'div',
2514
2611
  { className: 'vdi__body' },
2515
- h('h2', { className: 'vdi__title' }, titles[section] ?? '概览'),
2612
+ h('h2', { className: 'vdi__title' }, titles[shownSection] ?? '概览'),
2516
2613
  descriptions[section] ? h('p', { className: 'vdi__desc' }, descriptions[section]) : null,
2517
2614
  ready ? active() : h('div', { className: 'vdi-status__meta', style: { marginTop: 12 } }, '正在读取设置…'),
2518
2615
  error === undefined ? null : h('div', { className: 'vdi-error' }, error),