chore: 无界测试
This commit is contained in:
40
packages/renderer-adapter/wujie-vue3/package.json
Normal file
40
packages/renderer-adapter/wujie-vue3/package.json
Normal 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:"
|
||||
}
|
||||
}
|
||||
62
packages/renderer-adapter/wujie-vue3/src/adapter.vue
Normal file
62
packages/renderer-adapter/wujie-vue3/src/adapter.vue
Normal 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>
|
||||
1
packages/renderer-adapter/wujie-vue3/src/index.ts
Normal file
1
packages/renderer-adapter/wujie-vue3/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './adapter.vue';
|
||||
29
packages/renderer-adapter/wujie-vue3/tsconfig.json
Normal file
29
packages/renderer-adapter/wujie-vue3/tsconfig.json
Normal 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"]
|
||||
}
|
||||
68
packages/renderer-adapter/wujie-vue3/vite.config.ts
Normal file
68
packages/renderer-adapter/wujie-vue3/vite.config.ts
Normal 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,
|
||||
}),
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user