@fulgurjs/federation 5.8.0 → 5.9.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/CHANGELOG.md +14 -4
- package/README.en.md +60 -24
- package/README.md +60 -24
- package/dist/cli.js +327 -29
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/runtime.js +1 -1
- package/docs/API.en.md +14 -3
- package/docs/API.md +7 -6
- package/docs/webpack-mf-/345/257/271/347/205/247/344/270/216/347/274/272/345/217/243.md +2 -2
- package/examples/README.md +3 -67
- package/examples/templates/README.md +88 -0
- package/examples/templates/react-host-vue-remote/README.md +18 -0
- package/examples/templates/react-host-vue-remote/package.json +11 -0
- package/examples/templates/react-host-vue-remote/pnpm-lock.yaml +1627 -0
- package/examples/templates/react-host-vue-remote/pnpm-workspace.yaml +10 -0
- package/examples/{bridge → templates/react-host-vue-remote}/react-host/README.md +8 -7
- package/examples/{bridge → templates/react-host-vue-remote}/react-host/package.json +1 -1
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote.d/_paths.d.ts +4 -0
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote.d/bridge.ts +3 -0
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote.d.ts +9 -0
- package/examples/templates/react-host-vue-remote/scripts/dev.config.json +6 -0
- package/examples/templates/react-host-vue-remote/scripts/dev.mjs +173 -0
- package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/README.md +10 -5
- package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/package.json +1 -1
- package/examples/{react → templates/react-react}/README.md +9 -13
- package/examples/{react → templates/react-react}/host/README.md +6 -8
- package/examples/{react → templates/react-react}/host/package.json +1 -1
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/ClickButton.ts +3 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/_paths.d.ts +4 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/pages/DetailPage.ts +3 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/pages/HomePage.ts +3 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d/utils.ts +2 -0
- package/examples/templates/react-react/host/src/fulgurjs/types/react-remote.d.ts +26 -0
- package/examples/templates/react-react/package.json +11 -0
- package/examples/templates/react-react/pnpm-lock.yaml +1537 -0
- package/examples/templates/react-react/pnpm-workspace.yaml +10 -0
- package/examples/{react → templates/react-react}/remote/README.md +7 -6
- package/examples/{react → templates/react-react}/remote/package.json +1 -1
- package/examples/templates/react-react/scripts/dev.config.json +6 -0
- package/examples/templates/react-react/scripts/dev.mjs +173 -0
- package/examples/templates/showcase/README.md +109 -0
- package/examples/templates/showcase/package.json +13 -0
- package/examples/templates/showcase/pnpm-lock.yaml +1858 -0
- package/examples/templates/showcase/pnpm-workspace.yaml +12 -0
- package/examples/templates/showcase/react-host/fulgurjs.config.ts +21 -0
- package/examples/templates/showcase/react-host/index.html +13 -0
- package/examples/templates/showcase/react-host/package.json +26 -0
- package/examples/templates/showcase/react-host/src/GuardBanner.tsx +33 -0
- package/examples/templates/showcase/react-host/src/Layout.tsx +42 -0
- package/examples/templates/showcase/react-host/src/ObsPanel.tsx +44 -0
- package/examples/templates/showcase/react-host/src/demo-log.ts +74 -0
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote.d/_paths.d.ts +4 -0
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote.d/bridge.ts +3 -0
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote.d.ts +7 -0
- package/examples/templates/showcase/react-host/src/main.tsx +33 -0
- package/examples/templates/showcase/react-host/src/pages/AboutPage.tsx +18 -0
- package/examples/templates/showcase/react-host/src/pages/BridgeVuePage.tsx +77 -0
- package/examples/templates/showcase/react-host/src/pages/HomePage.tsx +14 -0
- package/examples/templates/showcase/react-host/src/routing.ts +30 -0
- package/examples/templates/showcase/react-host/tsconfig.json +15 -0
- package/examples/templates/showcase/react-host/vite.config.ts +8 -0
- package/examples/templates/showcase/react-remote/fulgurjs.config.ts +18 -0
- package/examples/templates/showcase/react-remote/index.html +13 -0
- package/examples/templates/showcase/react-remote/package.json +25 -0
- package/examples/templates/showcase/react-remote/src/ChildLayout.tsx +48 -0
- package/examples/templates/showcase/react-remote/src/bridge.tsx +62 -0
- package/examples/templates/showcase/react-remote/src/child-bus.ts +32 -0
- package/examples/templates/showcase/react-remote/src/main.tsx +18 -0
- package/examples/templates/showcase/react-remote/src/pages/Locked.tsx +23 -0
- package/examples/templates/showcase/react-remote/src/pages/OrderDetail.tsx +36 -0
- package/examples/templates/showcase/react-remote/src/pages/OrderList.tsx +110 -0
- package/examples/templates/showcase/react-remote/src/pages/Settings.tsx +50 -0
- package/examples/templates/showcase/react-remote/src/settings-store.ts +11 -0
- package/examples/templates/showcase/react-remote/tsconfig.json +14 -0
- package/examples/templates/showcase/react-remote/vite.config.ts +14 -0
- package/examples/templates/showcase/scripts/dev.config.json +8 -0
- package/examples/templates/showcase/scripts/dev.mjs +173 -0
- package/examples/templates/showcase/vue-host/fulgurjs.config.ts +21 -0
- package/examples/templates/showcase/vue-host/index.html +13 -0
- package/examples/templates/showcase/vue-host/package.json +25 -0
- package/examples/templates/showcase/vue-host/src/App.vue +50 -0
- package/examples/templates/showcase/vue-host/src/GuardBanner.vue +24 -0
- package/examples/templates/showcase/vue-host/src/ObsPanel.vue +60 -0
- package/examples/templates/showcase/vue-host/src/demo-log.ts +49 -0
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote.d/_paths.d.ts +4 -0
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote.d/bridge.ts +3 -0
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote.d.ts +7 -0
- package/examples/templates/showcase/vue-host/src/guard.ts +47 -0
- package/examples/templates/showcase/vue-host/src/main.ts +30 -0
- package/examples/templates/showcase/vue-host/src/pages/AboutPage.vue +17 -0
- package/examples/templates/showcase/vue-host/src/pages/BridgeReactPage.vue +74 -0
- package/examples/templates/showcase/vue-host/src/pages/HomePage.vue +13 -0
- package/examples/templates/showcase/vue-host/src/routing.ts +31 -0
- package/examples/templates/showcase/vue-host/tsconfig.json +14 -0
- package/examples/templates/showcase/vue-remote/fulgurjs.config.ts +17 -0
- package/examples/templates/showcase/vue-remote/index.html +13 -0
- package/examples/templates/showcase/vue-remote/package.json +23 -0
- package/examples/templates/showcase/vue-remote/src/ChildLayout.vue +54 -0
- package/examples/templates/showcase/vue-remote/src/bridge.ts +48 -0
- package/examples/templates/showcase/vue-remote/src/child-bus.ts +32 -0
- package/examples/templates/showcase/vue-remote/src/main.ts +16 -0
- package/examples/templates/showcase/vue-remote/src/pages/Locked.vue +28 -0
- package/examples/templates/showcase/vue-remote/src/pages/OrderDetail.vue +46 -0
- package/examples/templates/showcase/vue-remote/src/pages/OrderList.vue +116 -0
- package/examples/templates/showcase/vue-remote/src/pages/Settings.vue +34 -0
- package/examples/templates/showcase/vue-remote/src/settings-store.ts +13 -0
- package/examples/templates/showcase/vue-remote/tsconfig.json +14 -0
- package/examples/templates/showcase/vue-remote/vite.config.ts +14 -0
- package/examples/templates/vue-host-react-remote/README.md +18 -0
- package/examples/templates/vue-host-react-remote/package.json +11 -0
- package/examples/templates/vue-host-react-remote/pnpm-lock.yaml +1663 -0
- package/examples/templates/vue-host-react-remote/pnpm-workspace.yaml +10 -0
- package/examples/{bridge → templates/vue-host-react-remote}/react-remote/README.md +9 -4
- package/examples/{bridge → templates/vue-host-react-remote}/react-remote/package.json +1 -1
- package/examples/templates/vue-host-react-remote/scripts/dev.config.json +6 -0
- package/examples/templates/vue-host-react-remote/scripts/dev.mjs +173 -0
- package/examples/{bridge → templates/vue-host-react-remote}/vue-host/README.md +8 -7
- package/examples/{bridge → templates/vue-host-react-remote}/vue-host/package.json +1 -1
- package/examples/{bridge → templates/vue-host-react-remote}/vue-host/src/App.vue +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote.d/_paths.d.ts +4 -0
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote.d/bridge.ts +3 -0
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote.d.ts +9 -0
- package/examples/{vue → templates/vue-vue}/README.md +9 -13
- package/examples/{vue → templates/vue-vue}/host/README.md +6 -8
- package/examples/{vue → templates/vue-vue}/host/package.json +1 -1
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/ClickButton.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/_paths.d.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/pages/DetailPage.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/pages/HomePage.ts +4 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d/utils.ts +2 -0
- package/examples/templates/vue-vue/host/src/fulgurjs/types/vue-remote.d.ts +29 -0
- package/examples/templates/vue-vue/host/vite.config.ts +8 -0
- package/examples/templates/vue-vue/package.json +11 -0
- package/examples/templates/vue-vue/pnpm-lock.yaml +1199 -0
- package/examples/templates/vue-vue/pnpm-workspace.yaml +10 -0
- package/examples/{vue → templates/vue-vue}/remote/README.md +7 -6
- package/examples/{vue → templates/vue-vue}/remote/package.json +1 -1
- package/examples/{vue → templates/vue-vue}/remote/src/App.vue +1 -1
- package/examples/templates/vue-vue/scripts/dev.config.json +6 -0
- package/examples/templates/vue-vue/scripts/dev.mjs +173 -0
- package/package.json +4 -4
- package/examples/README.en.md +0 -67
- package/examples/bridge/README.md +0 -36
- package/examples/bridge/react-host/package-lock.json +0 -2466
- package/examples/bridge/react-remote/package-lock.json +0 -2391
- package/examples/bridge/vue-host/package-lock.json +0 -1894
- package/examples/bridge/vue-remote/package-lock.json +0 -1865
- package/examples/react/host/package-lock.json +0 -2391
- package/examples/react/remote/package-lock.json +0 -2333
- package/examples/vue/host/package-lock.json +0 -1865
- package/examples/vue/remote/package-lock.json +0 -1843
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/index.html +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/src/host-session.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/src/main.tsx +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/tsconfig.json +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/react-host/vite.config.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/index.html +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/src/App.vue +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/src/bridge.ts +0 -0
- /package/examples/{bridge/react-remote → templates/react-host-vue-remote/vue-remote}/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/src/main.ts +0 -0
- /package/examples/{bridge/vue-host → templates/react-host-vue-remote/vue-remote}/tsconfig.json +0 -0
- /package/examples/{bridge → templates/react-host-vue-remote}/vue-remote/vite.config.ts +0 -0
- /package/examples/{react → templates/react-react}/host/fulgurjs.config.ts +0 -0
- /package/examples/{react → templates/react-react}/host/index.html +0 -0
- /package/examples/{react → templates/react-react}/host/src/App.tsx +0 -0
- /package/examples/{react → templates/react-react}/host/src/main.tsx +0 -0
- /package/examples/{react → templates/react-react}/host/src/pages/UtilsDemo.tsx +0 -0
- /package/examples/{react → templates/react-react}/host/src/remotePages.tsx +0 -0
- /package/examples/{bridge/react-remote → templates/react-react/host}/tsconfig.json +0 -0
- /package/examples/{react → templates/react-react}/host/vite.config.ts +0 -0
- /package/examples/{react → templates/react-react}/remote/fulgurjs.config.ts +0 -0
- /package/examples/{react → templates/react-react}/remote/index.html +0 -0
- /package/examples/{react → templates/react-react}/remote/src/App.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/ClickButton.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/pages/DetailPage.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/pages/HomePage.tsx +0 -0
- /package/examples/{react → templates/react-react}/remote/src/exposes/utils.ts +0 -0
- /package/examples/{react → templates/react-react}/remote/src/main.tsx +0 -0
- /package/examples/{react/host → templates/react-react/remote}/tsconfig.json +0 -0
- /package/examples/{react → templates/react-react}/remote/vite.config.ts +0 -0
- /package/examples/{vue/host → templates/showcase/vue-host}/vite.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/index.html +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/src/bridge.tsx +0 -0
- /package/examples/{bridge/vue-host → templates/vue-host-react-remote/react-remote}/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/src/main.tsx +0 -0
- /package/examples/{react/remote → templates/vue-host-react-remote/react-remote}/tsconfig.json +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/react-remote/vite.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/fulgurjs.config.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/index.html +0 -0
- /package/examples/{bridge/vue-remote → templates/vue-host-react-remote/vue-host}/src/env.d.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/src/host-session.ts +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/src/main.ts +0 -0
- /package/examples/{bridge/vue-remote → templates/vue-host-react-remote/vue-host}/tsconfig.json +0 -0
- /package/examples/{bridge → templates/vue-host-react-remote}/vue-host/vite.config.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/host/fulgurjs.config.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/host/index.html +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/App.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/main.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/pages/HomePage.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/host/src/pages/UtilsDemo.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/host/tsconfig.json +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/fulgurjs.config.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/index.html +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/ClickButton.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/pages/DetailPage.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/pages/HomePage.vue +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/exposes/utils.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/src/main.ts +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/tsconfig.json +0 -0
- /package/examples/{vue → templates/vue-vue}/remote/vite.config.ts +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* examples/templates/showcase/vue-remote/src/pages/Locked.vue — 锁定页(守卫放行后才可见)。
|
|
4
|
+
* 前往本页的导航会被宿主守卫(Vue:异步 beforeEach;React:useBlocker)拦截,等待「继续/取消」。
|
|
5
|
+
*/
|
|
6
|
+
import { useRouter } from 'vue-router'
|
|
7
|
+
import { reportNav } from '../child-bus'
|
|
8
|
+
|
|
9
|
+
const router = useRouter()
|
|
10
|
+
|
|
11
|
+
const handleBack = (): void => {
|
|
12
|
+
reportNav('子应用 Link', 'push', '/orders')
|
|
13
|
+
void router.push('/orders')
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<section class="demo-page">
|
|
19
|
+
<h3 class="demo-page-title">锁定页(子应用路由 /locked)</h3>
|
|
20
|
+
<p>你能看到本页,说明宿主守卫选择了「继续」。</p>
|
|
21
|
+
<p><button @click="handleBack">回工单列表</button></p>
|
|
22
|
+
</section>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<style scoped>
|
|
26
|
+
.demo-page { padding: 8px 0; }
|
|
27
|
+
.demo-page-title { margin: 4px 0; }
|
|
28
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* examples/templates/showcase/vue-remote/src/pages/OrderDetail.vue — 工单详情页(路径参数 /orders/:id)。
|
|
4
|
+
* 「返回列表」走 go(-1)(委托宿主浏览器历史);「回列表」走 push(经通道写宿主 URL)。
|
|
5
|
+
*/
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
8
|
+
import { reportNav } from '../child-bus'
|
|
9
|
+
|
|
10
|
+
const route = useRoute()
|
|
11
|
+
const router = useRouter()
|
|
12
|
+
|
|
13
|
+
const id = computed(() => String(route.params.id ?? ''))
|
|
14
|
+
const queryEcho = computed(() => {
|
|
15
|
+
const rest = route.fullPath.slice(route.path.length)
|
|
16
|
+
return rest === '' ? '(无)' : rest
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const handleBack = (): void => {
|
|
20
|
+
reportNav('子应用 go', 'go', '-1')
|
|
21
|
+
router.back()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const handleLinkBack = (): void => {
|
|
25
|
+
reportNav('子应用 Link', 'push', '/orders')
|
|
26
|
+
void router.push('/orders')
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<section class="demo-page">
|
|
32
|
+
<h3 class="demo-page-title">工单详情(子应用路由 /orders/:id)</h3>
|
|
33
|
+
<p>工单 ID:<code>{{ id }}</code>;query 回显:<code>{{ queryEcho }}</code></p>
|
|
34
|
+
<div class="demo-row">
|
|
35
|
+
<button @click="handleBack">返回列表(go(-1))</button>
|
|
36
|
+
<button @click="handleLinkBack">回列表(push /orders)</button>
|
|
37
|
+
</div>
|
|
38
|
+
</section>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<style scoped>
|
|
42
|
+
.demo-page { padding: 8px 0; }
|
|
43
|
+
.demo-page-title { margin: 4px 0; }
|
|
44
|
+
.demo-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
|
|
45
|
+
.demo-row button { cursor: pointer; }
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* examples/templates/showcase/vue-remote/src/pages/OrderList.vue — 工单列表页(筛选 + 分页)。
|
|
4
|
+
* 筛选关键词与页码写入子应用路由 query(q=xxx&page=n,中文可输入),
|
|
5
|
+
* 经桥接通道同步到宿主 URL;跳详情再返回时组件重建、状态从 query 还原。
|
|
6
|
+
*/
|
|
7
|
+
import { computed, ref } from 'vue'
|
|
8
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
9
|
+
import { reportNav } from '../child-bus'
|
|
10
|
+
|
|
11
|
+
interface OrderItem {
|
|
12
|
+
id: number
|
|
13
|
+
title: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const ORDERS: OrderItem[] = [
|
|
17
|
+
{ id: 1, title: '登录异常排查' },
|
|
18
|
+
{ id: 2, title: '网络抖动投诉' },
|
|
19
|
+
{ id: 3, title: '权限配置变更' },
|
|
20
|
+
{ id: 4, title: '数据导出失败' },
|
|
21
|
+
{ id: 5, title: '消息推送延迟' },
|
|
22
|
+
{ id: 6, title: '账单核对差异' },
|
|
23
|
+
{ id: 7, title: '接口超时告警' },
|
|
24
|
+
{ id: 8, title: '存储扩容申请' },
|
|
25
|
+
]
|
|
26
|
+
const PAGE_SIZE = 3
|
|
27
|
+
|
|
28
|
+
const route = useRoute()
|
|
29
|
+
const router = useRouter()
|
|
30
|
+
|
|
31
|
+
const queryText = computed(() => (typeof route.query.q === 'string' ? route.query.q : ''))
|
|
32
|
+
const page = computed(() => {
|
|
33
|
+
const raw = typeof route.query.page === 'string' ? Number.parseInt(route.query.page, 10) : 1
|
|
34
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 1
|
|
35
|
+
})
|
|
36
|
+
// 输入框初值跟随当前 q:详情返回后组件重建,仍能还原筛选
|
|
37
|
+
const qInput = ref(queryText.value)
|
|
38
|
+
|
|
39
|
+
const filtered = computed(() =>
|
|
40
|
+
queryText.value === '' ? ORDERS : ORDERS.filter((item) => item.title.includes(queryText.value)),
|
|
41
|
+
)
|
|
42
|
+
const totalPages = computed(() => Math.max(1, Math.ceil(filtered.value.length / PAGE_SIZE)))
|
|
43
|
+
const pageItems = computed(() => filtered.value.slice((page.value - 1) * PAGE_SIZE, page.value * PAGE_SIZE))
|
|
44
|
+
|
|
45
|
+
const buildTarget = (qValue: string, pageValue: number): string =>
|
|
46
|
+
`/orders?page=${pageValue}${qValue === '' ? '' : `&q=${encodeURIComponent(qValue)}`}`
|
|
47
|
+
|
|
48
|
+
const handleSearch = (): void => {
|
|
49
|
+
const target = buildTarget(qInput.value.trim(), 1)
|
|
50
|
+
reportNav('子应用 push/replace', 'push', target)
|
|
51
|
+
void router.push(target)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const handlePageStep = (delta: number): void => {
|
|
55
|
+
const next = Math.min(totalPages.value, Math.max(1, page.value + delta))
|
|
56
|
+
if (next === page.value) return
|
|
57
|
+
const target = buildTarget(queryText.value, next)
|
|
58
|
+
reportNav('子应用 push/replace', 'push', target)
|
|
59
|
+
void router.push(target)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const handleOpenDetail = (item: OrderItem): void => {
|
|
63
|
+
reportNav('子应用 Link', 'push', `/orders/${item.id}?src=row`)
|
|
64
|
+
void router.push(`/orders/${item.id}?src=row`)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handleGoSettings = (): void => {
|
|
68
|
+
reportNav('子应用 Link', 'push', '/settings')
|
|
69
|
+
void router.push('/settings')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const handleGoLocked = (): void => {
|
|
73
|
+
reportNav('子应用 Link', 'push', '/locked')
|
|
74
|
+
void router.push('/locked')
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<section class="demo-page">
|
|
80
|
+
<h3 class="demo-page-title">工单列表(子应用路由 /orders)</h3>
|
|
81
|
+
<p class="demo-muted">
|
|
82
|
+
当前筛选:q={{ queryText === '' ? '(空)' : queryText }},页码:{{ page }}/{{ totalPages }}(来自子应用路由 query)
|
|
83
|
+
</p>
|
|
84
|
+
<div class="demo-row">
|
|
85
|
+
<input v-model="qInput" placeholder="输入筛选关键词(支持中文,如:网络)" aria-label="筛选关键词" />
|
|
86
|
+
<button @click="handleSearch">筛选(push ?q=&page=1)</button>
|
|
87
|
+
</div>
|
|
88
|
+
<ul class="demo-order-list">
|
|
89
|
+
<li v-for="item in pageItems" :key="item.id">
|
|
90
|
+
<span>#{{ item.id }} {{ item.title }}</span>
|
|
91
|
+
<button @click="handleOpenDetail(item)">查看详情</button>
|
|
92
|
+
</li>
|
|
93
|
+
<li v-if="pageItems.length === 0" class="demo-muted">无匹配工单</li>
|
|
94
|
+
</ul>
|
|
95
|
+
<div class="demo-row">
|
|
96
|
+
<button :disabled="page <= 1" @click="handlePageStep(-1)">上一页</button>
|
|
97
|
+
<span>第 {{ page }} / {{ totalPages }} 页</span>
|
|
98
|
+
<button :disabled="page >= totalPages" @click="handlePageStep(1)">下一页</button>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="demo-row">
|
|
101
|
+
<button @click="handleGoSettings">前往设置页</button>
|
|
102
|
+
<button @click="handleGoLocked">锁定页(触发宿主守卫)</button>
|
|
103
|
+
</div>
|
|
104
|
+
</section>
|
|
105
|
+
</template>
|
|
106
|
+
|
|
107
|
+
<style scoped>
|
|
108
|
+
.demo-page { padding: 8px 0; }
|
|
109
|
+
.demo-page-title { margin: 4px 0; }
|
|
110
|
+
.demo-muted { color: #666; font-size: 13px; margin: 4px 0; }
|
|
111
|
+
.demo-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
|
|
112
|
+
.demo-row button { cursor: pointer; }
|
|
113
|
+
.demo-order-list { list-style: none; padding: 0; margin: 8px 0; }
|
|
114
|
+
.demo-order-list li { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
|
|
115
|
+
.demo-order-list button { cursor: pointer; }
|
|
116
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* examples/templates/showcase/vue-remote/src/pages/Settings.vue — 设置页(本地状态表单,状态刻意不进 URL)。
|
|
4
|
+
* v-model 直写模块级 settings-store:路由往返后仍保留 → 佐证子应用 store 未重建。
|
|
5
|
+
*/
|
|
6
|
+
import { settingsState } from '../settings-store'
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<section class="demo-page">
|
|
11
|
+
<h3 class="demo-page-title">设置(子应用路由 /settings,本地状态)</h3>
|
|
12
|
+
<div class="demo-form">
|
|
13
|
+
<label>昵称:<input v-model="settingsState.nickname" /></label>
|
|
14
|
+
<label><input v-model="settingsState.notifyEnabled" type="checkbox" /> 接收通知</label>
|
|
15
|
+
<label>
|
|
16
|
+
主题:
|
|
17
|
+
<select v-model="settingsState.theme">
|
|
18
|
+
<option value="light">浅色</option>
|
|
19
|
+
<option value="dark">深色</option>
|
|
20
|
+
</select>
|
|
21
|
+
</label>
|
|
22
|
+
</div>
|
|
23
|
+
<p class="demo-muted">
|
|
24
|
+
本表单为子应用本地状态(不在 URL 中)。路由往返后设置仍在 → 子应用未重挂、store 未重建。
|
|
25
|
+
</p>
|
|
26
|
+
</section>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style scoped>
|
|
30
|
+
.demo-page { padding: 8px 0; }
|
|
31
|
+
.demo-page-title { margin: 4px 0; }
|
|
32
|
+
.demo-form { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; max-width: 320px; }
|
|
33
|
+
.demo-muted { color: #666; font-size: 13px; margin: 4px 0; }
|
|
34
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* examples/templates/showcase/vue-remote/src/settings-store.ts — 设置页本地状态(模块级 reactive,刻意不写入 URL)。
|
|
3
|
+
* 子应用 root 不重挂 → 模块不重建:路由往返后设置仍保留,佐证「内部状态跨路由保留」。
|
|
4
|
+
*/
|
|
5
|
+
import { reactive } from 'vue'
|
|
6
|
+
|
|
7
|
+
export interface SettingsState {
|
|
8
|
+
nickname: string
|
|
9
|
+
notifyEnabled: boolean
|
|
10
|
+
theme: 'light' | 'dark'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const settingsState = reactive<SettingsState>({ nickname: '张三', notifyEnabled: true, theme: 'light' })
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"types": ["vite/client"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src", "fulgurjs.config.ts", "vite.config.ts"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import { federation } from '@fulgurjs/federation'
|
|
4
|
+
import fulgurjsConfig from './fulgurjs.config.ts'
|
|
5
|
+
|
|
6
|
+
export default defineConfig(({ command }) => ({
|
|
7
|
+
base: command === 'build' ? '/vue-remote/' : undefined,
|
|
8
|
+
// vue-router 双实例防护(同 fixtures/remote-a):dedupe 强制单实例;vue-router 不进
|
|
9
|
+
// 预构建——预构建副本会内联本地 vue,与 shared singleton 协商出的 vue 形成双实例,
|
|
10
|
+
// 路由 provide/inject 断链。exclude 后走源码,其 vue 导入被插件 dev 改写到 shared 门面。
|
|
11
|
+
resolve: { dedupe: ['vue', 'vue-router'] },
|
|
12
|
+
optimizeDeps: { exclude: ['vue-router'] },
|
|
13
|
+
plugins: [vue(), federation(fulgurjsConfig)],
|
|
14
|
+
}))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# vue-host-react-remote:完整子应用桥接模板
|
|
2
|
+
|
|
3
|
+
`vue-host/` 是宿主,`react-remote/` 是子应用。复制整个模板目录,在根目录运行:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm install --frozen-lockfile
|
|
7
|
+
pnpm dev
|
|
8
|
+
# http://localhost:5314
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
宿主展示远程应用、上下文传递与会话切换;切换用户或登出会卸载旧代次。远程独立运行与被嵌入时使用不同路由接线。
|
|
12
|
+
|
|
13
|
+
- 单独启动:`pnpm dev:remote`、`pnpm dev:host`。
|
|
14
|
+
- 生产构建:`pnpm build`,按各子应用配置的 base 部署 dist;远程入口与宿主的 prod 地址必须一致。各子应用 README 提供配置与部署细节。
|
|
15
|
+
- 本模板展示挂载、卸载与会话,不开启宿主/子应用 URL 同步;需要深链、刷新和前进后退,使用 [showcase](../showcase/)。
|
|
16
|
+
- 无 JS 沙箱或自动 CSS 隔离,子应用全局样式和 body 副作用需要自行管理。
|
|
17
|
+
|
|
18
|
+
环境要求见[模板指南](../README.md)。所有依赖来自 registry,不需要本仓库源码或其他模板。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fulgurjs-template-vue-host-react-remote",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev:remote": "pnpm --dir react-remote dev",
|
|
7
|
+
"dev:host": "pnpm --dir vue-host dev",
|
|
8
|
+
"dev": "node scripts/dev.mjs",
|
|
9
|
+
"build": "pnpm --dir react-remote build && pnpm --dir vue-host build"
|
|
10
|
+
}
|
|
11
|
+
}
|