|
|
|
@ -20,6 +20,9 @@ import { getUserInfo } from '@/api/user';
|
|
|
|
import { setSessionUserInfo } from '@/utils/auth';
|
|
|
|
import { setSessionUserInfo } from '@/utils/auth';
|
|
|
|
import store from '@/store';
|
|
|
|
import store from '@/store';
|
|
|
|
import { updateUserInfo } from '@/store/user';
|
|
|
|
import { updateUserInfo } from '@/store/user';
|
|
|
|
|
|
|
|
import { getMyComponents, getPubComponents, getTeamComponents } from '@/api/components';
|
|
|
|
|
|
|
|
import { getPublishPage } from '@/api/flow';
|
|
|
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface RenderConfig {
|
|
|
|
interface RenderConfig {
|
|
|
|
@ -55,9 +58,72 @@ export default function MyApp({
|
|
|
|
store.dispatch(updateUserInfo({ userInfo: { ...res.data } }));
|
|
|
|
store.dispatch(updateUserInfo({ userInfo: { ...res.data } }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getComponentData = async () => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const requests = [
|
|
|
|
|
|
|
|
{ promise: getMyComponents(), key: 'myLibs' },
|
|
|
|
|
|
|
|
{ promise: getPubComponents(), key: 'pubLibs' },
|
|
|
|
|
|
|
|
{ promise: getTeamComponents(), key: 'teamLibs' },
|
|
|
|
|
|
|
|
{ promise: getPublishPage(), key: 'pubFlow' }
|
|
|
|
|
|
|
|
// {promise: appId ? getMineSubs({id: appId}) : Promise.resolve(null), key: 'myFlow'},
|
|
|
|
|
|
|
|
// {promise: getEventList(), key: 'eventList'}
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const obj: any = {
|
|
|
|
|
|
|
|
myLibs: null,
|
|
|
|
|
|
|
|
pubLibs: null,
|
|
|
|
|
|
|
|
teamLibs: null,
|
|
|
|
|
|
|
|
pubFlow: null,
|
|
|
|
|
|
|
|
// myFlow: null,
|
|
|
|
|
|
|
|
updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 分别处理每个请求
|
|
|
|
|
|
|
|
for (const { promise, key } of requests) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const res: any = await promise;
|
|
|
|
|
|
|
|
if (res?.code === 200 && res.data?.length > 0) {
|
|
|
|
|
|
|
|
// if (key === 'myLibs') {
|
|
|
|
|
|
|
|
// addCompInfo(res.data);
|
|
|
|
|
|
|
|
// libsStore.setMyLibs(res.data);
|
|
|
|
|
|
|
|
// } else if (key === 'pubLibs') {
|
|
|
|
|
|
|
|
// addCompInfo(res.data);
|
|
|
|
|
|
|
|
// libsStore.setPubLibs(res.data);
|
|
|
|
|
|
|
|
// } else if (key === 'teamLibs') {
|
|
|
|
|
|
|
|
// addCompInfo(res.data);
|
|
|
|
|
|
|
|
// libsStore.setTeamLibs(res.data);
|
|
|
|
|
|
|
|
// } else if (key === 'pubFlow') {
|
|
|
|
|
|
|
|
// addCompInfo(res.data, true);
|
|
|
|
|
|
|
|
// libsStore.setPubFlow(res.data);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else if (key === 'myFlow') {
|
|
|
|
|
|
|
|
// let newData = formatFlowMy(res.data);
|
|
|
|
|
|
|
|
// addCompInfo(newData, true);
|
|
|
|
|
|
|
|
// libsStore.setMyFlow(newData);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else if (key === 'eventList') {
|
|
|
|
|
|
|
|
// eventStore.setEventList(res.data);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新本地存储数据
|
|
|
|
|
|
|
|
obj[key] = res?.data || null;
|
|
|
|
|
|
|
|
sessionStorage.setItem(`compLibs${userInfo.userId}`, JSON.stringify(obj));
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error(`加载${key}失败:`, error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('加载组件库失败:', error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
if (checkLogin()) {
|
|
|
|
if (checkLogin()) {
|
|
|
|
fetchUserInfo();
|
|
|
|
fetchUserInfo();
|
|
|
|
|
|
|
|
getComponentData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (window.location.pathname.replace(/\//g, '') !== 'login') {
|
|
|
|
else if (window.location.pathname.replace(/\//g, '') !== 'login') {
|
|
|
|
Message.error('token过期,请重新登录');
|
|
|
|
Message.error('token过期,请重新登录');
|
|
|
|
|