Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6648c6

Browse files
author
knight.chen
committed
fix: 修复 i18n schema 解析错误
1 parent 5e81c34 commit f6648c6

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

packages/vue-renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"main": "./dist/vue-renderer.js",
44
"module": "./dist/vue-renderer.mjs",
55
"typings": "./dist/vue-renderer.d.ts",
6-
"version": "1.6.0-beta.6",
6+
"version": "1.6.0-beta.7",
77
"keywords": [
88
"vue",
99
"lowcode",

packages/vue-renderer/src/core/use.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import {
5757
isNil,
5858
isString,
5959
isFunction,
60-
isDOMText,
6160
isJSExpression,
6261
isNodeSchema,
6362
isObject,
@@ -144,20 +143,13 @@ export type RenderComponent = (
144143
) => VNode | VNode[] | null;
145144

146145
export type SlotSchemaMap = {
147-
[x: string]: SlotSchema | NodeData | NodeData[] | undefined;
146+
[x: string]: unknown;
148147
};
149148

150149
export type PropSchemaMap = {
151150
[x: string]: unknown;
152151
};
153152

154-
export function isNodeData(val: unknown): val is NodeData | NodeData[] {
155-
if (isArray(val)) {
156-
return val.every((item) => isNodeData(item));
157-
}
158-
return isDOMText(val) || isNodeSchema(val) || isJSExpression(val);
159-
}
160-
161153
export function isVueComponent(val: unknown): val is Component {
162154
if (isFunction(val)) return true;
163155
if (isObject(val) && ('render' in val || 'setup' in val)) {
@@ -238,11 +230,8 @@ export function useLeaf(
238230
// 若 schema 不为 NodeSchema,则直接渲染
239231
if (isString(schema)) {
240232
return createTextVNode(schema);
241-
} else if (isJSExpression(schema)) {
242-
const result = parser.parseExpression(schema, scope);
243-
return createTextVNode(toDisplayString(result));
244-
} else if (isI18nData(schema)) {
245-
const result = parser.parseI18n(schema, scope);
233+
} else if (!isNodeSchema(schema)) {
234+
const result = parser.parseSchema(schema, scope);
246235
return createTextVNode(toDisplayString(result));
247236
}
248237

@@ -422,7 +411,7 @@ export function useLeaf(
422411
};
423412
}
424413
} else {
425-
renderSlot = () => ensureArray(renderComp(slotSchema, blockScope));
414+
renderSlot = () => ensureArray(renderComp(slotSchema as NodeData, blockScope));
426415
}
427416

428417
prev[next] =
@@ -451,6 +440,8 @@ export function useLeaf(
451440
if (isJSExpression(schema) || isJSFunction(schema)) {
452441
// 处理表达式和函数
453442
return parser.parseExpression(schema, scope);
443+
} else if (isI18nData(schema)) {
444+
return parser.parseI18n(schema, scope);
454445
} else if (isJSSlot(schema)) {
455446
// 处理属性插槽
456447
let slotParams: string[];
@@ -832,9 +823,9 @@ export const buildSchema = (schema: NodeSchema, node?: Node | null) => {
832823
} else if (key === 'className') {
833824
// 适配 react className
834825
normalProps.class = val;
835-
} else if (key === 'children' && isNodeData(val)) {
826+
} else if (key === 'children') {
836827
// 处理属性中的默认插槽,属性的重默认插槽会覆盖节点 chilren 插槽
837-
slotProps.default = ensureArray(val);
828+
slotProps.default = val;
838829
} else {
839830
// 处理普通属性
840831
normalProps[key] = val;

packages/vue-simulator-renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"main": "./dist/vue-simulator-renderer.js",
44
"module": "./dist/vue-simulator-renderer.mjs",
55
"typings": "./dist/vue-simulator-renderer.d.ts",
6-
"version": "1.6.0-beta.6",
6+
"version": "1.6.0-beta.7",
77
"keywords": [
88
"vue",
99
"lowcode",

packages/vue-simulator-renderer/src/simulator-view.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ export const Renderer = defineComponent({
5858
const { schema, scope, messages } = documentInstance;
5959
const { designMode, device, locale, components } = simulator;
6060

61-
if (!simulator.autoRender) return null;
62-
6361
return h(Suspense, null, {
6462
default: () =>
6563
h(LowCodeRenderer, {

packages/vue-simulator-renderer/src/simulator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ function createSimulatorRenderer() {
257257
config: markRaw(config),
258258
layout,
259259
device,
260+
locale,
260261
designMode,
261262
libraryMap,
262263
components,

0 commit comments

Comments
 (0)