2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 06:47:20 +08:00

fix: 部分接口修改

This commit is contained in:
耗子
2024-10-13 13:48:18 +08:00
parent 82a74a538b
commit 7677c3b50e
16 changed files with 61 additions and 54 deletions

View File

@@ -13,7 +13,7 @@ func init() {
Route: func(r chi.Router) {
service := NewService()
r.Get("/jails", service.List)
r.Post("/jails", service.Add)
r.Post("/jails", service.Create)
r.Delete("/jails", service.Delete)
r.Get("/jails/{name}", service.BanList)
r.Post("/unban", service.Unban)

View File

@@ -3,9 +3,9 @@ package fail2ban
type Add struct {
Name string `json:"name"`
Type string `json:"type"`
MaxRetry string `json:"maxretry"`
FindTime string `json:"findtime"`
BanTime string `json:"bantime"`
MaxRetry int `json:"maxretry"`
FindTime int `json:"findtime"`
BanTime int `json:"bantime"`
WebsiteName string `json:"website_name"`
WebsiteMode string `json:"website_mode"`
WebsitePath string `json:"website_path"`

View File

@@ -28,7 +28,7 @@ func NewService() *Service {
}
}
// List 所有 Fail2ban 规则
// List 所有规则
func (s *Service) List(w http.ResponseWriter, r *http.Request) {
raw, err := io.Read("/etc/fail2ban/jail.local")
if err != nil {
@@ -77,8 +77,8 @@ func (s *Service) List(w http.ResponseWriter, r *http.Request) {
})
}
// Add 添加 Fail2ban 规则
func (s *Service) Add(w http.ResponseWriter, r *http.Request) {
// Create 添加规则
func (s *Service) Create(w http.ResponseWriter, r *http.Request) {
req, err := service.Bind[Add](r)
if err != nil {
service.Error(w, http.StatusUnprocessableEntity, "%v", err)
@@ -86,9 +86,9 @@ func (s *Service) Add(w http.ResponseWriter, r *http.Request) {
}
jailName := req.Name
jailType := req.Type
jailMaxRetry := req.MaxRetry
jailFindTime := req.FindTime
jailBanTime := req.BanTime
jailMaxRetry := cast.ToString(req.MaxRetry)
jailFindTime := cast.ToString(req.FindTime)
jailBanTime := cast.ToString(req.BanTime)
jailWebsiteName := req.WebsiteName
jailWebsiteMode := req.WebsiteMode
jailWebsitePath := req.WebsitePath

View File

@@ -14,8 +14,8 @@ func init() {
service := NewService()
r.Get("/users", service.List)
r.Post("/users", service.Create)
r.Delete("/users/{name}", service.Delete)
r.Post("/users/{name}/password", service.ChangePassword)
r.Delete("/users/{username}", service.Delete)
r.Post("/users/{username}/password", service.ChangePassword)
r.Get("/port", service.GetPort)
r.Post("/port", service.UpdatePort)
},

View File

@@ -18,14 +18,14 @@ func init() {
r.Get("/config", service.GetConfig)
r.Post("/config", service.UpdateConfig)
r.Get("/processes", service.Processes)
r.Post("/processes/{name}/start", service.StartProcess)
r.Post("/processes/{name}/stop", service.StopProcess)
r.Post("/processes/{name}/restart", service.RestartProcess)
r.Get("/processes/{name}/log", service.ProcessLog)
r.Post("/processes/{name}/clearLog", service.ClearProcessLog)
r.Get("/processes/{name}", service.ProcessConfig)
r.Post("/processes/{name}", service.UpdateProcessConfig)
r.Delete("/processes/{name}", service.DeleteProcess)
r.Post("/processes/{process}/start", service.StartProcess)
r.Post("/processes/{process}/stop", service.StopProcess)
r.Post("/processes/{process}/restart", service.RestartProcess)
r.Get("/processes/{process}/log", service.ProcessLog)
r.Post("/processes/{process}/clearLog", service.ClearProcessLog)
r.Get("/processes/{process}", service.ProcessConfig)
r.Post("/processes/{process}", service.UpdateProcessConfig)
r.Delete("/processes/{process}", service.DeleteProcess)
r.Post("/processes", service.CreateProcess)
},
})

View File

@@ -5,12 +5,12 @@ type UpdateConfig struct {
}
type UpdateProcessConfig struct {
Process string `form:"config" json:"process"`
Process string `form:"process" json:"process"`
Config string `form:"config" json:"config"`
}
type ProcessName struct {
Process string `form:"config" json:"process"`
Process string `form:"process" json:"process"`
}
type CreateProcess struct {

View File

@@ -89,7 +89,7 @@ func (s *Service) GetSWAP(w http.ResponseWriter, r *http.Request) {
}
match := regexp.MustCompile(`Swap:\s+(\d+)\s+(\d+)\s+(\d+)`).FindStringSubmatch(raw)
if len(match) > 0 {
if len(match) >= 4 {
used = str.FormatBytes(cast.ToFloat64(match[2]) * 1024)
free = str.FormatBytes(cast.ToFloat64(match[3]) * 1024)
}
@@ -119,7 +119,7 @@ func (s *Service) UpdateSWAP(w http.ResponseWriter, r *http.Request) {
service.Error(w, http.StatusInternalServerError, "%v", err)
return
}
if _, err = shell.Execf(`sed -i "|^%s|d" /etc/fstab`, filepath.Join(app.Root, "swap")); err != nil {
if _, err = shell.Execf(`sed -i "\|^%s|d" /etc/fstab`, filepath.Join(app.Root, "swap")); err != nil {
service.Error(w, http.StatusInternalServerError, "%v", err)
return
}

View File

@@ -8,6 +8,7 @@ export function createViteProxy(isUseProxy = true, proxyType: ProxyType) {
const proxy: Record<string, string | ProxyOptions> = {
[proxyConfig.prefix]: {
target: proxyConfig.target,
secure: proxyConfig.secure,
changeOrigin: true,
rewrite: (path: string) => path.replace(new RegExp(`^${proxyConfig.prefix}`), '')
}

View File

@@ -4,9 +4,9 @@ import { request } from '@/utils'
export default {
// 获取配置
config: (service: string): Promise<AxiosResponse<any>> =>
request.get('/apps/frp/config', { params: { service } }),
config: (name: string): Promise<AxiosResponse<any>> =>
request.get('/apps/frp/config', { params: { name } }),
// 保存配置
saveConfig: (service: string, config: string): Promise<AxiosResponse<any>> =>
request.post('/apps/frp/config', { service, config })
saveConfig: (name: string, config: string): Promise<AxiosResponse<any>> =>
request.post('/apps/frp/config', { name, config })
}

View File

@@ -5,16 +5,16 @@ import { request } from '@/utils'
export default {
// 列表
list: (page: number, limit: number): Promise<AxiosResponse<any>> =>
request.get('/apps/pureftpd/list', { params: { page, limit } }),
request.get('/apps/pureftpd/users', { params: { page, limit } }),
// 添加
add: (username: string, password: string, path: string): Promise<AxiosResponse<any>> =>
request.post('/apps/pureftpd/add', { username, password, path }),
request.post('/apps/pureftpd/users', { username, password, path }),
// 删除
delete: (username: string): Promise<AxiosResponse<any>> =>
request.delete('/apps/pureftpd/delete', { params: { username } }),
request.delete(`/apps/pureftpd/users/${username}`),
// 修改密码
changePassword: (username: string, password: string): Promise<AxiosResponse<any>> =>
request.post('/apps/pureftpd/changePassword', { username, password }),
request.post(`/apps/pureftpd/users/${username}/password`, { password }),
// 获取端口
port: (): Promise<AxiosResponse<any>> => request.get('/apps/pureftpd/port'),
// 修改端口

View File

@@ -5,9 +5,9 @@ import { request } from '@/utils'
export default {
// 列表
list: (page: number, limit: number): Promise<AxiosResponse<any>> =>
request.get('/apps/s3fs/list', { params: { page, limit } }),
request.get('/apps/s3fs/mounts', { params: { page, limit } }),
// 添加
add: (data: any): Promise<AxiosResponse<any>> => request.post('/apps/s3fs/add', data),
add: (data: any): Promise<AxiosResponse<any>> => request.post('/apps/s3fs/mounts', data),
// 删除
delete: (id: number): Promise<AxiosResponse<any>> => request.post('/apps/s3fs/delete', { id })
delete: (id: number): Promise<AxiosResponse<any>> => request.post('/apps/s3fs/mounts', { id })
}

View File

@@ -5,8 +5,6 @@ import { request } from '@/utils'
export default {
// 服务名称
service: (): Promise<AxiosResponse<any>> => request.get('/apps/supervisor/service'),
// 负载状态
load: (): Promise<AxiosResponse<any>> => request.get('/apps/supervisor/load'),
// 获取错误日志
log: (): Promise<AxiosResponse<any>> => request.get('/apps/supervisor/log'),
// 清空错误日志
@@ -21,29 +19,29 @@ export default {
request.get('/apps/supervisor/processes', { params: { page, limit } }),
// 进程启动
startProcess: (process: string): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/startProcess', { process }),
request.post(`/apps/supervisor/processes/${process}/start`, {}),
// 进程停止
stopProcess: (process: string): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/stopProcess', { process }),
request.post(`/apps/supervisor/processes/${process}/stop`, {}),
// 进程重启
restartProcess: (process: string): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/restartProcess', { process }),
request.post(`/apps/supervisor/processes/${process}/restart`, {}),
// 进程日志
processLog: (process: string): Promise<AxiosResponse<any>> =>
request.get('/apps/supervisor/processLog', { params: { process } }),
request.get(`/apps/supervisor/processes/${process}/log`),
// 清空进程日志
clearProcessLog: (process: string): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/clearProcessLog', { process }),
request.post(`/apps/supervisor/processes/${process}/clearLog`, {}),
// 进程配置
processConfig: (process: string): Promise<AxiosResponse<any>> =>
request.get('/apps/supervisor/processConfig', { params: { process } }),
request.get(`/apps/supervisor/processes/${process}`),
// 保存进程配置
saveProcessConfig: (process: string, config: string): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/processConfig', { process, config }),
// 添加进程
addProcess: (process: any): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/addProcess', process),
request.post(`/apps/supervisor/processes/${process}`, { config }),
// 创建进程
createProcess: (process: any): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/processes', process),
// 删除进程
deleteProcess: (process: string): Promise<AxiosResponse<any>> =>
request.post('/apps/supervisor/deleteProcess', { process })
request.delete(`/apps/supervisor/processes/${process}`)
}

View File

@@ -111,14 +111,14 @@
"title": "资源监控"
},
"appIndex": {
"title": "应用市场",
"title": "应用中心",
"alerts": {
"cache": "缓存更新成功",
"warning": "升级应用前强烈建议先备份/快照,以免出现问题时无法回滚!",
"setup": "设置成功",
"install": "任务已提交,请稍后查看任务进度",
"update": "任务已提交,请前往任务中心查看任务进度",
"uninstall": "任务已提交,请前往任务中心查看任务进度"
"update": "任务已提交,请前往后台任务查看任务进度",
"uninstall": "任务已提交,请前往后台任务查看任务进度"
},
"buttons": {
"updateCache": "更新缓存",
@@ -286,7 +286,7 @@
}
},
"taskIndex": {
"title": "任务中心",
"title": "后台任务",
"alerts": {
"delete": "任务已删除"
},

View File

@@ -82,7 +82,13 @@ const handleClose = () => {
</n-form>
<n-row :gutter="[0, 24]">
<n-col :span="24">
<n-button type="info" block :loading="doSubmit" :disabled="doSubmit" @click="handleSubmit">
<n-button
type="info"
block
:loading="doSubmit"
:disabled="model.channel == null || doSubmit"
@click="handleSubmit"
>
提交
</n-button>
</n-col>

View File

@@ -291,7 +291,7 @@ const handleReload = async () => {
}
const handleAddProcess = async () => {
await supervisor.addProcess(addProcessModel.value)
await supervisor.createProcess(addProcessModel.value)
window.$message.success('添加成功')
addProcessModal.value = false
onPageChange(1)

2
web/types/env.d.ts vendored
View File

@@ -15,4 +15,6 @@ interface ProxyConfig {
prefix: string
/** 代理目标地址,后端真实接口地址 */
target: string
/** 是否校验https证书 */
secure: boolean
}