create-jnrs-template-vue 1.1.5 → 1.1.6
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/jnrs-template-vue/.prettierrc.json +1 -1
- package/jnrs-template-vue/auto-imports.d.ts +1 -0
- package/jnrs-template-vue/components.d.ts +10 -0
- package/jnrs-template-vue/package.json +1 -1
- package/jnrs-template-vue/public/system/menu.json +29 -9
- package/jnrs-template-vue/src/App.vue +2 -2
- package/jnrs-template-vue/src/api/{base → system}/index.ts +30 -6
- package/jnrs-template-vue/src/layout/RouterTabs.vue +1 -1
- package/jnrs-template-vue/src/layout/SideMenuItem.vue +1 -1
- package/jnrs-template-vue/src/layout/TopHeader.vue +11 -23
- package/jnrs-template-vue/src/layout/index.vue +35 -5
- package/jnrs-template-vue/src/main.ts +0 -2
- package/jnrs-template-vue/src/router/index.ts +10 -4
- package/jnrs-template-vue/src/types/index.d.ts +6 -0
- package/jnrs-template-vue/src/views/common/403.vue +2 -2
- package/jnrs-template-vue/src/views/common/404.vue +2 -2
- package/jnrs-template-vue/src/views/home/index.vue +2 -2
- package/jnrs-template-vue/src/views/login/index.vue +12 -17
- package/jnrs-template-vue/src/views/system/dict/index.vue +176 -0
- package/jnrs-template-vue/src/views/system/menu/index.vue +67 -0
- package/jnrs-template-vue/src/views/system/mine/baseInfo.vue +38 -30
- package/jnrs-template-vue/src/views/system/mine/securitySettings.vue +11 -19
- package/jnrs-template-vue/src/views/system/role/editDialog.vue +94 -0
- package/jnrs-template-vue/src/views/system/role/index.vue +30 -3
- package/jnrs-template-vue/vite.config.ts +2 -1
- package/jnrs-template-vue/viteMockServe/dictItemRes.json +27 -0
- package/jnrs-template-vue/viteMockServe/dictRes.json +141 -0
- package/jnrs-template-vue/viteMockServe/fail.ts +26 -0
- package/jnrs-template-vue/viteMockServe/index.ts +18 -25
- package/jnrs-template-vue/viteMockServe/{login.json → loginRes.json} +1 -0
- package/jnrs-template-vue/viteMockServe/success.ts +31 -0
- package/package.json +1 -1
- package/jnrs-template-vue/src/types/index.ts +0 -2
- package/jnrs-template-vue/src/views/system/user/index.vue +0 -9
|
@@ -17,21 +17,31 @@ declare module 'vue' {
|
|
|
17
17
|
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
|
|
18
18
|
ElCard: typeof import('element-plus/es')['ElCard']
|
|
19
19
|
ElCascader: typeof import('element-plus/es')['ElCascader']
|
|
20
|
+
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
|
|
20
21
|
ElContainer: typeof import('element-plus/es')['ElContainer']
|
|
21
22
|
ElDatePickerPanel: typeof import('element-plus/es')['ElDatePickerPanel']
|
|
23
|
+
ElDialog: typeof import('element-plus/es')['ElDialog']
|
|
22
24
|
ElForm: typeof import('element-plus/es')['ElForm']
|
|
23
25
|
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
|
24
26
|
ElHeader: typeof import('element-plus/es')['ElHeader']
|
|
25
27
|
ElIcon: typeof import('element-plus/es')['ElIcon']
|
|
26
28
|
ElInput: typeof import('element-plus/es')['ElInput']
|
|
29
|
+
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
|
27
30
|
ElMain: typeof import('element-plus/es')['ElMain']
|
|
28
31
|
ElMenu: typeof import('element-plus/es')['ElMenu']
|
|
29
32
|
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
|
33
|
+
ElOption: typeof import('element-plus/es')['ElOption']
|
|
30
34
|
ElPopover: typeof import('element-plus/es')['ElPopover']
|
|
35
|
+
ElSelect: typeof import('element-plus/es')['ElSelect']
|
|
31
36
|
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
|
37
|
+
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
|
38
|
+
ElTable: typeof import('element-plus/es')['ElTable']
|
|
39
|
+
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
|
32
40
|
ElTabPane: typeof import('element-plus/es')['ElTabPane']
|
|
33
41
|
ElTabs: typeof import('element-plus/es')['ElTabs']
|
|
42
|
+
ElTag: typeof import('element-plus/es')['ElTag']
|
|
34
43
|
ElUpload: typeof import('element-plus/es')['ElUpload']
|
|
44
|
+
ElWatermark: typeof import('element-plus/es')['ElWatermark']
|
|
35
45
|
}
|
|
36
46
|
export interface GlobalDirectives {
|
|
37
47
|
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"meta": {
|
|
28
28
|
"title": "系统管理",
|
|
29
29
|
"icon": "Tools",
|
|
30
|
-
"todoCount": 99
|
|
30
|
+
"todoCount": 99,
|
|
31
|
+
"permissions": ["system:view"]
|
|
31
32
|
},
|
|
32
33
|
"children": [
|
|
33
34
|
{
|
|
@@ -35,8 +36,8 @@
|
|
|
35
36
|
"name": "SystemMine",
|
|
36
37
|
"meta": {
|
|
37
38
|
"title": "个人中心",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
39
|
+
"todoCount": 99,
|
|
40
|
+
"permissions": ["mine:view", "mine:edit"]
|
|
40
41
|
},
|
|
41
42
|
"component": "/system/mine/index"
|
|
42
43
|
},
|
|
@@ -45,19 +46,38 @@
|
|
|
45
46
|
"name": "SystemUser",
|
|
46
47
|
"meta": {
|
|
47
48
|
"title": "用户管理",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
49
|
+
"todoCount": 0,
|
|
50
|
+
"permissions": ["user:view", "user:edit"]
|
|
50
51
|
},
|
|
51
|
-
"component": "/system/user/index"
|
|
52
|
+
"component": "/system/user/index",
|
|
53
|
+
"redirect": "/crud"
|
|
52
54
|
},
|
|
53
55
|
{
|
|
54
56
|
"path": "/system/role",
|
|
55
57
|
"name": "SystemRole",
|
|
56
58
|
"meta": {
|
|
57
|
-
"title": "
|
|
59
|
+
"title": "角色管理",
|
|
60
|
+
"permissions": ["role:view", "role:edit"]
|
|
58
61
|
},
|
|
59
|
-
"component": "/system/role/index"
|
|
60
|
-
|
|
62
|
+
"component": "/system/role/index"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"path": "/system/dict",
|
|
66
|
+
"name": "SystemDict",
|
|
67
|
+
"meta": {
|
|
68
|
+
"title": "字典管理",
|
|
69
|
+
"permissions": ["dict:view", "dict:edit"]
|
|
70
|
+
},
|
|
71
|
+
"component": "/system/dict/index"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"path": "/system/menu",
|
|
75
|
+
"name": "SystemMenu",
|
|
76
|
+
"meta": {
|
|
77
|
+
"title": "菜单管理",
|
|
78
|
+
"permissions": ["menu:view", "menu:edit"]
|
|
79
|
+
},
|
|
80
|
+
"component": "/system/menu/index"
|
|
61
81
|
}
|
|
62
82
|
]
|
|
63
83
|
}
|
|
@@ -5,8 +5,8 @@ import { ElConfigProvider } from 'element-plus'
|
|
|
5
5
|
import zhCn from 'element-plus/es/locale/lang/zh-CN'
|
|
6
6
|
import en from 'element-plus/es/locale/lang/en'
|
|
7
7
|
import { useI18n } from 'vue-i18n'
|
|
8
|
-
import { changeLocales as changeLocalesForShared } from '@jnrs/shared'
|
|
9
|
-
import { changeLocales as changeLocalesForCore } from '@jnrs/core'
|
|
8
|
+
import { changeLocales as changeLocalesForShared } from '@jnrs/shared/locales'
|
|
9
|
+
import { changeLocales as changeLocalesForCore } from '@jnrs/core/locales'
|
|
10
10
|
|
|
11
11
|
const { locale } = useI18n()
|
|
12
12
|
const { theme } = useSystemStore()
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { request } from '../request'
|
|
2
|
-
import type { Dict } from '
|
|
3
|
-
import type { User } from '@/types'
|
|
2
|
+
import type { Dict, DictItem, User } from '@jnrs/shared'
|
|
4
3
|
import type { MenuItem } from '@jnrs/vue-core'
|
|
5
4
|
|
|
6
5
|
// 登录结果
|
|
@@ -16,8 +15,8 @@ interface PasswordChange {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
// 菜单
|
|
19
|
-
export const MenuApi = () => {
|
|
20
|
-
return request
|
|
18
|
+
export const MenuApi = (): Promise<MenuItem[]> => {
|
|
19
|
+
return request({
|
|
21
20
|
url: '/system/menu.json', // /public 文件夹下
|
|
22
21
|
mockUrl: '/mock/menu',
|
|
23
22
|
method: 'get'
|
|
@@ -48,14 +47,14 @@ export const LogoutApi = () => {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
// 获取用户信息
|
|
51
|
-
export const UserInfoApi = () => {
|
|
50
|
+
export const UserInfoApi = (): Promise<User> => {
|
|
52
51
|
return request({
|
|
53
52
|
url: '/api/auth/user-info',
|
|
54
53
|
method: 'get'
|
|
55
54
|
})
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
// 修改密码
|
|
59
58
|
export const PasswordChangeApi = (data: PasswordChange) => {
|
|
60
59
|
return request({
|
|
61
60
|
url: '/api/auth/change-password',
|
|
@@ -63,3 +62,28 @@ export const PasswordChangeApi = (data: PasswordChange) => {
|
|
|
63
62
|
data
|
|
64
63
|
})
|
|
65
64
|
}
|
|
65
|
+
|
|
66
|
+
// 获取字典列表
|
|
67
|
+
export const DictApi = (): Promise<DictItem[]> => {
|
|
68
|
+
return request({
|
|
69
|
+
url: '/api/dict-manager',
|
|
70
|
+
method: 'get'
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 获取单个字典
|
|
75
|
+
export const DictDetailApi = (id: string) => {
|
|
76
|
+
return request({
|
|
77
|
+
url: `/api/dict-manager/detail/${id}`,
|
|
78
|
+
method: 'get'
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 修改单个字典
|
|
83
|
+
export const DictChangeApi = (data: DictItem) => {
|
|
84
|
+
return request({
|
|
85
|
+
url: '/api/dict-manager/detail',
|
|
86
|
+
method: 'post',
|
|
87
|
+
data
|
|
88
|
+
})
|
|
89
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, watch, computed, onMounted } from 'vue'
|
|
3
3
|
import type { TabsPaneContext } from 'element-plus'
|
|
4
|
-
import type { MenuItem } from '
|
|
4
|
+
import type { MenuItem } from '@jnrs/vue-core'
|
|
5
5
|
import { handleRouter, getRoutes, useRoute } from '@jnrs/vue-core/router'
|
|
6
6
|
|
|
7
7
|
// 初始化时添加当前路由
|
|
@@ -6,14 +6,14 @@ import { ElMessageBox } from 'element-plus'
|
|
|
6
6
|
import { handleRouter } from '@jnrs/vue-core/router'
|
|
7
7
|
import { useSystemStore, useAuthStore } from '@/stores'
|
|
8
8
|
import { useAvatar } from '@/composables/common/useAvatar'
|
|
9
|
-
import { LogoutApi } from '@/api/
|
|
9
|
+
import { LogoutApi } from '@/api/system'
|
|
10
10
|
import { getDictLabel, getDictColor } from '@/utils/common'
|
|
11
11
|
|
|
12
12
|
const { avatar } = useAvatar()
|
|
13
13
|
const { userInfo, asyncClearAuth } = useAuthStore()
|
|
14
14
|
|
|
15
|
-
const roleLabel = computed(() => getDictLabel('role', userInfo
|
|
16
|
-
const roleColor = computed(() => getDictColor('role', userInfo
|
|
15
|
+
const roleLabel = computed(() => getDictLabel('role', userInfo?.role || ''))
|
|
16
|
+
const roleColor = computed(() => getDictColor('role', userInfo?.role || ''))
|
|
17
17
|
|
|
18
18
|
const systemStore = useSystemStore()
|
|
19
19
|
const { documentFullscreen } = storeToRefs(systemStore)
|
|
@@ -61,34 +61,24 @@ const showGlobalSetting = () => {
|
|
|
61
61
|
<component :is="!documentFullscreen ? 'FullScreen' : 'Rank'" />
|
|
62
62
|
</el-icon>
|
|
63
63
|
<!-- 头像和用户名 -->
|
|
64
|
-
<el-popover
|
|
65
|
-
placement="bottom"
|
|
66
|
-
trigger="click"
|
|
67
|
-
:teleported="false"
|
|
68
|
-
:width="260"
|
|
69
|
-
:hide-after="0"
|
|
70
|
-
>
|
|
64
|
+
<el-popover placement="bottom" trigger="click" :teleported="false" :width="260" :hide-after="0">
|
|
71
65
|
<template #reference>
|
|
72
66
|
<span class="userMenu_reference">
|
|
73
67
|
<img class="userMenu_avatar" :src="avatar" alt="avatar" />
|
|
74
|
-
<span>{{ userInfo
|
|
75
|
-
<span class="userMenu_roleName" :style="{ color: roleColor }" v-if="userInfo
|
|
76
|
-
[{{ roleLabel }}]
|
|
77
|
-
</span>
|
|
68
|
+
<span>{{ userInfo?.name }}</span>
|
|
69
|
+
<span class="userMenu_roleName" :style="{ color: roleColor }" v-if="userInfo?.role">[{{ roleLabel }}]</span>
|
|
78
70
|
<el-icon class="userMenu_icon"><arrow-down /></el-icon>
|
|
79
71
|
</span>
|
|
80
72
|
</template>
|
|
81
73
|
<div class="userMenu_dropdown">
|
|
82
74
|
<img class="userMenu_dropdown_avatar" :src="avatar" alt="avatar" />
|
|
83
75
|
<b>
|
|
84
|
-
{{ userInfo
|
|
85
|
-
<span class="userMenu_roleName" :style="{ color: roleColor }" v-if="userInfo
|
|
86
|
-
[{{ roleLabel }}]
|
|
87
|
-
</span>
|
|
76
|
+
{{ userInfo?.name }}
|
|
77
|
+
<span class="userMenu_roleName" :style="{ color: roleColor }" v-if="userInfo?.role">[{{ roleLabel }}]</span>
|
|
88
78
|
</b>
|
|
89
|
-
<div class="loginDateTime">
|
|
79
|
+
<div class="loginDateTime" v-if="userInfo?.loginDateTime">
|
|
90
80
|
<span>登录时间</span>
|
|
91
|
-
<p>{{ userInfo
|
|
81
|
+
<p>{{ userInfo?.loginDateTime }}</p>
|
|
92
82
|
</div>
|
|
93
83
|
<div class="userMenu_dropdown_btn">
|
|
94
84
|
<el-button
|
|
@@ -102,9 +92,7 @@ const showGlobalSetting = () => {
|
|
|
102
92
|
>
|
|
103
93
|
个人中心
|
|
104
94
|
</el-button>
|
|
105
|
-
<el-button type="danger" icon="SwitchButton" @click="handleLogout()">
|
|
106
|
-
退出系统
|
|
107
|
-
</el-button>
|
|
95
|
+
<el-button type="danger" icon="SwitchButton" @click="handleLogout()">退出系统</el-button>
|
|
108
96
|
</div>
|
|
109
97
|
</div>
|
|
110
98
|
</el-popover>
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { ref, watch, toRefs } from 'vue'
|
|
2
3
|
import SideMenu from './SideMenu.vue'
|
|
3
4
|
import TopHeader from './TopHeader.vue'
|
|
4
5
|
import RouterTabs from './RouterTabs.vue'
|
|
6
|
+
import { useAuthStore, useSystemStore } from '@/stores'
|
|
7
|
+
|
|
8
|
+
const watermarkFont = ref({
|
|
9
|
+
color: 'rgba(0, 0, 0, 0)',
|
|
10
|
+
fontSize: 12
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const { userInfo } = useAuthStore()
|
|
14
|
+
|
|
15
|
+
const { computedThemeMode } = toRefs(useSystemStore())
|
|
16
|
+
watch(
|
|
17
|
+
computedThemeMode,
|
|
18
|
+
(newVal) => {
|
|
19
|
+
if (newVal === 'dark') {
|
|
20
|
+
watermarkFont.value.color = 'rgba(255, 255, 255, .06)'
|
|
21
|
+
} else {
|
|
22
|
+
watermarkFont.value.color = 'rgba(0, 0, 0, .06)'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
immediate: true
|
|
27
|
+
}
|
|
28
|
+
)
|
|
5
29
|
</script>
|
|
6
30
|
|
|
7
31
|
<template>
|
|
@@ -13,11 +37,17 @@ import RouterTabs from './RouterTabs.vue'
|
|
|
13
37
|
</el-header>
|
|
14
38
|
<RouterTabs />
|
|
15
39
|
<el-main>
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
<el-watermark
|
|
41
|
+
:font="watermarkFont"
|
|
42
|
+
:content="[userInfo?.name, userInfo?.workNo]"
|
|
43
|
+
style="width: 100%; height: 100%"
|
|
44
|
+
>
|
|
45
|
+
<router-view v-slot="{ Component }">
|
|
46
|
+
<keep-alive>
|
|
47
|
+
<component :is="Component" />
|
|
48
|
+
</keep-alive>
|
|
49
|
+
</router-view>
|
|
50
|
+
</el-watermark>
|
|
21
51
|
</el-main>
|
|
22
52
|
</el-container>
|
|
23
53
|
</el-container>
|
|
@@ -10,8 +10,6 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
|
10
10
|
import App from './App.vue'
|
|
11
11
|
import { router } from './router'
|
|
12
12
|
import locales from './locales/index'
|
|
13
|
-
import { changeLocales as changeLocalesForShared } from '@jnrs/shared'
|
|
14
|
-
changeLocalesForShared('en')
|
|
15
13
|
|
|
16
14
|
const app = createApp(App)
|
|
17
15
|
|
|
@@ -2,7 +2,8 @@ import { LAYOUT_NAME, GLOBAL_COMPONENT, routes } from './routes'
|
|
|
2
2
|
import { createVueRouter } from '@jnrs/vue-core/router'
|
|
3
3
|
import type { FileModules, RouteLocationNormalizedGeneric } from '@jnrs/vue-core/router'
|
|
4
4
|
import { useAuthStore, useMenuStore } from '@/stores'
|
|
5
|
-
import { MenuApi } from '@/api/
|
|
5
|
+
import { MenuApi } from '@/api/system'
|
|
6
|
+
import { hasPermission } from '@jnrs/shared'
|
|
6
7
|
|
|
7
8
|
const fileModules = import.meta.glob('/src/views/**/*.vue') as FileModules
|
|
8
9
|
|
|
@@ -14,15 +15,20 @@ const router = createVueRouter({
|
|
|
14
15
|
layoutName: LAYOUT_NAME,
|
|
15
16
|
globalComponent: GLOBAL_COMPONENT,
|
|
16
17
|
handleBeforeEach: async (to: RouteLocationNormalizedGeneric) => {
|
|
17
|
-
//
|
|
18
|
+
// 如果是不需要[身份验证]的页面,直接放行
|
|
18
19
|
if (to.meta.noAuth) return true
|
|
19
20
|
|
|
20
|
-
//
|
|
21
|
-
const { hasAuthenticated } = useAuthStore()
|
|
21
|
+
// 页面刷新处理:未[身份验证]时,重定向到[身份验证]页
|
|
22
|
+
const { hasAuthenticated, userInfo } = useAuthStore()
|
|
22
23
|
if (!hasAuthenticated) {
|
|
23
24
|
return { name: 'Login', query: { redirect: to.path }, replace: true }
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
// 校验访问权限
|
|
28
|
+
if (to.meta.permissions && !hasPermission(to.meta.permissions, userInfo?.permissions || [])) {
|
|
29
|
+
return { name: '403' }
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
// 页面刷新处理:菜单未获取时,先获取菜单,再重定向当前路由,即重新开始进入handleBeforeEach
|
|
27
33
|
const { hasFetchedAsyncMenus, asyncSetMenus } = useMenuStore()
|
|
28
34
|
if (!hasFetchedAsyncMenus) {
|
|
@@ -38,15 +38,15 @@ const goBack = () => {
|
|
|
38
38
|
justify-content: center;
|
|
39
39
|
width: 100%;
|
|
40
40
|
height: 100vh;
|
|
41
|
-
background: #f9fafe;
|
|
42
41
|
overflow: hidden;
|
|
42
|
+
background: var(--jnrs-background-primary);
|
|
43
43
|
.main_mid {
|
|
44
44
|
text-align: center;
|
|
45
45
|
img {
|
|
46
46
|
width: 300px;
|
|
47
47
|
}
|
|
48
48
|
h3 {
|
|
49
|
-
color:
|
|
49
|
+
color: var(--jnrs-font-primary);
|
|
50
50
|
}
|
|
51
51
|
.main_mid_btn {
|
|
52
52
|
margin-top: 30px;
|
|
@@ -38,15 +38,15 @@ const goBack = () => {
|
|
|
38
38
|
justify-content: center;
|
|
39
39
|
width: 100%;
|
|
40
40
|
height: 100vh;
|
|
41
|
-
background: #f9fafe;
|
|
42
41
|
overflow: hidden;
|
|
42
|
+
background: var(--jnrs-background-primary);
|
|
43
43
|
.main_mid {
|
|
44
44
|
text-align: center;
|
|
45
45
|
img {
|
|
46
46
|
width: 300px;
|
|
47
47
|
}
|
|
48
48
|
h3 {
|
|
49
|
-
color:
|
|
49
|
+
color: var(--jnrs-font-primary);
|
|
50
50
|
}
|
|
51
51
|
.main_mid_btn {
|
|
52
52
|
margin-top: 30px;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, onMounted } from 'vue'
|
|
3
3
|
import { ElMessage } from 'element-plus'
|
|
4
|
-
import { MenuApi, LoginApi, UserInfoApi } from '@/api/
|
|
4
|
+
import { MenuApi, LoginApi, UserInfoApi } from '@/api/system'
|
|
5
5
|
import { NotFoundApi, NoAuth } from '@/api/mock'
|
|
6
6
|
import { handleRouter } from '@jnrs/vue-core/router'
|
|
7
|
-
import type { MenuItem } from '
|
|
7
|
+
import type { MenuItem } from '@jnrs/vue-core'
|
|
8
8
|
|
|
9
9
|
const loginParams = ref({
|
|
10
10
|
account: 'admin',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { FormInstance, FormRules } from 'element-plus'
|
|
3
3
|
import { ref } from 'vue'
|
|
4
|
-
import { LoginApi } from '@/api/
|
|
4
|
+
import { LoginApi } from '@/api/system'
|
|
5
5
|
import { useAuthStore } from '@/stores'
|
|
6
6
|
import { handleRouter, useRoute } from '@jnrs/vue-core/router'
|
|
7
7
|
import { isWeakPwd } from '@jnrs/shared/validator'
|
|
@@ -9,6 +9,7 @@ import { formatDateTime, formatWeekday } from '@jnrs/shared'
|
|
|
9
9
|
|
|
10
10
|
const route = useRoute()
|
|
11
11
|
const loading = ref(false)
|
|
12
|
+
const { setUserInfo, setToken, setDict } = useAuthStore()
|
|
12
13
|
|
|
13
14
|
// 表单 ref
|
|
14
15
|
const ruleFormRef = ref<FormInstance>()
|
|
@@ -34,14 +35,15 @@ const submitForm = () => {
|
|
|
34
35
|
loading.value = true
|
|
35
36
|
try {
|
|
36
37
|
const res = await LoginApi(ruleForm.value)
|
|
37
|
-
const { token, dict, ...
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
userInfo: userInfo
|
|
38
|
+
const { token, dict, ...restParameter } = res
|
|
39
|
+
const loginDateTime = formatDateTime() + ' ' + formatWeekday()
|
|
40
|
+
setUserInfo({
|
|
41
|
+
...restParameter,
|
|
42
|
+
account: ruleForm.value.account,
|
|
43
|
+
loginDateTime
|
|
44
44
|
})
|
|
45
|
+
setToken(token)
|
|
46
|
+
setDict(dict)
|
|
45
47
|
handleRouter({ path: route.query.redirect?.toString() || '/' }, 'replace')
|
|
46
48
|
} catch {
|
|
47
49
|
} finally {
|
|
@@ -72,12 +74,7 @@ const submitForm = () => {
|
|
|
72
74
|
@keyup.enter="submitForm()"
|
|
73
75
|
>
|
|
74
76
|
<el-form-item prop="account">
|
|
75
|
-
<el-input
|
|
76
|
-
v-model="ruleForm.account"
|
|
77
|
-
placeholder="请输入账号"
|
|
78
|
-
prefix-icon="User"
|
|
79
|
-
clearable
|
|
80
|
-
/>
|
|
77
|
+
<el-input v-model="ruleForm.account" placeholder="请输入账号" prefix-icon="User" clearable />
|
|
81
78
|
</el-form-item>
|
|
82
79
|
<el-form-item prop="password">
|
|
83
80
|
<el-input
|
|
@@ -90,9 +87,7 @@ const submitForm = () => {
|
|
|
90
87
|
></el-input>
|
|
91
88
|
</el-form-item>
|
|
92
89
|
<el-form-item>
|
|
93
|
-
<el-button class="btn" type="primary" :loading="loading" @click="submitForm()">
|
|
94
|
-
登 录
|
|
95
|
-
</el-button>
|
|
90
|
+
<el-button class="btn" type="primary" :loading="loading" @click="submitForm()">登 录</el-button>
|
|
96
91
|
</el-form-item>
|
|
97
92
|
</el-form>
|
|
98
93
|
<div class="greeting">欢迎使用</div>
|