Skip to content

Commit f866311

Browse files
committed
chore: update
1 parent 5b56334 commit f866311

File tree

8 files changed

+114
-51
lines changed

8 files changed

+114
-51
lines changed

packages/v2/.vitepress/theme/Layout.vue

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<!-- docs/.vitepress/theme/Layout.vue -->
22
<script lang="ts" setup>
33
import DefaultTheme from 'vitepress/theme'
4-
import { inBrowser, useData } from 'vitepress'
4+
import { inBrowser, useData, useRoute, useRouter } from 'vitepress'
55
import { watchEffect } from 'vue'
66
import { darkTheme, lightTheme } from 'naive-ui'
77
import { useQuasar } from 'quasar'
88
import { useI18n } from 'vue-i18n'
99

10+
const { Layout } = DefaultTheme
11+
const route = useRoute()
12+
const router = useRouter()
13+
1014
// const isDark = ref(false)
1115
// isDark.value = useColorMode().value === 'dark';
1216

@@ -42,21 +46,30 @@ watchEffect(() => {
4246
</script>
4347

4448
<template>
45-
<!-- todo x:
46-
- 此文件相当于 app.vue
47-
- naive ui 的一些涉及 全局样式的设置, 都在此修改
48-
- naive ui 组件配置:
49-
- https://www.naiveui.com/zh-CN/dark/components/message
50-
- dark mode:
51-
- https://www.naiveui.com/zh-CN/dark/docs/customize-theme
52-
- https://vitepress.dev/zh/guide/custom-theme
53-
- https://vueuse.org/core/useDark/#basic-usage
54-
55-
-->
56-
<n-config-provider :theme="isDark ? darkTheme : lightTheme">
57-
<n-message-provider>
58-
<!-- 默认-->
59-
<DefaultTheme.Layout />
60-
</n-message-provider>
61-
</n-config-provider>
49+
<router-view>
50+
<!-- todo x:
51+
- 此文件相当于 app.vue
52+
- naive ui 的一些涉及 全局样式的设置, 都在此修改
53+
- naive ui 组件配置:
54+
- https://www.naiveui.com/zh-CN/dark/components/message
55+
- dark mode:
56+
- https://www.naiveui.com/zh-CN/dark/docs/customize-theme
57+
- https://vitepress.dev/zh/guide/custom-theme
58+
- https://vueuse.org/core/useDark/#basic-usage
59+
60+
-->
61+
<n-config-provider :theme="isDark ? darkTheme : lightTheme">
62+
<n-message-provider>
63+
<!-- 默认-->
64+
<!-- <DefaultTheme.Layout />-->
65+
<Layout>
66+
<!-- todo x: -->
67+
<template #aside-outline-before>
68+
<!-- My custom sidebar top content-->
69+
<!-- <router-view></router-view>-->
70+
</template>
71+
</Layout>
72+
</n-message-provider>
73+
</n-config-provider>
74+
</router-view>
6275
</template>

packages/v2/.vitepress/theme/index.ts

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
11
// https://vitepress.dev/guide/custom-theme
2-
import type { Theme } from 'vitepress'
2+
import type {Theme} from 'vitepress'
33
import DefaultTheme from 'vitepress/theme'
44
import './style.css'
55
import Layout from './Layout.vue'
66
import naive from 'naive-ui' // import "unocss"
7-
import {
8-
QAvatar,
9-
QBadge,
10-
QBar,
11-
QBtn,
12-
QCard,
13-
QCarousel,
14-
QCarouselSlide,
15-
QFooter,
16-
QForm,
17-
QHeader,
18-
QIcon,
19-
QImg,
20-
QInput,
21-
QLayout,
22-
QPage,
23-
QPageContainer,
24-
QSeparator,
25-
QTab,
26-
QTabPanel,
27-
QTabPanels,
28-
QTabs,
29-
QTree,
30-
Quasar,
31-
} from 'quasar' // Import icon libraries
7+
import {QAvatar, QBadge, QBar, QBtn, QCard, QCarousel, QCarouselSlide, QFooter, QForm, QHeader, QIcon, QImg, QInput, QLayout, QPage, QPageContainer, QSeparator, QTab, QTabPanel, QTabPanels, QTabs, QTree, Quasar,} from 'quasar' // Import icon libraries
328
import '@quasar/extras/material-icons/material-icons.css' // Import Quasar css
339
import 'quasar/src/css/index.sass'
34-
import { createI18n } from 'vue-i18n'
10+
import {createI18n} from 'vue-i18n'
3511
import messages from '../../src/i18n'
12+
import {createRouter, createWebHashHistory} from 'vue-router'
13+
14+
// 1. 定义路由组件.
15+
// 也可以从其他文件导入
16+
const Team = { template: '<div>Team</div>' }
17+
const About = { template: '<div>About</div>' }
3618

3719
export default {
3820
extends: DefaultTheme,
@@ -46,8 +28,51 @@ export default {
4628
// })
4729
// },
4830
enhanceApp({ app, router, siteData }) {
49-
// ...
31+
// router
32+
console.log('router: ', router)
33+
34+
// router.onBeforePageLoad = async (to) => {
35+
// // Here you can set the routes you want to configure.
36+
// if (to == '/about2' || to == '/about2.html') {
37+
// router.route.path = to
38+
// router.route.component = markRaw(About) // Here you set your .vue file
39+
// router.route.data = {
40+
// frontmatter: { sidebar: false, layout: 'page' },
41+
// }
42+
// return false
43+
// }
44+
// return true
45+
// }
46+
47+
// 2. 定义一些路由
48+
// 每个路由都需要映射到一个组件。
49+
// 我们后面再讨论嵌套路由。
50+
const routes = [
51+
{ path: '/team', component: Team },
52+
{ path: '/about', component: About },
53+
]
54+
55+
// 3. 创建路由实例并传递 `routes` 配置
56+
// 你可以在这里输入更多的配置,但我们在这里
57+
// 暂时保持简单
58+
const myRouter = createRouter({
59+
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
60+
history: createWebHashHistory(),
61+
routes, // `routes: routes` 的缩写
62+
})
63+
64+
// 确保 _use_ 路由实例使
65+
// 整个应用支持路由。
66+
app.use(myRouter)
67+
68+
//
69+
// todo x: naive-ui, 不使用, 620 KB, 使用, 1.9MB
70+
//
5071
app.use(naive) // todo x: 不使用, 620 KB, 使用, 1.9MB
72+
73+
//
74+
// todo x: quasar
75+
//
5176
app.use(
5277
Quasar,
5378
{
@@ -89,7 +114,7 @@ export default {
89114
)
90115

91116
//
92-
// i18n
117+
// todo x: fix i18n
93118
//
94119
const i18n = createI18n({
95120
locale: 'en-US',
@@ -98,5 +123,7 @@ export default {
98123
messages,
99124
})
100125
app.use(i18n)
126+
127+
// app.mount('#app')
101128
},
102129
} satisfies Theme

packages/v2/Taskfile.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ tasks:
4747
- bun add --dev @quasar/vite-plugin sass@^1.33.0
4848
- bun add --dev unplugin-vue-components
4949
- bun add --dev unplugin-auto-import
50-
- bun add vue-i18n
50+
- bun add --dev vue
51+
- bun add --dev vue-i18n
52+
- bun add --dev vue-router
5153

5254
check:
5355
cmds:

packages/v2/bun.lockb

475 Bytes
Binary file not shown.

packages/v2/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
"tailwindcss": "^3.4.3",
2323
"unplugin-auto-import": "^0.17.6",
2424
"unplugin-vue-components": "^0.27.0",
25-
"vitepress": "^1.1.3"
25+
"vitepress": "^1.1.3",
26+
"vue": "^3.4.27",
27+
"vue-i18n": "^9.13.1",
28+
"vue-router": "^4.3.2"
2629
},
2730
"dependencies": {
2831
"@quasar/extras": "^1.16.11",
29-
"quasar": "^2.16.2",
30-
"vue-i18n": "^9.13.1"
32+
"quasar": "^2.16.2"
3133
}
3234
}

packages/v2/src/[pkg].md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# about
2+
3+
- about page

packages/v2/src/[pkg].path.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// packages/[pkg].paths.js
2+
export default {
3+
paths() {
4+
return [
5+
{ params: { pkg: 'foo' } },
6+
{ params: { pkg: 'about' } },
7+
{ params: { pkg: 'bar' } },
8+
]
9+
},
10+
}

packages/v2/src/products/product1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ layout: home
66

77
## Overview
88

9+
- [home](/home){target="_self"}
10+
- [demo](/demo){target="_self"}
11+
- [Link to pure.html](/pure.html){target="_self"}
12+
913
<product-page/>
1014

1115
## DownLoad
@@ -25,6 +29,8 @@ layout: home
2529
<w-help></w-help>
2630

2731

32+
<n-back-top />
33+
2834
<script setup>
2935
// prettier-ignore
3036
import ProductPage from "../pages/ProductPage.vue";

0 commit comments

Comments
 (0)