web-权限修改
This commit is contained in:
@@ -43,7 +43,7 @@ export const TokenManager = {
|
||||
* 创建axios实例
|
||||
*/
|
||||
const request = axios.create({
|
||||
baseURL: process.env.VITE_API_BASE_URL || "/api",
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || "/api",
|
||||
timeout: 30000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
@@ -178,40 +178,54 @@ request.interceptors.response.use(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* API封装
|
||||
*/
|
||||
/**
|
||||
* API封装
|
||||
*/
|
||||
export const api = {
|
||||
/**
|
||||
* GET请求
|
||||
* GET请求 - data参数会作为URL查询参数追加
|
||||
*/
|
||||
get<T = any>(url: string, config?: CustomAxiosRequestConfig): Promise<AxiosResponse<ResultDomain<T>>> {
|
||||
get<T = any>(url: string, data?: any, config?: CustomAxiosRequestConfig): Promise<AxiosResponse<ResultDomain<T>>> {
|
||||
// 如果有data参数,将其转换为URL查询参数
|
||||
if (data) {
|
||||
const params = new URLSearchParams();
|
||||
Object.keys(data).forEach(key => {
|
||||
if (data[key] !== undefined && data[key] !== null) {
|
||||
params.append(key, String(data[key]));
|
||||
}
|
||||
});
|
||||
const queryString = params.toString();
|
||||
url += (url.includes('?') ? '&' : '?') + queryString;
|
||||
}
|
||||
return request.get<ResultDomain<T>>(url, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* POST请求
|
||||
* POST请求 - data参数放到请求体
|
||||
*/
|
||||
post<T = any>(url: string, data?: any, config?: CustomAxiosRequestConfig): Promise<AxiosResponse<ResultDomain<T>>> {
|
||||
return request.post<ResultDomain<T>>(url, data, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* PUT请求
|
||||
* PUT请求 - data参数放到请求体
|
||||
*/
|
||||
put<T = any>(url: string, data?: any, config?: CustomAxiosRequestConfig): Promise<AxiosResponse<ResultDomain<T>>> {
|
||||
return request.put<ResultDomain<T>>(url, data, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* DELETE请求
|
||||
* DELETE请求 - data参数放到请求体
|
||||
*/
|
||||
delete<T = any>(url: string, config?: CustomAxiosRequestConfig): Promise<AxiosResponse<ResultDomain<T>>> {
|
||||
return request.delete<ResultDomain<T>>(url, config);
|
||||
delete<T = any>(url: string, data?: any, config?: CustomAxiosRequestConfig): Promise<AxiosResponse<ResultDomain<T>>> {
|
||||
return request.delete<ResultDomain<T>>(url, { ...config, data });
|
||||
},
|
||||
|
||||
/**
|
||||
* PATCH请求
|
||||
* PATCH请求 - data参数放到请求体
|
||||
*/
|
||||
patch<T = any>(url: string, data?: any, config?: CustomAxiosRequestConfig): Promise<AxiosResponse<ResultDomain<T>>> {
|
||||
return request.patch<ResultDomain<T>>(url, data, config);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @since 2025-10-06
|
||||
*/
|
||||
|
||||
import { api } from './index';
|
||||
import { api } from '@/apis/index';
|
||||
import type { LoginParam, LoginDomain } from '@/types';
|
||||
|
||||
/**
|
||||
@@ -4,7 +4,7 @@
|
||||
* @since 2025-10-06
|
||||
*/
|
||||
|
||||
import { api } from './index';
|
||||
import { api } from '@/apis/index';
|
||||
import type { SysMenu, MenuTreeNode } from '@/types';
|
||||
|
||||
/**
|
||||
66
schoolNewsWeb/src/apis/system/permission.ts
Normal file
66
schoolNewsWeb/src/apis/system/permission.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @description 权限相关API
|
||||
* @author yslg
|
||||
* @since 2025-10-06
|
||||
*/
|
||||
import { api } from '@/apis/index';
|
||||
import { SysPermission } from '@/types';
|
||||
|
||||
|
||||
export const permissionApi = {
|
||||
|
||||
/**
|
||||
* @description 获取权限信息
|
||||
* @param permission 权限
|
||||
* @author yslg
|
||||
* @ since 2025-10-08
|
||||
*/
|
||||
async getPermission(permission: SysPermission|null=null): Promise<SysPermission[]> {
|
||||
const response = await api.get<SysPermission>('/permissions/permission', permission);
|
||||
return response.data.dataList!;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description 添加权限
|
||||
* @param permission 权限
|
||||
* @author yslg
|
||||
* @ since 2025-10-08
|
||||
*/
|
||||
async addPermission(permission: SysPermission): Promise<SysPermission[]> {
|
||||
const response = await api.post<SysPermission>('/permissions/permission', permission);
|
||||
return response.data.dataList!;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description 更新权限
|
||||
* @param permission 权限
|
||||
* @author yslg
|
||||
* @ since 2025-10-08
|
||||
*/
|
||||
async updatePermission(permission: SysPermission): Promise<SysPermission[]> {
|
||||
const response = await api.put<SysPermission>('/permissions/permission', permission);
|
||||
return response.data.dataList!;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description 删除权限
|
||||
* @param permission 权限
|
||||
* @author yslg
|
||||
* @ since 2025-10-08
|
||||
*/
|
||||
async deletePermission(permission: SysPermission): Promise<SysPermission[]> {
|
||||
const response = await api.delete<SysPermission>('/permissions/permission', permission);
|
||||
return response.data.dataList!;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description 获取权限列表
|
||||
* @param permission 权限
|
||||
* @author yslg
|
||||
* @ since 2025-10-08
|
||||
*/
|
||||
async getPermissionList(permission: SysPermission|null=null): Promise<SysPermission[]> {
|
||||
const response = await api.post<SysPermission>('/permissions/list', permission);
|
||||
return response.data.dataList!;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* @since 2025-10-06
|
||||
*/
|
||||
|
||||
import { api } from './index';
|
||||
import { api } from '@/apis/index';
|
||||
import type { SysUser, SysUserInfo, UserVO, PageDomain, PageParam } from '@/types';
|
||||
|
||||
/**
|
||||
Reference in New Issue
Block a user