Compare commits

...

8 Commits

Author SHA1 Message Date
8b09394295 Update src/views/user/UserLoginView.vue
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-11 21:58:43 +08:00
82a2acbdbe Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-11 21:58:19 +08:00
2dfb891465 Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-11 21:58:01 +08:00
4f679e8eb6 Update src/api/file/file.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-11 21:57:39 +08:00
67db6e8d53 Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-11 21:57:25 +08:00
d4c2572cf3 Update src/api/file/file.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-11 21:56:49 +08:00
9d18d05a58 feat(api): 新增文件上传相关API及用户邮箱字段
refactor(auth): 使用isApiSuccess统一校验API响应
refactor(store): 更新用户信息获取逻辑以适配新响应格式

chore: 添加eslint和prettier配置及脚本
style: 调整vite代理配置端口号

新增文件上传相关API接口及类型定义
扩展用户信息接口添加邮箱相关字段
统一API响应校验逻辑
更新package.json添加代码格式化工具
2026-01-11 21:50:38 +08:00
d01117c6ea feat(router): 添加根路径重定向到首页的路由配置
添加根路径("/")的重定向配置,使其自动跳转到首页("/home"),并设置该路由不在菜单中显示
2026-01-10 19:37:39 +08:00
11 changed files with 1939 additions and 19 deletions

