mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
feat: php支持设置为cli默认版本
This commit is contained in:
@@ -16,11 +16,12 @@ func init() {
|
||||
Slug: fmt.Sprintf("php%d", version),
|
||||
Route: func(r chi.Router) {
|
||||
service := NewService(version)
|
||||
r.Get("/load", service.Load)
|
||||
r.Post("/setCli", service.SetCli)
|
||||
r.Get("/config", service.GetConfig)
|
||||
r.Post("/config", service.UpdateConfig)
|
||||
r.Get("/fpmConfig", service.GetFPMConfig)
|
||||
r.Post("/fpmConfig", service.UpdateFPMConfig)
|
||||
r.Get("/load", service.Load)
|
||||
r.Get("/errorLog", service.ErrorLog)
|
||||
r.Get("/slowLog", service.SlowLog)
|
||||
r.Post("/clearErrorLog", service.ClearErrorLog)
|
||||
|
||||
@@ -33,6 +33,15 @@ func NewService(version uint) *Service {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) SetCli(w http.ResponseWriter, r *http.Request) {
|
||||
if _, err := shell.Execf("ln -sf %s/server/php/%d/bin/php /usr/bin/php", app.Root, s.version); err != nil {
|
||||
service.Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
service.Success(w, nil)
|
||||
}
|
||||
|
||||
func (s *Service) GetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
config, err := io.Read(fmt.Sprintf("%s/server/php/%d/etc/php.ini", app.Root, s.version))
|
||||
if err != nil {
|
||||
|
||||
@@ -3,8 +3,9 @@ import type { AxiosResponse } from 'axios'
|
||||
import { request } from '@/utils'
|
||||
|
||||
export default {
|
||||
// 负载状态
|
||||
load: (version: number): Promise<AxiosResponse<any>> => request.get(`/apps/php${version}/load`),
|
||||
// 设为 CLI 版本
|
||||
setCli: (version: number): Promise<AxiosResponse<any>> =>
|
||||
request.post(`/apps/php${version}/setCli`),
|
||||
// 获取配置
|
||||
config: (version: number): Promise<AxiosResponse<any>> =>
|
||||
request.get(`/apps/php${version}/config`),
|
||||
@@ -17,6 +18,8 @@ export default {
|
||||
// 保存FPM配置
|
||||
saveFPMConfig: (version: number, config: string): Promise<AxiosResponse<any>> =>
|
||||
request.post(`/apps/php${version}/fpmConfig`, { config }),
|
||||
// 负载状态
|
||||
load: (version: number): Promise<AxiosResponse<any>> => request.get(`/apps/php${version}/load`),
|
||||
// 获取错误日志
|
||||
errorLog: (version: number): Promise<AxiosResponse<any>> =>
|
||||
request.get(`/apps/php${version}/errorLog`),
|
||||
|
||||
@@ -175,6 +175,11 @@ const getFPMConfig = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleSetCli = async () => {
|
||||
await php.setCli(version.value)
|
||||
window.$message.success('设置成功')
|
||||
}
|
||||
|
||||
const handleSaveConfig = async () => {
|
||||
await php.saveConfig(version.value, config.value)
|
||||
window.$message.success('保存成功')
|
||||
@@ -262,6 +267,9 @@ onMounted(() => {
|
||||
<template>
|
||||
<common-page show-footer>
|
||||
<template #action>
|
||||
<n-button v-if="currentTab == 'status'" class="ml-16" type="info" @click="handleSetCli">
|
||||
设为 CLI 默认版本
|
||||
</n-button>
|
||||
<n-button
|
||||
v-if="currentTab == 'config'"
|
||||
class="ml-16"
|
||||
|
||||
Reference in New Issue
Block a user