feat: Applications support setting a description field. (#8437)

Refs https://github.com/1Panel-dev/1Panel/issues/7065
This commit is contained in:
ChengPlay
2025-04-21 08:12:49 +00:00
committed by GitHub
parent 0d857d2f0c
commit 9ee8cc86aa
4 changed files with 26 additions and 14 deletions
+14 -13
View File
@@ -132,19 +132,20 @@ type AppForm struct {
}
type AppFormFields struct {
Type string `json:"type"`
LabelZh string `json:"labelZh"`
LabelEn string `json:"labelEn"`
Label Locale `json:"label"`
Required bool `json:"required"`
Default interface{} `json:"default"`
EnvKey string `json:"envKey"`
Disabled bool `json:"disabled"`
Edit bool `json:"edit"`
Rule string `json:"rule"`
Multiple bool `json:"multiple"`
Child interface{} `json:"child"`
Values []AppFormValue `json:"values"`
Type string `json:"type"`
LabelZh string `json:"labelZh"`
LabelEn string `json:"labelEn"`
Label Locale `json:"label"`
Description Locale `json:"description"`
Required bool `json:"required"`
Default interface{} `json:"default"`
EnvKey string `json:"envKey"`
Disabled bool `json:"disabled"`
Edit bool `json:"edit"`
Rule string `json:"rule"`
Multiple bool `json:"multiple"`
Child interface{} `json:"child"`
Values []AppFormValue `json:"values"`
}
type AppFormValue struct {
+1
View File
@@ -92,6 +92,7 @@ export namespace App {
multiple?: boolean;
allowCreate?: boolean;
label: Locale;
description: Locale;
}
export interface FromFieldChild extends FromField {
+9
View File
@@ -666,6 +666,15 @@ export function getLabel(row: any) {
}
}
export function getDescription(row: any) {
const language = localStorage.getItem('lang') || 'zh';
let lang = language == 'tw' ? 'zh-Hant' : language;
if (row.description && row.description[lang] != '') {
return row.description[lang];
}
return '';
}
export function emptyLineFilter(str: string, spilt: string) {
let list = str.split(spilt);
let results = [];
@@ -116,6 +116,7 @@
</span>
</el-col>
</el-row>
<span class="input-help" v-if="p.description">{{ getDescription(p) }}</span>
</el-form-item>
</div>
</template>
@@ -125,7 +126,7 @@ import { getRandomStr } from '@/utils/util';
import { getAppService } from '@/api/modules/app';
import { Rules } from '@/global/form-rules';
import { App } from '@/api/interface/app';
import { getDBName, getLabel } from '@/utils/util';
import { getDBName, getLabel, getDescription } from '@/utils/util';
import { getPathByType } from '@/api/modules/files';
interface ParamObj extends App.FromField {