chore: 无界测试

This commit is contained in:
wangxuefeng
2025-03-17 17:38:03 +08:00
parent d55ae2e97d
commit 32db9d8175
10 changed files with 485 additions and 93 deletions

View File

@@ -0,0 +1,40 @@
{
"name": "@sy/wujie-vue3-renderer-adapter",
"version": "1.0.0-alpha.1",
"description": "wujie-vue3 renderer adapter",
"private": true,
"type": "module",
"scripts": {
"build": "vite build"
},
"alias": {
"#": "./src"
},
"files": [
"dist"
],
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"unpkg": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.mjs"
}
},
"dependencies": {
"postmate": "catalog:",
"vue": "catalog:",
"wujie-vue3": "1.0.24"
},
"devDependencies": {
"@farmfe/cli": "^1.0.4",
"@farmfe/core": "^1.7.1",
"@types/postmate": "catalog:",
"@vitejs/plugin-vue": "catalog:",
"vite-plugin-dts": "catalog:"
}
}

View File

@@ -0,0 +1,62 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted } from 'vue';
import WujieVue from 'wujie-vue3';
const props = defineProps<{
accessToken?: string;
applicationId: number | string;
fileId: number | string;
name: string;
projectId: number | string;
url: string;
}>();
console.log('props', props);
const { bus } = WujieVue;
// 传递给子应用的属性
const subAppProps = {
accessToken: props.accessToken,
applicationId: props.applicationId,
fileId: props.fileId,
projectId: props.projectId,
};
// 生命周期钩子
const beforeLoad = (appWindow: Window) => {
console.log(`${props.name} 开始加载`, appWindow);
};
const afterMount = (appWindow: Window) => {
console.log(`${props.name} 加载完成`, appWindow);
};
// 事件处理
const handleMessage = (data: any) => {
console.log('收到子应用消息:', data);
};
onMounted(() => {
bus.$on('message', handleMessage);
});
onBeforeUnmount(() => {
bus.$off('message', handleMessage);
});
</script>
<template>
<div class="low-code-adapter" style="width: 100%; height: 100%">
{{ url }}
<WujieVue width="100%" height="100%" :props="subAppProps" />
</div>
</template>
<style scoped>
.low-code-adapter {
width: 100%;
height: 100%;
}
</style>

View File

@@ -0,0 +1 @@
export { default } from './adapter.vue';

View File

@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "ESNext",
"jsx": "preserve",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"baseUrl": ".",
"module": "ESNext",
"moduleResolution": "Node",
"paths": {
"@/*": ["src/*"]
},
"resolveJsonModule": true,
"types": ["vite/client"],
"strict": true,
"useUnknownInCatchVariables": false,
"declaration": true,
"declarationDir": "dist/types",
"outDir": "dist",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"exclude": ["node_modules", "dist"]
}

View File

@@ -0,0 +1,68 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
build: {
cssCodeSplit: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
fileName: (format) => {
switch (format) {
case 'cjs': {
return 'index.cjs';
}
case 'es': {
return 'index.mjs';
}
case 'umd': {
return 'index.js';
}
default: {
return `index.${format}.js`;
}
}
},
formats: ['es', 'cjs', 'umd'],
name: 'RendererAdapter',
},
outDir: 'dist',
rollupOptions: {
external: ['vue'],
output: {
assetFileNames: (assetInfo) => {
if (assetInfo.name === 'style.css') return 'assets/[name][extname]';
return 'assets/[name]-[hash][extname]';
},
globals: {
vue: 'Vue',
},
},
},
sourcemap: true,
},
css: {
extract: false,
modules: {
localsConvention: 'camelCaseOnly',
scopeBehaviour: 'local',
},
},
plugins: [
vue({
css: {
injectCss: true,
},
}),
dts({
insertTypesEntry: true,
outDir: 'dist/types',
staticImport: true,
}),
],
});