test: 低代码依赖升级尝试

This commit is contained in:
wangxuefeng
2025-03-18 14:32:33 +08:00
parent 1019afc24c
commit d1cbb3f1f7
7 changed files with 1076 additions and 656 deletions

View File

@@ -11,7 +11,9 @@ import { LowCodeService } from './service';
// 解析 url 参数
const urlParams = new URLSearchParams(window.location.search);
const fileId = urlParams.get('fileId');
console.log('urlParams-fileId', fileId);
const projectId = urlParams.get('projectId');
console.log('urlParams-projectId', projectId);
// 定义 wujie props 的类型
interface WujieProps {
@@ -65,33 +67,11 @@ const hideLoading = () => {
}
};
// 校验必要参数
const validateProps = () => {
const { fileId, projectId } = wujieProps;
if (!fileId) {
ElMessage.error('缺少必要参数fileId');
return false;
}
if (!projectId) {
ElMessage.error('缺少必要参数projectId');
return false;
}
return true;
};
// 初始化低代码引擎 - 只初始化一次
const initLowCodeEngine = async () => {
// 如果已经初始化过,直接返回
if (provider.value) return provider.value;
// 校验参数
if (!validateProps()) {
throw new Error('参数校验失败');
}
// 初始化请求配置
initRequestConfig(wujieProps.accessToken);
@@ -99,7 +79,7 @@ const initLowCodeEngine = async () => {
const { provider: lowCodeProvider, onReady } = createProvider({
nodeEnv: import.meta.env.NODE_ENV,
service: lowCodeService,
project: { id: Number(wujieProps.projectId) || -1 },
project: { id: Number(wujieProps.projectId) },
adapter: {
request,
jsonp,
@@ -117,8 +97,6 @@ const initLowCodeEngine = async () => {
// 获取渲染组件
const getRenderComponent = async () => {
if (!validateProps()) return null;
isLoading.value = true;
showLoading();