Skip to content

Commit cb5bf0d

Browse files
committed
update
1 parent 842de91 commit cb5bf0d

File tree

13 files changed

+202
-37
lines changed

13 files changed

+202
-37
lines changed

Diff for: .env

Whitespace-only changes.

Diff for: .env.development

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
VITE_PORT = 3100
2+
3+
# Whether to open mock
4+
VITE_USE_MOCK = true
5+
6+
# public path
7+
VITE_PUBLIC_PATH = /

Diff for: README.md

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center"><a href="https://blog.csdn.net/csdn_yudong/article/details/85250412"><img width="120" src="https://raw.githubusercontent.com/Neveryu/vue-cms/master/static/image/login-logo.png"></a></p>
22

3-
<p align="center">基于 Vue 和 antd design vue 3.x 构建的企业级后台管理项目</p>
3+
<p align="center">基于 Vue3.x 和 antd design vue 3.x 构建的企业级后台管理项目</p>
44

55
<p align="center">
66
<a href="https://github.com/vuejs/vue" rel="nofollow" target="_blank">
@@ -25,8 +25,7 @@
2525

2626
## 简介
2727

28-
29-
// todo
28+
> 本分支是基于[vue3.x + antd design vue 3.x]为核心构建的企业级后台管理项目.
3029
3130

3231
`vue-cms` 是一个企业级管理后台项目,基于 `Vue``ElementUI` 构建。它使用了最新的前端技术栈,内置了 `i18n` 国际化解决方案,支持多语言,路由嵌套,动态路由,权限验证等很多功能特性。
@@ -61,7 +60,7 @@ npm start
6160

