From 0a3904512d549c201dc70cb3425a504c8a7a0070 Mon Sep 17 00:00:00 2001 From: wangxuefeng Date: Thu, 13 Mar 2025 14:56:29 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20v1=20=E6=82=A6=E7=A0=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=A4=A9=E6=A2=AF=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/designer/src/io/instance.ts | 5 ++++ apps/designer/src/views/index.vue | 1 + apps/platform/.env.production | 2 +- apps/platform/.env.staging | 2 +- .../platform/src/router/routes/modules/acl.ts | 19 +++++++++++- .../src/router/routes/modules/micro.ts | 2 ++ apps/y-code-v1/package.json | 2 ++ apps/y-code-v1/src/main.ts | 29 +++++++++++++++++++ apps/y-code-v1/src/utils/request.ts | 2 +- pnpm-lock.yaml | 6 ++++ turbo.json | 4 +-- 11 files changed, 68 insertions(+), 6 deletions(-) diff --git a/apps/designer/src/io/instance.ts b/apps/designer/src/io/instance.ts index a7a106a..68735d4 100644 --- a/apps/designer/src/io/instance.ts +++ b/apps/designer/src/io/instance.ts @@ -1,3 +1,4 @@ +import { useUserStore } from '@/store'; import axios from 'axios'; const apiBase = import.meta.env.VITE_BASE_API_URL; @@ -11,6 +12,10 @@ const instance = axios.create({ instance.interceptors.request.use( (config) => { // 可在此处添加统一请求头等配置 + const userStore = useUserStore(); + console.log(localStorage.getItem('y-code-access-token')); + console.log(userStore.token); + config.headers.Authorization = `Bearer ${userStore.token}`; return config; }, (error) => { diff --git a/apps/designer/src/views/index.vue b/apps/designer/src/views/index.vue index 23a3a20..f89ea15 100644 --- a/apps/designer/src/views/index.vue +++ b/apps/designer/src/views/index.vue @@ -27,6 +27,7 @@ onMounted(async () => { Object.assign(model, parent.model); // console.log('get parent model', model); userStore.setToken(model.accessToken); + localStorage.setItem('y-code-access-token', model.accessToken); request.useRequest((req) => { req.headers.set('Authorization', `Bearer ${model.accessToken}`); return req; diff --git a/apps/platform/.env.production b/apps/platform/.env.production index 215cf85..63a9f95 100644 --- a/apps/platform/.env.production +++ b/apps/platform/.env.production @@ -30,4 +30,4 @@ VITE_BASE_API_URL = 'https://custom-chart-api.shiyuegame.com/' VITE_PLATFORM_URL = 'https://y-code.shiyue.com/' VITE_DESIGNER_URL = 'https://y-code-designer.shiyue.com/' VITE_RENDERER_URL = 'https://y-code-renderer.shiyue.com/' -Y_CODE_V1_URL = 'https://custom-chart.shiyuegame.com/' +VITE_V1_URL = 'https://custom-chart.shiyuegame.com/' diff --git a/apps/platform/.env.staging b/apps/platform/.env.staging index 2f2334a..caff002 100644 --- a/apps/platform/.env.staging +++ b/apps/platform/.env.staging @@ -10,4 +10,4 @@ VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/' VITE_PLATFORM_URL = 'https://y-code-pre.shiyue.com/' VITE_DESIGNER_URL = 'https://y-code-designer-pre.shiyue.com/' VITE_RENDERER_URL = 'https://y-code-renderer-pre.shiyue.com/' -Y_CODE_V1_URL = 'https://custom-chart.shiyue.com/' +VITE_V1_URL = 'https://custom-chart.shiyue.com/' diff --git a/apps/platform/src/router/routes/modules/acl.ts b/apps/platform/src/router/routes/modules/acl.ts index 4a71980..4ac7d67 100644 --- a/apps/platform/src/router/routes/modules/acl.ts +++ b/apps/platform/src/router/routes/modules/acl.ts @@ -18,7 +18,7 @@ const routes: Array = [ name: moduleName, redirect: '/acl/list', meta: { - title: '权限管理', + title: '用户管理', icon: 'ant-design:user-outlined', }, children: [ @@ -39,6 +39,23 @@ const routes: Array = [ fileId: '1hsd0407hf', }), }, + { + path: 'user', + name: `${moduleName}-user`, + meta: { + title: '用户列表', + keepAlive: true, + icon: 'ant-design:list', + }, + component: () => + h(RendererAdapter, { + url: VITE_RENDERER_URL, + name: 'y-code-platform-user-list', + applicationId: LOW_CODE_APPLICATION_ID, + projectId: LOW_CODE_PROJECT_ID, + fileId: '7pfu5radx', + }), + }, ], }, ]; diff --git a/apps/platform/src/router/routes/modules/micro.ts b/apps/platform/src/router/routes/modules/micro.ts index abca419..852cbb9 100644 --- a/apps/platform/src/router/routes/modules/micro.ts +++ b/apps/platform/src/router/routes/modules/micro.ts @@ -30,6 +30,7 @@ const routes: Array = [ url: VITE_DESIGNER_URL, name: 'y-code-designer', projectId: 4, + accessToken: localStorage.getItem('y-code-access-token'), }), }, { @@ -52,6 +53,7 @@ const routes: Array = [ h(RendererAdapter, { url: VITE_V1_URL, name: 'y-code-v1', + accessToken: localStorage.getItem('y-code-access-token'), // sync: true, // alive: true, degrade: true, diff --git a/apps/y-code-v1/package.json b/apps/y-code-v1/package.json index 44bd216..eda7fd9 100644 --- a/apps/y-code-v1/package.json +++ b/apps/y-code-v1/package.json @@ -36,6 +36,7 @@ "@rushstack/eslint-patch": "^1.10.5", "@tsconfig/node20": "^20.1.4", "@types/node": "^20.17.17", + "@types/postmate": "catalog:", "@vitejs/plugin-vue": "^5.2.1", "@vitejs/plugin-vue-jsx": "^4.1.1", "@vue/eslint-config-typescript": "^13.0.0", @@ -43,6 +44,7 @@ "eslint": "^9.20.1", "eslint-plugin-vue": "^9.32.0", "less": "^4.2.2", + "postmate": "catalog:", "semantic-release": "^24.2.2", "typescript": "catalog:", "unplugin-vue-components": "^0.26.0", diff --git a/apps/y-code-v1/src/main.ts b/apps/y-code-v1/src/main.ts index c78d45d..e1d5f98 100644 --- a/apps/y-code-v1/src/main.ts +++ b/apps/y-code-v1/src/main.ts @@ -1,7 +1,9 @@ import { createApp } from 'vue'; import VueGridLayout from 'vue-grid-layout'; // 引入layout +import { baseAxios } from '@/utils/request'; import { createPinia } from 'pinia'; +import Postmate from 'postmate'; import { qiankunWindow, renderWithQiankun, @@ -12,6 +14,33 @@ import { createProjectRouter } from './router'; import './global.less'; +// Postmate 握手协议 +const postmate = new Postmate.Model({ + sayHi: (data: any) => { + console.log('sayHi', data); + }, +}); + +// 数据模型 +const model = { + name: '', + applicationId: -1, + projectId: -1, + fileId: '', + url: '', + accessToken: '', +}; + +await postmate.then((parent) => { + parent.emit('some-event', 'y-code-renderer is ready'); + Object.assign(model, parent.model); + localStorage.setItem('y-code-access-token', model.accessToken || ''); + baseAxios.interceptors.request.use((config) => { + config.headers.Authorization = `Bearer ${model.accessToken}`; + return config; + }); +}); + let app; function render(props: object = {}) { app = createApp(App); diff --git a/apps/y-code-v1/src/utils/request.ts b/apps/y-code-v1/src/utils/request.ts index 2d70215..9b1d1f2 100644 --- a/apps/y-code-v1/src/utils/request.ts +++ b/apps/y-code-v1/src/utils/request.ts @@ -111,4 +111,4 @@ const put = (config?: RequestConfig) => const del = (config?: { url: string }) => request>({ ...config, method: 'DELETE' }); -export { del, get, post, put, request }; +export { baseAxios, del, get, post, put, request }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 380ddde..e1920b6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -981,6 +981,9 @@ importers: '@types/node': specifier: ^20.17.17 version: 20.17.24 + '@types/postmate': + specifier: 'catalog:' + version: 1.5.4 '@vitejs/plugin-vue': specifier: ^5.2.1 version: 5.2.1(vite@6.2.1(@types/node@20.17.24)(jiti@2.4.2)(less@4.2.2)(sass@1.85.1)(terser@5.39.0)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2)) @@ -1002,6 +1005,9 @@ importers: less: specifier: ^4.2.2 version: 4.2.2 + postmate: + specifier: 'catalog:' + version: 1.5.2 semantic-release: specifier: ^24.2.2 version: 24.2.3(typescript@5.8.2) diff --git a/turbo.json b/turbo.json index 453876f..be1ced7 100644 --- a/turbo.json +++ b/turbo.json @@ -53,13 +53,13 @@ "dev:staging": { "dependsOn": ["^build"], "outputs": [], - "cache": false, + "cache": true, "persistent": true }, "dev:prod": { "dependsOn": ["^build"], "outputs": [], - "cache": false, + "cache": true, "persistent": true }, "typecheck": {