tools-vue3
vue3 tools
2,321
| Install | |
|---|---|
npm install tools-vue3 |
|
| Latest Version: | 2.0.12 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Jul 2, 2025 |
| Links: | Gitee · npm |
Maintainer: a1518079148
vue3 工具
CRouter 复杂示例
import System from '@/utils/System'
import { createRouter, createWebHashHistory } from 'vue-router'
import CRouter from './CRouter'
/**
* 默认主题
*/
const themeList = ['light', 'dark'] as any[]
const defaultTheme = 'light' as any
const diffTheme = 'dark' as any
/**
* 路由目录/src/views/light/home/index.vue、/src/views/dark/home/index.vue
*/
export const initRouter = () => {
let _modules = import.meta.glob([
'@/views/**/*.vue',
'!@/views/**/*-com/**/*.vue',
'!@/views/**/com/**/*.vue',
'!@/views/**/components/**/*.vue'
])
const _defaultModules = {} as any
const _diffModules = {} as any
Object.keys(_modules).forEach((key) => {
themeList.forEach((item) => {
if (defaultTheme != item) {
if (!new RegExp(`^/src/views/${item}`).test(key)) {
_defaultModules[key] = _modules[key]
}
if (diffTheme != defaultTheme && new RegExp(`^/src/views/${diffTheme}`).test(key)) {
_diffModules[key] = _modules[key]
}
}
})
})
const pathHook = (path: string) => {
return path
.replace(/\/index$/, '')
.replace(new RegExp(`/${defaultTheme}/`), '/')
.replace(new RegExp(`/${diffTheme}/`), '/')
}
const _routes = CRouter.init({
modules: _defaultModules,
diffModules: _diffModules,
children: [
{
path: '/layout',
component: '/layout',
childrenReg: ['^/pages']
}
],
setInfoHook(item) {
item.meta = {
title: item.path
}
},
mapKeyPathHook(path) {
return pathHook(path)
},
pathHook(path) {
return pathHook(path).replace(/^\/pages/, '')
}
})
const router = createRouter({
history: createWebHashHistory(),
routes: [
..._routes.array,
{
path: '/',
redirect: '/home'
}
]
})
System.router = router
return router
}
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 2.0.12 | ^3.4.29 | MIT | |
| 2.0.11 | ^3.4.29 | MIT | |
| 2.0.10 | ^3.4.29 | MIT | |
| 2.0.9 | ^3.4.29 | MIT | |
| 2.0.8 | ^3.4.29 | MIT | |
| 2.0.7 | ^3.4.29 | MIT | |
| 2.0.6 | ^3.4.29 | MIT | |
| 2.0.5 | ^3.4.29 | MIT | |
| 2.0.4 | ^3.4.29 | MIT | |
| 2.0.3 | ^3.4.29 | MIT | |
| 2.0.2 | ^3.4.29 | MIT | |
| 2.0.1 | ^3.4.29 | MIT | |
| 2.0.0 | ^3.4.29 | MIT | |
| 1.2.1 | ^3.3.8 | MIT | |
| 1.2.0 | ^3.3.8 | MIT | |
| 1.1.7 | ^3.3.8 | MIT | |
| 1.1.6 | MIT | ||
| 1.1.5 | MIT | ||
| 1.1.4 | MIT | ||
| 1.1.3 | MIT | ||
| 1.1.2 | MIT | ||
| 1.1.1 | MIT | ||
| 1.1.0 | ^3.2.47 | MIT | |
| 1.0.50 | ^3.2.47 | MIT | |
| 1.0.49 | ^3.2.47 | MIT | |
| 1.0.48 | ^3.2.47 | MIT | |
| 1.0.47 | ^3.2.47 | MIT | |
| 1.0.46 | ^3.2.47 | MIT | |
| 1.0.45 | ^3.2.47 | MIT | |
| 1.0.44 | ^3.2.47 | MIT |
Showing the latest 30 of 74. See every release on npm