6261
浏览器访问 [http://localhost:8080](http://localhost:8080)
6362

64-
## 构建发布
63+
## 构建,发布
6564

6665
```
6766
# build for production with minification
@@ -94,15 +93,14 @@ npm run build --report
9493
- 富文本
9594
```
9695

97-
## 截图
98-
![](./resource/screenhot3.png)
99-
![](./resource/screenhot1.png)
100-
![](./resource/screenhot2.png)
101-
![](./resource/screenhot4.png)
96+
## 快照|snapshot
97+
98+
// todo
99+
102100

103-
## Online Demo
101+
## Online demo
104102

105-
[在线 Demo](https://neveryu.github.io/vue-cms/index.html)
103+
[在线 Demo 演示](https://neveryu.github.io/vue-cms/index.html)
106104

107105
## Donate
108106

@@ -113,7 +111,7 @@ npm run build --report
113111

114112
## Browsers support
115113

116-
Modern browsers and Internet Explorer 10+.
114+
Modern browsers and Internet Explorer 11+.
117115

118116
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
119117
| --------- | --------- | --------- | --------- |
@@ -123,4 +121,4 @@ Modern browsers and Internet Explorer 10+.
123121

124122
[MIT](https://github.com/Neveryu/vue-cms/blob/master/LICENSE)
125123

126-
Copyright (c) 2017-present NeverYu
124+
Copyright (c) 2017-present, [NeverYu](https://github.com/Neveryu)

Diff for: index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<meta name="keywords" content="vue-cms-后台管理系统" />
8-
<meta name="description" content="vue-cms-后台管理系统" />
7+
<meta name="keywords" content="vue-cms,后台管理系统,vue,vue3,vuex,vue-router" />
8+
<meta name="description" content="基于最新的Vue框架开发的企业级后台管理系统" />
99
<meta name="referrer" content="no-referrer"/>
1010
<title>vue-cms</title>
1111
</head>

Diff for: note.md

+26
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,29 @@ export default {
112112
```
113113

114114
【总结:】如果确实想要使用按需加载的话,借助 `babel-plugin-import` 是一个很好的方案吧,但还是那句话,样式还是全量引入吧。
115+
116+
## 四、useRouter, useRoute??
117+
118+
因为我们在 setup 里面没有访问 this,所以我们不能再直接访问 this.$router 或 this.$route。作为替代,我们使用 useRouter 函数:
119+
120+
```
121+
import { useRouter, useRoute } from 'vue-router'
122+
123+
export default {
124+
setup() {
125+
const router = useRouter()
126+
const route = useRoute()
127+
128+
function pushWithQuery(query) {
129+
router.push({
130+
name: 'search',
131+
query: {
132+
...route.query,
133+
},
134+
})
135+
}
136+
},
137+
}
138+
```
139+
140+
请注意,在模板中我们仍然可以访问 $router 和 $route,所以不需要在 setup 中返回 router 或 route。

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"private": true,
44
"version": "3.0.0",
55
"scripts": {
6+
"start": "npm run serve",
67
"serve": "npm run dev",
78
"dev": "vite",
89
"build": "vue-tsc --noEmit && vite build",

Diff for: src/components/HelloWorld.vue

-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
<script setup lang="ts">
22
import { ref } from 'vue'
33
4-
54
const count = ref(0)
65
</script>
76

87
<template>
9-
10-
<p>
11-
Recommended IDE setup:
12-
<a href="https://code.visualstudio.com/" target="_blank">VS Code</a>
13-
+
14-
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
15-
</p>
16-
17-
<p>See <code>README.md</code> for more information.</p>
18-
19-
<p>
20-
<a href="https://vitejs.dev/guide/features.html" target="_blank">
21-
Vite Docs
22-
</a>
23-
|
24-
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
25-
</p>
26-
278
<button type="button" @click="count++">count is: {{ count }}</button>
289
<p>
2910
Edit

Diff for: src/enums/roleEnum.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export enum RoleEnum {
2+
// super admin
3+
SUPER = 'super',
4+
5+
// tester
6+
TEST = 'test'
7+
}

Diff for: src/router/constant.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const REDIRECT_NAME = 'Redirect'
2+
3+
export const PARENT_LAYOUT_NAME = 'ParentLayout'
4+
5+
export const EXCEPTION_COMPONENT = () =>
6+
import('../views/sys/exception/Exception.vue')
7+
8+
/**
9+
* @description: default layout
10+
*/
11+
export const LAYOUT = () => import('/@/layouts/default/index.vue')
12+
13+
/**
14+
* @description: parent-layout
15+
*/
16+
export const getParentLayout = (_name?: string) => {
17+
return () =>
18+
new Promise((resolve) => {
19+
resolve({
20+
name: PARENT_LAYOUT_NAME
21+
})
22+
})
23+
}

Diff for: src/router/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import type { RouteRecordRaw } from 'vue-router'
22
import type { App } from 'vue'
33

44
import { createRouter, createWebHashHistory } from 'vue-router'
5-
// import { basicRoutes, LoginRoute } from './routes'
6-
// import { REDIRECT_NAME } from './constant'
5+
import { basicRoutes, LoginRoute } from './routes'
6+
import { REDIRECT_NAME } from './constant'
77

8-
const WHITE_NAME_LIST = [LoginRoute.name, REDIRECT_NAME]
8+
const WHITE_NAME_LIST = [REDIRECT_NAME]
9+
// const WHITE_NAME_LIST = [LoginRoute.name, REDIRECT_NAME]
910

1011
// app router
1112
const router = createRouter({
13+
/**
14+
* import.meta.env是vite的加载配置文件变量的方式
15+
* 官方说明:https://cn.vitejs.dev/guide/env-and-mode.html
16+
*/
1217
history: createWebHashHistory(import.meta.env.VITE_PUBLIC_PATH),
1318
routes: basicRoutes as unknown as RouteRecordRaw[],
1419
strict: true,

Diff for: src/router/routes/basic.ts

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import type { AppRouteRecordRaw } from '/@/router/types'
2+
import { t } from '/@/hooks/web/useI18n'
3+
import { REDIRECT_NAME, LAYOUT, EXCEPTION_COMPONENT } from '/@/router/constant'
4+
5+
// 404 on a page
6+
export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = {
7+
path: '/:path(.*)*',
8+
name: 'ErrorPage',
9+
component: LAYOUT,
10+
meta: {
11+
title: 'ErrorPage',
12+
hideBreadcrumb: true
13+
},
14+
children: [
15+
{
16+
path: '/:path(.*)*',
17+
name: 'ErrorPage',
18+
component: EXCEPTION_COMPONENT,
19+
meta: {
20+
title: 'ErrorPage',
21+
hideBreadcrumb: true
22+
}
23+
}
24+
]
25+
}
26+
27+
export const REDIRECT_ROUTE: AppRouteRecordRaw = {
28+
path: '/redirect',
29+
name: REDIRECT_NAME,
30+
component: LAYOUT,
31+
meta: {
32+
title: REDIRECT_NAME,
33+
hideBreadcrumb: true
34+
},
35+
children: [
36+
{
37+
path: '/redirect/:path(.*)',
38+
name: REDIRECT_NAME,
39+
component: () => import('/@/views/sys/redirect/index.vue'),
40+
meta: {
41+
title: REDIRECT_NAME,
42+
hideBreadcrumb: true
43+
}
44+
}
45+
]
46+
}
47+
48+
export const ERROR_LOG_ROUTE: AppRouteRecordRaw = {
49+
path: '/error-log',
50+
name: 'errorLog',
51+
component: LAYOUT,
52+
meta: {
53+
title: 'ErrorLog',
54+
hideBreadcrumb: true
55+
},
56+
children: [
57+
{
58+
path: 'list',
59+
name: 'errorLogList',
60+
component: () => import('/@/views/sys/error-log/index.vue'),
61+
meta: {
62+
title: t('routes.basic.errorLogList'),
63+
hideBreadcrumb: true
64+
}
65+
}
66+
]
67+
}

Diff for: src/router/routes/index.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types'
2+
3+
import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic'
4+
5+
import { mainOutRoutes } from './mainOut'
6+
import { PageEnum } from '/@/enums/pageEnum'
7+
import { t } from '/@/hooks/web/useI18n'
8+
9+
const modules = import.meta.globEager('./modules/**/*.ts')
10+
11+
const routeModuleList: AppRouteModule[] = []
12+
13+
Object.keys(modules).forEach((key) => {
14+
const mod = modules[key].default || {}
15+
const modList = Array.isArray(mod) ? [...mod] : [mod]
16+
routeModuleList.push(...modList)
17+
})
18+
19+
export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList]
20+
21+
export const RootRoute: AppRouteRecordRaw = {
22+
path: '/',
23+
name: 'Root',
24+
redirect: PageEnum.BASE_HOME,
25+
meta: {
26+
title: 'Root'
27+
}
28+
}
29+
30+
export const LoginRoute: AppRouteRecordRaw = {
31+
path: '/login',
32+
name: 'Login',
33+
component: () => import('/@/views/sys/login/Login.vue'),
34+
meta: {
35+
title: t('routes.basic.login')
36+
}
37+
}
38+
39+
// Basic routing without permission
40+
export const basicRoutes = [
41+
LoginRoute,
42+
RootRoute,
43+
...mainOutRoutes,
44+
REDIRECT_ROUTE
45+
]

Diff for: src/router/types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export interface RouteMeta {
5151
isLink?: boolean
5252
}
5353

54+
55+
/**
56+
* Omit<K,T>类型让我们可以从另一个对象类型中剔除某些属性,并创建一个新的对象类型
57+
* 怎么剔除多个属性?Omit<K,"T|L|Q">
58+
*/
5459
// @ts-ignore
5560
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
5661
name: string

0 commit comments

Comments
 (0)