chore: v1 悦码增加天梯校验

This commit is contained in:
wangxuefeng
2025-03-13 14:56:29 +08:00
parent f2c9e426e5
commit 0a3904512d
11 changed files with 68 additions and 6 deletions

View File

@@ -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",

View File

@@ -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);

View File

@@ -111,4 +111,4 @@ const put = <T = any>(config?: RequestConfig) =>
const del = <T = any>(config?: { url: string }) =>
request<ResopnseType<T>>({ ...config, method: 'DELETE' });
export { del, get, post, put, request };
export { baseAxios, del, get, post, put, request };