From a57f79cf90e8fc70f646c1dd91fac79b0df6ce73 Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 25 Jul 2022 16:53:36 +0800 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20vue2=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codegen/java/controller/vo/exportReqVO.vm | 10 ++----- .../codegen/java/controller/vo/pageReqVO.vm | 10 ++----- .../resources/codegen/vue/views/index.vue.vm | 14 +++------- .../src/router/modules/remaining.ts | 2 +- .../codegen/{ => components}/EditTable.vue | 7 ++--- .../infra/codegen/components/GenInfoForm.vue | 5 ++++ .../infra/codegen/components/ImportTable.vue | 28 +++++++++---------- .../views/infra/codegen/components/index.ts | 7 +++++ .../src/views/infra/codegen/index.vue | 3 +- .../src/views/infra/codegen/index.vue | 2 +- 10 files changed, 42 insertions(+), 46 deletions(-) rename yudao-ui-admin-vue3/src/views/infra/codegen/{ => components}/EditTable.vue (92%) create mode 100644 yudao-ui-admin-vue3/src/views/infra/codegen/components/index.ts diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm index 10ab97afc..afd583c28 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; #end ## 字段模板 #macro(columnTpl $prefix $prefixStr) -#if (${column.javaType} == "Date")## 时间类型 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) -#end @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; #end @@ -27,12 +24,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; public class ${sceneEnum.prefixClass}${table.className}ExportReqVO { #foreach ($column in $columns) -#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 #if (${column.listOperation})##查询操作 #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 - #columnTpl('begin', '开始') - - #columnTpl('end', '结束') + @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private ${column.javaType}[] ${column.javaField}; #else##情况二,非 Between 的时间 #columnTpl('', '') #end diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm index 5f5952c59..df2be7036 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; #end ## 字段模板 #macro(columnTpl $prefix $prefixStr) -#if (${column.javaType} == "Date")## 时间类型 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) -#end @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; #end @@ -29,12 +26,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam { #foreach ($column in $columns) -#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 #if (${column.listOperation})##查询操作 #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 - #columnTpl('begin', '开始') - - #columnTpl('end', '结束') + @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private ${column.javaType}[] ${column.javaField}; #else##情况二,非 Between 的时间 #columnTpl('', '') #end diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm index d49fa93c5..95f7d66a2 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm @@ -219,22 +219,16 @@ export default { title: "", // 是否显示弹出层 open: false, - #foreach ($column in $columns)## 时间范围 - #if ($column.listOperation) - #if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") - #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - dateRange${AttrName}: [], - #end - #end - #end // 查询参数 queryParams: { pageNo: 1, pageSize: 10, #foreach ($column in $columns) - #if ($column.listOperation && $column.listOperationCondition != 'BETWEEN') + #if ($column.listOperation) + #if ($column.listOperationCondition != 'BETWEEN') $column.javaField: null, - #else if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") + #end + #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") $column.javaField: [], #end #end diff --git a/yudao-ui-admin-vue3/src/router/modules/remaining.ts b/yudao-ui-admin-vue3/src/router/modules/remaining.ts index 92f3a367e..7c3c524e6 100644 --- a/yudao-ui-admin-vue3/src/router/modules/remaining.ts +++ b/yudao-ui-admin-vue3/src/router/modules/remaining.ts @@ -72,7 +72,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ children: [ { path: 'edit', - component: () => import('@/views/infra/codegen/EditTable.vue'), + component: () => import('@/views/infra/codegen/components/EditTable.vue'), name: 'EditTable', meta: { noCache: true, diff --git a/yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue b/yudao-ui-admin-vue3/src/views/infra/codegen/components/EditTable.vue similarity index 92% rename from yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue rename to yudao-ui-admin-vue3/src/views/infra/codegen/components/EditTable.vue index 07dfa5221..47e2c89e6 100644 --- a/yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue +++ b/yudao-ui-admin-vue3/src/views/infra/codegen/components/EditTable.vue @@ -1,9 +1,9 @@ + + diff --git a/yudao-ui-admin/src/views/infra/codegen/index.vue b/yudao-ui-admin/src/views/infra/codegen/index.vue index dea674742..adb006995 100644 --- a/yudao-ui-admin/src/views/infra/codegen/index.vue +++ b/yudao-ui-admin/src/views/infra/codegen/index.vue @@ -98,7 +98,7 @@ hljs.registerLanguage("html", require("highlight.js/lib/languages/xml")); hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml")); hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript")); hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql")); - +hljs.registerLanguage("typescript", require("highlight.js/lib/languages/typescript")); export default { name: "Codegen", components: { importTable }, From 611e11ae23e961057bde65b724d0ca29762d6fbc Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 25 Jul 2022 19:14:33 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8C=BA=E9=97=B4?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=AD=97=E6=AE=B5=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/mybatis/core/query/LambdaQueryWrapperX.java | 4 ++-- .../yudao/framework/mybatis/core/query/QueryWrapperX.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java index d9ba7c4be..d387e2865 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java @@ -98,10 +98,10 @@ public class LambdaQueryWrapperX extends LambdaQueryWrapper { if (values!= null && values.length >0 && values[0] != null && values[1] != null) { return (LambdaQueryWrapperX) super.between(column, values[0], values[1]); } - if (values != null && values[0] != null) { + if (values != null && values.length >0 && values[0] != null) { return (LambdaQueryWrapperX) ge(column, values[0]); } - if (values != null && values[1] != null) { + if (values != null && values.length >0 && values[1] != null) { return (LambdaQueryWrapperX) le(column, values[2]); } return this; diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java index 1effb19ed..a44300833 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java @@ -95,13 +95,13 @@ public class QueryWrapperX extends QueryWrapper { } public QueryWrapperX betweenIfPresent(String column, Object[] values) { - if (values!= null && values[0] != null && values[1] != null) { + if (values!= null && values.length != 0 && values[0] != null && values[1] != null) { return (QueryWrapperX) super.between(column, values[0], values[1]); } - if (values!= null && values[0] != null) { + if (values!= null && values.length != 0 && values[0] != null) { return (QueryWrapperX) ge(column, values[0]); } - if (values!= null && values[1] != null) { + if (values!= null && values.length != 0 && values[1] != null) { return (QueryWrapperX) le(column, values[1]); } return this; From b085f35dfeb7a83e213bb942a7ed99298f330fdc Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 25 Jul 2022 21:03:14 +0800 Subject: [PATCH 4/9] feat: vue3 axios add download function --- .../src/api/infra/apiAccessLog/index.ts | 2 +- .../src/api/infra/apiErrorLog/index.ts | 5 ++++- yudao-ui-admin-vue3/src/api/infra/codegen/index.ts | 2 +- yudao-ui-admin-vue3/src/api/infra/config/index.ts | 2 +- yudao-ui-admin-vue3/src/api/infra/dbDoc/index.ts | 6 +++--- yudao-ui-admin-vue3/src/api/infra/job/index.ts | 2 +- yudao-ui-admin-vue3/src/api/infra/jobLog/index.ts | 5 ++--- yudao-ui-admin-vue3/src/api/pay/app/index.ts | 2 +- yudao-ui-admin-vue3/src/api/pay/channel/index.ts | 2 +- yudao-ui-admin-vue3/src/api/pay/merchant/index.ts | 2 +- yudao-ui-admin-vue3/src/api/pay/order/index.ts | 2 +- yudao-ui-admin-vue3/src/api/pay/refund/index.ts | 2 +- .../src/api/system/errorCode/index.ts | 2 +- yudao-ui-admin-vue3/src/api/system/loginLog/index.ts | 2 +- .../src/api/system/operatelog/index.ts | 2 +- yudao-ui-admin-vue3/src/api/system/post/index.ts | 2 +- .../src/api/system/sensitiveWord/index.ts | 2 +- .../src/api/system/sms/smsLog/index.ts | 2 +- .../src/api/system/sms/smsTemplate/index.ts | 5 ++++- yudao-ui-admin-vue3/src/api/system/tenant/index.ts | 2 +- yudao-ui-admin-vue3/src/api/system/user/index.ts | 4 ++-- yudao-ui-admin-vue3/src/config/axios/index.ts | 3 ++- yudao-ui-admin-vue3/src/hooks/web/useAxios.ts | 7 ++++++- yudao-ui-admin-vue3/src/utils/download.ts | 12 ++++++------ .../src/views/infra/codegen/index.vue | 4 ++-- .../src/views/system/oauth2/client/index.vue | 2 +- 26 files changed, 48 insertions(+), 37 deletions(-) diff --git a/yudao-ui-admin-vue3/src/api/infra/apiAccessLog/index.ts b/yudao-ui-admin-vue3/src/api/infra/apiAccessLog/index.ts index 544118e4d..9f3614f5a 100644 --- a/yudao-ui-admin-vue3/src/api/infra/apiAccessLog/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/apiAccessLog/index.ts @@ -9,5 +9,5 @@ export const getApiAccessLogPageApi = (params) => { // 导出API 访问日志 export const exportApiAccessLogApi = (params) => { - return request.get({ url: '/infra/api-access-log/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/infra/api-access-log/export-excel', params }) } diff --git a/yudao-ui-admin-vue3/src/api/infra/apiErrorLog/index.ts b/yudao-ui-admin-vue3/src/api/infra/apiErrorLog/index.ts index 1bf019691..e8209b2b4 100644 --- a/yudao-ui-admin-vue3/src/api/infra/apiErrorLog/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/apiErrorLog/index.ts @@ -16,5 +16,8 @@ export const updateApiErrorLogPageApi = (id: number, processStatus: number) => { // 导出API 访问日志 export const exportApiErrorLogApi = (params) => { - return request.get({ url: '/infra/api-error-log/export-excel', params, responseType: 'blob' }) + return request.download({ + url: '/infra/api-error-log/export-excel', + params + }) } diff --git a/yudao-ui-admin-vue3/src/api/infra/codegen/index.ts b/yudao-ui-admin-vue3/src/api/infra/codegen/index.ts index 12fc05365..dbce9518b 100644 --- a/yudao-ui-admin-vue3/src/api/infra/codegen/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/codegen/index.ts @@ -40,7 +40,7 @@ export const previewCodegenApi = (id: number) => { // 下载生成代码 export const downloadCodegenApi = (id: number) => { - return request.get({ url: '/infra/codegen/download?tableId=' + id, responseType: 'blob' }) + return request.download({ url: '/infra/codegen/download?tableId=' + id }) } // 获得表定义 diff --git a/yudao-ui-admin-vue3/src/api/infra/config/index.ts b/yudao-ui-admin-vue3/src/api/infra/config/index.ts index 2628e1aba..d3c042a57 100644 --- a/yudao-ui-admin-vue3/src/api/infra/config/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/config/index.ts @@ -35,5 +35,5 @@ export const deleteConfigApi = (id: number) => { // 导出参数 export const exportConfigApi = (params) => { - return request.get({ url: '/infra/config/export', params, responseType: 'blob' }) + return request.download({ url: '/infra/config/export', params }) } diff --git a/yudao-ui-admin-vue3/src/api/infra/dbDoc/index.ts b/yudao-ui-admin-vue3/src/api/infra/dbDoc/index.ts index 0942e3b2e..2fd771635 100644 --- a/yudao-ui-admin-vue3/src/api/infra/dbDoc/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/dbDoc/index.ts @@ -4,15 +4,15 @@ const request = useAxios() // 导出Html export const exportHtmlApi = () => { - return request.get({ url: '/infra/db-doc/export-html', responseType: 'blob' }) + return request.download({ url: '/infra/db-doc/export-html' }) } // 导出Word export const exportWordApi = () => { - return request.get({ url: '/infra/db-doc/export-word', responseType: 'blob' }) + return request.download({ url: '/infra/db-doc/export-word' }) } // 导出Markdown export const exportMarkdownApi = () => { - return request.get({ url: '/infra/db-doc/export-markdown', responseType: 'blob' }) + return request.download({ url: '/infra/db-doc/export-markdown' }) } diff --git a/yudao-ui-admin-vue3/src/api/infra/job/index.ts b/yudao-ui-admin-vue3/src/api/infra/job/index.ts index 5739c788a..bf1193194 100644 --- a/yudao-ui-admin-vue3/src/api/infra/job/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/job/index.ts @@ -30,7 +30,7 @@ export const deleteJobApi = (id: number) => { // 导出定时任务调度 export const exportJobApi = (params) => { - return request.get({ url: '/infra/job/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/infra/job/export-excel', params }) } // 任务状态修改 diff --git a/yudao-ui-admin-vue3/src/api/infra/jobLog/index.ts b/yudao-ui-admin-vue3/src/api/infra/jobLog/index.ts index 50ff327d1..a82724ddf 100644 --- a/yudao-ui-admin-vue3/src/api/infra/jobLog/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/jobLog/index.ts @@ -14,9 +14,8 @@ export const getJobLogApi = (id: number) => { // 导出定时任务日志 export const exportJobLogApi = (params) => { - return request.get({ + return request.download({ url: '/infra/job-log/export-excel', - params, - responseType: 'blob' + params }) } diff --git a/yudao-ui-admin-vue3/src/api/pay/app/index.ts b/yudao-ui-admin-vue3/src/api/pay/app/index.ts index 1a8cef698..19885e3a6 100644 --- a/yudao-ui-admin-vue3/src/api/pay/app/index.ts +++ b/yudao-ui-admin-vue3/src/api/pay/app/index.ts @@ -39,7 +39,7 @@ export const deleteAppApi = (id: number) => { // 导出支付应用 export const exportAppApi = (params) => { - return request.get({ url: '/pay/app/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/pay/app/export-excel', params }) } // 根据商ID称搜索应用列表 diff --git a/yudao-ui-admin-vue3/src/api/pay/channel/index.ts b/yudao-ui-admin-vue3/src/api/pay/channel/index.ts index e7e875df3..05fdddb30 100644 --- a/yudao-ui-admin-vue3/src/api/pay/channel/index.ts +++ b/yudao-ui-admin-vue3/src/api/pay/channel/index.ts @@ -35,5 +35,5 @@ export const deleteChannelApi = (id: number) => { // 导出支付渠道 export const exportChannelApi = (params) => { - return request.get({ url: '/pay/channel/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/pay/channel/export-excel', params }) } diff --git a/yudao-ui-admin-vue3/src/api/pay/merchant/index.ts b/yudao-ui-admin-vue3/src/api/pay/merchant/index.ts index 679ed8815..d6aba8dd2 100644 --- a/yudao-ui-admin-vue3/src/api/pay/merchant/index.ts +++ b/yudao-ui-admin-vue3/src/api/pay/merchant/index.ts @@ -40,7 +40,7 @@ export const deleteMerchantApi = (id: number) => { // 导出支付商户 export const exportMerchantApi = (params) => { - return request.get({ url: '/pay/merchant/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/pay/merchant/export-excel', params }) } // 支付商户状态修改 export const changeMerchantStatusApi = (id: number, status: number) => { diff --git a/yudao-ui-admin-vue3/src/api/pay/order/index.ts b/yudao-ui-admin-vue3/src/api/pay/order/index.ts index 62bf63e8f..662b2ebee 100644 --- a/yudao-ui-admin-vue3/src/api/pay/order/index.ts +++ b/yudao-ui-admin-vue3/src/api/pay/order/index.ts @@ -30,5 +30,5 @@ export const deleteOrderApi = async (id: number) => { // 导出支付订单 export const exportOrderApi = async (params) => { - return await request.get({ url: '/pay/order/export-excel', params, responseType: 'blob' }) + return await request.download({ url: '/pay/order/export-excel', params }) } diff --git a/yudao-ui-admin-vue3/src/api/pay/refund/index.ts b/yudao-ui-admin-vue3/src/api/pay/refund/index.ts index 56da12236..55185b7e0 100644 --- a/yudao-ui-admin-vue3/src/api/pay/refund/index.ts +++ b/yudao-ui-admin-vue3/src/api/pay/refund/index.ts @@ -30,5 +30,5 @@ export const deleteRefundApi = (id: number) => { // 导出退款订单 export const exportRefundApi = (params) => { - return request.get({ url: '/pay/refund/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/pay/refund/export-excel', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts b/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts index e3e7be3e7..fe3f128cc 100644 --- a/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts @@ -29,5 +29,5 @@ export const deleteErrorCodeApi = (id: number) => { } // 导出错误码 export const excelErrorCodeApi = (params) => { - return request.get({ url: '/system/error-code/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/system/error-code/export-excel', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts b/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts index 1a746805f..f117439f9 100644 --- a/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts @@ -8,5 +8,5 @@ export const getLoginLogPageApi = (params) => { } // 导出登录日志 export const exportLoginLogApi = (params) => { - return request.get({ url: '/system/login-log/export', params, responseType: 'blob' }) + return request.download({ url: '/system/login-log/export', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/operatelog/index.ts b/yudao-ui-admin-vue3/src/api/system/operatelog/index.ts index ac95fb027..aa55e1a85 100644 --- a/yudao-ui-admin-vue3/src/api/system/operatelog/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/operatelog/index.ts @@ -8,5 +8,5 @@ export const getOperateLogPageApi = (params) => { } // 导出操作日志 export const exportOperateLogApi = (params) => { - return request.get({ url: '/system/operate-log/export', params, responseType: 'blob' }) + return request.download({ url: '/system/operate-log/export', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/post/index.ts b/yudao-ui-admin-vue3/src/api/system/post/index.ts index feb9389b2..40eb9705a 100644 --- a/yudao-ui-admin-vue3/src/api/system/post/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/post/index.ts @@ -34,5 +34,5 @@ export const deletePostApi = async (id: number) => { // 导出岗位 export const exportPostApi = async (params) => { - return await request.get({ url: '/system/post/export', params, responseType: 'blob' }) + return await request.download({ url: '/system/post/export', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/sensitiveWord/index.ts b/yudao-ui-admin-vue3/src/api/system/sensitiveWord/index.ts index 513b3982e..af2e832b8 100644 --- a/yudao-ui-admin-vue3/src/api/system/sensitiveWord/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/sensitiveWord/index.ts @@ -30,7 +30,7 @@ export const deleteSensitiveWordApi = (id: number) => { // 导出敏感词 export const exportSensitiveWordApi = (params) => { - return request.get({ url: '/system/sensitive-word/export', params, responseType: 'blob' }) + return request.download({ url: '/system/sensitive-word/export-excel', params }) } // 获取所有敏感词的标签数组 diff --git a/yudao-ui-admin-vue3/src/api/system/sms/smsLog/index.ts b/yudao-ui-admin-vue3/src/api/system/sms/smsLog/index.ts index 4d110fc6d..92401fa01 100644 --- a/yudao-ui-admin-vue3/src/api/system/sms/smsLog/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/sms/smsLog/index.ts @@ -9,5 +9,5 @@ export const getSmsLogPageApi = (params) => { // 导出短信日志 export const exportSmsLogApi = (params) => { - return request.get({ url: '/system/sms-log/export', params, responseType: 'blob' }) + return request.download({ url: '/system/sms-log/export', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/sms/smsTemplate/index.ts b/yudao-ui-admin-vue3/src/api/system/sms/smsTemplate/index.ts index 26cc883c0..cfc9b4c08 100644 --- a/yudao-ui-admin-vue3/src/api/system/sms/smsTemplate/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/sms/smsTemplate/index.ts @@ -35,5 +35,8 @@ export const sendSmsApi = (data) => { // 导出短信模板 export const exportPostApi = (params) => { - return request.get({ url: '/system/sms-template/export-excel', params, responseType: 'blob' }) + return request.download({ + url: '/system/sms-template/export-excel', + params + }) } diff --git a/yudao-ui-admin-vue3/src/api/system/tenant/index.ts b/yudao-ui-admin-vue3/src/api/system/tenant/index.ts index 98b25b6e2..851ac11d1 100644 --- a/yudao-ui-admin-vue3/src/api/system/tenant/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/tenant/index.ts @@ -30,5 +30,5 @@ export const deleteTenantApi = (id: number) => { // 导出租户 export const exportTenantApi = (params) => { - return request.get({ url: '/system/tenant/export-excel', params, responseType: 'blob' }) + return request.download({ url: '/system/tenant/export-excel', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/user/index.ts b/yudao-ui-admin-vue3/src/api/system/user/index.ts index b556fd830..f4a484eaf 100644 --- a/yudao-ui-admin-vue3/src/api/system/user/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/user/index.ts @@ -30,12 +30,12 @@ export const deleteUserApi = (id: number) => { // 导出用户 export const exportUserApi = (params) => { - return request.get({ url: '/system/user/export', params, responseType: 'blob' }) + return request.download({ url: '/system/user/export', params }) } // 下载用户导入模板 export const importUserTemplateApi = () => { - return request.get({ url: '/system/user/get-import-template', responseType: 'blob' }) + return request.download({ url: '/system/user/get-import-template' }) } // 用户密码重置 diff --git a/yudao-ui-admin-vue3/src/config/axios/index.ts b/yudao-ui-admin-vue3/src/config/axios/index.ts index fe4b2a95a..95023c4e4 100644 --- a/yudao-ui-admin-vue3/src/config/axios/index.ts +++ b/yudao-ui-admin-vue3/src/config/axios/index.ts @@ -29,7 +29,8 @@ export const PATH_URL = base_url[import.meta.env.VITE_API_BASEPATH] // 创建axios实例 const service: AxiosInstance = axios.create({ baseURL: BASE_URL + BASE_API, // api 的 base_url - timeout: config.request_timeout // 请求超时时间 + timeout: config.request_timeout, // 请求超时时间 + withCredentials: false // 禁用 Cookie 等信息 }) // request拦截器 diff --git a/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts b/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts index bca77b85b..f8aacd087 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts @@ -37,12 +37,17 @@ async function putFn(option: AxiosConfig): Promise { const res = await request({ method: 'PUT', ...option }) return res.data } +async function downloadFn(option: AxiosConfig): Promise { + const res = await request({ method: 'GET', responseType: 'blob', ...option }) + return res as unknown as Promise +} export const useAxios = () => { return { get: getFn, post: postFn, delete: deleteFn, - put: putFn + put: putFn, + download: downloadFn } } diff --git a/yudao-ui-admin-vue3/src/utils/download.ts b/yudao-ui-admin-vue3/src/utils/download.ts index 12c01fea1..ab2001494 100644 --- a/yudao-ui-admin-vue3/src/utils/download.ts +++ b/yudao-ui-admin-vue3/src/utils/download.ts @@ -1,4 +1,4 @@ -const download0 = (data: any, fileName: string, mineType: string) => { +const download0 = (data: Blob, fileName: string, mineType: string) => { // 创建 blob const blob = new Blob([data], { type: mineType }) // 创建 href 超链接,点击进行下载 @@ -14,23 +14,23 @@ const download0 = (data: any, fileName: string, mineType: string) => { const download = { // 下载 Excel 方法 - excel: (data: any, fileName: string) => { + excel: (data: Blob, fileName: string) => { download0(data, fileName, 'application/vnd.ms-excel') }, // 下载 Word 方法 - word: (data: any, fileName: string) => { + word: (data: Blob, fileName: string) => { download0(data, fileName, 'application/msword') }, // 下载 Zip 方法 - zip: (data: any, fileName: string) => { + zip: (data: Blob, fileName: string) => { download0(data, fileName, 'application/zip') }, // 下载 Html 方法 - html: (data: any, fileName: string) => { + html: (data: Blob, fileName: string) => { download0(data, fileName, 'text/html') }, // 下载 Markdown 方法 - markdown: (data: any, fileName: string) => { + markdown: (data: Blob, fileName: string) => { download0(data, fileName, 'text/markdown') } } diff --git a/yudao-ui-admin-vue3/src/views/infra/codegen/index.vue b/yudao-ui-admin-vue3/src/views/infra/codegen/index.vue index 0c604473e..7583abb4a 100644 --- a/yudao-ui-admin-vue3/src/views/infra/codegen/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/codegen/index.vue @@ -45,8 +45,8 @@ const handleSynchDb = (row: CodegenTableVO) => { }) } // 生成代码操作 -const handleGenTable = (row: CodegenTableVO) => { - const res = CodegenApi.downloadCodegenApi(row.id) +const handleGenTable = async (row: CodegenTableVO) => { + const res = await CodegenApi.downloadCodegenApi(row.id) download.zip(res, 'codegen-' + row.className + '.zip') } // 删除操作 diff --git a/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue b/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue index 607cf9b5c..fadc430f7 100644 --- a/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue @@ -113,7 +113,7 @@ getList() @register="register" >