chore: 无界渲染器发布 alpha.2

This commit is contained in:
wangxuefeng
2025-03-19 21:51:35 +08:00
parent 86dc19193a
commit 22145b3893
5 changed files with 267 additions and 134 deletions

View File

@@ -2,7 +2,6 @@
"name": "@sy/vue3-renderer-adapter",
"version": "1.0.0-alpha.1",
"description": "vue3 renderer adapter",
"private": true,
"type": "module",
"scripts": {
"build": "vite build"

View File

@@ -30,7 +30,10 @@
"wujie-vue3": "1.0.22"
},
"devDependencies": {
"@types/axios": "0.14.4",
"@types/vue-router": "2.0.0",
"@vitejs/plugin-vue": "catalog:",
"axios": "catalog:",
"vite-plugin-dts": "catalog:",
"vue-router": "catalog:"
}

View File

@@ -1,38 +1,67 @@
<script setup lang="ts">
import type { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import type { Router, RouteRecordRaw } from 'vue-router';
import { computed, onBeforeUnmount, onMounted } from 'vue';
import { onBeforeUnmount, onMounted } from 'vue';
import WujieVue from 'wujie-vue3';
// @ts-ignore ignore the type error
import { version } from '/package.json';
// 定义拦截器类型
interface AxiosInterceptors {
request?: {
onFulfilled?: (
config: InternalAxiosRequestConfig,
) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
onRejected?: (error: any) => any;
};
response?: {
onFulfilled?: (
response: AxiosResponse,
) => AxiosResponse | Promise<AxiosResponse>;
onRejected?: (error: any) => any;
};
}
const props = withDefaults(
defineProps<{
[key: string]: any;
accessToken?: string;
applicationId: number;
degrade?: boolean;
fileId: number | string;
getRouter: () => Router;
name: string;
interceptors?: AxiosInterceptors;
name?: string;
// 传递给子应用的参数 payload
payload?: Record<string, any>;
projectId: number;
route: RouteRecordRaw;
router: Router;
sync: boolean;
url: string;
route?: RouteRecordRaw;
router?: Router;
sync?: boolean;
url?: string;
}>(),
{
// 默认 wujie 降级
// 默认 wujie 降级,能避免很多兼容问题
degrade: true,
// 默认不使用拦截器
interceptors: () => ({}),
// 默认不使用 name
name: undefined,
// 默认不使用 payload
payload: () => ({}),
// 默认不使用 route
route: undefined,
// 默认不使用 router
router: undefined,
sync: true,
url: 'https://y-code-renderer.shiyue.com',
},
);
const { bus } = WujieVue;
const isDegrade = computed(() => props.degrade ?? true);
// 生命周期钩子
const beforeLoad = (appWindow: Window) => {
console.log(`${props.name} 开始加载`, appWindow);
@@ -89,17 +118,15 @@ onBeforeUnmount(() => {
</script>
<template>
<div style="width: 100%; height: 100%">
<WujieVue
:name="name"
:url="url"
:sync="sync"
width="100%"
height="100%"
:degrade="isDegrade"
:props="subAppProps"
:before-load="beforeLoad"
:after-mount="afterMount"
/>
</div>
<WujieVue
:name="name || fileId"
:url="url"
:sync="sync"
width="100%"
height="100%"
:degrade="degrade"
:props="subAppProps"
:before-load="beforeLoad"
:after-mount="afterMount"
/>
</template>

View File

@@ -12,7 +12,7 @@
"@/*": ["src/*"]
},
"resolveJsonModule": true,
"types": ["vite/client"],
"types": ["vite/client", "vue/runtime-dom"],
"strict": true,
"useUnknownInCatchVariables": false,
"declaration": true,