mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 18:58:11 +00:00
fix: 修复 vc tip 字段没有生效的 bug
This commit is contained in:
parent
7b303b7a46
commit
28b69ae901
@ -29,6 +29,11 @@ export enum DISPLAY_TYPE {
|
|||||||
ENTRY = 'entry',
|
ENTRY = 'entry',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tip = string | {
|
||||||
|
content?: string;
|
||||||
|
url?: string;
|
||||||
|
[key: string]: string | undefined;
|
||||||
|
};
|
||||||
// from vision 5.4
|
// from vision 5.4
|
||||||
export interface OldPropConfig {
|
export interface OldPropConfig {
|
||||||
/**
|
/**
|
||||||
@ -45,10 +50,7 @@ export interface OldPropConfig {
|
|||||||
*/
|
*/
|
||||||
name: string; // =>
|
name: string; // =>
|
||||||
title?: string; // =>
|
title?: string; // =>
|
||||||
tip?: {
|
tip?: Tip;
|
||||||
content?: string;
|
|
||||||
url?: string;
|
|
||||||
};
|
|
||||||
defaultValue?: any; // => extraProps.defaultValue
|
defaultValue?: any; // => extraProps.defaultValue
|
||||||
initialValue?: any | ((value: any, defaultValue: any) => any); // => initials.initialValue
|
initialValue?: any | ((value: any, defaultValue: any) => any); // => initials.initialValue
|
||||||
initial?: (value: any, defaultValue: any) => any; // => initials.initialValue
|
initial?: (value: any, defaultValue: any) => any; // => initials.initialValue
|
||||||
@ -256,6 +258,21 @@ function formatPropValue(originalValue: any, value: any) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isTipString(tip: Tip): tip is string {
|
||||||
|
return typeof tip === 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTipAttr(tip: Tip, attrName: string, decorator: (originalValue: string) => string = v => v): string {
|
||||||
|
if (isTipString(tip)) {
|
||||||
|
return attrName === 'content' ? decorator(tip) : '';
|
||||||
|
}
|
||||||
|
return decorator(tip[attrName]!);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTipContent(tip: Tip, name: string): string {
|
||||||
|
return getTipAttr(tip, 'content', (v) => `属性:${name} | 说明:${v}`);
|
||||||
|
}
|
||||||
|
|
||||||
export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollector) {
|
export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollector) {
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
@ -301,14 +318,14 @@ export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollec
|
|||||||
if (typeof title !== 'object' || isI18nData(title) || isValidElement(title)) {
|
if (typeof title !== 'object' || isI18nData(title) || isValidElement(title)) {
|
||||||
newConfig.title = {
|
newConfig.title = {
|
||||||
label: title,
|
label: title,
|
||||||
tip: tip.content,
|
tip: getTipContent(tip, name),
|
||||||
docUrl: tip.url,
|
docUrl: getTipAttr(tip, 'url'),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
newConfig.title = {
|
newConfig.title = {
|
||||||
...(title as any),
|
...(title as any),
|
||||||
tip: tip.content,
|
tip: getTipContent(tip, name),
|
||||||
docUrl: tip.url,
|
docUrl: getTipAttr(tip, 'url'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user