添加属性编辑器
This commit is contained in:
1
components.d.ts
vendored
1
components.d.ts
vendored
@ -13,6 +13,7 @@ declare module 'vue' {
|
|||||||
MainView: typeof import('./src/components/MainView.vue')['default']
|
MainView: typeof import('./src/components/MainView.vue')['default']
|
||||||
NestedDirective: typeof import('./src/components/NestedDirective.vue')['default']
|
NestedDirective: typeof import('./src/components/NestedDirective.vue')['default']
|
||||||
NestedFunction: typeof import('./src/components/NestedFunction.vue')['default']
|
NestedFunction: typeof import('./src/components/NestedFunction.vue')['default']
|
||||||
|
PropertyEditor: typeof import('./src/components/PropertyEditor.vue')['default']
|
||||||
TestComponent: typeof import('./src/components/TestComponent.vue')['default']
|
TestComponent: typeof import('./src/components/TestComponent.vue')['default']
|
||||||
VueDemo: typeof import('./src/components/VueDemo.vue')['default']
|
VueDemo: typeof import('./src/components/VueDemo.vue')['default']
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,9 +22,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col flex="20%">
|
<a-col flex="20%">
|
||||||
<div class="property-editor">属性编辑器</div>
|
<div class="property-editor">
|
||||||
<div>
|
<PropertyEditor :scheme="scheme"></PropertyEditor>
|
||||||
{{ store.scheme }}
|
|
||||||
</div>
|
</div>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -38,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- 测试区域 -->
|
<!-- 测试区域 -->
|
||||||
<div class="test-area">
|
<div class="test-area">
|
||||||
{{ store.scheme }}
|
<!-- {{ store.scheme }} -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -53,7 +52,9 @@ import { uuid } from 'lsp-uuid';
|
|||||||
import { IPageComponent } from '../type/IPageComponent';
|
import { IPageComponent } from '../type/IPageComponent';
|
||||||
import { componentScheme } from '../schemes/scheme';
|
import { componentScheme } from '../schemes/scheme';
|
||||||
import { useSchemeStore } from '../stores/useSchemeStore'
|
import { useSchemeStore } from '../stores/useSchemeStore'
|
||||||
|
import PropertyEditor from './PropertyEditor.vue';
|
||||||
|
|
||||||
|
const scheme = ref<any>()
|
||||||
const baseScheme =
|
const baseScheme =
|
||||||
{
|
{
|
||||||
"type": "AdaptivePage",
|
"type": "AdaptivePage",
|
||||||
@ -79,45 +80,27 @@ const list = ref<IPageComponent[]>([]);
|
|||||||
const el2 = ref();
|
const el2 = ref();
|
||||||
const store = useSchemeStore()
|
const store = useSchemeStore()
|
||||||
|
|
||||||
//初始化scheme
|
store.$onAction(
|
||||||
const initScheme = () => {
|
|
||||||
store.initScheme([baseScheme])
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsubscribe = store.$onAction(
|
|
||||||
({
|
({
|
||||||
name, // action 名称
|
name, // action 名称
|
||||||
store, // store 实例,类似 `someStore`
|
|
||||||
args, // 传递给 action 的参数数组
|
|
||||||
after, // 在 action 返回或解决后的钩子
|
after, // 在 action 返回或解决后的钩子
|
||||||
onError, // action 抛出或拒绝的钩子
|
onError, // action 抛出或拒绝的钩子
|
||||||
}) => {
|
}) => {
|
||||||
// 为这个特定的 action 调用提供一个共享变量
|
|
||||||
const startTime = Date.now()
|
|
||||||
// 这将在执行 "store "的 action 之前触发。
|
|
||||||
console.log(`Start "${name}" with params [${args.join(', ')}].`)
|
|
||||||
|
|
||||||
// 这将在 action 成功并完全运行后触发。
|
|
||||||
// 它等待着任何返回的 promise
|
|
||||||
after((result) => {
|
after((result) => {
|
||||||
console.log(
|
scheme.value = result
|
||||||
`Finished "${name}" after ${
|
|
||||||
Date.now() - startTime
|
|
||||||
}ms.\nResult: ${JSON.stringify(result) }.`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 如果 action 抛出或返回一个拒绝的 promise,这将触发
|
// 如果 action 抛出或返回一个拒绝的 promise,这将触发
|
||||||
onError((error) => {
|
onError((error) => {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Failed "${name}" after ${Date.now() - startTime}ms.\nError: ${error}.`
|
`Failed "${name}" after\nError: ${error}.`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
//初始化scheme
|
||||||
// 手动删除监听器
|
const initScheme = () => {
|
||||||
// unsubscribe()
|
store.initScheme([baseScheme])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
21
src/components/PropertyEditor.vue
Normal file
21
src/components/PropertyEditor.vue
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<a-radio-group type="button">
|
||||||
|
<a-radio value="Beijing">Beijing</a-radio>
|
||||||
|
<a-radio value="Shanghai">Shanghai</a-radio>
|
||||||
|
<a-radio value="Guangzhou">Guangzhou</a-radio>
|
||||||
|
<a-radio value="Shenzhen">Shenzhen</a-radio>
|
||||||
|
</a-radio-group>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { defineProps, computed } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
scheme: Object
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const scheme = computed(() => props.scheme || '');
|
||||||
|
</script>
|
||||||
@ -29,5 +29,9 @@ export const useSchemeStore = defineStore('scheme', () => {
|
|||||||
function getSchemeObj(id) {
|
function getSchemeObj(id) {
|
||||||
return findObjectById(scheme.value, id)
|
return findObjectById(scheme.value, id)
|
||||||
}
|
}
|
||||||
return { scheme, initScheme, getSchemeObj }
|
function updateScheme(id,obj)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return { scheme, initScheme, getSchemeObj,updateScheme }
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user