feat: 设计器可获取天梯 token

This commit is contained in:
wangxuefeng
2025-03-07 14:46:22 +08:00
parent 8d0c890061
commit db10bb6a6c
13 changed files with 135 additions and 79 deletions

View File

@@ -2,8 +2,13 @@
import { ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import Postmate from 'postmate';
import { useUserStore } from '@/store/modules/user';
// import { Spin, Alert, Button } from 'ant-design-vue';
const userStore = useUserStore();
console.log('userStore', userStore);
const route = useRoute();
// const MAX_RETRIES = 3;
@@ -27,6 +32,7 @@
name: 'y-code-renderer',
classListArray: ['responsive-iframe'],
model: {
accessToken: userStore.token,
name: route.meta?.app?.name,
applicationId: route.meta?.app?.applicationId,
projectId: route.meta?.app?.projectId,

View File

@@ -0,0 +1,41 @@
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 = 'acl';
const routes: Array<RouteRecordRaw> = [
{
path: '/acl',
name: moduleName,
redirect: '/acl/list',
meta: {
title: '权限管理',
icon: 'ant-design:user-outlined',
},
children: [
{
path: 'list',
name: `${moduleName}-list`,
meta: {
title: '权限列表',
keepAlive: true,
icon: 'ant-design:list',
app: {
url: Y_CODE_RENDERER_URL,
name: 'y-code-platform-project-list',
// sync: true,
// alive: true,
// degrade: true,
applicationId: LOW_CODE_APPLICATION_ID,
projectId: LOW_CODE_PROJECT_ID,
fileId: 'b91ra0ej4',
},
},
component: () => import('@/components/renderer-adapter/index.vue'),
},
],
},
];
export default routes;

View File

@@ -4,4 +4,5 @@ import micro from './micro';
import application from './application';
import project from './project';
import staticFile from './static-file';
export default [...dashboard, ...user, ...micro, ...application, ...project, ...staticFile];
import acl from './acl';
export default [...dashboard, ...user, ...micro, ...application, ...project, ...staticFile, ...acl];

View File

@@ -22,7 +22,7 @@ const routes: Array<RouteRecordRaw> = [
app: {
url: Y_CODE_DESIGNER_URL,
name: 'y-code-designer',
applicationId: 4,
projectId: 4,
sync: true,
alive: true,
degrade: true,

View File

@@ -18,7 +18,7 @@ const routes: Array<RouteRecordRaw> = [
path: 'list',
name: `${moduleName}-list`,
meta: {
title: '项目列表',
title: '用户列表',
keepAlive: true,
icon: 'ant-design:list',
app: {

View File

@@ -1,16 +1,16 @@
import type { RouteRecordRaw } from 'vue-router';
import { LOGIN_NAME } from '@/router/constant';
// import type { RouteRecordRaw } from 'vue-router';
// import { LOGIN_NAME } from '@/router/constant';
/**
* layout布局之外的路由
*/
export const LoginRoute: RouteRecordRaw = {
path: '/login',
name: LOGIN_NAME,
component: () => import('@/views/login/index.vue'),
meta: {
title: '登录',
},
};
// export const LoginRoute: RouteRecordRaw = {
// path: '/login',
// name: LOGIN_NAME,
// component: () => import('@/views/login/index.vue'),
// meta: {
// title: '登录',
// },
// };
export default [LoginRoute];
export default [];

View File

@@ -31,16 +31,16 @@ export const useUserStore = defineStore(
/** 登录 */
const login = async () => {
tianti.checkQuery();
setTimeout(() => {
const token = localStorage.getItem('y-code-access-token');
if (token) {
setToken(token);
const token = localStorage.getItem('y-code-access-token');
if (token) {
setToken(token);
setTimeout(() => {
getCurrentUser().then((res) => {
userInfo.value = res.data.data;
console.log('userInfo', userInfo.value);
});
}
}, 0);
}, 1000);
}
};
/** 登出 */
const logout = async () => {