feat(core): 初始化项目基础架构和CMS功能模块
- 添加Docker相关配置文件(.dockerignore, .env.example, .gitignore) - 实现服务端API代理功能,支持文件、模块和服务器API转发 - 创建文章详情页、栏目文章列表页和单页内容展示页面 - 集成Ant Design Vue组件库并实现SSR样式提取功能 - 定义API响应数据结构类型和应用布局组件 - 开发开发者应用中心和文章管理页面 - 实现CMS导航菜单获取和多租户切换功能
This commit is contained in:
172
app/api/system/menu/index.ts
Normal file
172
app/api/system/menu/index.ts
Normal file
@@ -0,0 +1,172 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult } from '@/api';
|
||||
import type { Menu, MenuParam } from './model';
|
||||
import {SERVER_API_URL} from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 查询菜单列表
|
||||
*/
|
||||
export async function listMenus(params: MenuParam) {
|
||||
const res = await request.get<ApiResult<Menu[]>>(
|
||||
SERVER_API_URL + '/system/menu',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
*/
|
||||
export async function addMenu(data: Menu) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单
|
||||
*/
|
||||
export async function updateMenu(data: Menu) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*/
|
||||
export async function removeMenu(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除菜单
|
||||
*/
|
||||
export async function removeBatchMenu(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按顶级目录批量删除菜单
|
||||
*/
|
||||
export async function deleteParentMenu(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/deleteParentMenu/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 安装应用
|
||||
*/
|
||||
export async function installApp(data: any) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/install',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载应用
|
||||
*/
|
||||
export async function uninstallApp(data: any) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/uninstall',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
// 菜单克隆
|
||||
export async function clone(data: any) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/clone',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 制作插件
|
||||
*/
|
||||
export async function createPlug(data: Menu) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/plug',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
// 安装插件
|
||||
export async function installPlug(id?: number) {
|
||||
const res = await request.get<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/install/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入备份
|
||||
*/
|
||||
export async function importSystemMenu(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/menu/import',
|
||||
formData
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
67
app/api/system/menu/model/index.ts
Normal file
67
app/api/system/menu/model/index.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
export interface Menu {
|
||||
// 菜单id
|
||||
menuId?: number;
|
||||
// 上级id, 0是顶级
|
||||
parentId?: number;
|
||||
// 菜单名称
|
||||
title: string;
|
||||
// 菜单路由地址
|
||||
path: string;
|
||||
// 菜单组件地址
|
||||
component: string;
|
||||
// 模块API
|
||||
modulesUrl?: string;
|
||||
// 模块ID
|
||||
modules?: string;
|
||||
// 菜单类型, 0菜单, 1按钮
|
||||
menuType?: number;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 权限标识
|
||||
authority?: string;
|
||||
// 菜单图标
|
||||
icon?: string;
|
||||
// 是否隐藏, 0否,1是(仅注册路由不显示左侧菜单)
|
||||
hide?: number;
|
||||
// 路由元信息
|
||||
meta?: string;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 子菜单
|
||||
children?: Menu[];
|
||||
// 权限树回显选中状态, 0未选中, 1选中
|
||||
checked?: boolean;
|
||||
//
|
||||
key?: number;
|
||||
//
|
||||
value?: number;
|
||||
//
|
||||
parentIds?: number[];
|
||||
//
|
||||
openType?: number;
|
||||
disabled?: boolean;
|
||||
//
|
||||
appId?: number;
|
||||
//
|
||||
tenantId?: number;
|
||||
tenantName?: string;
|
||||
companyId?: number;
|
||||
// 插件Api
|
||||
plugUrl?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单搜索参数
|
||||
*/
|
||||
export interface MenuParam {
|
||||
title?: string;
|
||||
path?: string;
|
||||
authority?: string;
|
||||
parentId?: number;
|
||||
menuType?: number;
|
||||
hide?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user