Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
intelligent_qp_manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
intelligent_qp_manager
Commits
ff580321
Commit
ff580321
authored
Oct 15, 2024
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目框架搭建--动态路由
parent
d663bdb6
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
58 additions
and
42 deletions
+58
-42
.env
.env
+1
-1
pageEnum.ts
src/enums/pageEnum.ts
+1
-1
UpgradePrompt.vue
src/layouts/default/header/components/UpgradePrompt.vue
+11
-11
projectSetting.ts
src/settings/projectSetting.ts
+1
-1
permission.ts
src/store/modules/permission.ts
+9
-7
user.ts
src/store/modules/user.ts
+11
-12
LoginForm.vue
src/views/sys/login/LoginForm.vue
+2
-1
index.vue
src/views/system/user/index.vue
+15
-0
store.d.ts
types/store.d.ts
+4
-7
vite.config.ts
vite.config.ts
+3
-1
No files found.
.env
View file @
ff580321
# spa-title
# spa-title
VITE_GLOB_APP_TITLE =
Vben Admin
VITE_GLOB_APP_TITLE =
智能快速开发平台
src/enums/pageEnum.ts
View file @
ff580321
...
@@ -2,7 +2,7 @@ export enum PageEnum {
...
@@ -2,7 +2,7 @@ export enum PageEnum {
// basic login path
// basic login path
BASE_LOGIN
=
'/login'
,
BASE_LOGIN
=
'/login'
,
// basic home path
// basic home path
BASE_HOME
=
'/
dashboard
'
,
BASE_HOME
=
'/
system/user
'
,
// error page path
// error page path
ERROR_PAGE
=
'/exception'
,
ERROR_PAGE
=
'/exception'
,
// error log page path
// error log page path
...
...
src/layouts/default/header/components/UpgradePrompt.vue
View file @
ff580321
...
@@ -7,17 +7,17 @@
...
@@ -7,17 +7,17 @@
const
localKey
=
'vben-v5.0.0-upgrade-prompt'
;
const
localKey
=
'vben-v5.0.0-upgrade-prompt'
;
if
(
!
localStorage
.
getItem
(
localKey
))
{
//
if (!localStorage.getItem(localKey)) {
Modal
.
confirm
({
//
Modal.confirm({
title
:
t
(
'layout.header.upgrade-prompt.title'
),
//
title: t('layout.header.upgrade-prompt.title'),
content
:
h
(
'div'
,
{},
[
h
(
'p'
,
t
(
'layout.header.upgrade-prompt.content'
))]),
//
content: h('div', {}, [h('p', t('layout.header.upgrade-prompt.content'))]),
onOk
()
{
//
onOk() {
handleClick
();
//
handleClick();
},
//
},
okText
:
t
(
'layout.header.upgrade-prompt.ok-text'
),
//
okText: t('layout.header.upgrade-prompt.ok-text'),
cancelText
:
t
(
'common.closeText'
),
//
cancelText: t('common.closeText'),
});
//
});
}
//
}
localStorage
.
setItem
(
localKey
,
String
(
Date
.
now
()));
localStorage
.
setItem
(
localKey
,
String
(
Date
.
now
()));
function
handleClick
()
{
function
handleClick
()
{
...
...
src/settings/projectSetting.ts
View file @
ff580321
...
@@ -37,7 +37,7 @@ const setting: ProjectConfig = {
...
@@ -37,7 +37,7 @@ const setting: ProjectConfig = {
// 权限模式,默认前端角色权限模式
// 权限模式,默认前端角色权限模式
// ROUTE_MAPPING: 前端模式(菜单由路由生成,默认)
// ROUTE_MAPPING: 前端模式(菜单由路由生成,默认)
// ROLE:前端模式(菜单路由分开)
// ROLE:前端模式(菜单路由分开)
permissionMode
:
PermissionModeEnum
.
ROUTE_MAPPING
,
permissionMode
:
PermissionModeEnum
.
BACK
,
// Permission-related cache is stored in sessionStorage or localStorage
// Permission-related cache is stored in sessionStorage or localStorage
// 权限缓存存放位置。默认存放于localStorage
// 权限缓存存放位置。默认存放于localStorage
...
...
src/store/modules/permission.ts
View file @
ff580321
...
@@ -236,13 +236,15 @@ export const usePermissionStore = defineStore({
...
@@ -236,13 +236,15 @@ export const usePermissionStore = defineStore({
// this function may only need to be executed once, and the actual project can be put at the right time by itself
// this function may only need to be executed once, and the actual project can be put at the right time by itself
// 这个功能可能只需要执行一次,实际项目可以自己放在合适的时间
// 这个功能可能只需要执行一次,实际项目可以自己放在合适的时间
let
routeList
:
AppRouteRecordRaw
[]
=
[];
let
routeList
:
AppRouteRecordRaw
[]
=
[];
try
{
// try {
await
this
.
changePermissionCode
();
// await this.changePermissionCode();
routeList
=
(
await
getMenuList
())
as
AppRouteRecordRaw
[];
// routeList = (await getMenuList()) as AppRouteRecordRaw[];
}
catch
(
error
)
{
// } catch (error) {
console
.
error
(
error
);
// console.error(error);
}
// }
console
.
log
(
'userStore.getUserInfo.data.menus'
,
userStore
.
getUserInfo
.
data
.
menus
)
routeList
=
userStore
.
getUserInfo
.
data
.
menus
console
.
log
(
'routeList'
,
routeList
)
// Dynamically introduce components
// Dynamically introduce components
// 动态引入组件
// 动态引入组件
routeList
=
transformObjToRoute
(
routeList
);
routeList
=
transformObjToRoute
(
routeList
);
...
...
src/store/modules/user.ts
View file @
ff580321
...
@@ -61,7 +61,8 @@ export const useUserStore = defineStore({
...
@@ -61,7 +61,8 @@ export const useUserStore = defineStore({
this
.
token
=
info
?
info
:
''
;
// for null or undefined value
this
.
token
=
info
?
info
:
''
;
// for null or undefined value
setAuthCache
(
TOKEN_KEY
,
info
);
setAuthCache
(
TOKEN_KEY
,
info
);
},
},
setRoleList
(
roleList
:
RoleEnum
[])
{
// setRoleList(roleList: RoleEnum[]) {
setRoleList
(
roleList
:
any
)
{
this
.
roleList
=
roleList
;
this
.
roleList
=
roleList
;
setAuthCache
(
ROLES_KEY
,
roleList
);
setAuthCache
(
ROLES_KEY
,
roleList
);
},
},
...
@@ -90,9 +91,10 @@ export const useUserStore = defineStore({
...
@@ -90,9 +91,10 @@ export const useUserStore = defineStore({
):
Promise
<
any
|
null
>
{
):
Promise
<
any
|
null
>
{
try
{
try
{
const
{
goHome
=
true
,
mode
,
...
loginParams
}
=
params
;
const
{
goHome
=
true
,
mode
,
...
loginParams
}
=
params
;
// 1、调用登录接口
const
data
=
await
loginApi
(
loginParams
,
mode
);
const
data
=
await
loginApi
(
loginParams
,
mode
);
const
token
=
data
.
data
;
const
token
=
data
.
data
;
//
存储token
//
2、设置 token,并存储本地缓存。
this
.
setToken
(
token
);
this
.
setToken
(
token
);
return
this
.
afterLoginAction
(
goHome
);
return
this
.
afterLoginAction
(
goHome
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -101,17 +103,17 @@ export const useUserStore = defineStore({
...
@@ -101,17 +103,17 @@ export const useUserStore = defineStore({
},
},
async
afterLoginAction
(
goHome
?:
boolean
):
Promise
<
any
|
null
>
{
async
afterLoginAction
(
goHome
?:
boolean
):
Promise
<
any
|
null
>
{
if
(
!
this
.
getToken
)
return
null
;
if
(
!
this
.
getToken
)
return
null
;
//
get user info
//
3、获取用户信息
const
userInfo
=
await
this
.
getUserInfoAction
();
const
userInfo
=
await
this
.
getUserInfoAction
();
console
.
log
(
'userInfo'
,
userInfo
)
const
sessionTimeout
=
this
.
sessionTimeout
;
const
sessionTimeout
=
this
.
sessionTimeout
;
if
(
sessionTimeout
)
{
if
(
sessionTimeout
)
{
this
.
setSessionTimeout
(
false
);
this
.
setSessionTimeout
(
false
);
}
else
{
}
else
{
const
permissionStore
=
usePermissionStore
();
const
permissionStore
=
usePermissionStore
();
// 动态路由加载(首次)
// 动态路由加载(首次)
if
(
!
permissionStore
.
isDynamicAddedRoute
)
{
if
(
!
permissionStore
.
isDynamicAddedRoute
)
{
// 4、获取路由配置并动态添加路由配置
const
routes
=
await
permissionStore
.
buildRoutesAction
();
const
routes
=
await
permissionStore
.
buildRoutesAction
();
[...
routes
,
PAGE_NOT_FOUND_ROUTE
].
forEach
((
route
)
=>
{
[...
routes
,
PAGE_NOT_FOUND_ROUTE
].
forEach
((
route
)
=>
{
router
.
addRoute
(
route
as
unknown
as
RouteRecordRaw
);
router
.
addRoute
(
route
as
unknown
as
RouteRecordRaw
);
...
@@ -127,15 +129,12 @@ export const useUserStore = defineStore({
...
@@ -127,15 +129,12 @@ export const useUserStore = defineStore({
async
getUserInfoAction
():
Promise
<
UserInfo
|
null
>
{
async
getUserInfoAction
():
Promise
<
UserInfo
|
null
>
{
if
(
!
this
.
getToken
)
return
null
;
if
(
!
this
.
getToken
)
return
null
;
const
userInfo
=
await
getUserInfo
();
const
userInfo
=
await
getUserInfo
();
console
.
log
(
'userInfo'
,
userInfo
)
if
(
userInfo
.
data
.
roles
&&
userInfo
.
data
.
roles
.
length
>
0
)
{
const
{
roles
=
[]
}
=
userInfo
;
this
.
setRoleList
(
userInfo
.
data
.
roles
);
if
(
isArray
(
roles
))
{
const
roleList
=
roles
.
map
((
item
)
=>
item
.
value
)
as
RoleEnum
[];
this
.
setRoleList
(
roleList
);
}
else
{
}
else
{
userInfo
.
roles
=
[];
this
.
setRoleList
([
'ROLE_DEFAULT'
]);
this
.
setRoleList
([]);
}
}
// 设置用户信息,并存储本地缓存
this
.
setUserInfo
(
userInfo
);
this
.
setUserInfo
(
userInfo
);
return
userInfo
;
return
userInfo
;
},
},
...
...
src/views/sys/login/LoginForm.vue
View file @
ff580321
...
@@ -139,10 +139,11 @@
...
@@ -139,10 +139,11 @@
username
:
data
.
account
,
username
:
data
.
account
,
mode
:
'none'
,
//不要默认的错误提示
mode
:
'none'
,
//不要默认的错误提示
});
});
console
.
log
(
'11111111111111'
,
userInfo
)
if
(
userInfo
)
{
if
(
userInfo
)
{
notification
.
success
({
notification
.
success
({
message
:
t
(
'sys.login.loginSuccessTitle'
),
message
:
t
(
'sys.login.loginSuccessTitle'
),
description
:
`
${
t
(
'sys.login.loginSuccessDesc'
)}
:
${
userInfo
.
realN
ame
}
`
,
description
:
`
${
t
(
'sys.login.loginSuccessDesc'
)}
:
${
userInfo
.
data
.
user
.
n
ame
}
`
,
duration
:
3
,
duration
:
3
,
});
});
}
}
...
...
src/views/system/user/index.vue
0 → 100644
View file @
ff580321
<
template
>
<div>
用戶管理
</div>
</
template
>
<
script
>
export
default
{
name
:
"index"
}
</
script
>
<
style
scoped
>
</
style
>
types/store.d.ts
View file @
ff580321
...
@@ -36,13 +36,10 @@ export interface ErrorLogInfo {
...
@@ -36,13 +36,10 @@ export interface ErrorLogInfo {
}
}
export
interface
UserInfo
{
export
interface
UserInfo
{
userId
:
string
|
number
;
menus
:
[];
username
:
string
;
permissions
:
[];
realName
:
string
;
roles
:
[];
avatar
:
string
;
user
:
[];
desc
?:
string
;
homePath
?:
string
;
roles
:
RoleInfo
[];
}
}
export
interface
BeforeMiniState
{
export
interface
BeforeMiniState
{
...
...
vite.config.ts
View file @
ff580321
...
@@ -17,7 +17,9 @@ export default defineApplicationConfig({
...
@@ -17,7 +17,9 @@ export default defineApplicationConfig({
server
:
{
server
:
{
proxy
:
{
proxy
:
{
'/basic-api'
:
{
'/basic-api'
:
{
target
:
'http://localhost:3000'
,
// target: 'http://localhost:3000',
target
:
'http://106.3.97.198:20062/'
,
// target: `http://192.168.0.9:8082/`,
changeOrigin
:
true
,
changeOrigin
:
true
,
ws
:
true
,
ws
:
true
,
rewrite
:
(
path
)
=>
path
.
replace
(
new
RegExp
(
`^/basic-api`
),
''
),
rewrite
:
(
path
)
=>
path
.
replace
(
new
RegExp
(
`^/basic-api`
),
''
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment