refactor(frontend): 清理废弃资源与代码,优化项目结构

1.  删除大量旧版静态图标、图片资源,替换为新的svg图标
2.  移除废弃的API模块、页面组件与配置文件
3.  新增全局消息store与通用列表分页hook
4.  优化代码逻辑:简化错误处理、调整样式类顺序、更新路由鉴权
5.  替换旧的按钮样式属性,统一代码规范
This commit is contained in:
zhangtao
2026-08-03 00:15:44 +08:00
parent 6b14ee9edf
commit 27ab0d802c
82 changed files with 1073 additions and 5216 deletions
+4 -4
View File
@@ -16,10 +16,10 @@ import petMocks from './modules/pet'
import storeMocks from './modules/store'
import userMocks from './modules/user'
const canUseGroupLogger =
typeof console !== 'undefined'
&& typeof console.groupCollapsed === 'function'
&& typeof console.groupEnd === 'function'
const canUseGroupLogger
= typeof console !== 'undefined'
&& typeof console.groupCollapsed === 'function'
&& typeof console.groupEnd === 'function'
// 合并所有mock定义
const allMocks = [
+2 -1
View File
@@ -28,7 +28,8 @@ export const ChatAPI = {
},
/** 发送消息 (非流式) */
sendMessage(sessionId: number, content: string): Promise<ChatMessage> {
return http.Post(`${AI_BASE}/ai-chat`, { session_id: sessionId, content })
// silent:聊天页将错误内联展示为 AI 消息,避免与全局 toast 重复提示
return http.Post(`${AI_BASE}/ai-chat`, { session_id: sessionId, content }, { meta: { silent: true } })
},
/** 获取 AI 模型配置列表 */
getModels(): Promise<AIModelConfig[]> {
@@ -1,71 +0,0 @@
/**
* 代码生成 API 模块(对应后端 module_generator 插件)
*/
import { http } from '@/http'
const GEN_BASE = '/generator/gencode'
export const GencodeAPI = {
/** 查询业务表列表 */
getPage(params?: Record<string, any>): Promise<PageResult<GenTableItem>> {
return http.Get(`${GEN_BASE}/list`, params)
},
/** 查询数据库表列表 */
getDbTables(params?: Record<string, any>): Promise<PageResult<DbTableItem>> {
return http.Get(`${GEN_BASE}/db/list`, params)
},
/** 导入表结构 */
importTable(tableName: string): Promise<void> {
return http.Post(`${GEN_BASE}/import`, { table_name: tableName })
},
/** 获取业务表详情 */
getDetail(id: number): Promise<GenTableItem> {
return http.Get(`${GEN_BASE}/detail/${id}`)
},
/** 编辑业务表 */
update(id: number, data: Partial<GenTableItem>): Promise<GenTableItem> {
return http.Put(`${GEN_BASE}/update/${id}`, data)
},
/** 删除业务表 */
remove(ids: number[]): Promise<void> {
return http.Delete(`${GEN_BASE}/delete`, { ids: JSON.stringify(ids) })
},
/** 批量生成代码 (返回 zip) */
batchGenerate(ids: number[]): Promise<unknown> {
return http.Patch(`${GEN_BASE}/batch/output`, { ids })
},
/** 预览代码 */
preview(id: number): Promise<string | Record<string, any>> {
return http.Get(`${GEN_BASE}/preview/${id}`)
},
/** 同步数据库 */
syncDb(tableName: string): Promise<void> {
return http.Post(`${GEN_BASE}/sync_db/${tableName}`)
},
}
/* ==================== 类型定义 ==================== */
export interface GenTableItem {
id: number
table_name: string
table_comment?: string
class_name?: string
package_name?: string
module_name?: string
business_name?: string
function_name?: string
sub_table_name?: string
sub_table_fk_name?: string
parent_menu_id?: number
description?: string
created_time?: string
updated_time?: string
}
export interface DbTableItem {
table_name?: string
name?: string
table_comment?: string
comment?: string
}
@@ -1,59 +0,0 @@
import { http } from '@/http'
const MONITOR_BASE = '/monitor'
/**
* 缓存监控 API
* 与 web 端 module_monitor/cache.ts 对齐
*/
export const CacheAPI = {
getInfo(): Promise<CacheInfo> {
return http.Get(`${MONITOR_BASE}/cache/info`)
},
getNames(): Promise<string[]> {
return http.Get(`${MONITOR_BASE}/cache/get/names`)
},
getKeys(cacheName: string): Promise<string[]> {
return http.Get(`${MONITOR_BASE}/cache/get/keys/${cacheName}`)
},
getValue(cacheName: string, cacheKey: string): Promise<unknown> {
return http.Get(`${MONITOR_BASE}/cache/get/value/${cacheName}/${cacheKey}`)
},
deleteName(cacheName: string): Promise<void> {
return http.Delete(`${MONITOR_BASE}/cache/delete/name/${cacheName}`)
},
deleteKey(cacheKey: string): Promise<void> {
return http.Delete(`${MONITOR_BASE}/cache/delete/key/${cacheKey}`)
},
clear(): Promise<void> {
return http.Delete(`${MONITOR_BASE}/cache/clear`)
},
}
export interface CacheInfo {
db_size?: number
command_stats?: Record<string, any>[]
info?: Record<string, any>
// computed from info dict
keys_count?: number
hit_rate?: string
used_memory?: string
}
export interface CommandStats {
name: string
value: string
}
export interface RedisInfo {
redis_version: string
redis_mode: string
tcp_port: number
connected_clients: number
uptime_in_days: number
used_memory_human: string
maxmemory_human: string
aof_enabled: string
instantaneous_input_kbps: number
instantaneous_output_kbps: number
}
@@ -1,57 +0,0 @@
import { http } from '@/http'
const MONITOR_BASE = '/monitor'
/**
* 资源管理 API
* 与 web 端 module_monitor/resource.ts 对齐(补全完整字段)
*/
export const ResourceAPI = {
getPage(params?: Record<string, any>): Promise<PageResult<ResourceItem>> {
return http.Get(`${MONITOR_BASE}/resource/list`, params)
},
getDetail(id: number): Promise<ResourceItem> {
return http.Get(`${MONITOR_BASE}/resource/detail/${id}`)
},
remove(ids: number[]): Promise<void> {
return http.Delete(`${MONITOR_BASE}/resource/delete`, { ids: JSON.stringify(ids) })
},
upload(path: string, filePath: string, fileName: string): Promise<ResourceUploadSchema> {
return http.Post(`${MONITOR_BASE}/resource/upload`, { path, file_path: filePath, file_name: fileName })
},
download(id: number): Promise<{ url: string }> {
return http.Get(`${MONITOR_BASE}/resource/download`, { params: { id } })
},
mkdir(path: string, name: string): Promise<void> {
return http.Post(`${MONITOR_BASE}/resource/mkdir`, { path, name })
},
rename(id: number, newName: string): Promise<void> {
return http.Post(`${MONITOR_BASE}/resource/rename`, { id, new_name: newName })
},
move(id: number, targetPath: string): Promise<void> {
return http.Post(`${MONITOR_BASE}/resource/move`, { id, target_path: targetPath })
},
copy(id: number, targetPath: string): Promise<void> {
return http.Post(`${MONITOR_BASE}/resource/copy`, { id, target_path: targetPath })
},
}
export interface ResourceItem {
id: number
name: string
file_url: string
relative_path: string
is_file: boolean
is_dir: boolean
size?: number | null
created_time?: string
modified_time?: string
is_hidden?: boolean
}
export interface ResourceUploadSchema {
file_path?: string
file_name?: string
origin_name?: string
file_url?: string
}
+2 -1
View File
@@ -31,7 +31,8 @@ const AuthAPI = {
* @returns 新的访问令牌
*/
refreshToken(body: RefreshToekenBody): Promise<LoginResult> {
return http.Post(`${AUTH_BASE_URL}/token/refresh`, body, { meta: { ignoreAuth: true } })
// silent:刷新失败由 onAuthRequired 的刷新处理器统一跳转登录,无需全局 toast
return http.Post(`${AUTH_BASE_URL}/token/refresh`, body, { meta: { ignoreAuth: true, silent: true } })
},
/**
@@ -1,114 +0,0 @@
/**
* 定时任务 API 模块(对应后端 `plugin.module_task.cronjob.job`)
* 包含: 调度器管理 / 任务管理 / 任务执行日志
*/
import { http } from '@/http'
const JOB_BASE = '/task/cronjob/job'
/* ==================== 调度器管理 ==================== */
export const SchedulerAPI = {
/** 获取调度器状态 */
getStatus(): Promise<SchedulerStatus> {
return http.Get(`${JOB_BASE}/scheduler/status`)
},
/** 获取调度器任务列表 */
getJobs(): Promise<SchedulerJob[]> {
return http.Get(`${JOB_BASE}/scheduler/jobs`)
},
/** 启动调度器 */
start(): Promise<void> {
return http.Post(`${JOB_BASE}/scheduler/start`)
},
/** 暂停调度器 */
pause(): Promise<void> {
return http.Post(`${JOB_BASE}/scheduler/pause`)
},
/** 恢复调度器 */
resume(): Promise<void> {
return http.Post(`${JOB_BASE}/scheduler/resume`)
},
/** 关闭调度器 */
shutdown(): Promise<void> {
return http.Post(`${JOB_BASE}/scheduler/shutdown`)
},
/** 清空所有任务 */
clear(): Promise<void> {
return http.Delete(`${JOB_BASE}/scheduler/jobs/clear`)
},
/** 获取调度器控制台信息 */
getConsole(): Promise<unknown> {
return http.Get(`${JOB_BASE}/scheduler/console`)
},
}
/* ==================== 任务管理 ==================== */
export const JobAPI = {
/** 暂停任务 */
pause(jobId: string): Promise<void> {
return http.Post(`${JOB_BASE}/task/pause/${jobId}`)
},
/** 恢复任务 */
resume(jobId: string): Promise<void> {
return http.Post(`${JOB_BASE}/task/resume/${jobId}`)
},
/** 立即执行任务 */
run(jobId: string): Promise<void> {
return http.Post(`${JOB_BASE}/task/run/${jobId}`)
},
/** 修改任务 */
modify(jobId: string, data: Record<string, any>): Promise<void> {
return http.Put(`${JOB_BASE}/task/modify/${jobId}`, data)
},
/** 移除任务 */
remove(jobId: string): Promise<void> {
return http.Delete(`${JOB_BASE}/task/remove/${jobId}`)
},
}
/* ==================== 任务执行日志 ==================== */
export const JobLogAPI = {
/** 查询执行日志列表 */
getPage(params?: Record<string, any>): Promise<PageResult<JobLogItem>> {
return http.Get(`${JOB_BASE}/log/list`, params)
},
/** 获取执行日志详情 */
getDetail(id: number): Promise<JobLogItem> {
return http.Get(`${JOB_BASE}/log/detail/${id}`)
},
/** 删除执行日志 */
remove(ids: number[]): Promise<void> {
return http.Delete(`${JOB_BASE}/log/delete`, { ids: JSON.stringify(ids) })
},
}
/* ==================== 类型定义 ==================== */
export interface SchedulerStatus {
status?: string
is_running?: boolean
running: boolean
job_count: number
}
export interface SchedulerJob {
id: string
name: string
status?: string
next_run_time?: string
trigger?: string
func?: string
args?: any[]
}
export interface JobLogItem {
id: number
job_name?: string
job_id?: string
status?: string
result?: string
error_msg?: string
start_time?: string
end_time?: string
created_time?: string
}
@@ -1,70 +0,0 @@
/**
* 任务节点 API 模块(对应后端 `plugin.module_task.cronjob.node`)
*/
import { http } from '@/http'
const NODE_BASE = '/task/cronjob/node'
/* ==================== 任务节点 ==================== */
export const NodeAPI = {
/** 获取节点列表(选项) */
getOptions(): Promise<NodeOption[]> {
return http.Get(`${NODE_BASE}/options`)
},
/** 获取节点详情 */
getDetail(id: number): Promise<NodeItem> {
return http.Get(`${NODE_BASE}/detail/${id}`)
},
/** 节点分页列表 */
getPage(params?: Record<string, any>): Promise<PageResult<NodeItem>> {
return http.Get(`${NODE_BASE}/list`, params)
},
/** 创建节点 */
create(data: NodeForm): Promise<NodeItem> {
return http.Post(`${NODE_BASE}/create`, data)
},
/** 修改节点 */
update(id: number, data: NodeForm): Promise<NodeItem> {
return http.Put(`${NODE_BASE}/update/${id}`, data)
},
/** 删除节点 */
remove(ids: number[]): Promise<void> {
return http.Delete(`${NODE_BASE}/delete`, { ids: JSON.stringify(ids) })
},
/** 清空节点 */
clear(_id?: number): Promise<void> {
return http.Delete(`${NODE_BASE}/clear`)
},
/** 调试节点 */
execute(id: number): Promise<unknown> {
return http.Post(`${NODE_BASE}/execute/${id}`)
},
/** 批量设置节点状态 */
batchStatus(data: { ids: number[], status: number }): Promise<void> {
return http.Patch(`${NODE_BASE}/status/batch`, data)
},
}
/* ==================== 类型定义 ==================== */
export interface NodeOption {
value: number
label: string
path: string
}
export interface NodeForm {
name: string
host: string
port: number
type: string
description?: string
}
export interface NodeItem extends NodeForm {
id: number
status?: string
task_count?: number
created_time?: string
updated_time?: string
}
@@ -1,100 +0,0 @@
/**
* 工作流流程 API 模块(对应后端 `plugin.module_task.workflow.flow`)
* 与 web 端 module_task/workflow/flow.ts 对齐(完整字段定义)
*/
import { http } from '@/http'
const FLOW_BASE = '/task/workflow/flow'
/* ==================== 流程编排 ==================== */
export const WorkflowAPI = {
/** 工作流详情 */
getDetail(id: number): Promise<WorkflowItem> {
return http.Get(`${FLOW_BASE}/detail/${id}`)
},
/** 工作流列表 */
getPage(params?: Record<string, any>): Promise<PageResult<WorkflowItem>> {
return http.Get(`${FLOW_BASE}/list`, params)
},
/** 创建工作流 */
create(data: WorkflowForm): Promise<WorkflowItem> {
return http.Post(`${FLOW_BASE}/create`, data)
},
/** 更新工作流 */
update(id: number, data: WorkflowForm): Promise<WorkflowItem> {
return http.Put(`${FLOW_BASE}/update/${id}`, data)
},
/** 删除工作流 */
remove(ids: number[]): Promise<void> {
return http.Delete(`${FLOW_BASE}/delete`, { ids: JSON.stringify(ids) })
},
/** 发布工作流 */
publish(id: number): Promise<void> {
return http.Post(`${FLOW_BASE}/publish/${id}`)
},
/** 执行工作流 */
execute(data: WorkflowExecuteForm): Promise<WorkflowExecuteResult> {
return http.Post(`${FLOW_BASE}/execute`, data)
},
}
/* ==================== 类型定义 ==================== */
export interface WorkflowPageQuery extends PageQuery {
name?: string
code?: string
status?: number
}
export interface WorkflowForm {
name: string
description?: string
nodes?: WorkflowNode[]
edges?: WorkflowEdge[]
}
export interface WorkflowItem extends WorkflowForm {
id: number
status?: string
version?: number
created_time?: string
updated_time?: string
}
export interface WorkflowPublishForm {
remark?: string
}
export interface WorkflowExecuteForm {
workflow_id: number
variables?: Record<string, any>
business_key?: string
job_id?: number
}
export interface WorkflowExecuteResult {
workflow_id: number
workflow_name: string
status: number
start_time?: string
end_time?: string
variables?: Record<string, any>
node_results?: Record<string, any>
error?: string
}
export interface WorkflowNode {
id?: string
type: string
label?: string
position?: { x: number, y: number }
data?: Record<string, any>
}
export interface WorkflowEdge {
id?: string
source: string
target: string
label?: string
condition?: string
}
@@ -1,60 +0,0 @@
/**
* 工作流节点类型 API 模块(对应后端 `plugin.module_task.workflow.nodes`)
*/
import { http } from '@/http'
const NODES_BASE = '/task/workflow/nodes'
/* ==================== 工作流节点类型 ==================== */
export const WorkflowNodeTypeAPI = {
/** 节点选项 */
getOptions(): Promise<WorkflowNodeTypeOption[]> {
return http.Get(`${NODES_BASE}/options`)
},
/** 节点详情 */
getDetail(id: number): Promise<WorkflowNodeTypeItem> {
return http.Get(`${NODES_BASE}/detail/${id}`)
},
/** 节点列表 */
getPage(params?: Record<string, any>): Promise<PageResult<WorkflowNodeTypeItem>> {
return http.Get(`${NODES_BASE}/list`, params)
},
/** 创建节点 */
create(data: WorkflowNodeTypeForm): Promise<WorkflowNodeTypeItem> {
return http.Post(`${NODES_BASE}/create`, data)
},
/** 更新节点 */
update(id: number, data: WorkflowNodeTypeForm): Promise<WorkflowNodeTypeItem> {
return http.Put(`${NODES_BASE}/update/${id}`, data)
},
/** 删除节点 */
remove(ids: number[]): Promise<void> {
return http.Delete(`${NODES_BASE}/delete`, { ids: JSON.stringify(ids) })
},
/** 节点选择列表 */
getSelect(): Promise<WorkflowNodeTypeOption[]> {
return http.Get(`${NODES_BASE}/select`)
},
}
/* ==================== 类型定义 ==================== */
export interface WorkflowNodeTypeOption {
value: number
label: string
type: string
}
export interface WorkflowNodeTypeForm {
name: string
type: string
handler_path?: string
params_schema?: Record<string, any>
description?: string
}
export interface WorkflowNodeTypeItem extends WorkflowNodeTypeForm {
id: number
created_time?: string
updated_time?: string
}