mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 03:07:20 +08:00
feat(php): 添加 phpinfo() 快捷按钮功能 (#1226)
* Initial plan
* feat(php): 添加 phpinfo() 快捷按钮功能
- 后端:添加 PHPInfo 服务方法调用 php -r "phpinfo();"
- 后端:添加 /environment/php/{version}/phpinfo 路由
- 前端:添加 phpinfo API 调用
- 前端:在 PHP 运行状态页面添加"查看 PHPInfo"按钮
- 前端:添加弹窗展示 phpinfo 输出内容
- 添加中英文及繁体中文翻译
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
* fix: 添加 phpinfo 请求的错误处理
添加错误回调函数,在请求失败时关闭弹窗并显示错误提示
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
* fix: 使用 php-cgi 输出 HTML 格式的 phpinfo
- 后端:使用 php-cgi -q 执行 phpinfo 获取 HTML 格式输出
- 前端:使用 v-html 渲染 HTML 内容
- 前端:移除不必要的 onError 处理
- 前端:优化 phpinfo HTML 样式
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
* feat: PHP支持查看phpinfo
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
Co-authored-by: 耗子 <haozi@loli.email>
This commit is contained in:
@@ -298,6 +298,7 @@ func (route *Http) Register(r *chi.Mux) {
|
||||
r.Get("/is_installed", route.environment.IsInstalled)
|
||||
r.Route("/php", func(r chi.Router) {
|
||||
r.Post("/{version}/set_cli", route.environmentPHP.SetCli)
|
||||
r.Get("/{version}/phpinfo", route.environmentPHP.PHPInfo)
|
||||
r.Get("/{version}/config", route.environmentPHP.GetConfig)
|
||||
r.Post("/{version}/config", route.environmentPHP.UpdateConfig)
|
||||
r.Get("/{version}/fpm_config", route.environmentPHP.GetFPMConfig)
|
||||
|
||||
@@ -56,6 +56,27 @@ func (s *EnvironmentPHPService) SetCli(w http.ResponseWriter, r *http.Request) {
|
||||
Success(w, nil)
|
||||
}
|
||||
|
||||
func (s *EnvironmentPHPService) PHPInfo(w http.ResponseWriter, r *http.Request) {
|
||||
req, err := Bind[request.EnvironmentPHPVersion](r)
|
||||
if err != nil {
|
||||
Error(w, http.StatusUnprocessableEntity, "%v", err)
|
||||
return
|
||||
}
|
||||
if !s.environmentRepo.IsInstalled("php", fmt.Sprintf("%d", req.Version)) {
|
||||
Error(w, http.StatusUnprocessableEntity, s.t.Get("PHP-%d is not installed", req.Version))
|
||||
return
|
||||
}
|
||||
|
||||
// 使用 php-cgi 执行 phpinfo() 获取 HTML 格式输出
|
||||
output, err := shell.Execf("echo '<?php phpinfo();' | %s/server/php/%d/bin/php-cgi -q", app.Root, req.Version)
|
||||
if err != nil {
|
||||
Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
Success(w, output)
|
||||
}
|
||||
|
||||
func (s *EnvironmentPHPService) GetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
req, err := Bind[request.EnvironmentPHPVersion](r)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,6 +3,8 @@ import { http } from '@/utils'
|
||||
export default {
|
||||
// 设为 CLI 版本
|
||||
setCli: (slug: number): any => http.Post(`/environment/php/${slug}/set_cli`),
|
||||
// 获取 phpinfo
|
||||
phpinfo: (slug: number): any => http.Get(`/environment/php/${slug}/phpinfo`),
|
||||
// 获取配置
|
||||
config: (slug: number): any => http.Get(`/environment/php/${slug}/config`),
|
||||
// 保存配置
|
||||
|
||||
@@ -3744,6 +3744,10 @@ msgstr "Task submitted, please check progress in background tasks"
|
||||
msgid "Set as CLI Default Version"
|
||||
msgstr "Set as CLI Default Version"
|
||||
|
||||
#: src/views/environment/PHPView.vue:201
|
||||
msgid "View PHPInfo"
|
||||
msgstr "View PHPInfo"
|
||||
|
||||
#: src/views/environment/PHPView.vue:203
|
||||
msgid ""
|
||||
"This modifies the PHP %{ version } main configuration file. If you do not "
|
||||
@@ -6969,6 +6973,10 @@ msgstr ""
|
||||
msgid "Enter the default cipher suite, leave blank to reset to default"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:294
|
||||
msgid "PHPInfo"
|
||||
msgstr "PHPInfo"
|
||||
|
||||
#~ msgid "Edit - %{ file }"
|
||||
#~ msgstr "Edit - %{ file }"
|
||||
|
||||
|
||||
@@ -232,8 +232,8 @@ msgstr ""
|
||||
#: src/views/apps/rsync/IndexView.vue:177
|
||||
#: src/views/apps/supervisor/IndexView.vue:219
|
||||
#: src/views/apps/supervisor/IndexView.vue:284
|
||||
#: src/views/environment/PHPView.vue:137
|
||||
#: src/views/environment/PHPView.vue:143
|
||||
#: src/views/environment/PHPView.vue:154
|
||||
#: src/views/environment/PHPView.vue:160
|
||||
#: src/views/project/EditModal.vue:157
|
||||
#: src/views/setting/IndexView.vue:55
|
||||
#: src/views/toolbox/SystemView.vue:51
|
||||
@@ -634,7 +634,7 @@ msgstr ""
|
||||
#: src/views/apps/rsync/IndexView.vue:191
|
||||
#: src/views/apps/supervisor/IndexView.vue:298
|
||||
#: src/views/container/ContainerView.vue:102
|
||||
#: src/views/environment/PHPView.vue:175
|
||||
#: src/views/environment/PHPView.vue:192
|
||||
msgid "Running Status"
|
||||
msgstr ""
|
||||
|
||||
@@ -800,8 +800,8 @@ msgstr ""
|
||||
#: src/views/apps/redis/IndexView.vue:63
|
||||
#: src/views/apps/rsync/IndexView.vue:235
|
||||
#: src/views/apps/supervisor/IndexView.vue:342
|
||||
#: src/views/environment/PHPView.vue:212
|
||||
#: src/views/environment/PHPView.vue:230
|
||||
#: src/views/environment/PHPView.vue:232
|
||||
#: src/views/environment/PHPView.vue:250
|
||||
#: src/views/project/EditModal.vue:575
|
||||
#: src/views/setting/IndexView.vue:106
|
||||
#: src/views/task/CronView.vue:259
|
||||
@@ -1107,7 +1107,7 @@ msgstr ""
|
||||
#: src/views/database/DatabaseList.vue:101
|
||||
#: src/views/database/ServerList.vue:214
|
||||
#: src/views/database/UserList.vue:189
|
||||
#: src/views/environment/PHPView.vue:101
|
||||
#: src/views/environment/PHPView.vue:106
|
||||
#: src/views/file/ListView.vue:185
|
||||
#: src/views/file/ListView.vue:235
|
||||
#: src/views/file/ListView.vue:1355
|
||||
@@ -1411,7 +1411,7 @@ msgstr ""
|
||||
#: src/views/app/AppView.vue:152
|
||||
#: src/views/app/AppView.vue:157
|
||||
#: src/views/app/EnvironmentView.vue:145
|
||||
#: src/views/environment/PHPView.vue:74
|
||||
#: src/views/environment/PHPView.vue:79
|
||||
msgid "Install"
|
||||
msgstr ""
|
||||
|
||||
@@ -1421,7 +1421,7 @@ msgstr ""
|
||||
|
||||
#: src/views/app/AppView.vue:40
|
||||
#: src/views/app/EnvironmentView.vue:33
|
||||
#: src/views/environment/PHPView.vue:43
|
||||
#: src/views/environment/PHPView.vue:48
|
||||
#: src/views/project/EditModal.vue:188
|
||||
#: src/views/project/ListView.vue:38
|
||||
msgid "Description"
|
||||
@@ -1459,7 +1459,7 @@ msgstr ""
|
||||
#: src/views/database/DatabaseList.vue:77
|
||||
#: src/views/database/ServerList.vue:134
|
||||
#: src/views/database/UserList.vue:151
|
||||
#: src/views/environment/PHPView.vue:50
|
||||
#: src/views/environment/PHPView.vue:55
|
||||
#: src/views/file/ListView.vue:1206
|
||||
#: src/views/firewall/ForwardView.vue:79
|
||||
#: src/views/firewall/IpRuleView.vue:121
|
||||
@@ -1590,7 +1590,7 @@ msgstr ""
|
||||
#: src/views/apps/redis/IndexView.vue:78
|
||||
#: src/views/apps/rsync/IndexView.vue:240
|
||||
#: src/views/apps/supervisor/IndexView.vue:347
|
||||
#: src/views/environment/PHPView.vue:245
|
||||
#: src/views/environment/PHPView.vue:265
|
||||
msgid "Runtime Logs"
|
||||
msgstr ""
|
||||
|
||||
@@ -1798,7 +1798,7 @@ msgstr ""
|
||||
#: src/views/apps/nginx/NginxIndex.vue:130
|
||||
#: src/views/apps/postgresql/IndexView.vue:30
|
||||
#: src/views/apps/redis/IndexView.vue:24
|
||||
#: src/views/environment/PHPView.vue:115
|
||||
#: src/views/environment/PHPView.vue:120
|
||||
msgid "Property"
|
||||
msgstr ""
|
||||
|
||||
@@ -1807,7 +1807,7 @@ msgstr ""
|
||||
#: src/views/apps/nginx/NginxIndex.vue:137
|
||||
#: src/views/apps/postgresql/IndexView.vue:37
|
||||
#: src/views/apps/redis/IndexView.vue:31
|
||||
#: src/views/environment/PHPView.vue:122
|
||||
#: src/views/environment/PHPView.vue:127
|
||||
msgid "Current Value"
|
||||
msgstr ""
|
||||
|
||||
@@ -1820,7 +1820,7 @@ msgstr ""
|
||||
#: src/views/apps/nginx/NginxIndex.vue:535
|
||||
#: src/views/apps/postgresql/IndexView.vue:100
|
||||
#: src/views/apps/redis/IndexView.vue:68
|
||||
#: src/views/environment/PHPView.vue:235
|
||||
#: src/views/environment/PHPView.vue:255
|
||||
#: src/views/home/IndexView.vue:488
|
||||
msgid "Load Status"
|
||||
msgstr ""
|
||||
@@ -1843,8 +1843,8 @@ msgstr ""
|
||||
#: src/views/apps/nginx/NginxIndex.vue:329
|
||||
#: src/views/apps/postgresql/IndexView.vue:56
|
||||
#: src/views/apps/supervisor/IndexView.vue:225
|
||||
#: src/views/environment/PHPView.vue:149
|
||||
#: src/views/environment/PHPView.vue:155
|
||||
#: src/views/environment/PHPView.vue:166
|
||||
#: src/views/environment/PHPView.vue:172
|
||||
#: src/views/website/EditView.vue:160
|
||||
msgid "Cleared successfully"
|
||||
msgstr ""
|
||||
@@ -1910,7 +1910,7 @@ msgstr ""
|
||||
#: src/views/apps/nginx/NginxIndex.vue:552
|
||||
#: src/views/apps/postgresql/IndexView.vue:114
|
||||
#: src/views/apps/supervisor/IndexView.vue:354
|
||||
#: src/views/environment/PHPView.vue:252
|
||||
#: src/views/environment/PHPView.vue:272
|
||||
msgid "Clear Log"
|
||||
msgstr ""
|
||||
|
||||
@@ -1919,7 +1919,7 @@ msgid "Slow Query Log"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/apps/mysql/MysqlIndex.vue:134
|
||||
#: src/views/environment/PHPView.vue:262
|
||||
#: src/views/environment/PHPView.vue:282
|
||||
msgid "Clear Slow Log"
|
||||
msgstr ""
|
||||
|
||||
@@ -2042,7 +2042,7 @@ msgid "Add Upstream"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/apps/nginx/NginxIndex.vue:548
|
||||
#: src/views/environment/PHPView.vue:248
|
||||
#: src/views/environment/PHPView.vue:268
|
||||
msgid "Error Logs"
|
||||
msgstr ""
|
||||
|
||||
@@ -2202,7 +2202,7 @@ msgstr ""
|
||||
#: src/views/apps/redis/IndexView.vue:51
|
||||
#: src/views/apps/rsync/IndexView.vue:223
|
||||
#: src/views/apps/supervisor/IndexView.vue:330
|
||||
#: src/views/environment/PHPView.vue:199
|
||||
#: src/views/environment/PHPView.vue:219
|
||||
msgid "Main Configuration"
|
||||
msgstr ""
|
||||
|
||||
@@ -2219,7 +2219,7 @@ msgid "This modifies the PostgreSQL user configuration file. If you do not under
|
||||
msgstr ""
|
||||
|
||||
#: src/views/apps/postgresql/IndexView.vue:120
|
||||
#: src/views/environment/PHPView.vue:258
|
||||
#: src/views/environment/PHPView.vue:278
|
||||
msgid "Slow Logs"
|
||||
msgstr ""
|
||||
|
||||
@@ -2365,7 +2365,7 @@ msgid "Are you sure you want to delete module %{ name }?"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/apps/rsync/IndexView.vue:194
|
||||
#: src/views/environment/PHPView.vue:186
|
||||
#: src/views/environment/PHPView.vue:206
|
||||
msgid "Module Management"
|
||||
msgstr ""
|
||||
|
||||
@@ -3831,43 +3831,51 @@ msgstr ""
|
||||
msgid "Are you sure you want to delete the user?"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:36
|
||||
#: src/views/environment/PHPView.vue:41
|
||||
msgid "Module Name"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:64
|
||||
#: src/views/environment/PHPView.vue:69
|
||||
msgid "Are you sure you want to install %{ name }?"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:89
|
||||
#: src/views/environment/PHPView.vue:94
|
||||
msgid "Are you sure you want to uninstall %{ name }?"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:131
|
||||
#: src/views/environment/PHPView.vue:136
|
||||
msgid "Set successfully"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:161
|
||||
#: src/views/environment/PHPView.vue:167
|
||||
#: src/views/environment/PHPView.vue:178
|
||||
#: src/views/environment/PHPView.vue:184
|
||||
msgid "Task submitted, please check progress in background tasks"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:181
|
||||
#: src/views/environment/PHPView.vue:198
|
||||
msgid "Set as CLI Default Version"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:203
|
||||
#: src/views/environment/PHPView.vue:201
|
||||
msgid "View PHPInfo"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:223
|
||||
msgid "This modifies the PHP %{ version } main configuration file. If you do not understand the meaning of each parameter, please do not modify it randomly!"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:217
|
||||
#: src/views/environment/PHPView.vue:237
|
||||
msgid "FPM Configuration"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:221
|
||||
#: src/views/environment/PHPView.vue:241
|
||||
msgid "This modifies the PHP %{ version } FPM configuration file. If you do not understand the meaning of each parameter, please do not modify it randomly!"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:294
|
||||
msgid "PHPInfo"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/error-page/NotFound.vue:11
|
||||
msgid "Sorry, the page you visited does not exist."
|
||||
msgstr ""
|
||||
|
||||
@@ -3866,6 +3866,10 @@ msgstr "任务已提交,请在后台任务中查看进度"
|
||||
msgid "Set as CLI Default Version"
|
||||
msgstr "设置为 CLI 默认版本"
|
||||
|
||||
#: src/views/environment/PHPView.vue:201
|
||||
msgid "View PHPInfo"
|
||||
msgstr "查看 PHPInfo"
|
||||
|
||||
#: src/views/environment/PHPView.vue:203
|
||||
msgid "This modifies the PHP %{ version } main configuration file. If you do not understand the meaning of each parameter, please do not modify it randomly!"
|
||||
msgstr "这将修改 PHP %{ version } 的主配置文件。如果您不了解每个参数的含义,请不要随意修改!"
|
||||
@@ -6943,3 +6947,7 @@ msgstr "默认密码套件"
|
||||
msgid "Enter the default cipher suite, leave blank to reset to default"
|
||||
msgstr "输入默认密码套件,留空以重置为默认值"
|
||||
|
||||
#: src/views/environment/PHPView.vue:294
|
||||
msgid "PHPInfo"
|
||||
msgstr "PHPInfo"
|
||||
|
||||
|
||||
@@ -3866,6 +3866,10 @@ msgstr "任務已提交,請在後台任務中查看進度"
|
||||
msgid "Set as CLI Default Version"
|
||||
msgstr "設置為 CLI 默認版本"
|
||||
|
||||
#: src/views/environment/PHPView.vue:201
|
||||
msgid "View PHPInfo"
|
||||
msgstr "查看 PHPInfo"
|
||||
|
||||
#: src/views/environment/PHPView.vue:203
|
||||
msgid "This modifies the PHP %{ version } main configuration file. If you do not understand the meaning of each parameter, please do not modify it randomly!"
|
||||
msgstr "這將修改 PHP %{ version } 的主配置文件。如果您不了解每個參數的含義,請不要隨意修改!"
|
||||
@@ -6943,3 +6947,7 @@ msgstr ""
|
||||
msgid "Enter the default cipher suite, leave blank to reset to default"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/environment/PHPView.vue:294
|
||||
msgid "PHPInfo"
|
||||
msgstr "PHPInfo"
|
||||
|
||||
|
||||
@@ -12,6 +12,11 @@ const { $gettext } = useGettext()
|
||||
|
||||
const currentTab = ref('status')
|
||||
|
||||
// phpinfo 相关状态
|
||||
const showPHPInfoModal = ref(false)
|
||||
const phpinfoContent = ref('')
|
||||
const phpinfoLoading = ref(false)
|
||||
|
||||
const { data: config } = useRequest(php.config(slug), {
|
||||
initialData: ''
|
||||
})
|
||||
@@ -132,6 +137,18 @@ const handleSetCli = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handlePHPInfo = async () => {
|
||||
phpinfoLoading.value = true
|
||||
showPHPInfoModal.value = true
|
||||
useRequest(php.phpinfo(slug))
|
||||
.onSuccess((res) => {
|
||||
phpinfoContent.value = res.data
|
||||
})
|
||||
.onComplete(() => {
|
||||
phpinfoLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const handleSaveConfig = async () => {
|
||||
useRequest(php.saveConfig(slug, config.value)).onSuccess(() => {
|
||||
window.$message.success($gettext('Saved successfully'))
|
||||
@@ -180,6 +197,9 @@ const handleUninstallModule = async (module: string) => {
|
||||
<n-button type="info" @click="handleSetCli">
|
||||
{{ $gettext('Set as CLI Default Version') }}
|
||||
</n-button>
|
||||
<n-button type="primary" @click="handlePHPInfo">
|
||||
{{ $gettext('View PHPInfo') }}
|
||||
</n-button>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</n-tab-pane>
|
||||
@@ -266,7 +286,30 @@ const handleUninstallModule = async (module: string) => {
|
||||
</n-flex>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
|
||||
<!-- PHPInfo 弹窗 -->
|
||||
<n-modal
|
||||
v-model:show="showPHPInfoModal"
|
||||
preset="card"
|
||||
:title="$gettext('PHPInfo') + ' - PHP ' + slug"
|
||||
style="width: 90%; max-width: 1200px"
|
||||
:mask-closable="true"
|
||||
>
|
||||
<n-spin :show="phpinfoLoading">
|
||||
<n-scrollbar style="max-height: 70vh">
|
||||
<div class="phpinfo-content" v-html="phpinfoContent"></div>
|
||||
</n-scrollbar>
|
||||
</n-spin>
|
||||
</n-modal>
|
||||
</common-page>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
<style scoped lang="scss">
|
||||
.phpinfo-content {
|
||||
:deep(table) {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -25,7 +25,7 @@ const phpFrameworks = [
|
||||
const createModel = ref({
|
||||
name: '',
|
||||
type: '',
|
||||
root_dir: '/opt/ace',
|
||||
root_dir: '/opt/ace/projects',
|
||||
working_dir: '',
|
||||
exec_start: '',
|
||||
user: 'www'
|
||||
@@ -38,7 +38,7 @@ const phpOptions = ref({
|
||||
})
|
||||
|
||||
const showPathSelector = ref(false)
|
||||
const pathSelectorPath = ref('/opt/ace')
|
||||
const pathSelectorPath = ref('/opt/ace/projects')
|
||||
|
||||
const { data: installedEnvironment } = useRequest(home.installedEnvironment, {
|
||||
initialData: {
|
||||
@@ -76,7 +76,7 @@ watch(
|
||||
|
||||
// 处理目录选择
|
||||
const handleSelectPath = () => {
|
||||
pathSelectorPath.value = createModel.value.root_dir || '/opt/ace'
|
||||
pathSelectorPath.value = createModel.value.root_dir || '/opt/ace/projects'
|
||||
showPathSelector.value = true
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ const handleCreate = async () => {
|
||||
createModel.value = {
|
||||
name: '',
|
||||
type: '',
|
||||
root_dir: '/opt/ace',
|
||||
root_dir: '/opt/ace/projects',
|
||||
working_dir: '',
|
||||
exec_start: '',
|
||||
user: 'www'
|
||||
|
||||
@@ -82,7 +82,7 @@ const pathSelectorTarget = ref<'root_dir' | 'working_dir'>('root_dir')
|
||||
|
||||
const handleSelectPath = (target: 'root_dir' | 'working_dir') => {
|
||||
pathSelectorTarget.value = target
|
||||
pathSelectorPath.value = model.value[target] || '/opt/ace'
|
||||
pathSelectorPath.value = model.value[target] || '/opt/ace/projects'
|
||||
showPathSelector.value = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user