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

chore: normalize admin config line endings

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