mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 14:57:16 +08:00
fix: 修复一些问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -36,7 +37,18 @@ func (r *templateRepo) List() (api.Templates, error) {
|
||||
|
||||
// Get 获取模版详情
|
||||
func (r *templateRepo) Get(slug string) (*api.Template, error) {
|
||||
return r.api.TemplateBySlug(slug)
|
||||
templates, err := r.api.Templates()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, t := range *templates {
|
||||
if t.Slug == slug {
|
||||
return t, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("template %s not found", slug)
|
||||
}
|
||||
|
||||
// Callback 模版下载回调
|
||||
|
||||
@@ -16,10 +16,11 @@ type Template struct {
|
||||
Version string `json:"version"`
|
||||
Compose string `json:"compose"`
|
||||
Environments []struct {
|
||||
Name string `json:"name"` // 变量名
|
||||
Type string `json:"type"` // 变量类型, text, password, number, port, select
|
||||
Options map[string]string `json:"options,omitempty"` // 下拉框选项,key -> value
|
||||
Default string `json:"default"` // 默认值
|
||||
Name string `json:"name"` // 变量名
|
||||
Description string `json:"description"` // 变量描述
|
||||
Type string `json:"type"` // 变量类型, text, password, number, port, select
|
||||
Options map[string]string `json:"options,omitempty"` // 下拉框选项,key -> value
|
||||
Default string `json:"default"` // 默认值
|
||||
} `json:"environments"`
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ const deployModel = reactive({
|
||||
name: '',
|
||||
autoStart: true,
|
||||
autoFirewall: false,
|
||||
envs: {} as Record<string, string>
|
||||
envs: {} as Record<string, any>
|
||||
})
|
||||
|
||||
// 初始化环境变量默认值
|
||||
@@ -41,19 +41,6 @@ const initEnvDefaults = () => {
|
||||
deployModel.envs = envs
|
||||
}
|
||||
|
||||
// 根据类型渲染环境变量输入组件
|
||||
const getEnvInputType = (env: TemplateEnvironment) => {
|
||||
switch (env.type) {
|
||||
case 'password':
|
||||
return 'password'
|
||||
case 'number':
|
||||
case 'port':
|
||||
return 'number'
|
||||
default:
|
||||
return 'text'
|
||||
}
|
||||
}
|
||||
|
||||
// 获取 select 选项
|
||||
const getSelectOptions = (env: TemplateEnvironment) => {
|
||||
if (!env.options) return []
|
||||
@@ -189,7 +176,11 @@ watch(
|
||||
:tab="$gettext('Environment Variables')"
|
||||
>
|
||||
<n-form :model="deployModel" label-placement="left" label-width="160">
|
||||
<n-form-item v-for="env in template.environments" :key="env.name" :label="env.name">
|
||||
<n-form-item
|
||||
v-for="env in template.environments"
|
||||
:key="env.name"
|
||||
:label="env.description"
|
||||
>
|
||||
<!-- Select 类型 -->
|
||||
<n-select
|
||||
v-if="env.type === 'select'"
|
||||
@@ -218,7 +209,6 @@ watch(
|
||||
<n-input
|
||||
v-else
|
||||
v-model:value="deployModel.envs[env.name]"
|
||||
:type="getEnvInputType(env)"
|
||||
:placeholder="env.default || ''"
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
@@ -20,6 +20,7 @@ export interface Channel {
|
||||
|
||||
export interface TemplateEnvironment {
|
||||
name: string
|
||||
description: string
|
||||
type: 'text' | 'password' | 'number' | 'port' | 'select'
|
||||
options?: Record<string, string>
|
||||
default: string
|
||||
|
||||
Reference in New Issue
Block a user