From 06d4ada7c2d38b8dbf5feb830af1bf80008c40f8 Mon Sep 17 00:00:00 2001 From: "Mr.Z" Date: Thu, 14 Jul 2022 05:40:09 +0800 Subject: [PATCH] feat: assist todo --- packages/assist/examples/basic.vue | 90 ++++++++++- .../assist/examples/modules/array/editor.vue | 27 ++++ .../assist/examples/modules/array/root.jsx | 50 ++++++ .../assist/examples/modules/array/viewer.vue | 32 ++++ .../assist/examples/modules/page/editor.vue | 30 ++++ packages/assist/examples/modules/page/root.js | 35 +++++ .../assist/examples/modules/page/viewer.vue | 143 ++++++++++++++++++ packages/assist/examples/modules/root.js | 12 ++ .../assist/examples/modules/tpl/editor.vue | 33 ++++ packages/assist/examples/modules/tpl/root.js | 40 +++++ .../assist/examples/modules/tpl/viewer.vue | 32 ++++ 11 files changed, 522 insertions(+), 2 deletions(-) create mode 100755 packages/assist/examples/modules/array/editor.vue create mode 100755 packages/assist/examples/modules/array/root.jsx create mode 100755 packages/assist/examples/modules/array/viewer.vue create mode 100755 packages/assist/examples/modules/page/editor.vue create mode 100755 packages/assist/examples/modules/page/root.js create mode 100755 packages/assist/examples/modules/page/viewer.vue create mode 100755 packages/assist/examples/modules/root.js create mode 100755 packages/assist/examples/modules/tpl/editor.vue create mode 100755 packages/assist/examples/modules/tpl/root.js create mode 100755 packages/assist/examples/modules/tpl/viewer.vue diff --git a/packages/assist/examples/basic.vue b/packages/assist/examples/basic.vue index a1b7659..e7539bf 100644 --- a/packages/assist/examples/basic.vue +++ b/packages/assist/examples/basic.vue @@ -1,9 +1,95 @@ - diff --git a/packages/assist/examples/modules/array/root.jsx b/packages/assist/examples/modules/array/root.jsx new file mode 100755 index 0000000..40575b6 --- /dev/null +++ b/packages/assist/examples/modules/array/root.jsx @@ -0,0 +1,50 @@ + +import Viewer from './viewer.vue'; +import Editor from './editor.vue'; + +export const array = { + module: "array", + type: '营销', + name: "数组模版", + widgets: [ + // 写法一 + { + render() { + return ( +
一行两列
+ ); + } + }, + // 写法二 + { + name: '一行两列', + image: 'https://avatars3.githubusercontent.com/u/34465004?s=200&v=4', + } + ], + Viewer, + Editor, + // 初始数据 + data: (index) => ({ + // for draggable + w: 200, + h: 150, + r: 0, + x: 0, // 动态分配 + y: 0, // 动态分配 + z: 1, + parent: false, + // for frame + closeable: true, + + // for content + name: `名称${index}` + }), + dataValidity: (res = {}) => { + if (!res.name) { + return { + error: "输入框内容必填" + }; + } + return null; + } +}; \ No newline at end of file diff --git a/packages/assist/examples/modules/array/viewer.vue b/packages/assist/examples/modules/array/viewer.vue new file mode 100755 index 0000000..5585118 --- /dev/null +++ b/packages/assist/examples/modules/array/viewer.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/packages/assist/examples/modules/page/editor.vue b/packages/assist/examples/modules/page/editor.vue new file mode 100755 index 0000000..8c89db8 --- /dev/null +++ b/packages/assist/examples/modules/page/editor.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/packages/assist/examples/modules/page/root.js b/packages/assist/examples/modules/page/root.js new file mode 100755 index 0000000..ee5f116 --- /dev/null +++ b/packages/assist/examples/modules/page/root.js @@ -0,0 +1,35 @@ +import Viewer from './viewer.vue'; +import Editor from './editor.vue'; + +export const page = { + module: "page", + Viewer, + Editor, + // 初始数据 + data: { + name: '', + + w: window.screen.width, + h: window.screen.height, + parent: false, // 不能超过父级 + // handles: [], // 可以控制操作handles + draggable: false, // 可以拖拽 + rotatable: false, // 可以旋转 + resizable: false, // 可以变化 + // for frame + closeable: false, + active: false, + + dragProps: { + + } + }, + dataValidity: (res = {}) => { + if (!res.w && !res.h) { + return { + error: "输入框内容必填" + }; + } + return null; + } +}; \ No newline at end of file diff --git a/packages/assist/examples/modules/page/viewer.vue b/packages/assist/examples/modules/page/viewer.vue new file mode 100755 index 0000000..524d0ed --- /dev/null +++ b/packages/assist/examples/modules/page/viewer.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/packages/assist/examples/modules/root.js b/packages/assist/examples/modules/root.js new file mode 100755 index 0000000..38d2a38 --- /dev/null +++ b/packages/assist/examples/modules/root.js @@ -0,0 +1,12 @@ +/** + * roots + */ +import { tpl } from './tpl/root'; +import { array } from './array/root'; +import { page } from './page/root'; + +export const defaultModules = [ + tpl, + array, + page +]; diff --git a/packages/assist/examples/modules/tpl/editor.vue b/packages/assist/examples/modules/tpl/editor.vue new file mode 100755 index 0000000..e9ce559 --- /dev/null +++ b/packages/assist/examples/modules/tpl/editor.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/packages/assist/examples/modules/tpl/root.js b/packages/assist/examples/modules/tpl/root.js new file mode 100755 index 0000000..47aba69 --- /dev/null +++ b/packages/assist/examples/modules/tpl/root.js @@ -0,0 +1,40 @@ + +import Viewer from './viewer.vue'; +import Editor from './editor.vue'; + +export const tpl = { + module: "tpl", + type: '基础', + name: "模版", + Viewer, + Editor, + // 初始数据 + data: { + // for draggable + w: 200, + h: 200, + r: 0, + x: 0, // 动态分配 + y: 0, // 动态分配 + z: 1, + parent: true, // 不能超过父级 + // handles: [], // 可以控制操作handles + draggable: true, // 可以拖拽 + rotatable: true, // 可以旋转 + resizable: true, // 可以变化 + // for frame + closeable: true, + active: false, + + // for content + name: '名称' + }, + dataValidity: (res = {}) => { + if (!res.name) { + return { + error: "输入框内容必填" + }; + } + return null; + } +}; \ No newline at end of file diff --git a/packages/assist/examples/modules/tpl/viewer.vue b/packages/assist/examples/modules/tpl/viewer.vue new file mode 100755 index 0000000..3aafdc9 --- /dev/null +++ b/packages/assist/examples/modules/tpl/viewer.vue @@ -0,0 +1,32 @@ + + +