@proteus-vue/create-proteus 0.2.1-beta.0 → 0.2.1-beta.1
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/package.json
CHANGED
|
@@ -22,12 +22,23 @@ for (const [key, load] of Object.entries(modules)) {
|
|
|
22
22
|
}
|
|
23
23
|
const current = ref(adapter.getCurrentPages()[0]?.route || 'pages/index')
|
|
24
24
|
|
|
25
|
+
// ★路由参数(2026-09-19 修:此前 Web 端参数**两条路都拿不到**——外部实战报告第 4 条,
|
|
26
|
+
// 表现为写作页恒显示"第 0 章"):
|
|
27
|
+
// · 小程序端参数走 `onLoad(options)`(编译产物注入);
|
|
28
|
+
// · Web 端此前 onLoad 是 no-op(pageLifecycle)+ 本组件不传 props → 参数丢失。
|
|
29
|
+
// 现把 query 透传给页面组件:页面用 `defineProps<{ id?: string }>()` 即可收到
|
|
30
|
+
// (未声明 props 的页面不受影响——query 作为 attrs 落到根元素且不渲染)。
|
|
31
|
+
// ★同时 adapter 的当前页也保留了 query(`getCurrentPages()[0].query`),
|
|
32
|
+
// 需要命令式读取的页面两条路都可(与 MP `Page.options` 语义对齐)。
|
|
33
|
+
const currentQuery = ref<Record<string, string>>(adapter.getCurrentPages()[0]?.query ?? {})
|
|
34
|
+
|
|
25
35
|
// 路由变化 → 转场名(★透明化:routeType → Vue Transition 映射由框架共享表 webTransitionName 提供,
|
|
26
36
|
// 不再 RouterView 私有硬编码;三端共用同一枚举见 packages/router/src/transforms/transform-transition.ts)
|
|
27
37
|
const transitionName = ref('fade')
|
|
28
38
|
let lastForwardName = 'fade' // 当前页进入时的转场名(后退时取其反向)
|
|
29
|
-
adapter.onPageLoad?.((route,
|
|
39
|
+
adapter.onPageLoad?.((route, query, routeType, nav) => {
|
|
30
40
|
current.value = route || 'pages/index'
|
|
41
|
+
currentQuery.value = query ?? {}
|
|
31
42
|
if (nav === 'back') {
|
|
32
43
|
// 反向转场:用当前退出页进入时的转场名 + '-back'
|
|
33
44
|
transitionName.value =
|
|
@@ -83,7 +94,9 @@ const view = computed<Component | null>(() => {
|
|
|
83
94
|
:style="{ '--barrier-opacity': barrierOpacity }"
|
|
84
95
|
/>
|
|
85
96
|
<Transition :name="transitionName" :mode="isLayered ? undefined : 'out-in'">
|
|
86
|
-
|
|
97
|
+
<!-- ★v-bind="currentQuery":路由参数透传给页面(页面用 defineProps 声明即收到;
|
|
98
|
+
未声明的页面不受影响)。修 Web 端「参数两条路都拿不到」见 currentQuery 处注释 -->
|
|
99
|
+
<component :is="view" v-if="view" :key="currentRoute" v-bind="currentQuery" class="page" />
|
|
87
100
|
<div v-else :key="'404'" class="page">404 Not Found</div>
|
|
88
101
|
</Transition>
|
|
89
102
|
</div>
|