提交 74e84745 authored 作者: 王鹏飞's avatar 王鹏飞

chore: normalize admin config line endings

上级 bfe4669f
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="%BASE_URL%formula-editor/dist/formula-editor.min.js"></script> <script src="%BASE_URL%formula-editor/dist/formula-editor.min.js"></script>
<script type="module" src="/src/main.jsx"></script> <script type="module" src="/src/main.jsx"></script>
</body> </body>
</html> </html>
...@@ -18,7 +18,7 @@ createRoot(document.getElementById('root')).render( ...@@ -18,7 +18,7 @@ createRoot(document.getElementById('root')).render(
<PersistGate loading={null} persistor={persistor}> <PersistGate loading={null} persistor={persistor}>
<ConfigProvider locale={zhCN} theme={{ token: { colorPrimary: '#ab1941' } }}> <ConfigProvider locale={zhCN} theme={{ token: { colorPrimary: '#ab1941' } }}>
<App> <App>
<BrowserRouter basename="/admin"> <BrowserRouter basename="/admin">
<MyApp /> <MyApp />
</BrowserRouter> </BrowserRouter>
</App> </App>
......
...@@ -3,9 +3,9 @@ import Axios from 'axios' ...@@ -3,9 +3,9 @@ import Axios from 'axios'
import { message, Modal, notification } from 'antd' import { message, Modal, notification } from 'antd'
import md5 from 'js-md5' import md5 from 'js-md5'
import { get } from 'lodash-es' import { get } from 'lodash-es'
import { sortObjASCII } from '@/utils/common.js' import { sortObjASCII } from '@/utils/common.js'
import { ADMIN_LOGIN_PATH, normalizeAdminApiPath, stripAdminGatewayPrefix } from '@/utils/adminPaths.js' import { ADMIN_LOGIN_PATH, normalizeAdminApiPath, stripAdminGatewayPrefix } from '@/utils/adminPaths.js'
import qs from 'qs' import qs from 'qs'
// import { sm4 as Sm4js } from 'evit-gm-crypt' // import { sm4 as Sm4js } from 'evit-gm-crypt'
// const sm4 = new Sm4js({ // const sm4 = new Sm4js({
...@@ -38,9 +38,9 @@ function getToken() { ...@@ -38,9 +38,9 @@ function getToken() {
} }
// 请求拦截器 // 请求拦截器
axios.interceptors.request.use( axios.interceptors.request.use(
(config) => { (config) => {
config.url = normalizeAdminApiPath(config.url) config.url = normalizeAdminApiPath(config.url)
// 登录流程控制中,根据本地是否存在token判断用户的登录情况 // 登录流程控制中,根据本地是否存在token判断用户的登录情况
// 但是即使token存在,也有可能token是过期的,所以在每次的请求头中携带token // 但是即使token存在,也有可能token是过期的,所以在每次的请求头中携带token
// 后台根据携带的token判断用户的登录情况,并返回给我们对应的状态码 // 后台根据携带的token判断用户的登录情况,并返回给我们对应的状态码
...@@ -71,7 +71,7 @@ axios.interceptors.request.use( ...@@ -71,7 +71,7 @@ axios.interceptors.request.use(
if (config.url.indexOf('.tiangong.cn') > -1) { if (config.url.indexOf('.tiangong.cn') > -1) {
s = config.url s = config.url
} else { } else {
s = stripAdminGatewayPrefix(import.meta.env.VITE_API_URL + config.url) s = stripAdminGatewayPrefix(import.meta.env.VITE_API_URL + config.url)
} }
signData.url = decodeURIComponent(s) signData.url = decodeURIComponent(s)
// signData.url = 'http: //zijing.com/index.php/user/user/getList' // signData.url = 'http: //zijing.com/index.php/user/user/getList'
...@@ -132,7 +132,7 @@ axios.interceptors.response.use( ...@@ -132,7 +132,7 @@ axios.interceptors.response.use(
if (code === 401 || code === 403) { if (code === 401 || code === 403) {
if (!axios.errorNotified) { if (!axios.errorNotified) {
axios.errorNotified = true // 添加标志,表示通知已经弹出 axios.errorNotified = true // 添加标志,表示通知已经弹出
if (pathname === ADMIN_LOGIN_PATH) { if (pathname === ADMIN_LOGIN_PATH) {
return return
} }
Modal.warning({ Modal.warning({
...@@ -140,7 +140,7 @@ axios.interceptors.response.use( ...@@ -140,7 +140,7 @@ axios.interceptors.response.use(
// content: '请重新登录', // content: '请重新登录',
onOk() { onOk() {
localStorage.removeItem('kiwi.gpt.token') localStorage.removeItem('kiwi.gpt.token')
window.location.pathname = ADMIN_LOGIN_PATH window.location.pathname = ADMIN_LOGIN_PATH
}, },
}) })
cancelPending(response.config) // 取消后续请求 cancelPending(response.config) // 取消后续请求
...@@ -165,7 +165,7 @@ axios.interceptors.response.use( ...@@ -165,7 +165,7 @@ axios.interceptors.response.use(
content: '请重新登录', content: '请重新登录',
onOk() { onOk() {
localStorage.removeItem('kiwi.gpt.token') localStorage.removeItem('kiwi.gpt.token')
window.location.href = ADMIN_LOGIN_PATH window.location.href = ADMIN_LOGIN_PATH
}, },
}) })
} }
...@@ -180,7 +180,7 @@ axios.interceptors.response.use( ...@@ -180,7 +180,7 @@ axios.interceptors.response.use(
content: '请重新登录', content: '请重新登录',
onOk() { onOk() {
localStorage.removeItem('kiwi.gpt.token') localStorage.removeItem('kiwi.gpt.token')
window.location.href = ADMIN_LOGIN_PATH window.location.href = ADMIN_LOGIN_PATH
}, },
}) })
} }
......
import { fileURLToPath, URL } from 'node:url' import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite' import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import mkcert from 'vite-plugin-mkcert' import mkcert from 'vite-plugin-mkcert'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '') const env = loadEnv(mode, process.cwd(), '')
const adminApiTarget = env.VITE_ADMIN_API_TARGET || 'http://127.0.0.1:7419' const adminApiTarget = env.VITE_ADMIN_API_TARGET || 'http://127.0.0.1:7419'
return { return {
base: '/admin/', base: '/admin/',
plugins: [react(), mkcert()], plugins: [react(), mkcert()],
server: { server: {
open: '/admin/', open: '/admin/',
host: 'dev.ezijing.com', host: 'dev.ezijing.com',
port: 5174, port: 5174,
strictPort: true, strictPort: true,
proxy: { proxy: {
'/api/admin': { '/api/admin': {
target: adminApiTarget, target: adminApiTarget,
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
rewrite: path => path.replace(/^\/api\/admin/, ''), rewrite: path => path.replace(/^\/api\/admin/, ''),
}, },
}, },
}, },
build: { build: {
outDir: '../../dist/admin', outDir: '../../dist/admin',
emptyOutDir: true, emptyOutDir: true,
}, },
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)), '@': fileURLToPath(new URL('./src', import.meta.url)),
...@@ -37,7 +37,7 @@ export default defineConfig(({ mode }) => { ...@@ -37,7 +37,7 @@ export default defineConfig(({ mode }) => {
}, },
css: { css: {
preprocessorOptions: { preprocessorOptions: {
less: { javascriptEnabled: true }, less: { javascriptEnabled: true },
}, },
}, },
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论