wujingjing
2024-09-13 39ab910fe59480a35ebca316cd66e3995e70d4ed
支持刷新低代码,
已修改3个文件
38 ■■■■■ 文件已修改
src/api/login/UserMenuData.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/yw/lowCode/sqlAmis/edit/SqlAmisEdit.vue 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vite.config.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/login/UserMenuData.ts
@@ -40,7 +40,7 @@
                Permission: '',
                Icon: 'ywifont ywicon-a-appround15',
                IsIframe: true,
                OutLink: '/amis-editor/index.html?session={token}#/edit/lowCode&v=233',
                OutLink: '/amis-editor/index.html?session={token}#/edit/lowCode&v=33',
                IsHide: true,
                Weight: 0,
                SortCode: 2,
src/views/project/yw/lowCode/sqlAmis/edit/SqlAmisEdit.vue
@@ -68,9 +68,13 @@
                        <div class=" h-full">
                            <template v-if="currentDockConfig">
                                <div class=" flex justify-between items-center my-1 ml-1 h-[36px]">
                                    <el-select class="w-52 font-bold" v-model="currentDockConfig.type">
                                        <el-option v-for="item in Object.keys(amisDockTypeMap)" :key="item" :value="(item)" :label="amisDockTypeMap[item]"></el-option>
                                        <el-option
                                            v-for="item in Object.keys(amisDockTypeMap)"
                                            :key="item"
                                            :value="item"
                                            :label="amisDockTypeMap[item]"
                                        ></el-option>
                                    </el-select>
                                    <el-select class="w-40" v-model="currentDockConfig.database" @change="databaseSelectChange">
@@ -79,7 +83,7 @@
                                </div>
                                <codemirror
                                    class="overflow-auto"
                                    style="height: calc(100% - 36px);"
                                    style="height: calc(100% - 36px)"
                                    v-model="currentDockConfig.sql"
                                    :autofocus="true"
                                    :indent-with-tab="true"
@@ -141,7 +145,7 @@
    if(currentDockConfig.value){
        currentDockConfig.value.database = val;
    }
    updateSqlAndRs(currentDockConfig.value.id,currentDockConfig.value)
    updateSqlAndRs(currentDockConfig.value.id, currentDockConfig.value);
};
const backLastPage = () => {
    // setTimeout(() => {
@@ -219,7 +223,7 @@
        if (key === 'api') {
            // const url = value.url;
            const urlPath = path + PATH_SEPARATOR + 'url';
            const randomStr = 'query_' + uuid().slice(0, 12);
            const randomStr = 'q_' + value.url + '_' + uuid().slice(0, 12);
            const foundItem = apiDataList.find((item) => item.path === urlPath);
            const asyncId = foundItem?.asyncId ?? randomStr;
            const recordId = foundItem?.recordId ?? randomStr;
@@ -237,6 +241,7 @@
};
const checkValid = (showTip: boolean, tip?: string) => {
    if(!dockConfigList.value || dockConfigList.value.length===0) return true;
    const foundWithNoDatabase = dockConfigList.value?.find((item) => !item.database);
    if (foundWithNoDatabase && showTip) {
        ElMessage.warning(tip ?? `【${foundWithNoDatabase.id}】未选择数据库`);
@@ -246,10 +251,14 @@
const updateSqlAndRs = (id?, sqlValue?: { database?: string; sql?: string; type?: AmisDockType }) => {
    const apiConfig = configList.value.filter((item) => item.type === AmisDockType.Sql);
    if (apiConfig.length === 0) return;
    if (!checkValid(true)) {
        return;
    }
    const recordIds = apiConfig?.map(item=>item.recordId)??[];
    // 过滤出 apiConfig 中有的record;
    dockConfigList.value = dockConfigList.value?.filter(item=>recordIds.includes(item.id))??[]
    const asyncRsList = apiConfig.map((item) => ({
        amis_path: item.path,
        async_id: item.asyncId,
@@ -313,6 +322,7 @@
// 检查是否需要更新 rs
const checkRsUpdate = (originData: AmisDockConfig[], currentData: AmisDockConfig[]) => {
    // 都为空,不需要更新
    if ((!originData || originData.length === 0) && (!currentData || currentData.length === 0)) {
        return false;
@@ -376,10 +386,7 @@
        id: props.supervisor.id,
    });
    if (!xmlJson?.amis_json) {
        ElMessage.warning('暂无SQL配置');
        return;
    }
    const originConfig =
        xmlJson.async_rs?.map(
            (item) =>
@@ -400,7 +407,12 @@
        rsTableRef.value.setCurrentRow(configList.value[0]);
    }
    if (checkRsUpdate(originConfig, configList.value)) {
    if(!configList || configList.value.length===0 ){
        ElMessage.warning('暂无对接配置');
    }
    const isRsUpdate = checkRsUpdate(originConfig, configList.value)
    if (isRsUpdate) {
        // 自动更新Rs
        updateSqlAndRs();
    }
vite.config.ts
@@ -39,7 +39,7 @@
            host: '0.0.0.0',
            port: env.VITE_PORT as unknown as number,
            open: JSON.parse(env.VITE_OPEN),
            hmr: true,
            hmr: false,
            proxy: {
                '/gitee': {
                    target: 'https://gitee.com',