@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,127 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ShellSheet
|
|
3
|
+
:open="request !== null"
|
|
4
|
+
:title="request ? t('shell.permissionPrompt.title', { name: appName }) : ''"
|
|
5
|
+
@close="deny"
|
|
6
|
+
>
|
|
7
|
+
<div v-if="request && app" class="flex items-center gap-3 pb-3">
|
|
8
|
+
<ShellAppIcon :app="app" :size="44" />
|
|
9
|
+
<div class="min-w-0 flex-1">
|
|
10
|
+
<p class="text-[var(--font-size-base)] font-medium text-[var(--mobile-text-primary)] truncate">
|
|
11
|
+
{{ appName }}
|
|
12
|
+
</p>
|
|
13
|
+
<p class="text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)] truncate">
|
|
14
|
+
{{ app.version ? t('shell.detail.version', { version: app.version }) : app.id }}
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<ShellGroupCard v-if="request">
|
|
20
|
+
<div v-for="key in request.keys" :key="key" class="flex items-start gap-3 px-3 py-3">
|
|
21
|
+
<svg class="flex-shrink-0 mt-0.5" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" :style="{ color: 'var(--mobile-text-secondary)' }">
|
|
22
|
+
<path d="M12 21a9 9 0 100-18 9 9 0 000 18z M3 12h18 M12 3c2.5 2.6 3.8 5.7 3.8 9S14.5 18.4 12 21c-2.5-2.6-3.8-5.7-3.8-9S9.5 5.6 12 3z" />
|
|
23
|
+
</svg>
|
|
24
|
+
<div class="min-w-0 flex-1">
|
|
25
|
+
<div class="text-[var(--font-size-base)] font-medium text-[var(--mobile-text-primary)]">
|
|
26
|
+
{{ permissionTitle(key) }}
|
|
27
|
+
<code class="ml-1.5 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]">{{ key }}</code>
|
|
28
|
+
</div>
|
|
29
|
+
<div v-if="request.targets?.[key]" class="mt-0.5 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)] break-all">
|
|
30
|
+
{{ request.targets[key] }}
|
|
31
|
+
</div>
|
|
32
|
+
<div class="mt-0.5 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]">
|
|
33
|
+
{{ request.reasons?.[key] ? t('shell.permissionPrompt.purpose', { reason: request.reasons[key] }) : t('shell.permissionPrompt.purposeUnknown') }}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</ShellGroupCard>
|
|
38
|
+
|
|
39
|
+
<p v-if="request" class="pt-2.5 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]">
|
|
40
|
+
{{ t('shell.permissionPrompt.fineprint', { name: appName }) }}
|
|
41
|
+
</p>
|
|
42
|
+
<p v-if="resultNote" class="pt-2 text-[var(--font-size-xs)]" :style="{ color: 'var(--mobile-warning)' }">
|
|
43
|
+
{{ resultNote }}
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
<template #footer>
|
|
47
|
+
<div class="flex gap-3">
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
class="flex-1 rounded-[10px] border border-[var(--mobile-border)] px-4 py-3 text-[var(--font-size-base)] text-[var(--mobile-text-secondary)] transition-colors duration-200 active:bg-[var(--mobile-accent-muted)] min-h-[var(--mobile-touch-target-min)]"
|
|
51
|
+
@click="deny"
|
|
52
|
+
>
|
|
53
|
+
{{ t('shell.permissionPrompt.deny') }}
|
|
54
|
+
</button>
|
|
55
|
+
<button
|
|
56
|
+
type="button"
|
|
57
|
+
class="flex-1 rounded-[10px] px-4 py-3 text-[var(--font-size-base)] transition-colors duration-200 active:opacity-80 min-h-[var(--mobile-touch-target-min)]"
|
|
58
|
+
:style="{ background: 'var(--mobile-accent)', color: 'var(--mobile-text-on-accent)' }"
|
|
59
|
+
@click="allow"
|
|
60
|
+
>
|
|
61
|
+
{{ t('shell.permissionPrompt.allow') }}
|
|
62
|
+
</button>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
</ShellSheet>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script setup lang="ts">
|
|
69
|
+
/**
|
|
70
|
+
* 运行时授权弹窗(平台统一)
|
|
71
|
+
*
|
|
72
|
+
* 裁决口径写死在这里而不是交给应用:拒绝 = 该功能不可用(fail-closed),
|
|
73
|
+
* 且允许后必须真的落到数据源;数据源不支持时保留弹窗并说明,不做「点了就通过」。
|
|
74
|
+
*
|
|
75
|
+
* 真正的权限裁决在 Rust 端执行,本弹窗只是 UX(docs/security.md §1)。
|
|
76
|
+
*/
|
|
77
|
+
import { computed, ref, watch } from 'vue'
|
|
78
|
+
import { useI18n } from 'vue-i18n'
|
|
79
|
+
import { useShellApps } from '../composables/useShellApps'
|
|
80
|
+
import { useShellOverlays } from '../composables/useShellOverlays'
|
|
81
|
+
import { permissionTitleKey } from '../permissions'
|
|
82
|
+
import ShellAppIcon from './ShellAppIcon.vue'
|
|
83
|
+
import ShellGroupCard from './ShellGroupCard.vue'
|
|
84
|
+
import ShellSheet from './ShellSheet.vue'
|
|
85
|
+
|
|
86
|
+
const { t } = useI18n()
|
|
87
|
+
const overlays = useShellOverlays()
|
|
88
|
+
const { getApp, setPermissionGrant } = useShellApps()
|
|
89
|
+
|
|
90
|
+
const request = computed(() => overlays.permissionRequest.value)
|
|
91
|
+
const app = computed(() => (request.value ? getApp(request.value.appId) : undefined))
|
|
92
|
+
const appName = computed(() => app.value?.name ?? request.value?.appId ?? '')
|
|
93
|
+
|
|
94
|
+
/** 裁决结果提示(数据源不支持时要显性说明,不能默默关掉) */
|
|
95
|
+
const resultNote = ref<string | null>(null)
|
|
96
|
+
watch(request, () => {
|
|
97
|
+
resultNote.value = null
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
function permissionTitle(key: string): string {
|
|
101
|
+
const i18nKey = permissionTitleKey(key)
|
|
102
|
+
return i18nKey ? t(i18nKey) : key
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** 拒绝:直接关闭,不写任何状态(未授予即不可用,fail-closed) */
|
|
106
|
+
function deny(): void {
|
|
107
|
+
overlays.closePermissionRequest()
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function allow(): Promise<void> {
|
|
111
|
+
const current = request.value
|
|
112
|
+
if (!current) return
|
|
113
|
+
|
|
114
|
+
let unsupported = false
|
|
115
|
+
for (const key of current.keys) {
|
|
116
|
+
const ok = await setPermissionGrant(current.appId, key, true)
|
|
117
|
+
if (!ok) unsupported = true
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (unsupported) {
|
|
121
|
+
// 保留弹窗并说明:静默关闭会让用户以为授权成功了
|
|
122
|
+
resultNote.value = t('shell.detail.permissionUnsupported')
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
overlays.closePermissionRequest()
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex flex-col items-center justify-center flex-1 min-h-0 gap-3 px-8 text-center">
|
|
3
|
+
<ShellAppIcon v-if="app" :app="app" :size="56" />
|
|
4
|
+
|
|
5
|
+
<div>
|
|
6
|
+
<p class="text-[var(--font-size-base)] font-medium text-[var(--mobile-text-primary)]">
|
|
7
|
+
{{ t('shell.run.noSurface') }}
|
|
8
|
+
</p>
|
|
9
|
+
<p class="mt-1 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]">
|
|
10
|
+
{{ t('shell.run.noSurfaceHint') }}
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
/**
|
|
18
|
+
* 运行面缺位提示
|
|
19
|
+
* -----------------------------------------------------------------------------
|
|
20
|
+
* 应用尚未向壳注册运行界面时渲染它。只说两件用户能感知的事:现在没有界面、
|
|
21
|
+
* 原因是该应用没提供——不再讲「这是将来的挂载点」「平台只提供挂载与生命周期」
|
|
22
|
+
* 这类方案期说明(2026-10-14 修订:宿主文案不写平台实现)。
|
|
23
|
+
*
|
|
24
|
+
* 一旦应用注册了 surface,本组件自动让位(见 ShellAppSurface 的优先级)。
|
|
25
|
+
*/
|
|
26
|
+
import { useI18n } from 'vue-i18n'
|
|
27
|
+
import type { ShellApp } from '../types'
|
|
28
|
+
import ShellAppIcon from './ShellAppIcon.vue'
|
|
29
|
+
|
|
30
|
+
defineProps<{ app?: ShellApp }>()
|
|
31
|
+
|
|
32
|
+
const { t } = useI18n()
|
|
33
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex items-center justify-between gap-2 min-w-0 px-4 pt-4 pb-2">
|
|
3
|
+
<h2 class="text-[var(--font-size-sm)] font-semibold text-[var(--mobile-text-secondary)] truncate">
|
|
4
|
+
{{ title }}
|
|
5
|
+
</h2>
|
|
6
|
+
<div class="flex items-center gap-2 flex-shrink-0 min-w-0">
|
|
7
|
+
<span v-if="note" class="text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)] truncate">
|
|
8
|
+
{{ note }}
|
|
9
|
+
</span>
|
|
10
|
+
<slot name="action" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
/**
|
|
17
|
+
* 分组标题行
|
|
18
|
+
*
|
|
19
|
+
* 标题 + 可选说明 + 右侧动作插槽。壳内所有「分组头」都走这一个组件,
|
|
20
|
+
* 保证标题层级与右侧动作的对齐方式全平台一致。
|
|
21
|
+
*/
|
|
22
|
+
defineProps<{
|
|
23
|
+
title: string
|
|
24
|
+
/** 右侧说明(如「3 项」「由应用提供」) */
|
|
25
|
+
note?: string
|
|
26
|
+
}>()
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport to="body">
|
|
3
|
+
<!-- 遮罩与面板各自过渡:遮罩淡入、面板上滑,避免两者绑定同一时长显得拖沓 -->
|
|
4
|
+
<Transition name="shell-scrim">
|
|
5
|
+
<div
|
|
6
|
+
v-if="open"
|
|
7
|
+
class="fixed inset-0 z-50"
|
|
8
|
+
style="background: var(--mobile-overlay)"
|
|
9
|
+
@click="emit('close')"
|
|
10
|
+
/>
|
|
11
|
+
</Transition>
|
|
12
|
+
<Transition name="shell-sheet">
|
|
13
|
+
<div
|
|
14
|
+
v-if="open"
|
|
15
|
+
class="shell-ui fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-[var(--shell-radius-sheet)] border-t border-[var(--mobile-border)] bg-[var(--mobile-bg-card)] px-4 pt-2 pb-4"
|
|
16
|
+
role="dialog"
|
|
17
|
+
aria-modal="true"
|
|
18
|
+
:aria-label="title"
|
|
19
|
+
:style="{ paddingBottom: `calc(16px + ${bottomInset}px)` }"
|
|
20
|
+
@keydown.esc="emit('close')"
|
|
21
|
+
>
|
|
22
|
+
<!-- 抓手:视觉上暗示可下滑关闭 -->
|
|
23
|
+
<div class="mx-auto mb-3 h-1 w-9 rounded-full" style="background: var(--mobile-border-active)" aria-hidden="true" />
|
|
24
|
+
|
|
25
|
+
<div v-if="title || subtitle" class="pb-3">
|
|
26
|
+
<h3 class="text-[var(--font-size-lg)] font-semibold text-[var(--mobile-text-primary)]">
|
|
27
|
+
{{ title }}
|
|
28
|
+
</h3>
|
|
29
|
+
<p v-if="subtitle" class="mt-0.5 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]">
|
|
30
|
+
{{ subtitle }}
|
|
31
|
+
</p>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div class="min-h-0 overflow-y-auto">
|
|
35
|
+
<slot />
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div v-if="$slots.footer" class="pt-3">
|
|
39
|
+
<slot name="footer" />
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</Transition>
|
|
43
|
+
</Teleport>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
/**
|
|
48
|
+
* 底部抽屉(胶囊菜单 / 授权弹窗共用)
|
|
49
|
+
*
|
|
50
|
+
* 统一 Teleport 到 body + z-50(safe-stack 约定):壳内屏幕是 overflow-hidden 的
|
|
51
|
+
* 层叠容器,抽屉留在原地会被裁掉。底部内边距叠加安全区(Android WebView 不支持
|
|
52
|
+
* env(),取宿主注入的 JS 值)。
|
|
53
|
+
*/
|
|
54
|
+
import { computed, inject, type Ref } from 'vue'
|
|
55
|
+
|
|
56
|
+
defineProps<{
|
|
57
|
+
open: boolean
|
|
58
|
+
title?: string
|
|
59
|
+
subtitle?: string
|
|
60
|
+
}>()
|
|
61
|
+
|
|
62
|
+
const emit = defineEmits<{ close: [] }>()
|
|
63
|
+
|
|
64
|
+
// 安全区由 App.vue 注入(与 ShellView 同一来源),缺省 0 不影响桌面预览。
|
|
65
|
+
// 用 computed 而非 setup 期快照:安全区在 App 挂载后才就绪,快照会恒为 0
|
|
66
|
+
const safeArea = inject<Ref<{ top: number; bottom: number; navigationBar?: number }> | undefined>(
|
|
67
|
+
'safeArea',
|
|
68
|
+
undefined,
|
|
69
|
+
)
|
|
70
|
+
const bottomInset = computed(() => {
|
|
71
|
+
const value = safeArea?.value
|
|
72
|
+
return value?.navigationBar ?? value?.bottom ?? 0
|
|
73
|
+
})
|
|
74
|
+
</script>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 整条可点:Android 通知栏的入口之一(另一个是主屏铃铛,44px 主入口)。
|
|
3
|
+
dev-shell 的舞台本身就是手机框 / 手机视口:没有系统状态栏在场,
|
|
4
|
+
因此恒渲染壳自己的状态条(宿主那份会因 safeArea>0 而隐藏,dev 无此条件)。 -->
|
|
5
|
+
<div class="flex-shrink-0">
|
|
6
|
+
<button
|
|
7
|
+
type="button"
|
|
8
|
+
class="flex items-center justify-between w-full px-4 h-9 transition-colors duration-200 active:bg-[var(--mobile-accent-muted)]"
|
|
9
|
+
:aria-label="t('shell.notify.open', { count: badgeCount })"
|
|
10
|
+
@click="overlays.toggleShade()"
|
|
11
|
+
>
|
|
12
|
+
<span class="tabular-nums text-[var(--font-size-xs)]" :style="{ color: 'var(--mobile-text-secondary)' }">
|
|
13
|
+
{{ currentTime }}
|
|
14
|
+
</span>
|
|
15
|
+
<span class="flex items-center gap-1.5">
|
|
16
|
+
<!-- 通知指示:有未读时显示条目数,没有则不占位(不显示「0」) -->
|
|
17
|
+
<span
|
|
18
|
+
v-if="badgeCount > 0"
|
|
19
|
+
class="inline-flex items-center justify-center min-w-[16px] h-4 px-1 rounded-full text-[10px] font-semibold leading-none"
|
|
20
|
+
:style="{ background: 'var(--mobile-error)', color: 'var(--mobile-text-on-accent)' }"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
>
|
|
23
|
+
{{ badgeCount > 99 ? '99+' : badgeCount }}
|
|
24
|
+
</span>
|
|
25
|
+
<!-- 信号 -->
|
|
26
|
+
<svg width="17" height="12" viewBox="0 0 17 12" fill="currentColor" :style="{ color: 'var(--mobile-text-secondary)' }">
|
|
27
|
+
<rect x="0" y="7.5" width="3" height="4.5" rx="1" />
|
|
28
|
+
<rect x="4.6" y="5" width="3" height="7" rx="1" />
|
|
29
|
+
<rect x="9.2" y="2.5" width="3" height="9.5" rx="1" />
|
|
30
|
+
<rect x="13.8" y="0" width="3" height="12" rx="1" opacity=".35" />
|
|
31
|
+
</svg>
|
|
32
|
+
<!-- 电量 -->
|
|
33
|
+
<svg width="25" height="12" viewBox="0 0 25 12" fill="none" stroke="currentColor" :style="{ color: 'var(--mobile-text-secondary)' }">
|
|
34
|
+
<rect x=".6" y=".6" width="20" height="10.8" rx="3.2" stroke-width="1.2" />
|
|
35
|
+
<rect x="2.6" y="2.6" width="13" height="6.8" rx="1.6" fill="currentColor" stroke="none" />
|
|
36
|
+
<path d="M23 4v4" stroke-width="1.6" stroke-linecap="round" />
|
|
37
|
+
</svg>
|
|
38
|
+
</span>
|
|
39
|
+
</button>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
/**
|
|
45
|
+
* 壳内状态条(与宿主 ShellStatusbar.vue 同款视觉)
|
|
46
|
+
*
|
|
47
|
+
* 平台事实的显示面 + 通知栏入口:时间 / 信号 / 电量 + 未读通知角标。
|
|
48
|
+
* 角标 = 通知条数 + 待审批应用数(与通知栏头部的计数同口径)。
|
|
49
|
+
*
|
|
50
|
+
* 与宿主的两处差异(都是浏览器环境使然):
|
|
51
|
+
* · 不接 usePlatform / safeArea:宿主那份在「系统状态栏在场」时整条隐藏
|
|
52
|
+
* (避免上下两条时间/信号堆叠),dev-shell 的舞台没有系统状态栏,恒渲染;
|
|
53
|
+
* · 通知只有壳动作来源(启动 / 停止 / 审批 / 安装 / 卸载),没有宿主引擎事件。
|
|
54
|
+
*/
|
|
55
|
+
import { computed, onUnmounted, ref } from 'vue'
|
|
56
|
+
import { useI18n } from 'vue-i18n'
|
|
57
|
+
import { useShellApps } from '../composables/useShellApps'
|
|
58
|
+
import { useShellNotifications } from '../composables/useShellNotifications'
|
|
59
|
+
import { useShellOverlays } from '../composables/useShellOverlays'
|
|
60
|
+
|
|
61
|
+
const { t } = useI18n()
|
|
62
|
+
const overlays = useShellOverlays()
|
|
63
|
+
const { notificationCount } = useShellNotifications()
|
|
64
|
+
const { apps } = useShellApps()
|
|
65
|
+
|
|
66
|
+
/** 未读计数:通知 + 待审批(待审批由应用状态派生,批准后自然回落) */
|
|
67
|
+
const badgeCount = computed(
|
|
68
|
+
() => notificationCount.value + apps.value.filter((a) => a.state === 'approval').length,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const currentTime = ref('')
|
|
72
|
+
|
|
73
|
+
function updateTime(): void {
|
|
74
|
+
const now = new Date()
|
|
75
|
+
currentTime.value = `${now.getHours().toString().padStart(2, '0')}:${now
|
|
76
|
+
.getMinutes()
|
|
77
|
+
.toString()
|
|
78
|
+
.padStart(2, '0')}`
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
updateTime()
|
|
82
|
+
const timer = setInterval(updateTime, 30_000)
|
|
83
|
+
onUnmounted(() => clearInterval(timer))
|
|
84
|
+
</script>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 页头模式(descriptor.header 默认 true):平台提供返回 + 标题,插件只管内容 -->
|
|
3
|
+
<div v-if="pageMeta.header" class="flex flex-col h-full min-h-0 mobile-ui mobile-app">
|
|
4
|
+
<div class="flex items-center gap-2 px-2 pt-2 pb-1 flex-shrink-0">
|
|
5
|
+
<button
|
|
6
|
+
type="button"
|
|
7
|
+
class="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)]"
|
|
8
|
+
:aria-label="t('shell.common.back')"
|
|
9
|
+
@click="goBack"
|
|
10
|
+
>
|
|
11
|
+
<svg width="21" height="21" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
12
|
+
<path d="M15 6l-6 6 6 6" />
|
|
13
|
+
</svg>
|
|
14
|
+
</button>
|
|
15
|
+
<span class="text-[var(--font-size-base)] font-semibold text-[var(--mobile-text-primary)] truncate min-w-0">
|
|
16
|
+
{{ pageTitle }}
|
|
17
|
+
</span>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="flex-1 min-h-0 overflow-y-auto">
|
|
20
|
+
<PluginContextHost v-if="routeComponent" :plugin-id="pageMeta.pluginId" :component="routeComponent" />
|
|
21
|
+
<p v-else class="flex items-center justify-center h-full text-[var(--mobile-text-disabled)] text-sm">
|
|
22
|
+
{{ t('devshell.plugin.routeLoading') }}
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<!-- 裸渲染模式:插件自带布局与页头 -->
|
|
28
|
+
<div v-else class="h-full min-h-0 mobile-ui mobile-app">
|
|
29
|
+
<PluginContextHost v-if="routeComponent" :plugin-id="pageMeta.pluginId" :component="routeComponent" />
|
|
30
|
+
<p v-else class="flex items-center justify-center h-full text-[var(--mobile-text-disabled)] text-sm">
|
|
31
|
+
{{ t('devshell.plugin.routeLoading') }}
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup lang="ts">
|
|
37
|
+
/**
|
|
38
|
+
* PluginRoutePage — 插件动态路由页(宿主 `PluginRouteView.vue` 的 dev-shell 同形)
|
|
39
|
+
* -----------------------------------------------------------------------------
|
|
40
|
+
* 由 `mock-context.ts` 的 registerRoute 作为插件路由的统一组件挂到 vue-router
|
|
41
|
+
* (路径 `/plugin/{pluginId}/{routeId}`),经 route.meta.pluginRoute 定位插件与路由,
|
|
42
|
+
* 响应式解析注册表组件(插件晚激活时先显示加载中),并 provide pluginContext。
|
|
43
|
+
*
|
|
44
|
+
* 与运行面的分工:运行面是「应用在壳里的主界面」,本组件是「应用自己声明的整页跳转」
|
|
45
|
+
* (`context.ui.registerRoute` + `openPage`)。两条路径都不给壳加壳 chrome。
|
|
46
|
+
*/
|
|
47
|
+
import { computed, provide, watch } from 'vue'
|
|
48
|
+
import { useI18n } from 'vue-i18n'
|
|
49
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
50
|
+
import { findRoute, getPluginRecord } from '../../../registry'
|
|
51
|
+
import PluginContextHost from '../PluginContextHost.vue'
|
|
52
|
+
|
|
53
|
+
interface PluginRouteMeta {
|
|
54
|
+
pluginId: string
|
|
55
|
+
routeId: string
|
|
56
|
+
title?: string
|
|
57
|
+
header: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const route = useRoute()
|
|
61
|
+
const router = useRouter()
|
|
62
|
+
const { t } = useI18n()
|
|
63
|
+
|
|
64
|
+
/** 插件路由元信息(registerRoute 写入 meta.pluginRoute) */
|
|
65
|
+
const pageMeta = computed<PluginRouteMeta>(
|
|
66
|
+
() =>
|
|
67
|
+
(route.meta.pluginRoute as PluginRouteMeta | undefined) ?? {
|
|
68
|
+
pluginId: '',
|
|
69
|
+
routeId: '',
|
|
70
|
+
header: true,
|
|
71
|
+
},
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const routeEntry = computed(() =>
|
|
75
|
+
findRoute(pageMeta.value.pluginId, pageMeta.value.routeId),
|
|
76
|
+
)
|
|
77
|
+
const routeComponent = computed(() => routeEntry.value?.route.component)
|
|
78
|
+
|
|
79
|
+
/** 页头标题:取注册时声明的 title;未注册(晚激活)时显示加载中 */
|
|
80
|
+
const pageTitle = computed(
|
|
81
|
+
() => routeEntry.value?.route.title ?? t('devshell.plugin.routeLoading'),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
function goBack(): void {
|
|
85
|
+
// 无历史可退时回壳首页,避免停在空白页
|
|
86
|
+
if (window.history.length > 1) router.back()
|
|
87
|
+
else router.push('/')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// provide pluginContext(双保险同 PluginContextHost,避免实例复用拿旧 context)
|
|
91
|
+
function syncContext(): void {
|
|
92
|
+
const record = getPluginRecord(pageMeta.value.pluginId)
|
|
93
|
+
if (record?.context) provide('pluginContext', record.context)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
syncContext()
|
|
97
|
+
watch(() => pageMeta.value.pluginId, syncContext)
|
|
98
|
+
</script>
|