feat(vue-runtime-help): useDsl/useEditorDsl添加app默认参数

This commit is contained in:
roymondchen 2025-03-07 14:33:13 +08:00
parent a293bd8d3f
commit f671c670db
3 changed files with 4 additions and 8 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.1.0", "version": "1.1.1",
"name": "@tmagic/vue-runtime-help", "name": "@tmagic/vue-runtime-help",
"type": "module", "type": "module",
"sideEffects": false, "sideEffects": false,

View File

@ -1,12 +1,10 @@
import { inject, nextTick, onBeforeUnmount, reactive, ref } from 'vue-demi'; import { inject, nextTick, onBeforeUnmount, reactive, ref } from 'vue-demi';
import type TMagicCore from '@tmagic/core'; import type TMagicApp from '@tmagic/core';
import type { ChangeEvent, MNode } from '@tmagic/core'; import type { ChangeEvent, MNode } from '@tmagic/core';
import { isPage, replaceChildNode } from '@tmagic/core'; import { isPage, replaceChildNode } from '@tmagic/core';
export const useDsl = () => { export const useDsl = (app = inject<TMagicApp>('app')) => {
const app = inject<TMagicCore>('app');
if (!app) { if (!app) {
throw new Error('useDsl must be used after MagicApp is created'); throw new Error('useDsl must be used after MagicApp is created');
} }

View File

@ -11,9 +11,7 @@ declare global {
} }
} }
export const useEditorDsl = (win = window) => { export const useEditorDsl = (app = inject<TMagicApp>('app'), win = window) => {
const app = inject<TMagicApp>('app');
const root = ref<MApp>(); const root = ref<MApp>();
const curPageId = ref<Id>(); const curPageId = ref<Id>();
const selectedId = ref<Id>(); const selectedId = ref<Id>();