diff --git a/src/main/resources/static/src/config/axios-config.js b/src/main/resources/static/src/config/axios-config.js index bf994d6..6234e1a 100644 --- a/src/main/resources/static/src/config/axios-config.js +++ b/src/main/resources/static/src/config/axios-config.js @@ -34,6 +34,8 @@ axiosInstance.interceptors.response.use( } else { antd.message.error(message || '系统出错'); } + + return error.response.data; } return Promise.reject(error.message); } diff --git a/src/main/resources/static/src/views/database/DatabaseForm.js b/src/main/resources/static/src/views/database/DatabaseForm.js index 7749112..fd84bb1 100644 --- a/src/main/resources/static/src/views/database/DatabaseForm.js +++ b/src/main/resources/static/src/views/database/DatabaseForm.js @@ -288,11 +288,12 @@ const DatabaseForm = { async onDownloadZip() { this.downloadLoading = true; try { + // 重要:指定响应类型为blob const response = await axiosInstance({ url: "/generator/downloadByZip", method: "POST", data: this.form, - responseType: 'blob' // 重要:指定响应类型为blob + responseType: 'blob' }); // 从响应头中获取文件名 diff --git a/src/main/resources/templates/database.html b/src/main/resources/templates/database.html index 0d12bb3..240ad21 100644 --- a/src/main/resources/templates/database.html +++ b/src/main/resources/templates/database.html @@ -169,21 +169,32 @@ }, watch: { /* 数据表选择 */ - dbSelect: { - handler() { - this.getDatabaseTableList(); - } - }, + dbSelect: "getDatabaseTableList", /* 过滤数据表 */ - tableSelect: { - handler(val) { - this.tableList = this.rawTableList; - // 根据表名进行过滤筛选或者根据注释内容进行筛选 - this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val)); - } + tableSelect(val) { + this.tableList = this.rawTableList; + // 根据表名进行过滤筛选或者根据注释内容进行筛选 + this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val)); }, + + /** + * 监听form表单放到 localStorage + * 不要使用 immediate 否则初始话加载的时候会将 localStorage 改成 原始表单 + */ + form: { + deep: true, + handler(val) { + localStorage.setItem("form", JSON.stringify(val)); + }, + } }, + mounted() { + const form = localStorage.getItem("form"); + if (form !== null) { + this.form = JSON.parse(form); + } + } }); // 注册组件