fixed config and template
This commit is contained in:
parent
e1695ce65b
commit
47dacda7ce
@ -1,4 +1,4 @@
|
|||||||
NODE_ENV = development
|
NODE_ENV = development
|
||||||
VITE_APP_TITLE = 标题
|
VITE_APP_TITLE = DEV标题
|
||||||
VITE_BASE_URL = /
|
VITE_BASE_URL = /
|
||||||
VITE_API_BASE_URL = /api
|
VITE_API_BASE_URL = /api
|
||||||
@ -1,4 +1,4 @@
|
|||||||
NODE_ENV = production
|
NODE_ENV = production
|
||||||
VITE_APP_TITLE = 标题
|
VITE_APP_TITLE = PROD标题
|
||||||
VITE_BASE_URL = ./
|
VITE_BASE_URL = ./
|
||||||
VITE_API_BASE_URL = /api
|
VITE_API_BASE_URL = /api
|
||||||
@ -3,12 +3,13 @@ require('@rushstack/eslint-patch/modern-module-resolution')
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
'extends': [
|
extends: [
|
||||||
'plugin:vue/vue3-essential',
|
'plugin:vue/vue3-essential',
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
'@vue/eslint-config-prettier/skip-formatting'
|
'@vue/eslint-config-prettier/skip-formatting'
|
||||||
],
|
],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 'latest'
|
ecmaVersion: 'latest'
|
||||||
}
|
},
|
||||||
|
rules: {}
|
||||||
}
|
}
|
||||||
|
|||||||
16
package.json
16
package.json
@ -12,14 +12,14 @@
|
|||||||
"format": "prettier --write src/"
|
"format": "prettier --write src/"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.2",
|
"axios": "~1.6.2",
|
||||||
"element-plus": "^2.4.4",
|
"element-plus": "~2.4.4",
|
||||||
"mitt": "^3.0.1",
|
"mitt": "~3.0.1",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "~2.1.7",
|
||||||
"pinia-plugin-persistedstate": "^3.2.1",
|
"pinia-plugin-persistedstate": "~3.2.1",
|
||||||
"qs": "^6.11.2",
|
"qs": "~6.11.2",
|
||||||
"vue": "^3.3.11",
|
"vue": "~3.3.11",
|
||||||
"vue-router": "^4.2.5"
|
"vue-router": "~4.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rushstack/eslint-patch": "^1.3.3",
|
"@rushstack/eslint-patch": "^1.3.3",
|
||||||
|
|||||||
@ -3,7 +3,15 @@ import routes from './routes'
|
|||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
routes
|
routes,
|
||||||
|
scrollBehavior: () => ({ left: 0, top: 0, behavior: 'smooth' })
|
||||||
|
})
|
||||||
|
|
||||||
|
// 路由守卫
|
||||||
|
router.beforeEach(() => {})
|
||||||
|
|
||||||
|
router.afterEach((to) => {
|
||||||
|
document.title = import.meta.env.VITE_APP_TITLE + ` | ${to.meta.title || ''}`
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage, ElNotification } from 'element-plus'
|
||||||
|
|
||||||
const API_URL = import.meta.env.VITE_API_BASE_URL
|
const API_URL = import.meta.env.VITE_API_BASE_URL
|
||||||
|
|
||||||
@ -41,6 +41,13 @@ http.interceptors.response.use(
|
|||||||
})
|
})
|
||||||
router.push({ path: '/login' })
|
router.push({ path: '/login' })
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ElNotification({
|
||||||
|
title: '错误',
|
||||||
|
message: res.data.message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.data
|
return res.data
|
||||||
|
|||||||
23
src/utils/ls.js
Normal file
23
src/utils/ls.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const getItem = (itemName) => {
|
||||||
|
return window.localStorage.getItem(itemName)
|
||||||
|
}
|
||||||
|
|
||||||
|
const setItem = (itemName, itemValue) => {
|
||||||
|
return window.localStorage.setItem(itemName, itemValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeItem = (itemName) => {
|
||||||
|
return window.localStorage.removeItem(itemName)
|
||||||
|
}
|
||||||
|
|
||||||
|
const clear = () => {
|
||||||
|
return window.localStorage.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getToken = () => getItem('token')
|
||||||
|
|
||||||
|
export const setToken = (token) => setItem('token', token)
|
||||||
|
|
||||||
|
export const clearToken = () => removeItem('token')
|
||||||
|
|
||||||
|
export const clearAll = () => clear()
|
||||||
Loading…
x
Reference in New Issue
Block a user