mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-08 07:41:10 +08:00
【同步】前端项目源码
【修复】工作流兼容问题
This commit is contained in:
96
frontend/apps/allin-ssl/mock/access.ts
Normal file
96
frontend/apps/allin-ssl/mock/access.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 授权列表
|
||||
export const getAccessList = Mock.mock(/\/access\/get_list/, 'post', () => {
|
||||
const list = []
|
||||
for (let i = 0; i < 10; i++) {
|
||||
list.push({
|
||||
id: Mock.Random.id(),
|
||||
name: `授权-${Mock.Random.ctitle(3, 5)}`,
|
||||
type: Mock.Random.pick(['ssh', 'btpanel', '1panel', 'aliyun', 'tencent']),
|
||||
status: Mock.Random.integer(0, 1),
|
||||
created_at: Mock.Random.datetime('yyyy-MM-dd HH:mm:ss'),
|
||||
})
|
||||
}
|
||||
return {
|
||||
code: 0,
|
||||
count: list.length,
|
||||
data: {
|
||||
list,
|
||||
total: 18,
|
||||
},
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}
|
||||
})
|
||||
|
||||
// 授权类型列表
|
||||
export const getAccessTypes = Mock.mock(/\/access\/get_access_types/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 3,
|
||||
data: [
|
||||
{ key: 'ssh', name: 'SSH验证' },
|
||||
{ key: 'btpanel', name: '宝塔验证' },
|
||||
{ key: '1panel', name: '1Panel验证' },
|
||||
{ key: 'aliyun', name: '阿里云验证' },
|
||||
{ key: 'tencentcloud', name: '腾讯云验证' },
|
||||
],
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 新增授权
|
||||
export const addAccess = Mock.mock(/\/access\/add_access/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '添加成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 修改授权
|
||||
export const updateAccess = Mock.mock(/\/access\/upd_access/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '修改成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 删除授权
|
||||
export const deleteAccess = Mock.mock(/\/access\/del_access/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '删除成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 获取工作流 dns 配置
|
||||
|
||||
export const getAccessAllList = Mock.mock(/\/access\/get_all/, 'post', () => {
|
||||
const list: Array<{ id: string; name: string; type: string }> = []
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const group = Mock.Random.pick([
|
||||
{ name: '阿里云', type: 'aliyun' },
|
||||
{ name: '腾讯云', type: 'tencentcloud' },
|
||||
])
|
||||
list.push({
|
||||
id: Mock.Random.id(),
|
||||
name: `${group.name} DNS 配置`,
|
||||
type: group.type,
|
||||
})
|
||||
}
|
||||
return {
|
||||
code: 0,
|
||||
count: list.length,
|
||||
data: list,
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}
|
||||
})
|
||||
70
frontend/apps/allin-ssl/mock/cert.ts
Normal file
70
frontend/apps/allin-ssl/mock/cert.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 证书列表
|
||||
export const getCertList = Mock.mock(/\/cert\/get_list/, 'post', () => {
|
||||
const list = []
|
||||
for (let i = 0; i < 15; i++) {
|
||||
list.push({
|
||||
id: Mock.Random.id(),
|
||||
name: `${Mock.Random.domain()}证书`,
|
||||
domain: Mock.Random.domain(),
|
||||
expire_time: Mock.Random.datetime('yyyy-MM-dd'),
|
||||
status: Mock.Random.integer(0, 2),
|
||||
created_at: Mock.Random.datetime('yyyy-MM-dd HH:mm:ss'),
|
||||
})
|
||||
}
|
||||
return {
|
||||
code: 0,
|
||||
count: list.length,
|
||||
data: {
|
||||
list,
|
||||
total: 32,
|
||||
},
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}
|
||||
})
|
||||
|
||||
// 申请证书
|
||||
export const applyCert = Mock.mock(/\/cert\/apply_cert/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '申请成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 上传证书
|
||||
export const uploadCert = Mock.mock(/\/cert\/upload_cert/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '上传成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 删除证书
|
||||
export const deleteCert = Mock.mock(/\/cert\/del_cert/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '删除成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 下载证书
|
||||
export const downloadCert = Mock.mock(/\/cert\/download_cert/, 'get', () => {
|
||||
// 二进制文件流模拟,实际上应该是从服务器获取的二进制数据
|
||||
return {
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: 'certificate-file-content',
|
||||
message: '下载成功',
|
||||
status: true,
|
||||
}
|
||||
})
|
||||
9
frontend/apps/allin-ssl/mock/index.ts
Normal file
9
frontend/apps/allin-ssl/mock/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// 导出所有模块
|
||||
export * from './userInfo' // 示例接口
|
||||
export * from './overview'
|
||||
export * from './workflow'
|
||||
export * from './cert'
|
||||
export * from './access'
|
||||
export * from './siteMonitor'
|
||||
export * from './setting'
|
||||
export * from './login'
|
||||
14
frontend/apps/allin-ssl/mock/login.ts
Normal file
14
frontend/apps/allin-ssl/mock/login.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 登录
|
||||
export const login = Mock.mock(/\/login\/login/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
token:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNjE0NjE5MDQ2LCJleHAiOjE2MTQ3MDU0NDZ9._QS2nQa2FRpqH7zJSnjYVBXCOp7-QR-zrXsHl6dTHaU',
|
||||
},
|
||||
message: '登录成功',
|
||||
status: true,
|
||||
}))
|
||||
58
frontend/apps/allin-ssl/mock/overview.ts
Normal file
58
frontend/apps/allin-ssl/mock/overview.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 获取首页概览
|
||||
export const getOverviews = Mock.mock(/\/overview\/get_overviews/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
workfolw: {
|
||||
count: Mock.Random.integer(150, 250),
|
||||
active: Mock.Random.integer(120, 200),
|
||||
failure: Mock.Random.integer(0, 10),
|
||||
},
|
||||
cert: {
|
||||
count: Mock.Random.integer(30, 80),
|
||||
will: Mock.Random.integer(5, 15),
|
||||
end: Mock.Random.integer(0, 5),
|
||||
},
|
||||
site_monitor: {
|
||||
count: Mock.Random.integer(80, 150),
|
||||
exception: Mock.Random.integer(0, 8),
|
||||
},
|
||||
workflow_history: [
|
||||
{
|
||||
name: '服务A部署流水线',
|
||||
state: Mock.Random.integer(-1, 1),
|
||||
mode: Mock.Random.pick(['定时触发', '手动触发']),
|
||||
exec_time: Mock.Random.datetime('yyyy-MM-dd HH:mm'),
|
||||
},
|
||||
{
|
||||
name: '1panel 面板证书部署流水线',
|
||||
state: Mock.Random.integer(-1, 1),
|
||||
mode: Mock.Random.pick(['定时触发', '手动触发']),
|
||||
exec_time: Mock.Random.datetime('yyyy-MM-dd HH:mm'),
|
||||
},
|
||||
{
|
||||
name: '网站证书申请流水线',
|
||||
state: Mock.Random.integer(-1, 1),
|
||||
mode: Mock.Random.pick(['定时触发', '手动触发']),
|
||||
exec_time: Mock.Random.datetime('yyyy-MM-dd HH:mm'),
|
||||
},
|
||||
{
|
||||
name: '网站证书申请流水线',
|
||||
state: Mock.Random.integer(-1, 1),
|
||||
mode: Mock.Random.pick(['定时触发', '手动触发']),
|
||||
exec_time: Mock.Random.datetime('yyyy-MM-dd HH:mm'),
|
||||
},
|
||||
{
|
||||
name: '网站证书申请流水线',
|
||||
state: Mock.Random.integer(-1, 1),
|
||||
mode: Mock.Random.pick(['定时触发', '手动触发']),
|
||||
exec_time: Mock.Random.datetime('yyyy-MM-dd HH:mm'),
|
||||
},
|
||||
],
|
||||
},
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}))
|
||||
87
frontend/apps/allin-ssl/mock/setting.ts
Normal file
87
frontend/apps/allin-ssl/mock/setting.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 获取系统设置
|
||||
export const getSystemSetting = Mock.mock(/\/setting\/get_setting/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
auto_renew: true,
|
||||
renew_days: 30,
|
||||
notify_enable: true,
|
||||
notify_days: 15,
|
||||
},
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 保存系统设置
|
||||
export const saveSystemSetting = Mock.mock(/\/setting\/save_setting/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '保存成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 获取告警类型列表
|
||||
export const getReportTypes = Mock.mock(/\/setting\/get_report_types/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 4,
|
||||
data: [
|
||||
{ key: 'email', name: '邮件通知' },
|
||||
{ key: 'sms', name: '短信通知' },
|
||||
{ key: 'webhook', name: 'Webhook' },
|
||||
{ key: 'dingtalk', name: '钉钉通知' },
|
||||
],
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 配置告警
|
||||
export const setReport = Mock.mock(/\/setting\/set_report/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '配置成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 删除告警
|
||||
export const deleteReport = Mock.mock(/\/setting\/del_report/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '删除成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 获取证书过期通知模板
|
||||
export const getCertEndNoticeTemplate = Mock.mock(/\/setting\/get_certend_notice_temp/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
title: '证书即将过期通知',
|
||||
content: '您的证书 {{domain}} 将在 {{days}} 天后过期,请及时更新。',
|
||||
},
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 保存证书过期通知模板
|
||||
export const saveCertEndNoticeTemplate = Mock.mock(/\/setting\/save_certend_notice_temp/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '保存成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 系统更新
|
||||
export const systemUpdate = Mock.mock(/\/setting\/update/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '更新成功',
|
||||
status: true,
|
||||
}))
|
||||
68
frontend/apps/allin-ssl/mock/siteMonitor.ts
Normal file
68
frontend/apps/allin-ssl/mock/siteMonitor.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 站点监控列表
|
||||
export const getSiteMonitorList = Mock.mock(/\/siteMonitor\/get_list/, 'post', () => {
|
||||
const list = []
|
||||
for (let i = 0; i < 12; i++) {
|
||||
list.push({
|
||||
id: Mock.Random.id(),
|
||||
name: `${Mock.Random.ctitle(2, 5)}网站监控`,
|
||||
url: `https://${Mock.Random.domain()}/api/${Mock.Random.word(3, 8)}`,
|
||||
type: Mock.Random.pick(['HTTP', 'HTTPS', 'TCP', 'PING']),
|
||||
status: Mock.Random.integer(0, 1),
|
||||
check_result: Mock.Random.pick(['连接成功', '超时', '证书有效', '证书已过期']),
|
||||
created_at: Mock.Random.datetime('yyyy-MM-dd HH:mm:ss'),
|
||||
})
|
||||
}
|
||||
return {
|
||||
code: 0,
|
||||
count: list.length,
|
||||
data: {
|
||||
list,
|
||||
total: 25,
|
||||
},
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}
|
||||
})
|
||||
|
||||
// 新增站点监控
|
||||
export const addSiteMonitor = Mock.mock(/\/siteMonitor\/add_site_monitor/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '添加成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 修改站点监控
|
||||
export const updateSiteMonitor = Mock.mock(/\/siteMonitor\/upd_site_monitor/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '修改成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 删除站点监控
|
||||
export const deleteSiteMonitor = Mock.mock(/\/siteMonitor\/del_site_monitor/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '删除成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 启用/禁用站点监控
|
||||
export const setSiteMonitor = Mock.mock(/\/siteMonitor\/set_site_monitor/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '设置成功',
|
||||
status: true,
|
||||
}))
|
||||
24
frontend/apps/allin-ssl/mock/template.ts
Normal file
24
frontend/apps/allin-ssl/mock/template.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @description 成功模板
|
||||
* @param {string} msg 消息
|
||||
* @returns
|
||||
*/
|
||||
export const listTemplate = <T>(data: T, count: number) => ({
|
||||
code: 200, // 状态码
|
||||
count, // 总数,仅data 为数组时有效
|
||||
data, // 数据
|
||||
message: '', // 消息
|
||||
status: true, // 消息状态,true 为成功,false 为失败
|
||||
})
|
||||
|
||||
/**
|
||||
* @description 消息模板
|
||||
* @param {object} data 数据
|
||||
* @returns
|
||||
*/
|
||||
export const messageTemplate = (message: string, status: boolean) => ({
|
||||
code: 200, // 状态码
|
||||
count: 0, // 总数,仅data 为数组时有效
|
||||
message, // 消息
|
||||
status, // 消息状态,true 为成功,false 为失败
|
||||
})
|
||||
26
frontend/apps/allin-ssl/mock/userInfo.ts
Normal file
26
frontend/apps/allin-ssl/mock/userInfo.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 用户列表 (案例接口)
|
||||
export const listUser = Mock.mock(
|
||||
/\/api\/user\/list/,
|
||||
'post',
|
||||
listTemplate(
|
||||
{
|
||||
id: '@id',
|
||||
name: '@cname',
|
||||
avatar: '@image',
|
||||
'age|18-60': 18,
|
||||
'gender|1': ['男', '女'],
|
||||
phone: /^1[385][1-9]\d{8}/,
|
||||
email: '@EMAIL',
|
||||
address: '@county(true)',
|
||||
'role|1': ['admin', 'user'],
|
||||
},
|
||||
100,
|
||||
),
|
||||
)
|
||||
|
||||
// 用户详情 (案例接口)
|
||||
export const addUser = Mock.mock(/\/api\/user\/add/, 'post', messageTemplate('添加成功', true))
|
||||
|
||||
90
frontend/apps/allin-ssl/mock/workflow.ts
Normal file
90
frontend/apps/allin-ssl/mock/workflow.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import Mock from 'mockjs'
|
||||
import { listTemplate, messageTemplate } from './template'
|
||||
|
||||
// 工作流列表
|
||||
export const getWorkflowList = Mock.mock(/\/workflow\/get_list/, 'post', () => {
|
||||
const list = []
|
||||
for (let i = 0; i < 10; i++) {
|
||||
list.push({
|
||||
id: Mock.Random.id(),
|
||||
name: `${Mock.Random.ctitle(3, 8)}部署流水线`,
|
||||
type: Mock.Random.pick(['auto', 'manual']),
|
||||
status: Mock.Random.integer(0, 1),
|
||||
created_at: Mock.Random.datetime('yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: Mock.Random.datetime('yyyy-MM-dd HH:mm:ss'),
|
||||
})
|
||||
}
|
||||
return {
|
||||
code: 0,
|
||||
count: list.length,
|
||||
data: {
|
||||
list,
|
||||
total: 28,
|
||||
},
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}
|
||||
})
|
||||
|
||||
// 新增工作流
|
||||
export const addWorkflow = Mock.mock(/\/workflow\/add_workflow/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '添加成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 修改工作流
|
||||
export const updateWorkflow = Mock.mock(/\/workflow\/upd_workflow/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: {
|
||||
id: Mock.Random.id(),
|
||||
},
|
||||
message: '修改成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 删除工作流
|
||||
export const deleteWorkflow = Mock.mock(/\/workflow\/del_workflow/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '删除成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
// 获取工作流执行历史
|
||||
export const getWorkflowHistory = Mock.mock(/\/workflow\/get_workflow_history/, 'post', () => {
|
||||
const list = []
|
||||
for (let i = 0; i < 10; i++) {
|
||||
list.push({
|
||||
id: Mock.Random.id(),
|
||||
workflow_id: Mock.Random.id(),
|
||||
workflow_name: `${Mock.Random.ctitle(3, 8)}部署流水线`,
|
||||
state: Mock.Random.integer(-1, 1),
|
||||
mode: Mock.Random.pick(['定时触发', '手动触发']),
|
||||
exec_time: Mock.Random.datetime('yyyy-MM-dd HH:mm:ss'),
|
||||
})
|
||||
}
|
||||
return {
|
||||
code: 0,
|
||||
count: list.length,
|
||||
data: list,
|
||||
message: '获取成功',
|
||||
status: true,
|
||||
}
|
||||
})
|
||||
|
||||
// 手动执行工作流
|
||||
export const executeWorkflow = Mock.mock(/\/workflow\/execute_workflow/, 'post', () => ({
|
||||
code: 0,
|
||||
count: 0,
|
||||
data: null,
|
||||
message: '执行成功',
|
||||
status: true,
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user