diff --git a/resources/catalog.json b/resources/catalog.json index 2a428a3..02d1313 100644 --- a/resources/catalog.json +++ b/resources/catalog.json @@ -100005,7 +100005,21 @@ "placeholder": "", "description": "", "advanced": false, - "valueTypes": [] + "valueTypes": [], + "options": [ + { + "label": "内置运行浏览器", + "value": "zexplorer" + }, + { + "label": "Chrome 浏览器", + "value": "chrome" + }, + { + "label": "Edge 浏览器", + "value": "edge" + } + ] }, { "key": "url", @@ -101046,7 +101060,21 @@ "placeholder": "", "description": "选择浏览器类型", "advanced": false, - "valueTypes": [] + "valueTypes": [], + "options": [ + { + "label": "内置运行浏览器", + "value": "zexplorer" + }, + { + "label": "Chrome 浏览器", + "value": "chrome" + }, + { + "label": "Edge 浏览器", + "value": "edge" + } + ] }, { "key": "url", @@ -103389,7 +103417,21 @@ "placeholder": "", "description": "选择浏览器类型", "advanced": false, - "valueTypes": [] + "valueTypes": [], + "options": [ + { + "label": "内置运行浏览器", + "value": "zexplorer" + }, + { + "label": "Chrome 浏览器", + "value": "chrome" + }, + { + "label": "Edge 浏览器", + "value": "edge" + } + ] }, { "key": "url", @@ -106333,7 +106375,21 @@ "placeholder": "", "description": "选择浏览器类型", "advanced": false, - "valueTypes": [] + "valueTypes": [], + "options": [ + { + "label": "内置运行浏览器", + "value": "zexplorer" + }, + { + "label": "Chrome 浏览器", + "value": "chrome" + }, + { + "label": "Edge 浏览器", + "value": "edge" + } + ] }, { "key": "url", @@ -113804,4 +113860,4 @@ "slots": [] } ] -} \ No newline at end of file +} diff --git a/src/renderer/src/panels/Properties.tsx b/src/renderer/src/panels/Properties.tsx index cc28ca0..c89f9d0 100644 --- a/src/renderer/src/panels/Properties.tsx +++ b/src/renderer/src/panels/Properties.tsx @@ -46,6 +46,23 @@ function numberOr(value: unknown, fallback: number): number { return Number.isFinite(parsed) ? parsed : fallback; } +interface SelectOption { + label: string; + value: string; +} + +/** 归一化下拉/单选选项:字符串 → {label,value};当前值不在选项中时追加进去(兼容历史手填值) */ +function selectOptionsWith(field: CatalogField, rawValue: unknown): SelectOption[] { + const normalized = (field.options ?? []).map((option): SelectOption => + typeof option === "string" ? { label: option, value: option } : { label: option.label, value: option.value } + ); + const current = textOf(rawValue); + if (current && !normalized.some((option) => option.value === current)) { + normalized.unshift({ label: `${current}(当前值)`, value: current }); + } + return normalized; +} + export function Properties({ catalog, onToast }: PropertiesProps) { const [tab, setTab] = useState("props"); const flow = useEditorStore((state) => state.flow); @@ -575,22 +592,22 @@ function FieldControl({ ) : field.widget === "select" && field.options?.length ? ( ) : field.widget === "radio" && field.options?.length ? (
- {field.options.map((option) => ( + {selectOptionsWith(field, raw).map((option) => ( ))}
diff --git a/src/shared/types.ts b/src/shared/types.ts index e174e55..c570bc9 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -25,7 +25,8 @@ export interface CatalogField { description: string; advanced: boolean; valueTypes: string[]; - options?: string[]; + /** 下拉/单选选项:字符串(显示=存储值)或 { label, value }(显示与存储分离) */ + options?: Array; unit?: string; }