mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-04 23:29:57 +08:00
feat(vue-runtime-help): app不存在时抛异常,保证app一定存在,避免多余的可选链
This commit is contained in:
parent
e7e9197ae3
commit
fd7e737e8c
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"name": "@tmagic/vue-runtime-help",
|
"name": "@tmagic/vue-runtime-help",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
@ -65,13 +65,17 @@ export const registerNodeHooks = (node?: TMagicNode, methods: Methods = {}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useApp = <T extends TMagicApp = TMagicApp>({
|
export const useApp = <T extends TMagicApp = TMagicApp>({
|
||||||
methods = {},
|
methods,
|
||||||
config,
|
config,
|
||||||
iteratorContainerId,
|
iteratorContainerId,
|
||||||
iteratorIndex,
|
iteratorIndex,
|
||||||
}: UseAppOptions) => {
|
}: UseAppOptions) => {
|
||||||
const app = inject<T>('app');
|
const app = inject<T>('app');
|
||||||
|
|
||||||
|
if (!app) {
|
||||||
|
throw new Error(`component ${config.type}: app is not injected`);
|
||||||
|
}
|
||||||
|
|
||||||
const node = useNode(
|
const node = useNode(
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
@ -81,7 +85,7 @@ export const useApp = <T extends TMagicApp = TMagicApp>({
|
|||||||
app,
|
app,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (node) {
|
if (node && methods) {
|
||||||
registerNodeHooks(node, methods);
|
registerNodeHooks(node, methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user