2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 09:13:49 +08:00

fix: website save

This commit is contained in:
耗子
2024-10-11 02:56:28 +08:00
parent ac6c57b394
commit 07bb0961da
6 changed files with 31 additions and 11 deletions

View File

@@ -69,7 +69,7 @@ func (r *websiteRepo) Get(id uint) (*types.WebsiteSetting, error) {
setting.Name = website.Name
setting.Path = website.Path
setting.SSL = website.SSL
setting.PHP = strconv.Itoa(website.PHP)
setting.PHP = website.PHP
setting.Raw = config
portStr := str.Cut(config, "# port标记位开始", "# port标记位结束")

View File

@@ -2,6 +2,7 @@ package service
import (
"fmt"
"github.com/spf13/cast"
"net/http"
"regexp"
"strings"
@@ -173,9 +174,9 @@ func (s *InfoService) InstalledDbAndPhp(w http.ResponseWriter, r *http.Request)
postgresqlInstalled, _ := s.appRepo.IsInstalled("slug like ?", "postgresql%")
php, _ := s.appRepo.GetInstalledAll("slug like ?", "php%")
var phpData []types.LV
var phpData []types.LVInt
var dbData []types.LV
phpData = append(phpData, types.LV{Value: "0", Label: "不使用"})
phpData = append(phpData, types.LVInt{Value: 0, Label: "不使用"})
dbData = append(dbData, types.LV{Value: "0", Label: "不使用"})
for _, p := range php {
// 过滤 phpmyadmin
@@ -184,8 +185,8 @@ func (s *InfoService) InstalledDbAndPhp(w http.ResponseWriter, r *http.Request)
continue
}
app, _ := s.appRepo.Get(p.Slug)
phpData = append(phpData, types.LV{Value: strings.ReplaceAll(p.Slug, "php", ""), Label: app.Name})
item, _ := s.appRepo.Get(p.Slug)
phpData = append(phpData, types.LVInt{Value: cast.ToInt(strings.ReplaceAll(p.Slug, "php", "")), Label: item.Name})
}
if mysqlInstalled {

View File

@@ -15,6 +15,11 @@ type LV struct {
Value string `json:"value"`
}
type LVInt struct {
Label string `json:"label"`
Value int `json:"value"`
}
// KVToMap 将 key-value 切片转换为 map
func KVToMap(kvs []KV) map[string]string {
m := make(map[string]string)

View File

@@ -10,7 +10,7 @@ type WebsiteSetting struct {
Root string `json:"root"`
Path string `json:"path"`
Index string `json:"index"`
PHP string `json:"php"`
PHP int `json:"php"`
OpenBasedir bool `json:"open_basedir"`
SSL bool `json:"ssl"`
SSLCertificate string `json:"ssl_certificate"`

View File

@@ -38,8 +38,8 @@ const setting = ref<WebsiteSetting>({
const installedDbAndPhp = ref({
php: [
{
label: '',
value: ''
label: '不使用',
value: 0
}
],
db: [
@@ -131,7 +131,13 @@ onMounted(() => {
<n-form-item label="端口">
<n-dynamic-input v-model:value="setting.ports" show-sort-button>
<template #default="{ index }">
<n-input-number v-model:value="setting.ports[index]" :min="1" :max="65535" />
<n-input-number
v-model:value="setting.ports[index]"
:min="1"
:max="65535"
clearable
w-full
/>
</template>
</n-dynamic-input>
</n-form-item>
@@ -155,7 +161,7 @@ onMounted(() => {
<n-form-item label="PHP版本">
<n-select
v-model:value="setting.php"
default-value="0"
:default-value="0"
:options="installedDbAndPhp.php"
placeholder="选择PHP版本"
@keydown.enter.prevent

View File

@@ -450,7 +450,15 @@ onMounted(() => {
<n-form-item :label="$t('websiteIndex.create.fields.port.label')">
<n-dynamic-input v-model:value="addModel.ports" show-sort-button>
<template #default="{ index }">
<n-input-number v-model:value="addModel.ports[index]" :min="1" :max="65535" />
<div style="display: flex; align-items: center; width: 100%">
<n-input-number
v-model:value="addModel.ports[index]"
:min="1"
:max="65535"
clearable
w-full
/>
</div>
</template>
</n-dynamic-input>
</n-form-item>