feat: 初始化项目基础结构和配置

添加项目基础文件结构、依赖配置和核心功能模块
集成uni-app+Vue3+TypeScript开发环境
配置ESLint、Prettier、Stylelint等代码规范工具
实现主题管理、路由、状态管理等核心功能
添加登录认证、文件上传等常用API模块
This commit is contained in:
zhangtao
2025-08-09 14:21:42 +08:00
parent fd6b31f53f
commit eb32f03d76
113 changed files with 22539 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
import { getToken } from "@/utils/storage";
import { ApiCode } from "@/enums/api-code.enum";
// H5 使用 VITE_APP_BASE_API 作为代理路径,其他平台使用 VITE_APP_API_URL 作为请求路径
let baseApi = import.meta.env.VITE_APP_API_URL;
// #ifdef H5
baseApi = import.meta.env.VITE_APP_BASE_API;
// #endif
const FileAPI = {
/**
* 文件上传地址
*/
uploadUrl: baseApi + "/api/v1/files",
/**
* 上传文件
*
* @param filePath
*/
upload(filePath: string): Promise<FileInfo> {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: this.uploadUrl,
filePath: filePath,
name: "file",
header: {
Authorization: getToken() ? `Bearer ${getToken()}` : "",
},
formData: {},
success: (response) => {
const resData = JSON.parse(response.data) as ResponseData<FileInfo>;
// 业务状态码 00000 表示成功
if (resData.code === ApiCode.SUCCESS) {
resolve(resData.data);
} else {
// 其他业务处理失败
uni.showToast({
title: resData.msg || "文件上传失败",
icon: "none",
});
reject({
message: resData.msg || "业务处理失败",
code: resData.code,
});
}
},
fail: (error) => {
console.log("fail error", error);
uni.showToast({
title: "文件上传请求失败",
icon: "none",
duration: 2000,
});
reject({
message: "文件上传请求失败",
error,
});
},
});
});
},
};
export default FileAPI;
/**
* 文件API类型声明
*/
export interface FileInfo {
/** 文件名 */
name: string;
/** 文件路径 */
url: string;
}