chore: 悦码v1增加环境配置

This commit is contained in:
wangxuefeng 2025-03-06 10:28:14 +08:00
parent eecc2b1893
commit 9b2c728d4c
27 changed files with 540 additions and 689 deletions

View File

@ -1,7 +1,6 @@
import axios from 'axios';
const apiBase = import.meta.env.VITE_BASE_API_URL;
console.log('apiBase', apiBase);
// 创建独立实例
const instance = axios.create({

View File

@ -16,28 +16,45 @@ onMounted(async () => {
url: ''
};
const handshake = new Postmate.Model({});
await handshake.then((parent) => {
parent.emit('sync-context', 'Hello, World!');
Object.assign(model, parent.model);
console.log('model', model);
const engine = new Engine({
container,
service,
project: {
id: model.applicationId,
name: model.name
}
});
widgetManager.set('Previewer', {
props: {
path: (block: any) => {
const pathname = location.pathname;
return `${pathname}#/preview/${block.id}`;
}
}
});
const engine = new Engine({
container,
service,
project: {
id: 4,
name: 'test'
}
});
widgetManager.set('Previewer', {
props: {
path: (block: any) => {
const pathname = location.pathname;
return `${pathname}#/preview/${block.id}`;
}
}
});
// const handshake = new Postmate.Model({});
// await handshake.then((parent) => {
// parent.emit('sync-context', 'Hello, World!');
// Object.assign(model, parent.model);
// console.log('model', model);
// const engine = new Engine({
// container,
// service,
// project: {
// id: model.applicationId,
// name: model.name
// }
// });
// widgetManager.set('Previewer', {
// props: {
// path: (block: any) => {
// const pathname = location.pathname;
// return `${pathname}#/preview/${block.id}`;
// }
// }
// });
// });
});
</script>

View File

@ -14,3 +14,4 @@ VITE_DEBUG_MODE = true
Y_CODE_PLATFORM_URL = 'https://localhost:10010/'
Y_CODE_DESIGNER_URL = 'https://localhost:10011/'
Y_CODE_RENDERER_URL = 'https://localhost:10012/'
Y_CODE_V1_URL = 'https://localhost:10013/'

View File

@ -9,3 +9,4 @@ VITE_BASE_API_URL = 'https://custom-chart-api.shiyuegame.com/'
Y_CODE_PLATFORM_URL = 'https://y-code-platform.shiyuegame.com/'
Y_CODE_DESIGNER_URL = 'https://y-code-designer.shiyuegame.com/'
Y_CODE_RENDERER_URL = 'https://y-code-renderer.shiyuegame.com/'
Y_CODE_V1_URL = 'https://custom-chart.shiyuegame.com/'

View File

@ -10,3 +10,4 @@ VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
Y_CODE_PLATFORM_URL = 'https://y-code-platform-pre.shiyue.com/'
Y_CODE_DESIGNER_URL = 'https://y-code-designer-pre.shiyue.com/'
Y_CODE_RENDERER_URL = 'https://y-code-renderer-pre.shiyue.com/'
Y_CODE_V1_URL = 'https://custom-chart.shiyue.com/'

View File

@ -29,9 +29,11 @@
"@ant-design/icons-vue": "~7.0.1",
"@iconify/vue": "^4.3.0",
"@iframe-resizer/parent": "^5.3.3",
"@sy/unified-login": "1.0.29",
"@sy/y-code-renderer-adapter": "workspace:*",
"@tanstack/query-core": "^5.66.4",
"@tanstack/vue-query": "^5.66.9",
"@vue/runtime-core": "^3.5.13",
"@vueuse/core": "~11.1.0",
"ant-design-vue": "~4.2.6",
"axios": "~1.8.1",
@ -51,11 +53,10 @@
"vue": "~3.5.13",
"vue-i18n": "^11.1.1",
"vue-router": "~4.4.5",
"vue-types": "~5.1.3",
"vue-types": "~6.0.0",
"vue-virtual-scroller": "2.0.0-beta.8",
"wujie": "^1.0.25",
"xlsx": "~0.18.5",
"@sy/unified-login": "1.0.29"
"wujie-vue3": "^1.0.25",
"xlsx": "~0.18.5"
},
"devDependencies": {
"@commitlint/cli": "~19.5.0",
@ -63,9 +64,9 @@
"@iconify-json/ant-design": "^1.2.5",
"@iconify-json/ep": "^1.2.2",
"@iconify/json": "^2.2.307",
"@sy/y-code-designer": "workspace:*",
"@sy/low-code-shared": "workspace:*",
"@sy/vite-plugin-http2-proxy": "workspace:*",
"@sy/y-code-designer": "workspace:*",
"@types/crypto-js": "^4.2.2",
"@types/lodash-es": "~4.17.12",
"@types/node": "~22.7.9",
@ -75,8 +76,8 @@
"@typescript-eslint/parser": "~8.11.0",
"@umijs/openapi": "^1.13.0",
"@vitejs/plugin-vue": "~5.1.5",
"@vitejs/plugin-vue-jsx": "~4.0.1",
"@vue/tsconfig": "^0.5.1",
"@vitejs/plugin-vue-jsx": "~4.1.1",
"@vue/tsconfig": "^0.7.0",
"commitizen": "~4.3.1",
"conventional-changelog-cli": "~4.1.0",
"cross-env": "~7.0.3",
@ -91,9 +92,9 @@
"lint-staged": "~15.2.11",
"msw": "^2.7.0",
"postcss": "~8.4.49",
"postcss-html": "~1.7.0",
"postcss-html": "~1.8.0",
"postcss-less": "~6.0.0",
"prettier": "~3.3.3",
"prettier": "~3.5.3",
"rimraf": "~6.0.1",
"stylelint": "~16.10.0",
"stylelint-config-property-sort-order-smacss": "^10.0.0",
@ -102,7 +103,7 @@
"stylelint-config-standard": "~36.0.1",
"stylelint-order": "~6.0.4",
"stylelint-prettier": "^5.0.3",
"typescript": "~5.6.3",
"typescript": "~5.8.2",
"unocss": "^65.5.0",
"unplugin-vue-components": "~0.27.5",
"vite": "~6.2.0",
@ -111,8 +112,8 @@
"vite-plugin-mkcert": "^1.17.6",
"vite-plugin-svg-icons": "~2.0.1",
"vite-plugin-vue-inspector": "^5.3.1",
"vue-eslint-parser": "~9.4.3",
"vue-tsc": "~2.1.10"
"vue-eslint-parser": "~10.1.1",
"vue-tsc": "~2.2.8"
},
"keywords": [
"vue",

View File

@ -19,10 +19,10 @@
</template>
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { theme } from 'ant-design-vue';
import { LockScreen } from '@/components/basic/lockscreen';
import { useRoute } from 'vue-router';
const route = useRoute();

View File

@ -1,21 +1,24 @@
<template>
<!-- <div id="container" /> -->
<iframe
<!-- <iframe
ref="iframeRef"
width="100%"
style="border: none"
height="100%"
:src="route.meta?.app?.url"
/>
<!-- <component :is="WujieVue" v-bind="route.meta?.app" /> -->
/> -->
<WujieVue width="100%" height="100%" v-bind="route.meta?.app" />
</template>
<script setup>
import { onMounted } from 'vue';
import { setupApp, startApp } from 'wujie';
// import { setupApp, startApp } from 'wujie';
import { useRoute } from 'vue-router';
import WujieVue from 'wujie-vue3';
const route = useRoute();
console.log(route.meta?.app);
// console.log(route.meta?.app);
// onMounted(() => {
// setupApp({
// el: '#container',

View File

@ -5,11 +5,11 @@
// import { Spin, Alert, Button } from 'ant-design-vue';
const route = useRoute();
const MAX_RETRIES = 3;
// const MAX_RETRIES = 3;
const loading = ref(true);
const errorMessage = ref('');
const retryCount = ref(0);
// const retryCount = ref(0);
const initPostmate = async () => {
loading.value = true;
@ -21,7 +21,7 @@
return;
}
const handle = new Postmate({
const connection = new Postmate({
container,
url: route.meta?.app?.url,
name: 'y-code-renderer',
@ -35,23 +35,27 @@
},
});
handle
.then((instance) => {
console.log('Postmate连接成功', instance);
retryCount.value = 0; //
})
.catch((err) => {
retryCount.value++;
errorMessage.value = `连接失败: ${err.message}`;
if (retryCount.value < MAX_RETRIES) {
initPostmate(); //
} else {
errorMessage.value = '已达到最大重试次数,请检查网络连接';
}
})
.finally(() => {
loading.value = false;
connection.then((child) => {
console.log('Postmate 连接成功', child);
child.on('some-event', (data) => console.log(data)); // Logs "Hello, World!"
child.call('sayHi', {
name: route.meta?.app?.name,
});
// retryCount.value = 0; //
});
// .catch((err) => {
// retryCount.value++;
// errorMessage.value = `: ${err.message}`;
// if (retryCount.value < MAX_RETRIES) {
// initPostmate(); //
// } else {
// errorMessage.value = '';
// }
// })
// .finally(() => {
// loading.value = false;
// });
};
onMounted(() => {
@ -60,18 +64,7 @@
</script>
<template>
<div class="iframe-container">
<div id="low-code-adapter" />
<!-- <div v-if="loading" class="loading-overlay">
<Spin :tip="`正在连接应用(${retryCount + 1}/${MAX_RETRIES}`" />
</div> -->
<!-- <div v-if="errorMessage" class="error-overlay">
<Alert type="error" :message="errorMessage" show-icon />
<Button v-if="retryCount < MAX_RETRIES" @click="initPostmate">重新连接</Button>
</div> -->
</div>
<div id="low-code-adapter" />
</template>
<style>
@ -84,39 +77,8 @@
</style>
<style lang="scss" scoped>
.iframe-container {
position: relative;
height: 100%;
}
#low-code-adapter {
width: 100%;
height: 100%;
}
.loading-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.error-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 1001;
height: 99%;
}
</style>

View File

@ -14,3 +14,4 @@ export const isStagingMode = import.meta.env.MODE === stagingMode;
export const Y_CODE_RENDERER_URL = currentEnv.Y_CODE_RENDERER_URL;
export const Y_CODE_DESIGNER_URL = currentEnv.Y_CODE_DESIGNER_URL;
export const Y_CODE_PLATFORM_URL = currentEnv.Y_CODE_PLATFORM_URL;
export const Y_CODE_V1_URL = currentEnv.Y_CODE_V1_URL;

View File

@ -1,2 +1,3 @@
// export * from '@sy/low-code-shared/constants';
export * from './env';
export * from './low-code';

View File

@ -0,0 +1,2 @@
export const LOW_CODE_APPLICATION_ID = 0;
export const LOW_CODE_PROJECT_ID = 4;

View File

@ -1,7 +1,6 @@
import type { RouteRecordRaw } from 'vue-router';
import { Y_CODE_DESIGNER_URL } from '@/constants';
import { Y_CODE_DESIGNER_URL, Y_CODE_V1_URL } from '@/constants';
// 微前端路由
const moduleName = 'micro';
const routes: Array<RouteRecordRaw> = [
@ -18,54 +17,36 @@ const routes: Array<RouteRecordRaw> = [
name: `${moduleName}-designer`,
meta: {
title: '低代码编辑器',
keepAlive: true,
icon: 'ant-design:edit-outlined',
app: {
url: Y_CODE_DESIGNER_URL,
name: 'y-code-designer',
applicationId: 4,
// sync: true,
// alive: true,
// degrade: true,
sync: true,
alive: true,
degrade: true,
},
},
component: () => import('@/components/renderer-adapter/index.vue'),
},
// {
// path: 'renderer',
// name: `${moduleName}-renderer`,
// meta: {
// title: '低代码渲染器',
// keepAlive: true,
// // hideInMenu: true,
// icon: 'ant-design:eye-outlined',
// app: {
// url: 'https://localhost:10010',
// name: 'y-code-renderer',
// applicationId: 4,
// // sync: true,
// // alive: true,
// // degrade: true,
// },
// },
// component: () => import('@/components/renderer-adapter/index.vue'),
// },
{
path: 'y-code-v1',
name: `${moduleName}-y-code-v1`,
meta: {
title: '悦码 1.0',
// keepAlive: true,
keepAlive: true,
// hideInMenu: true,
icon: 'ant-design:delete-outlined',
app: {
url: 'http://localhost:10012',
url: Y_CODE_V1_URL,
name: 'y-code-v1',
// sync: true,
// alive: true,
degrade: true,
},
},
component: () => import('@/components/micro-container/index.vue'),
component: () => import('@/components/renderer-adapter/index.vue'),
},
],
},

View File

@ -1,5 +1,6 @@
import type { RouteRecordRaw } from 'vue-router';
import { Y_CODE_RENDERER_URL } from '@/constants';
import { LOW_CODE_APPLICATION_ID, LOW_CODE_PROJECT_ID } from '@/constants/low-code';
// 微前端路由
const moduleName = 'project';
@ -26,8 +27,8 @@ const routes: Array<RouteRecordRaw> = [
// sync: true,
// alive: true,
// degrade: true,
applicationId: 0,
projectId: 4,
applicationId: LOW_CODE_APPLICATION_ID,
projectId: LOW_CODE_PROJECT_ID,
fileId: '4g4mz6qi8u',
},
},

View File

@ -1,4 +1,6 @@
import type { RouteRecordRaw } from 'vue-router';
import { Y_CODE_RENDERER_URL } from '@/constants';
import { LOW_CODE_APPLICATION_ID, LOW_CODE_PROJECT_ID } from '@/constants/low-code';
// 微前端路由
const moduleName = 'static-file';
@ -20,11 +22,11 @@ const routes: Array<RouteRecordRaw> = [
keepAlive: true,
icon: 'ant-design:list',
app: {
url: 'https://localhost:10010',
url: Y_CODE_RENDERER_URL,
name: 'y-code-platform-application-list',
sync: true,
alive: true,
degrade: true,
applicationId: LOW_CODE_APPLICATION_ID,
projectId: LOW_CODE_PROJECT_ID,
fileId: '7pfr394d6',
},
},
component: () => import('@/components/renderer-adapter/index.vue'),

View File

@ -5,8 +5,7 @@ interface KeepAliveState {
list: string[];
}
export const useKeepAliveStore = defineStore({
id: 'keep-alive',
export const useKeepAliveStore = defineStore('keep-alive', {
state: (): KeepAliveState => ({
list: [],
}),

View File

@ -32,7 +32,7 @@
"strictFunctionTypes": false,
"noImplicitAny": false,
"lib": ["dom", "esnext", "DOM.Iterable"],
"types": ["node", "vite/client"],
"types": ["node", "vite/client", "vue"],
"paths": {
"@/*": ["src/*"]
}

View File

@ -14,6 +14,7 @@ declare module 'vue' {
Reflect: Reflect;
suspenseStatus: '' | 'pending' | 'resolve' | 'fallback';
}
export * from '@vue/runtime-core';
}
declare type Nullable<T> = T | null;

View File

@ -47,6 +47,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
server: {
open: true,
host: true,
cors: true,
port: Number(env.VITE_PORT),
proxy: {
'/api': {

View File

@ -13,7 +13,11 @@ const renderer = ref()
const lowCodeService = new LowCodeService()
// Postmate
const handshake = new Postmate.Model({})
const postmate = new Postmate.Model({
sayHi: (data: any) => {
console.log('sayHi',data)
}
})
//
const model = {
@ -28,8 +32,12 @@ const model = {
const { data: file, isFetching } = useQuery({
queryKey: ['getFile'],
queryFn: async () => {
await handshake.then((parent) => {
// parent.emit('sync-context', 'Hello, World!')
await postmate.then((parent) => {
parent.emit('some-event', 'sync-context!')
parent.emit('some-event', 'sync-context!')
parent.emit('some-event', 'sync-context!')
parent.emit('some-event', 'sync-context!')
Object.assign(model, parent.model)
// console.log('model', model)

View File

@ -12,7 +12,6 @@ const app = createApp(App);
// 批量注册组件
Object.entries(VtjUI).forEach(([name, component]) => {
console.log("name", name, component);
app.component(name, component);
});
app

View File

@ -43,11 +43,11 @@
"eslint-plugin-vue": "^9.32.0",
"less": "^4.2.2",
"semantic-release": "^24.2.2",
"typescript": "~5.3.3",
"typescript": "~5.8.2",
"unplugin-vue-components": "^0.26.0",
"vite": "^6.2.0",
"vite-plugin-qiankun": "^1.0.15",
"vue-tsc": "^2.2.0",
"vue-tsc": "^2.2.8",
"yargs-parser": "^21.1.1"
},
"packageManager": "pnpm@10.4.1"

View File

@ -38,7 +38,9 @@
"eslint-plugin-prettier": "~5.2.3",
"eslint-plugin-unused-imports": "^4.1.4",
"husky": "~9.1.7",
"inquirer": "^12.4.2",
"lint-staged": "~15.2.11",
"ora": "^8.2.0",
"postcss-html": "~1.7.0",
"prettier": "~3.3.3",
"stylelint": "~16.10.0",
@ -48,11 +50,8 @@
"stylelint-config-standard": "~36.0.1",
"stylelint-order": "~6.0.4",
"stylelint-prettier": "^5.0.3",
"typescript": "~5.6.3",
"vue-eslint-parser": "~9.4.3",
"vue-tsc": "~2.1.10",
"inquirer": "^12.4.2",
"ora": "^8.2.0"
},
"dependencies": {}
"typescript": "~5.8.2",
"vue-eslint-parser": "~10.1.1",
"vue-tsc": "~2.2.8"
}
}

View File

@ -16,6 +16,6 @@
"clean": "rimraf node_modules"
},
"devDependencies": {
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}

941
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff