Merge remote-tracking branch 'origin/main' into feature/0915_素材中心新增手动上传

This commit is contained in:
rd
2025-09-19 13:37:10 +08:00
12 changed files with 21 additions and 186 deletions

View File

@ -3,8 +3,10 @@ import { configAutoImport, configComponents,configIcons } from './unplugin';
import viteCompression from 'vite-plugin-compression'; import viteCompression from 'vite-plugin-compression';
import progress from 'vite-plugin-progress'; import progress from 'vite-plugin-progress';
import defineOptions from 'unplugin-vue-define-options/vite'; import defineOptions from 'unplugin-vue-define-options/vite';
import { setServerConfig } from './utils';
export * from './utils'; // 移除可能导致循环引用的导出
// export * from './utils';
export const pluginsConfig = [ export const pluginsConfig = [
configUnocss(), configUnocss(),
@ -17,3 +19,6 @@ export const pluginsConfig = [
include: [/\.vue$/, /\.vue\?vue/], include: [/\.vue$/, /\.vue\?vue/],
}), }),
]; ];
export { resolve } from './utils';
export { setServerConfig };

View File

@ -62,10 +62,10 @@ export const setServerConfig =
return { return {
port: Number(env.APP_PORT), port: Number(env.APP_PORT),
proxy: { proxy: {
[env.EO_API_URL]: { '/api': {
target: env.API_PROXY, target: env.VITE_API_URL || 'http://lingjiapi.lvfunai.com/api',
changeOrigin: true, changeOrigin: true,
rewrite: (path: string) => path.replace(env.EO_API_URL, ''), rewrite: (path: string) => path.replace(/^\/api/, ''),
}, },
}, },
...opts, ...opts,

20
env/.env vendored
View File

@ -1,19 +1,3 @@
# 环境变量前缀
# 此前缀开头的变量通过 import.meta.env 暴露出去
ENV_PREFIX=EO_
APP_TITLE=${APP_TITLE}
# router base
EO_BASE=/
# 协议
APP_PROTOCOL=https://
# 接口地址 # 接口地址
EO_API_URL=${APP_PROTOCOL}${API_PATH} VITE_API_URL=${VITE_API_URL}
OSS_API_URL=${APP_PROTOCOL}${OSS_API_PATH} VITE_ENV=${VITE_ENV}
# 接口代理地址
API_PROXY=${APP_PROTOCOL}${API_PATH}
OSS_API_PROXY=${APP_PROTOCOL}${OSS_API_PATH}

14
env/.env.development vendored
View File

@ -1,15 +1,5 @@
# 开发环境
APP_TITLE='development'
# 端口
APP_PORT=48438
# 协议
APP_PROTOCOL=http://
# 接口路径
API_PATH=192.168.40.5
# 接口地址 # 接口地址
EO_API_URL=/api VITE_API_URL=https://lingjiapi.lvfunai.com/api
VITE_ENV='development' VITE_ENV='development'

10
env/.env.production vendored
View File

@ -1,8 +1,4 @@
# 生产环境
APP_TITLE='production | eyo'
# 接口路径
API_PATH=zzz
# 接口地址 # 接口地址
EO_API_URL=http://lingjiapi.lvfunai.com/api VITE_API_URL=https://lingjiapi.lvfunai.com/api
VITE_ENV='production'

14
env/.env.test vendored
View File

@ -1,16 +1,4 @@
# 测试环境
APP_TITLE='test'
# 端口
APP_PORT=48438
# 协议
APP_PROTOCOL=http://
# 接口路径
API_PATH=xxxx
# 接口地址 # 接口地址
EO_API_URL=https://lingjiapi.lvfunai.com/api VITE_API_URL=https://lingjiapi.lvfunai.com/api
VITE_ENV='test' VITE_ENV='test'

31
env/README.md vendored
View File

@ -1,31 +0,0 @@
### 环境变量和模式
| 模式 | 环境 | 描述 |
| ----------------- | ------------------- | ------------ |
| `env` | - | 通用设置 |
| `env.development` | 开发环境 | - |
| `env.preview` | 预览环境 | 本地预览使用 |
| `env.production` | 生产环境 | - |
| `env.staging` | 预发布环境/测试环境 | - |
#### 参数说明
| 参数 | 描述 | 环境 | 说明 |
| -------------- | ------------------------ | ------------- | -------------------------------------------------------- |
| `EO_BASE` | `vue-router` 路由 `base` | - | - |
| `APP_TITLE` | 文档标题 | - | - |
| `APP_PROTOCOL` | 协议 | - | 区别 `webSocket` |
| `APP_PORT` | 端口 | `开发`,`预览` | - |
| `EO_API_URL` | 接口地址 | `开发`,`预览` | - |
| `API_PROXY` | 代理接口地址 | - | - |
| `API_PATH` | 实际接口地址 | - | 开发中只需修改 `API_PATH` 参数,其他参数根据实际情况修改 |
#### 示例
```dotenv
API_PATH=192.168.0.1:48438
```
```dotenv
API_PATH=192.168.0.1:48438/api
```

View File

@ -1,36 +0,0 @@
/*
* @Author: 田鑫
* @Date: 2023-02-17 11:15:23
* @LastEditors: 田鑫
* @LastEditTime: 2023-02-21 16:25:32
* @Description: API状态码
*/
export enum API_STATUS_CODE {
/** 正常响应 */
SUCCESS = 200,
/** 会话失效,请重新登录 */
SESSION_FAILUIRE = 1000,
/** 认证失败,无法访问系统资源 */
AUTH_FAILED = 1001,
/** 未授权,无法访问系统资源 */
RESOURCE_FORBIDDEN = 1002,
/** 黑名单用户 */
BLACK_LIST_USER = 1003,
/** 非法IP地址 */
ILLEGAL_IP = 1004,
/** 网关访问受限 */
GATEWAY_FORBIDDEN = 1005,
/** 网关访问异常,请稍后重试 */
GATEWAY_ERROR = 1006,
/** 流控异常 */
TRAFFIC_CONTROL_ERROR = 1007,
/** 资源找不到服务 */
RESOURCE_NOT_FOUND = 1008,
/** 资源请求超时 */
FETCH_TIMEOUT = 1009,
/** 资源响应异常 */
RESOURCE_RESPONSE_ERROR = 1010,
/** 请求路径不符合规范 */
ILLEGAL_PATH = 1011,
}

View File

@ -1,32 +0,0 @@
/*
* @Author: 田鑫
* @Date: 2023-02-21 16:34:47
* @LastEditors: 田鑫
* @LastEditTime: 2023-02-21 16:59:10
* @Description:
*/
import router from '@/router';
import { clearToken } from '@/utils/auth';
import { message } from 'ant-design-vue';
/**
* 处理业务逻辑定义的错误code
* @param errStatus
*/
export const handleCodeError = (error: any) => {
let errMessage = '未知错误';
console.log(error);
errMessage = error.msg;
switch (error.code) {
case 1000:
router.replace({
name: '/login/password',
});
clearToken();
break;
default:
errMessage = error.msg || `未知错误-${error.code}`;
}
message.error(errMessage);
};

View File

@ -1,11 +1,3 @@
/*
* @Author: 田鑫
* @Date: 2023-02-17 11:58:44
* @LastEditors: rd 1344903914@qq.com
* @LastEditTime: 2025-07-08 14:50:57
* @Description:
*/
import axios from 'axios'; import axios from 'axios';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
@ -31,7 +23,7 @@ export class Request {
private instance: AxiosInstance; private instance: AxiosInstance;
//* 基础配置 //* 基础配置
private baseConfig: AxiosRequestConfig = { private baseConfig: AxiosRequestConfig = {
baseURL: import.meta.env.EO_API_URL, baseURL: `${import.meta.env.VITE_API_URL}`,
timeout: requestTimeout, timeout: requestTimeout,
headers: { headers: {
'Content-Type': contentType, 'Content-Type': contentType,

19
src/api/types.d.ts vendored
View File

@ -1,19 +0,0 @@
/*
* @Author: 田鑫
* @Date: 2023-02-19 21:52:10
* @LastEditors: 田鑫
* @LastEditTime: 2023-02-21 16:59:27
* @Description:
*/
import 'axios';
import { API_STATUS_CODE } from './apiCodes';
declare module 'axios' {
export interface IWygResponse<T> {
success: boolean;
msg: string;
code: API_STATUS_CODE;
data: T;
timestamp: number;
}
}

View File

@ -9,12 +9,11 @@ import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx'; import vueJsx from '@vitejs/plugin-vue-jsx';
import analyzer from 'rollup-plugin-visualizer'; import analyzer from 'rollup-plugin-visualizer';
import { pluginsConfig, setServerConfig, resolve } from './config'; import { pluginsConfig, resolve } from './config';
export default defineConfig(({ mode }: ConfigEnv): UserConfig => { export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const envDir = resolve('env'); const envDir = resolve('env');
const env = loadEnv(mode, envDir, ''); const env = loadEnv(mode, envDir, '');
const setServer = setServerConfig({ env });
return { return {
define: { define: {
@ -43,11 +42,10 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
'/api': { '/api': {
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''), rewrite: (path) => path.replace(/^\/api/, ''),
target: 'https://lingjiapi.lvfunai.com/api', target: env.VITE_API_URL,
}, },
}, },
}, },
preview: setServer(),
}; };
}); });
@ -57,7 +55,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
* @returns * @returns
*/ */
function setAnalyzer(env = 'development') { function setAnalyzer(env = 'development') {
console.log('env: ', env); // console.log('env: ', env);
if (env === 'development') { if (env === 'development') {
return analyzer({ return analyzer({
filename: 'analyzer.html', filename: 'analyzer.html',