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 16:12:49 +08:00 committed by GitHub
parent 0d857d2f0c
commit 9ee8cc86aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 14 deletions

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 {

View file

@ -92,6 +92,7 @@ export namespace App {
multiple?: boolean;
allowCreate?: boolean;
label: Locale;
description: Locale;
}
export interface FromFieldChild extends FromField {

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 = [];

View file

@ -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 {