@binblink/wasmnest-plugin-sdk-mobile 0.0.0-stage → 0.0.2
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 +439 -2
- package/README_en.md +415 -0
- package/bin/build.js +271 -0
- package/bin/cli.js +96 -0
- package/bin/lib.js +349 -0
- package/bin/manifest-gen.js +327 -0
- package/bin/package.js +151 -0
- package/bin/scaffold.js +299 -0
- package/dev-shell/README.md +151 -0
- package/dev-shell/index.html +27 -0
- package/dev-shell/package.json +27 -0
- package/dev-shell/pnpm-workspace.yaml +9 -0
- package/dev-shell/postcss.config.js +6 -0
- package/dev-shell/src/App.vue +90 -0
- package/dev-shell/src/apps/mock-terminal/MockTerminalSlotCard.vue +43 -0
- package/dev-shell/src/apps/mock-terminal/MockTerminalView.vue +168 -0
- package/dev-shell/src/apps/mock-terminal/index.ts +50 -0
- package/dev-shell/src/components/DevToolbar.vue +100 -0
- package/dev-shell/src/components/DialogHost.vue +119 -0
- package/dev-shell/src/components/LogPanel.vue +80 -0
- package/dev-shell/src/i18n.ts +22 -0
- package/dev-shell/src/loader.ts +239 -0
- package/dev-shell/src/locale.ts +29 -0
- package/dev-shell/src/locales/en-shell.ts +332 -0
- package/dev-shell/src/locales/index.ts +70 -0
- package/dev-shell/src/locales/shell.ts +331 -0
- package/dev-shell/src/main.ts +58 -0
- package/dev-shell/src/mock/dialog-service.ts +58 -0
- package/dev-shell/src/mock/file-transfer.ts +390 -0
- package/dev-shell/src/mock/mobile-api.ts +369 -0
- package/dev-shell/src/mock/preset-tasks.ts +186 -0
- package/dev-shell/src/mock/session.ts +121 -0
- package/dev-shell/src/mock-context.ts +374 -0
- package/dev-shell/src/registry.ts +151 -0
- package/dev-shell/src/shared-runtime.ts +44 -0
- package/dev-shell/src/shell/ShellView.vue +52 -0
- package/dev-shell/src/shell/adapters/devAppSource.ts +144 -0
- package/dev-shell/src/shell/components/PluginContextHost.vue +40 -0
- package/dev-shell/src/shell/components/ShellAppCell.vue +75 -0
- package/dev-shell/src/shell/components/ShellAppIcon.vue +111 -0
- package/dev-shell/src/shell/components/ShellAppSurface.vue +46 -0
- package/dev-shell/src/shell/components/ShellBrandTile.vue +27 -0
- package/dev-shell/src/shell/components/ShellCapsuleMenu.vue +123 -0
- package/dev-shell/src/shell/components/ShellChip.vue +49 -0
- package/dev-shell/src/shell/components/ShellGroupCard.vue +17 -0
- package/dev-shell/src/shell/components/ShellHost.vue +75 -0
- package/dev-shell/src/shell/components/ShellNotificationShade.vue +501 -0
- package/dev-shell/src/shell/components/ShellPermissionPrompt.vue +127 -0
- package/dev-shell/src/shell/components/ShellPlaceholderSurface.vue +33 -0
- package/dev-shell/src/shell/components/ShellSection.vue +27 -0
- package/dev-shell/src/shell/components/ShellSheet.vue +74 -0
- package/dev-shell/src/shell/components/ShellStatusbar.vue +84 -0
- package/dev-shell/src/shell/components/screens/PluginRoutePage.vue +98 -0
- package/dev-shell/src/shell/components/screens/ShellAppDetailScreen.vue +359 -0
- package/dev-shell/src/shell/components/screens/ShellAppRunScreen.vue +90 -0
- package/dev-shell/src/shell/components/screens/ShellAppsScreen.vue +195 -0
- package/dev-shell/src/shell/components/screens/ShellHomeScreen.vue +357 -0
- package/dev-shell/src/shell/components/screens/ShellPermissionsScreen.vue +376 -0
- package/dev-shell/src/shell/components/screens/ShellSettingsScreen.vue +240 -0
- package/dev-shell/src/shell/components/screens/ShellSwitcherScreen.vue +559 -0
- package/dev-shell/src/shell/components/ui/ConfirmDialog.vue +137 -0
- package/dev-shell/src/shell/components/ui/Toggle.vue +53 -0
- package/dev-shell/src/shell/composables/useShellApps.ts +417 -0
- package/dev-shell/src/shell/composables/useShellNavigation.ts +197 -0
- package/dev-shell/src/shell/composables/useShellNotifications.ts +115 -0
- package/dev-shell/src/shell/composables/useShellOpen.ts +44 -0
- package/dev-shell/src/shell/composables/useShellOverlays.ts +101 -0
- package/dev-shell/src/shell/composables/useShellPreferences.ts +143 -0
- package/dev-shell/src/shell/composables/useShellRecent.ts +84 -0
- package/dev-shell/src/shell/composables/useSlotCarousel.ts +238 -0
- package/dev-shell/src/shell/composables/useToast.ts +33 -0
- package/dev-shell/src/shell/index.ts +88 -0
- package/dev-shell/src/shell/logger.ts +45 -0
- package/dev-shell/src/shell/permissions.ts +145 -0
- package/dev-shell/src/shell/registry.ts +220 -0
- package/dev-shell/src/shell/slotCards.ts +47 -0
- package/dev-shell/src/shell/styles/shell.css +1155 -0
- package/dev-shell/src/shell/surfaceIntent.ts +107 -0
- package/dev-shell/src/shell/types.ts +152 -0
- package/dev-shell/src/shell/utils.ts +54 -0
- package/dev-shell/src/styles/main.css +153 -0
- package/dev-shell/src/styles/mobile.css +981 -0
- package/dev-shell/src/styles/wallpaper.css +130 -0
- package/dev-shell/src/theme.ts +71 -0
- package/dev-shell/src/vite-env.d.ts +20 -0
- package/dev-shell/tailwind.config.js +101 -0
- package/dev-shell/tsconfig.json +16 -0
- package/dev-shell/vite.config.ts +130 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +229 -0
- package/dist/types.d.ts +738 -0
- package/dist/types.js +0 -0
- package/dist/vite-plugin.d.ts +16 -0
- package/dist/vite-plugin.js +95 -0
- package/package.json +88 -3
- package/src/constants.ts +6 -0
- package/src/global-dialog.ts +168 -0
- package/src/index.ts +96 -0
- package/src/runtime.ts +44 -0
- package/src/types.ts +822 -0
- package/src/ui/AppUpdateSection.d.ts +44 -0
- package/src/ui/AppUpdateSection.vue +253 -0
- package/src/ui/PluginGlobalDialog.vue +388 -0
- package/src/ui/QuickCard.d.ts +33 -0
- package/src/ui/QuickCard.vue +167 -0
- package/src/ui/Select.d.ts +37 -0
- package/src/ui/Select.vue +307 -0
- package/src/ui/plugin-global-dialog.d.ts +11 -0
- package/src/ui/useSwipeTabs.d.ts +20 -0
- package/src/ui/useSwipeTabs.ts +53 -0
- package/src/update.ts +123 -0
- package/src/vite-plugin.ts +132 -0
- package/template/.gitignore +4 -0
- package/template/README.md +46 -0
- package/template/package.json +23 -0
- package/template/plugin.json +13 -0
- package/template/rust/Cargo.toml +19 -0
- package/template/rust/src/lib.rs +33 -0
- package/template/src/env.d.ts +24 -0
- package/template/src/index.ts +37 -0
- package/template/tsconfig.json +17 -0
- package/template/vite.config.ts +21 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
平台主屏
|
|
4
|
+
--------------------------------------------------------------------------
|
|
5
|
+
对齐桌面方案 C 的主屏语义(运行卡片带 + 应用宫格 + 系统宫格),落到 Android
|
|
6
|
+
启动器的形态上:壁纸铺底、图标宫格、系统入口与应用同层。壁纸层不随内容滚动
|
|
7
|
+
(绝对定位铺满根容器),内容层单独滚动。
|
|
8
|
+
-->
|
|
9
|
+
<div
|
|
10
|
+
class="relative flex flex-col h-full min-h-0 shell-wall"
|
|
11
|
+
:class="wallClass"
|
|
12
|
+
:style="{ '--wall-dim': wallDim }"
|
|
13
|
+
>
|
|
14
|
+
<!-- 壁纸层:纯装饰,不参与交互与读屏 -->
|
|
15
|
+
<div class="shell-wallpaper" aria-hidden="true" :style="wallImageStyle" />
|
|
16
|
+
|
|
17
|
+
<!-- ==================== 头部 ==================== -->
|
|
18
|
+
<header class="relative z-10 flex items-center gap-3 px-4 pt-3 pb-2 flex-shrink-0">
|
|
19
|
+
<ShellBrandTile :size="38" />
|
|
20
|
+
<div class="flex-1 min-w-0">
|
|
21
|
+
<div class="text-[var(--font-size-lg)] font-semibold leading-tight text-[var(--mobile-text-primary)]">
|
|
22
|
+
<span>Wasm</span><em class="not-italic" :style="{ color: 'var(--shell-brand-ember)' }">App</em>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)] truncate">
|
|
25
|
+
{{ t('shell.home.localDevice') }} ·
|
|
26
|
+
{{ t('shell.home.appCount', { count: stats.installed }) }}
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<!-- 通知入口(主入口,44px):状态条上还有一条(系统状态栏占位时不渲染) -->
|
|
30
|
+
<button
|
|
31
|
+
type="button"
|
|
32
|
+
class="relative flex items-center justify-center rounded-[10px] min-w-[var(--mobile-touch-target-min)] min-h-[var(--mobile-touch-target-min)] transition-colors duration-200 active:bg-[var(--mobile-accent-muted)]"
|
|
33
|
+
:aria-label="t('shell.notify.open', { count: badgeCount })"
|
|
34
|
+
@click="overlays.toggleShade()"
|
|
35
|
+
>
|
|
36
|
+
<svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
37
|
+
<path d="M18 8a6 6 0 1 0-12 0c0 7-3 8-3 8h18s-3-1-3-8" />
|
|
38
|
+
<path d="M10.3 21a2 2 0 0 0 3.4 0" />
|
|
39
|
+
</svg>
|
|
40
|
+
<span
|
|
41
|
+
v-if="badgeCount > 0"
|
|
42
|
+
class="absolute top-1 right-1 inline-flex items-center justify-center min-w-[16px] h-4 px-1 rounded-full text-[10px] font-semibold leading-none"
|
|
43
|
+
:style="{ background: 'var(--mobile-error)', color: 'var(--mobile-text-on-accent)' }"
|
|
44
|
+
aria-hidden="true"
|
|
45
|
+
>
|
|
46
|
+
{{ badgeCount > 99 ? '99+' : badgeCount }}
|
|
47
|
+
</span>
|
|
48
|
+
</button>
|
|
49
|
+
</header>
|
|
50
|
+
|
|
51
|
+
<!-- ==================== 内容 ==================== -->
|
|
52
|
+
<div class="relative z-10 flex-1 min-h-0 overflow-y-auto pb-6">
|
|
53
|
+
<!-- ======== 正在运行(MRU 卡片带,桌面同构) ======== -->
|
|
54
|
+
<template v-if="runningOrdered.length > 0">
|
|
55
|
+
<ShellSection :title="t('shell.home.runningTitle')" class="shell-reveal">
|
|
56
|
+
<!-- 多任务入口:recents 在业界是全局可达的(Android / iOS 都能从任意屏进入),
|
|
57
|
+
底部系统条退役后这里补上,不至于只能从运行页胶囊绕进去 -->
|
|
58
|
+
<template #action>
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
class="shell-icon-action"
|
|
62
|
+
:aria-label="t('shell.switcher.title')"
|
|
63
|
+
@click="nav.openSwitcher()"
|
|
64
|
+
>
|
|
65
|
+
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
66
|
+
<rect x="7" y="3" width="14" height="14" rx="3" />
|
|
67
|
+
<path d="M3 7v10a4 4 0 004 4h10" />
|
|
68
|
+
</svg>
|
|
69
|
+
</button>
|
|
70
|
+
</template>
|
|
71
|
+
</ShellSection>
|
|
72
|
+
<div class="px-4 flex gap-2.5 overflow-x-auto pb-1 shell-reveal" role="list" :style="{ animationDelay: '50ms' }">
|
|
73
|
+
<article
|
|
74
|
+
v-for="app in runningOrdered"
|
|
75
|
+
:key="app.id"
|
|
76
|
+
class="flex-shrink-0 w-[150px] rounded-[14px] border border-[var(--mobile-border)] bg-[var(--mobile-bg-card)] p-3"
|
|
77
|
+
:style="{ boxShadow: 'var(--mobile-card-shadow)' }"
|
|
78
|
+
role="listitem"
|
|
79
|
+
>
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
class="flex items-center gap-2 w-full text-left min-h-[var(--mobile-touch-target-min)] active:opacity-70 transition-opacity duration-150"
|
|
83
|
+
:aria-label="t('shell.home.switchTo', { name: app.name })"
|
|
84
|
+
@click="open(app.id)"
|
|
85
|
+
>
|
|
86
|
+
<ShellAppIcon :app="app" :size="30" />
|
|
87
|
+
<span class="flex-1 min-w-0">
|
|
88
|
+
<span class="block text-[var(--font-size-sm)] font-medium text-[var(--mobile-text-primary)] truncate">
|
|
89
|
+
{{ app.name }}
|
|
90
|
+
</span>
|
|
91
|
+
<span class="flex items-center gap-1 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)] truncate min-w-0">
|
|
92
|
+
<span class="w-1.5 h-1.5 rounded-full flex-shrink-0" style="background: var(--mobile-success)" aria-hidden="true" />
|
|
93
|
+
<span class="min-w-0 truncate">{{ t('shell.common.running') }}</span>
|
|
94
|
+
</span>
|
|
95
|
+
</span>
|
|
96
|
+
</button>
|
|
97
|
+
<!-- 关闭 = 停用实例(Android 卡片关闭的同一语义:回收内存,数据保留) -->
|
|
98
|
+
<div class="mt-1.5 flex justify-end">
|
|
99
|
+
<ShellChip
|
|
100
|
+
:label="t('shell.home.stopInstance')"
|
|
101
|
+
tone="danger"
|
|
102
|
+
clickable
|
|
103
|
+
@click="stopApp(app.id)"
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
</article>
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|
|
109
|
+
|
|
110
|
+
<!-- ======== 快捷卡片(应用贡献,横向轮播) ========
|
|
111
|
+
与宿主同构:定宽卡片 + 原生 scroll-snap,多张时自动轮播(触摸 / 聚焦 /
|
|
112
|
+
切后台 / 减少动效时停走);整张卡是宿主按钮,点击打开贡献方应用。 -->
|
|
113
|
+
<template v-if="slotCards.length > 0">
|
|
114
|
+
<ShellSection :title="t('shell.home.slotsTitle')" class="shell-reveal" :style="{ animationDelay: '80ms' }">
|
|
115
|
+
<template v-if="slotCards.length > 1 && !reducedMotion" #action>
|
|
116
|
+
<button
|
|
117
|
+
type="button"
|
|
118
|
+
class="shell-icon-action"
|
|
119
|
+
:aria-label="playing ? t('shell.home.slotPause') : t('shell.home.slotPlay')"
|
|
120
|
+
@click="toggleAutoplay()"
|
|
121
|
+
>
|
|
122
|
+
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
123
|
+
<template v-if="playing">
|
|
124
|
+
<path d="M9 5v14M15 5v14" />
|
|
125
|
+
</template>
|
|
126
|
+
<template v-else>
|
|
127
|
+
<path d="M8 5.5v13l10-6.5Z" />
|
|
128
|
+
</template>
|
|
129
|
+
</svg>
|
|
130
|
+
</button>
|
|
131
|
+
</template>
|
|
132
|
+
</ShellSection>
|
|
133
|
+
<div ref="slotTrack" class="shell-slot-track shell-reveal" role="list" :style="{ animationDelay: '120ms' }">
|
|
134
|
+
<div v-for="card in slotCards" :key="card.key" class="shell-slot-item" role="listitem">
|
|
135
|
+
<!-- 可访问名 = 隐藏动作前缀「打开 <应用>」+ 卡片内容:不覆盖应用自持的读数。
|
|
136
|
+
点击除打开应用外,还把应用现算的入口意图投递给它(与宿主同构)。 -->
|
|
137
|
+
<button type="button" class="shell-slot-card" @click="openSlotCard(card)">
|
|
138
|
+
<span class="sr-only">{{ t('shell.home.slotOpen', { name: card.app.name }) }}</span>
|
|
139
|
+
<component :is="card.component" :app="card.app" />
|
|
140
|
+
</button>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</template>
|
|
144
|
+
|
|
145
|
+
<!-- ======== 应用宫格 ======== -->
|
|
146
|
+
<ShellSection :title="t('shell.home.appsTitle')" :note="t('shell.home.appsNote', { count: apps.length })" class="shell-reveal" :style="{ animationDelay: '160ms' }">
|
|
147
|
+
<template #action>
|
|
148
|
+
<!-- 图标按钮(44px 触控目标):入口语义是「应用管理」,文字 chip 在宫格标题行里
|
|
149
|
+
抢视觉重心且显得扁平,改用单图标 + 可访问名(ui-ux-pro-max --domain icons:
|
|
150
|
+
图标控件必须有 accessible name,不能只有一个图形) -->
|
|
151
|
+
<button
|
|
152
|
+
type="button"
|
|
153
|
+
class="shell-icon-action"
|
|
154
|
+
:aria-label="t('shell.home.manageApps')"
|
|
155
|
+
@click="nav.navigate('apps')"
|
|
156
|
+
>
|
|
157
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
158
|
+
<path d="M5 6h8M17.5 6H19M5 12h1.5M11 12h8M5 18h8M17.5 18H19" />
|
|
159
|
+
<circle cx="15" cy="6" r="2" />
|
|
160
|
+
<circle cx="8.5" cy="12" r="2" />
|
|
161
|
+
<circle cx="15" cy="18" r="2" />
|
|
162
|
+
</svg>
|
|
163
|
+
</button>
|
|
164
|
+
</template>
|
|
165
|
+
</ShellSection>
|
|
166
|
+
<div class="px-4">
|
|
167
|
+
<div v-if="apps.length > 0" class="grid grid-cols-4 gap-1 shell-reveal" role="list" :style="{ animationDelay: '200ms' }">
|
|
168
|
+
<ShellAppCell v-for="app in sortedApps" :key="app.id" :app="app" @open="open" />
|
|
169
|
+
</div>
|
|
170
|
+
<!-- 空态给出下一步(安装入口在应用管理页),而不是只留一句「暂无应用」 -->
|
|
171
|
+
<p
|
|
172
|
+
v-else
|
|
173
|
+
class="rounded-[12px] border border-dashed border-[var(--mobile-border-hover)] px-3 py-5 text-center text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]"
|
|
174
|
+
>
|
|
175
|
+
{{ t('shell.home.emptyAppsHint') }}
|
|
176
|
+
</p>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<!-- ======== 系统宫格(平台自有面,与应用同层) ======== -->
|
|
180
|
+
<ShellSection :title="t('shell.home.sysTitle')" class="shell-reveal" :style="{ animationDelay: '240ms' }" />
|
|
181
|
+
<div class="px-4">
|
|
182
|
+
<div class="grid grid-cols-4 gap-1 shell-reveal" role="list" :style="{ animationDelay: '280ms' }">
|
|
183
|
+
<button
|
|
184
|
+
v-for="entry in sysEntries"
|
|
185
|
+
:key="entry.id"
|
|
186
|
+
type="button"
|
|
187
|
+
class="flex flex-col items-center gap-1.5 py-2 rounded-[12px] transition-colors duration-200 active:bg-[var(--mobile-accent-muted)] active:opacity-70"
|
|
188
|
+
:aria-label="entry.label"
|
|
189
|
+
role="listitem"
|
|
190
|
+
@click="entry.run()"
|
|
191
|
+
>
|
|
192
|
+
<span
|
|
193
|
+
class="flex items-center justify-center flex-shrink-0 rounded-[12px] w-11 h-11 border"
|
|
194
|
+
:style="{ background: entry.tileBg, color: entry.tileColor, borderColor: entry.tileBorder }"
|
|
195
|
+
aria-hidden="true"
|
|
196
|
+
>
|
|
197
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
|
198
|
+
<path :d="entry.icon" />
|
|
199
|
+
</svg>
|
|
200
|
+
</span>
|
|
201
|
+
<span class="w-full text-center text-[var(--font-size-xs)] text-[var(--mobile-text-primary)] truncate">
|
|
202
|
+
{{ entry.label }}
|
|
203
|
+
</span>
|
|
204
|
+
</button>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</template>
|
|
210
|
+
|
|
211
|
+
<script setup lang="ts">
|
|
212
|
+
/**
|
|
213
|
+
* 平台主屏
|
|
214
|
+
*
|
|
215
|
+
* 主屏是「应用注册表 + 壳偏好的聚合视图」,自身不含业务:快捷卡片由应用注册组件,
|
|
216
|
+
* 运行卡片带是运行态投影,系统宫格是平台自有面。新增应用不需要改本文件。
|
|
217
|
+
*
|
|
218
|
+
* 壁纸与遮罩来自壳偏好(useShellPreferences);壁纸只落主屏——应用运行面保持纯色,
|
|
219
|
+
* 业务内容可读性优先(与桌面壳同口径)。
|
|
220
|
+
*
|
|
221
|
+
* 正文案纪律(2026-10-14 修订):分组标题行只留标题与计数,不再写「平台自带」
|
|
222
|
+
* 「由应用提供」「最近使用在前」这类方案期解释——用户看得到事实,不需要旁白。
|
|
223
|
+
*/
|
|
224
|
+
import { computed, ref } from 'vue'
|
|
225
|
+
import { useI18n } from 'vue-i18n'
|
|
226
|
+
import { useShellApps } from '../../composables/useShellApps'
|
|
227
|
+
import { useShellNavigation } from '../../composables/useShellNavigation'
|
|
228
|
+
import { useShellNotifications } from '../../composables/useShellNotifications'
|
|
229
|
+
import { useShellOpen } from '../../composables/useShellOpen'
|
|
230
|
+
import { useShellOverlays } from '../../composables/useShellOverlays'
|
|
231
|
+
import { useShellPreferences } from '../../composables/useShellPreferences'
|
|
232
|
+
import { useShellRecent } from '../../composables/useShellRecent'
|
|
233
|
+
import { useSlotCarousel } from '../../composables/useSlotCarousel'
|
|
234
|
+
import { selectSlotCards, type ShellSlotCard } from '../../slotCards'
|
|
235
|
+
import { logger } from '../../logger'
|
|
236
|
+
import type { ShellSurfaceIntent } from '../../../../src/types'
|
|
237
|
+
// dev-shell 无 asset protocol:自定义壁纸图恒不可达(wallpaperImage 恒 null),该导入宿主独有
|
|
238
|
+
import type { ShellApp } from '../../types'
|
|
239
|
+
import ShellAppCell from '../ShellAppCell.vue'
|
|
240
|
+
import ShellAppIcon from '../ShellAppIcon.vue'
|
|
241
|
+
import ShellBrandTile from '../ShellBrandTile.vue'
|
|
242
|
+
import ShellChip from '../ShellChip.vue'
|
|
243
|
+
import ShellSection from '../ShellSection.vue'
|
|
244
|
+
|
|
245
|
+
const { t } = useI18n()
|
|
246
|
+
const nav = useShellNavigation()
|
|
247
|
+
const { stats, apps, sortedApps, stop } = useShellApps()
|
|
248
|
+
const { recentIds } = useShellRecent()
|
|
249
|
+
const { open } = useShellOpen()
|
|
250
|
+
const overlays = useShellOverlays()
|
|
251
|
+
const { notificationCount } = useShellNotifications()
|
|
252
|
+
const { wallpaper, wallDim, wallpaperImage } = useShellPreferences()
|
|
253
|
+
|
|
254
|
+
/** 壁纸类名:none 时只保留壳根类(纯页面底色);自定义图片走 style 背景 */
|
|
255
|
+
const wallClass = computed(() => (wallpaper.value === 'none' ? '' : `wall-${wallpaper.value}`))
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 自定义壁纸的图片层(asset protocol URL)
|
|
259
|
+
*
|
|
260
|
+
* 宿主侧由 asset 工具拼接 URL;dev-shell 没有 asset protocol,且没有宿主命令
|
|
261
|
+
* 可以落盘自定义壁纸(useShellPreferences 的 custom 档恒不可达),因此这里
|
|
262
|
+
* 恒返回 undefined——档位与校验与宿主同构,只是「永远没有图」是 dev 环境的既定事实。
|
|
263
|
+
*/
|
|
264
|
+
const wallImageStyle = computed(() => {
|
|
265
|
+
if (wallpaper.value !== 'custom' || !wallpaperImage.value) return undefined
|
|
266
|
+
// dev-shell:不放行任意本地路径作为背景图(浏览器里那是页面自身的源),
|
|
267
|
+
// 恒回落纯色面,不渲染图片层
|
|
268
|
+
return undefined
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
/** 未读计数:通知 + 待审批(与状态条角标同口径) */
|
|
272
|
+
const badgeCount = computed(
|
|
273
|
+
() => notificationCount.value + apps.value.filter((a) => a.state === 'approval').length,
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* 运行中应用按「最近使用」排序(MRU)
|
|
278
|
+
*
|
|
279
|
+
* recentIds 里没有记录的运行中应用排在其后(例如 WebView 重载后后端实例仍在跑),
|
|
280
|
+
* 兜底排序用名称,保证顺序稳定而不是随注册表写入顺序跳动。
|
|
281
|
+
*/
|
|
282
|
+
const runningOrdered = computed<ShellApp[]>(() => {
|
|
283
|
+
const running = apps.value.filter((a) => a.state === 'running')
|
|
284
|
+
const rank = (app: ShellApp): number => {
|
|
285
|
+
const index = recentIds.value.indexOf(app.id)
|
|
286
|
+
return index === -1 ? Number.MAX_SAFE_INTEGER : index
|
|
287
|
+
}
|
|
288
|
+
return [...running].sort((a, b) => {
|
|
289
|
+
const diff = rank(a) - rank(b)
|
|
290
|
+
return diff !== 0 ? diff : a.name.localeCompare(b.name, 'zh-Hans-CN')
|
|
291
|
+
})
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
/** 应用贡献的快捷卡片(注册顺序,超过展示上限的部分不渲染;与宿主同构) */
|
|
295
|
+
const slotCards = computed(() => selectSlotCards(apps.value))
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 点击快捷卡片:打开应用 + 投递应用现算的入口意图(与宿主同构)
|
|
299
|
+
*
|
|
300
|
+
* `onPress` 抛错不阻断「打开应用」主路径,只落一条壳日志。
|
|
301
|
+
*/
|
|
302
|
+
function openSlotCard(card: ShellSlotCard): void {
|
|
303
|
+
let intent: ShellSurfaceIntent | null | undefined
|
|
304
|
+
try {
|
|
305
|
+
intent = card.onPress?.()
|
|
306
|
+
} catch (e) {
|
|
307
|
+
logger.warn(`[shell] 快捷卡片入口意图计算失败 appId=${card.app.id}`, e)
|
|
308
|
+
}
|
|
309
|
+
void open(card.app.id, intent)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** 轨道轮播(与宿主同构:自动播放 / 触摸停走 / 减少动效停走) */
|
|
313
|
+
const slotTrack = ref<HTMLElement | null>(null)
|
|
314
|
+
const {
|
|
315
|
+
playing,
|
|
316
|
+
reducedMotion,
|
|
317
|
+
toggle: toggleAutoplay,
|
|
318
|
+
} = useSlotCarousel(slotTrack, computed(() => slotCards.value.length))
|
|
319
|
+
|
|
320
|
+
/** 系统宫格:平台自有面(应用管理 / 权限管理 / 设置),全部 push 进栈以便返回。
|
|
321
|
+
* 每个入口一个档案色(tile*),色相用于入口辨识而非危险等级;
|
|
322
|
+
* 图标为重新绘制版本(圆角宫格 / 盾+勾 / 齿轮+孔)。 */
|
|
323
|
+
const sysEntries = computed(() => [
|
|
324
|
+
{
|
|
325
|
+
id: 'apps',
|
|
326
|
+
label: t('shell.home.sysApps'),
|
|
327
|
+
icon: 'M5 3h5a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z M16 3h5a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z M5 14h5a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2z M16 14h5a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2z',
|
|
328
|
+
tileBg: 'var(--shell-tile-apps-bg)',
|
|
329
|
+
tileColor: 'var(--shell-tile-apps-color)',
|
|
330
|
+
tileBorder: 'var(--shell-tile-apps-border)',
|
|
331
|
+
run: () => nav.navigate('apps'),
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
id: 'permissions',
|
|
335
|
+
label: t('shell.home.sysPermissions'),
|
|
336
|
+
icon: 'M12 3l8 3v6c0 4.5-3.2 7.6-8 9-4.8-1.4-8-4.5-8-9V6l8-3z M9.2 12.1l2 2 3.6-3.8',
|
|
337
|
+
tileBg: 'var(--shell-tile-perms-bg)',
|
|
338
|
+
tileColor: 'var(--shell-tile-perms-color)',
|
|
339
|
+
tileBorder: 'var(--shell-tile-perms-border)',
|
|
340
|
+
run: () => nav.openPermissions(),
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
id: 'settings',
|
|
344
|
+
label: t('shell.home.sysSettings'),
|
|
345
|
+
// 齿轮(lucide settings 形态) + 中心孔
|
|
346
|
+
icon: 'M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z',
|
|
347
|
+
tileBg: 'var(--shell-tile-settings-bg)',
|
|
348
|
+
tileColor: 'var(--shell-tile-settings-color)',
|
|
349
|
+
tileBorder: 'var(--shell-tile-settings-border)',
|
|
350
|
+
run: () => nav.navigate('settings'),
|
|
351
|
+
},
|
|
352
|
+
])
|
|
353
|
+
|
|
354
|
+
async function stopApp(appId: string): Promise<void> {
|
|
355
|
+
await stop(appId)
|
|
356
|
+
}
|
|
357
|
+
</script>
|