Browse Source

feat: 增加登陆

master
betaqi 3 weeks ago
parent
commit
b9ced5e520
  1. 4
      .env.development
  2. 4
      src/api/server/axiosInstance.ts
  3. 2
      src/components/dashboard/Edfs-exception.vue
  4. 1
      src/pages/fileDoc/components/markdownDrawer.vue
  5. 10
      src/pages/layout.vue
  6. 4
      src/pages/system/login/index.vue
  7. 26
      src/router/index.ts

4
.env.development

@ -1,2 +1,2 @@ @@ -1,2 +1,2 @@
VITE_BASE_URL = 'http://192.168.1.3:48080'
VITE_SOCKET_SERVER = 'http://192.168.1.3:48080'
VITE_BASE_URL = 'http://192.168.1.3:48081'
VITE_SOCKET_SERVER = 'http://192.168.1.3:48081'

4
src/api/server/axiosInstance.ts

@ -183,7 +183,7 @@ const createAxiosInstance = (module: APIConfigKeys, config: Config) => { @@ -183,7 +183,7 @@ const createAxiosInstance = (module: APIConfigKeys, config: Config) => {
const unKnowError = `连接出错(${error.response.status})!`
if (status === 401) {
localStorage.removeItem(Keys.STORAGE_TOKEN)
router.push('/file/document')
router.push('/login')
}
const msg = networkErrMap[status] ? networkErrMap[status] : unKnowError
@ -229,7 +229,7 @@ async function logout() { @@ -229,7 +229,7 @@ async function logout() {
removeToken()
isShowLogout = false
deleteUserCache()
window.location.href = '/file/document'
window.location.href = '/login'
}
export default createAxiosInstance

2
src/components/dashboard/Edfs-exception.vue

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
type="primary"
@click="
() => {
router.push('/file/document')
router.push('/login')
}
"
>返回首页</el-button

1
src/pages/fileDoc/components/markdownDrawer.vue

@ -84,7 +84,6 @@ function initEditor() { @@ -84,7 +84,6 @@ function initEditor() {
enable: false,
},
after: () => {
debugger
// document.getElementById('exportButton').addEventListener('click', () => {
// const content = vditor.getValue() //
// const filename = 'my-exported-document.md' //

10
src/pages/layout.vue

@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
style="--el-switch-on-color: #2c2c2c; --el-switch-off-color: #f2f2f2"
@change="toggle"
/>
<!-- <el-dropdown
<el-dropdown
style="width: 100%; height: 100%"
@command="command => handleCommand(command)"
>
@ -87,12 +87,12 @@ @@ -87,12 +87,12 @@
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="personal">个人中心</el-dropdown-item>
<el-dropdown-item command="theme">{{ themeText }}</el-dropdown-item>
<!-- <el-dropdown-item command="personal">个人中心</el-dropdown-item> -->
<!-- <el-dropdown-item command="theme">{{ themeText }}</el-dropdown-item> -->
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown> -->
</el-dropdown>
</div>
</el-header>
<main class="layout-main">
@ -259,7 +259,7 @@ async function loginOut() { @@ -259,7 +259,7 @@ async function loginOut() {
type: 'warning',
})
await userStore.loginout()
push('/file/document')
push('/login')
} catch {}
}
</script>

4
src/pages/system/login/index.vue

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
/>
</el-form-item>
</el-form>
<el-button color="#08a4f0" class="login-btn" @click="onLogin" :loading="isLoading"
<el-button color="#08a4f0" class="login-btn" @click="onLogin" :loading="isLoading"
>登录</el-button
>
</div>
@ -231,7 +231,7 @@ onMounted(() => { @@ -231,7 +231,7 @@ onMounted(() => {
color: #333333;
margin-bottom: 48px;
}
:deep(.el-form-item) {
:deep(.el-form-item) {
margin-bottom: 26px;
}
:deep(.el-input) {

26
src/router/index.ts

@ -4,6 +4,7 @@ import { useUserStore } from '../stores/user' @@ -4,6 +4,7 @@ import { useUserStore } from '../stores/user'
import { usePermissionStore } from '@/stores/permission'
import { useDictStore } from '@/stores/dict'
import { getToken } from '@/utils/auth'
import { pa } from 'element-plus/es/locale/index.mjs'
export const defaultRoute = [
{
@ -15,6 +16,15 @@ export const defaultRoute = [ @@ -15,6 +16,15 @@ export const defaultRoute = [
title: '404',
},
},
{
path: '/login',
name: 'Login',
component: () => import('@/pages/system/login/index.vue'),
meta: {
hidden: true,
title: '登录',
},
},
{
path: '/file',
@ -59,14 +69,14 @@ const router = createRouter({ @@ -59,14 +69,14 @@ const router = createRouter({
const whiteList = ['/login']
router.beforeEach(async (to, from, next) => {
// if (!getToken()) {
// if (whiteList.indexOf(to.path) !== -1) {
// next()
// } else {
// next('/file/document')
// }
// return
// }
if (!getToken()) {
if (whiteList.indexOf(to.path) !== -1) {
next()
} else {
next('/login')
}
return
}
if (to.path === '/OnlineDocument') {
next('/file/document')
return

Loading…
Cancel
Save