mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-15 17:43:43 +08:00
feat(vue-runtime-help): 只有dsl中的组件才触发生命周期hook
This commit is contained in:
parent
831cdfb2d6
commit
69f3cb2f12
68
pnpm-lock.yaml
generated
68
pnpm-lock.yaml
generated
@ -955,20 +955,20 @@ importers:
|
||||
runtime/vue-runtime-help:
|
||||
dependencies:
|
||||
'@tmagic/core':
|
||||
specifier: '>=1.4.8'
|
||||
version: 1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
specifier: '>=1.4.16'
|
||||
version: 1.4.16(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
'@tmagic/data-source':
|
||||
specifier: '>=1.4.8'
|
||||
version: 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
specifier: '>=1.4.16'
|
||||
version: 1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
'@tmagic/schema':
|
||||
specifier: '>=1.4.8'
|
||||
version: 1.4.15(typescript@5.5.4)
|
||||
specifier: '>=1.4.16'
|
||||
version: 1.4.16(typescript@5.5.4)
|
||||
'@tmagic/stage':
|
||||
specifier: '>=1.4.8'
|
||||
version: 1.4.15(@tmagic/core@1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4)
|
||||
specifier: '>=1.4.16'
|
||||
version: 1.4.16(@tmagic/core@1.4.16(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4)
|
||||
'@tmagic/utils':
|
||||
specifier: '>=1.4.8'
|
||||
version: 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4)
|
||||
specifier: '>=1.4.16'
|
||||
version: 1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4)
|
||||
'@vue/composition-api':
|
||||
specifier: '>=1.7.2'
|
||||
version: 1.7.2(vue@3.4.35(typescript@5.5.4))
|
||||
@ -2356,17 +2356,6 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
'@tmagic/data-source@1.4.15':
|
||||
resolution: {integrity: sha512-Ua6jawvo0Lb41MmsWQ8Ockyq1p7gWZMZWzFPFqWOIAlp8llgiH2LMYXz8OkAEkXZOeRtGzHqcd/5zg5qF9HtXA==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
'@tmagic/schema': 1.4.15
|
||||
'@tmagic/utils': 1.4.15
|
||||
typescript: '*'
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
'@tmagic/data-source@1.4.16':
|
||||
resolution: {integrity: sha512-gYUARAJ5IpJzh2R9nTsvpISTJk8uiEwGwiRfpErgD2OzX9a2uEKvDaFK3GWTUtg8LLlw+UUC/vIt3Qk/89aEGg==}
|
||||
engines: {node: '>=18'}
|
||||
@ -7507,16 +7496,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
typescript: 5.5.4
|
||||
|
||||
'@tmagic/core@1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)':
|
||||
dependencies:
|
||||
'@tmagic/data-source': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
'@tmagic/schema': 1.4.15(typescript@5.5.4)
|
||||
'@tmagic/utils': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4)
|
||||
events: 3.3.0
|
||||
lodash-es: 4.17.21
|
||||
optionalDependencies:
|
||||
typescript: 5.5.4
|
||||
|
||||
'@tmagic/core@1.4.15(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)':
|
||||
dependencies:
|
||||
'@tmagic/data-source': 1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
@ -7537,17 +7516,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
typescript: 5.5.4
|
||||
|
||||
'@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)':
|
||||
dependencies:
|
||||
'@tmagic/dep': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
'@tmagic/schema': 1.4.15(typescript@5.5.4)
|
||||
'@tmagic/utils': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4)
|
||||
deep-state-observer: 5.5.13
|
||||
events: 3.3.0
|
||||
lodash-es: 4.17.21
|
||||
optionalDependencies:
|
||||
typescript: 5.5.4
|
||||
|
||||
'@tmagic/data-source@1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)':
|
||||
dependencies:
|
||||
'@tmagic/dep': 1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
@ -7704,22 +7672,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
typescript: 5.5.4
|
||||
|
||||
'@tmagic/stage@1.4.15(@tmagic/core@1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4)':
|
||||
dependencies:
|
||||
'@scena/guides': 0.29.2
|
||||
'@tmagic/core': 1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)
|
||||
'@tmagic/schema': 1.4.15(typescript@5.5.4)
|
||||
'@tmagic/utils': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4)
|
||||
events: 3.3.0
|
||||
keycon: 1.4.0
|
||||
lodash-es: 4.17.21
|
||||
moveable: 0.53.0
|
||||
moveable-helper: 0.4.0(scenejs@1.10.3)
|
||||
optionalDependencies:
|
||||
typescript: 5.5.4
|
||||
transitivePeerDependencies:
|
||||
- scenejs
|
||||
|
||||
'@tmagic/stage@1.4.15(@tmagic/core@1.4.15(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4)':
|
||||
dependencies:
|
||||
'@scena/guides': 0.29.2
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.0.7",
|
||||
"version": "0.1.0",
|
||||
"name": "@tmagic/vue-runtime-help",
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
@ -32,11 +32,11 @@
|
||||
"vue-demi": "^0.14.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tmagic/core": ">=1.4.8",
|
||||
"@tmagic/data-source": ">=1.4.8",
|
||||
"@tmagic/schema": ">=1.4.8",
|
||||
"@tmagic/stage": ">=1.4.8",
|
||||
"@tmagic/utils": ">=1.4.8",
|
||||
"@tmagic/core": ">=1.4.16",
|
||||
"@tmagic/data-source": ">=1.4.16",
|
||||
"@tmagic/schema": ">=1.4.16",
|
||||
"@tmagic/stage": ">=1.4.16",
|
||||
"@tmagic/utils": ">=1.4.16",
|
||||
"@vue/composition-api": ">=1.7.2",
|
||||
"typescript": "*",
|
||||
"vue": ">=2.0.0 || >=3.0.0"
|
||||
|
@ -16,10 +16,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { computed, inject, onBeforeUnmount, onMounted } from 'vue-demi';
|
||||
import { inject, onBeforeUnmount, onMounted } from 'vue-demi';
|
||||
|
||||
import type Core from '@tmagic/core';
|
||||
import type { MNode } from '@tmagic/schema';
|
||||
import { IS_DSL_NODE_KEY } from '@tmagic/utils';
|
||||
|
||||
interface UseAppOptions<T extends MNode = MNode> {
|
||||
config: T;
|
||||
@ -28,13 +29,11 @@ interface UseAppOptions<T extends MNode = MNode> {
|
||||
};
|
||||
}
|
||||
|
||||
const isDslNode = (config: MNode) => typeof config[IS_DSL_NODE_KEY] === 'undefined' || config[IS_DSL_NODE_KEY] === true;
|
||||
|
||||
export default ({ methods, config }: UseAppOptions) => {
|
||||
const app: Core | undefined = inject('app');
|
||||
|
||||
const node = app?.page?.getNode(config.id || '');
|
||||
|
||||
const style = computed(() => (app ? app.transformStyle(config.style || {}) : config.style));
|
||||
|
||||
const emitData = {
|
||||
config,
|
||||
...methods,
|
||||
@ -53,6 +52,8 @@ export default ({ methods, config }: UseAppOptions) => {
|
||||
return displayCfg !== false;
|
||||
};
|
||||
|
||||
const node = isDslNode(config) ? app?.page?.getNode(config.id || '') : undefined;
|
||||
|
||||
if (node) {
|
||||
node.emit('created', emitData);
|
||||
|
||||
@ -68,7 +69,6 @@ export default ({ methods, config }: UseAppOptions) => {
|
||||
return {
|
||||
app,
|
||||
node,
|
||||
style,
|
||||
|
||||
display,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user