0797410eef
* 支持从项目, 本地电脑, 主站导入/引用素材. * 页面复杂, 需要足够空间, 作为资源打开时会占满右侧 * 编辑结果作为一种新的美术资源. * 新增素材按钮现在是空的实现, 临时在旁边加了一个新增UI设计的按钮 临时入口:  简化: * 组件实现了最基本的图片和文本 * 容器式布局未接入llm编辑 * 不同阶段统一维护一个状态State, 任何阶段都可以人工调整, 不设单独的步骤 * 多图的UI合并功能暂时不要求, 隐藏入口 * 因为生成工具尚未从主站迁移, 主站地图子画布未实现, 以tab栏的形式容纳素材的子画布需求搁置 * 未实现llm绑定字体功能 * 识别会替换现有UI树, 暂时不是增量的 Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/170 Co-authored-by: 王德宇 <kvtodev@outlook.com> Co-committed-by: 王德宇 <kvtodev@outlook.com>
94 lines
2.4 KiB
TypeScript
94 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import type { State } from '../src/features/ui-editor/types/State';
|
|
import { applyUiDesignSuggestions } from '../src/features/ui-editor/uiDesignSuggestions';
|
|
|
|
function state(): State {
|
|
return {
|
|
ui_trees: [],
|
|
sprite_assets: {},
|
|
font_assets: {},
|
|
ui_design_images: {
|
|
page: {
|
|
metadata: { name: '', description: '', role: null, slave_to: null },
|
|
path: 'page.png',
|
|
pixel_size: [100, 100],
|
|
pixels_per_unit: 1,
|
|
},
|
|
section: {
|
|
metadata: {
|
|
name: '已有名称',
|
|
description: '',
|
|
role: 'Section',
|
|
slave_to: null,
|
|
},
|
|
path: 'section.png',
|
|
pixel_size: [100, 100],
|
|
pixels_per_unit: 1,
|
|
},
|
|
detail: {
|
|
metadata: {
|
|
name: '',
|
|
description: '已有描述',
|
|
role: null,
|
|
slave_to: null,
|
|
},
|
|
path: 'detail.png',
|
|
pixel_size: [100, 100],
|
|
pixels_per_unit: 1,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
describe('applyUiDesignSuggestions', () => {
|
|
it('masks existing metadata and maps descendants to their owning Page', () => {
|
|
const before = state();
|
|
const after = applyUiDesignSuggestions(before, [
|
|
{
|
|
id: 'page',
|
|
name: '主页面',
|
|
description: '页面描述',
|
|
role: 'Page',
|
|
children: [
|
|
{
|
|
id: 'section',
|
|
name: '模型名称不应覆盖',
|
|
description: '页签描述',
|
|
role: 'Section',
|
|
children: [
|
|
{
|
|
id: 'detail',
|
|
name: '详情',
|
|
description: '模型描述不应覆盖',
|
|
role: 'Detail',
|
|
children: [],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
|
|
expect(after.ui_design_images.page.metadata).toEqual({
|
|
name: '主页面',
|
|
description: '页面描述',
|
|
role: 'Page',
|
|
slave_to: null,
|
|
});
|
|
expect(after.ui_design_images.section.metadata).toEqual({
|
|
name: '已有名称',
|
|
description: '页签描述',
|
|
role: 'Section',
|
|
slave_to: 'page',
|
|
});
|
|
expect(after.ui_design_images.detail.metadata).toEqual({
|
|
name: '详情',
|
|
description: '已有描述',
|
|
role: 'Detail',
|
|
slave_to: 'page',
|
|
});
|
|
expect(before.ui_design_images.page.metadata.name).toBe('');
|
|
});
|
|
});
|