refactor: 项目优化
This commit is contained in:
parent
3a5399e7d5
commit
5420e8ed77
|
|
@ -1,4 +1,4 @@
|
||||||
## 开发环境变量配置
|
## 开发环境
|
||||||
|
|
||||||
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
|
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
|
||||||
NODE_ENV='development'
|
NODE_ENV='development'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
## 生产环境变量配置
|
## 生产环境
|
||||||
NODE_ENV='production'
|
NODE_ENV='production'
|
||||||
|
|
||||||
VITE_APP_TITLE = '有来商城管理系统'
|
VITE_APP_TITLE = '有来商城管理系统'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
## 模拟环境变量配置
|
## 模拟环境
|
||||||
NODE_ENV='staging'
|
NODE_ENV='production'
|
||||||
|
|
||||||
VITE_APP_TITLE = '有来商城管理系统'
|
VITE_APP_TITLE = '有来商城管理系统'
|
||||||
VITE_APP_PORT = 9527
|
VITE_APP_PORT = 9527
|
||||||
VITE_APP_BASE_API = '/stage-api'
|
VITE_APP_BASE_API = '/prod--api'
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,8 @@ function clearSelected() {
|
||||||
allNode.forEach((element) => element.classList.remove('is-current'))
|
allNode.forEach((element) => element.classList.remove('is-current'))
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
function initHandle(){
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const selectedValue = modelValue.value;
|
const selectedValue = modelValue.value;
|
||||||
if (selectedValue !== null && typeof (selectedValue) !== "undefined") {
|
if (selectedValue !== null && typeof (selectedValue) !== "undefined") {
|
||||||
const node = proxy.$refs.selectTree.getNode(selectedValue)
|
const node = proxy.$refs.selectTree.getNode(selectedValue)
|
||||||
|
|
@ -125,6 +125,10 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initHandle();
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(modelValue, () => {
|
watch(modelValue, () => {
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,13 @@ declare module '*.vue' {
|
||||||
export default component
|
export default component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 环境变量 TypeScript的智能提示
|
||||||
// 环境变量智能提示
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
NODE_ENV:string,
|
|
||||||
VITE_APP_TITLE: string,
|
VITE_APP_TITLE: string,
|
||||||
VITE_APP_PORT: string,
|
VITE_APP_PORT: string,
|
||||||
VITE_APP_BASE_API: string
|
VITE_APP_BASE_API: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import {useUserStoreHook} from "@/store/modules/user";
|
||||||
|
|
||||||
// 创建 axios 实例
|
// 创建 axios 实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: import.meta.env.VITE_APP_BASE_API as any,
|
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||||
timeout: 50000,
|
timeout: 50000,
|
||||||
headers: {'Content-Type': 'application/json;charset=utf-8'}
|
headers: {'Content-Type': 'application/json;charset=utf-8'}
|
||||||
})
|
})
|
||||||
|
|
@ -28,7 +28,6 @@ service.interceptors.request.use(
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
({data}) => {
|
({data}) => {
|
||||||
// 对响应数据做点什么
|
|
||||||
const {code, msg} = data;
|
const {code, msg} = data;
|
||||||
if (code === '00000') {
|
if (code === '00000') {
|
||||||
return data;
|
return data;
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,12 @@
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"lib": ["esnext", "dom"],
|
"lib": ["esnext", "dom"],
|
||||||
|
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["src/*"]
|
"@/*": ["src/*"]
|
||||||
},
|
},
|
||||||
"extends": "./tsconfig.extends.json",
|
"skipLibCheck": true, // 不对第三方依赖类型检查 ,element-plus 生产打包报错
|
||||||
"skipLibCheck": true, // element-plus 生产打包报错,通过此配置修改 TS 不对第三方依赖类型检查
|
|
||||||
"allowSyntheticDefaultImports": true // 默认导入
|
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
|
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||||
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"moduleResolution": "node"
|
"moduleResolution": "node",
|
||||||
|
|
||||||
|
"allowSyntheticDefaultImports": true // 默认导入
|
||||||
},
|
},
|
||||||
"include": ["vite.config.ts"]
|
"include": ["vite.config.ts"]
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {UserConfig, ConfigEnv, loadEnv} from 'vite'
|
import {UserConfig, ConfigEnv, loadEnv} from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import viteSvgIcons from 'vite-plugin-svg-icons';
|
import viteSvgIcons from 'vite-plugin-svg-icons';
|
||||||
// 如果编辑器提示 path 模块找不到,则可以安装一下 @types/node -> npm i @types/node -D
|
// 如果编辑器提示 path 模块找不到,则可以安装一下 @types/node -> npm install @types/node --save-dev
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
// @see: https://gitee.com/holysheng/vite2-config-description/blob/master/vite.config.ts
|
// @see: https://gitee.com/holysheng/vite2-config-description/blob/master/vite.config.ts
|
||||||
|
|
@ -38,7 +38,7 @@ export default ({command, mode}: ConfigEnv): UserConfig => {
|
||||||
resolve: {
|
resolve: {
|
||||||
// Vite 设置别名路径
|
// Vite 设置别名路径
|
||||||
alias: {
|
alias: {
|
||||||
"@": path.resolve("./src"), // 相对路径别名配置,@表示src
|
"@": path.resolve("./src"), // @ 代替 src
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue