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

@ -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) => {

View File

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

View File

@ -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/'

View File

@ -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/'

View File

@ -18,7 +18,7 @@ const routes: Array<RouteRecordRaw> = [
name: moduleName,
redirect: '/acl/list',
meta: {
title: '权限管理',
title: '用户管理',
icon: 'ant-design:user-outlined',
},
children: [
@ -39,6 +39,23 @@ const routes: Array<RouteRecordRaw> = [
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',
}),
},
],
},
];

View File

@ -30,6 +30,7 @@ const routes: Array<RouteRecordRaw> = [
url: VITE_DESIGNER_URL,
name: 'y-code-designer',
projectId: 4,
accessToken: localStorage.getItem('y-code-access-token'),
}),
},
{
@ -52,6 +53,7 @@ const routes: Array<RouteRecordRaw> = [
h(RendererAdapter, {
url: VITE_V1_URL,
name: 'y-code-v1',
accessToken: localStorage.getItem('y-code-access-token'),
// sync: true,
// alive: true,
degrade: true,

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 };

6
pnpm-lock.yaml generated
View File

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

View File

@ -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": {