1761
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,9 +10,32 @@
"build:prod": "vue-tsc -b && vite build --mode prod",
"preview": "vite preview",
"lint": "eslint . --ext .ts,.vue",
"lint:fix": "eslint . --ext .ts,.vue --fix",
"format": "prettier . --write",
"format:check": "prettier . --check",
"type-check": "vue-tsc --noEmit",
"build:types": "vue-tsc --declaration --emitDeclarationOnly"
},
"eslintConfig": {
"root": true,
"env": {
"browser": true,
"node": true,
"es2022": true
},
"extends": [
"eslint:recommended",
"plugin:vue/vue3-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser",
"ecmaVersion": "latest",
"sourceType": "module"
}
},
"dependencies": {
"@arco-design/web-vue": "^2.57.0",
"axios": "^1.13.2",
@@ -23,12 +46,19 @@
},
"devDependencies": {
"@types/node": "^24.10.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitejs/plugin-vue": "^6.0.1",
"@vue/tsconfig": "^0.8.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.23.0",
"openapi-typescript-codegen": "^0.29.0",
"prettier": "^3.2.5",
"sass-embedded": "^1.93.3",
"typescript": "~5.9.3",
"vite": "npm:rolldown-vite@7.2.2",
"vue-eslint-parser": "^9.4.3",
"vue-tsc": "^3.1.3"
},
"overrides": {

View File

@@ -38,6 +38,16 @@ export interface UserInfo {
*/
userAvatar?: string;
/**
* 用户邮箱
*/
userEmail?: string;
/**
* 用户邮箱是否验证
*/
userEmailVerified?: boolean;
/**
* 用户简介
*/
@@ -62,8 +72,8 @@ export interface UserInfo {
* 获取当前登录用户信息
* @returns 当前登录用户信息
*/
export const getUserInfoByToken = () => {
return request<ApiResponse<UserInfo>>({
export const getUserInfoByToken = (): Promise<ApiResponse<UserInfo>> => {
return request({
url: "/v1/auth/getUserInfo",
method: "GET",
})

121
src/api/file/file.ts Normal file
View File

@@ -0,0 +1,121 @@
import request from "@/plugins/axios";
/**
* 分页查询文件列表
*/
export const getFileList = async(current: number,size: number) =>{
return request({
url: "/v1/file/page",
method: "GET",
params: {
current,
size,
},
});
}
/**
* 根据ID查询文件详情
* @param id
* @returns
*/
export const getFileById = async (id: number) => {
return request({
url: "/v1/file/" + id,
method: "GET",
});
}
/**
* 检查文件是否已经上传,本地计算文件哈希
* @param hash
* @returns
*/
export const checkHash = async (hash: string) => {
return request({
url: "/v1/file/check",
method: "GET",
params: {
hash,
},
});
};
/**
* 上传文件
* @param file
* @returns
*/
export const uploadFile = async (file: File, hash: string) => {
const formData = new FormData();
formData.append("file", file);
formData.append("hash", hash);
return request({
url: "/v1/file/upload",
method: "POST",
data: formData,
});
}
/**
* 删除文件
* @param id
* @returns
*/
export const deleteFile = async (id: number) => {
return request({
url: "/v1/file/" + id,
method: "DELETE",
});
}
export interface FileListItem {
/* 文件记录的唯一标识 ID */
id: number;
/* 文件的原始名称(不包含扩展名) */
fileName: string;
/* 文件扩展名,例如 "png"、"jpg"、"pdf" 等 */
fileExtension: string;
/* 文件大小单位为字节Byte */
fileSize: number;
/* 文件内容的哈希值(例如 MD5 或 SHA-256用于校验与秒传 */
fileHash: string;
/* 文件的 MIME 类型,例如 "image/png"、"application/pdf" 等 */
mimeType: string;
/* 文件存储方式类型,例如本地存储、对象存储等 */
storageType: string;
/* 文件在存储系统中的物理或逻辑路径 */
storagePath: string;
/* 业务类型标识,用于区分文件所属的业务场景 */
businessType: string;
/* 关联的业务主键 ID例如订单 ID、用户资料 ID 等 */
businessId: number;
/* 上传该文件的用户 ID */
userId: number;
/* 图片文件的附加信息,例如宽高、分辨率等(非图片可为空) */
imageInfo: string;
/* 逻辑删除标记0 表示未删除1 表示已删除 */
isDeleted: number;
/* 记录创建时间信息 */
createdAt: Record<string, unknown>;
/* 记录最近一次更新时间信息 */
updatedAt: Record<string, unknown>;
}
export type FileListArray = FileListItem[];

View File

@@ -1,6 +1,11 @@
// 统一响应格式
export interface ApiResponse<T = any> {
success: boolean;
message: string;
code?: string | number;
success?: boolean;
message?: string | null;
data: T;
}
export const isApiSuccess = (response: ApiResponse<unknown>): boolean => {
return response?.success === true || response?.code === 0 || response?.code === "0";
};

View File

@@ -10,6 +10,7 @@ import {
clearTokens,
} from "@/utils/token";
import { Message } from "@arco-design/web-vue";
import { isApiSuccess } from "@/api/response";
// 是否正在刷新 token
let isRefreshing = false;
@@ -86,7 +87,7 @@ request.interceptors.response.use(
}
);
if (response.data?.success) {
if (isApiSuccess(response.data)) {
const { accessToken, refreshToken: newRefreshToken } =
response.data.data;
// 更新本地存储

View File

@@ -9,6 +9,12 @@ import AiChatView from "../views/ai/AiChatView.vue";
* 路由配置
*/
export const routes: Array<RouteRecordRaw> = [
{
path: "/",
name: "root",
redirect: "/home",
meta: { hideInMenu: true },
},
{
path: "/home",
name: "HomeView",

View File

@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
import ACCESS_ENUM from "../access/accessEnum";
import type { LoginUesr } from "../store/types";
import { getUserInfoByToken } from "@/api/auth/user";
import { isApiSuccess } from "@/api/response";
/**
*
*/
@@ -23,8 +24,8 @@ export const useUserStore = defineStore("user", {
try {
const res = await getUserInfoByToken();
console.log("获取登录用户成功", res);
if(res.data.success === true){
this.updateUserLoginStatus(res.data.data);
if (isApiSuccess(res)) {
this.updateUserLoginStatus(res.data);
}
} catch (e) {
console.error("获取登录用户失败", e);

View File

@@ -78,6 +78,7 @@ import { login } from "@/api/auth/auth";
import { setTokens } from "@/utils/token";
import { useUserStore } from "@/store/user";
import ACCESS_ENUM from "@/access/accessEnum";
import { isApiSuccess } from "@/api/response";
const router = useRouter();
const userStore = useUserStore();
@@ -114,7 +115,7 @@ const handleSubmit = async (data: any) => {
userPassword: form.userPassword,
});
if (response.success) {
if (isApiSuccess(response)) {
Message.success("登录成功!");
// 存储 token

View File

@@ -28,7 +28,7 @@ export default defineConfig(({ command, mode }) => {
proxy: {
// 代理所有 /api 开头的请求
'/api': {
target: 'http://localhost:8085', // 后端服务器地址
target: 'http://localhost:18085', // 后端服务器地址
changeOrigin: true, // 改变请求头中的 origin
secure: false, // 支持 https
// 如果后端 API 路径不包含 /api可以重写路径