diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln index 28916cf62..bd2ebe432 100644 --- a/aspnet-core/LINGYUN.MicroService.Common.sln +++ b/aspnet-core/LINGYUN.MicroService.Common.sln @@ -105,11 +105,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.BlobStoring.Ali EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "console", "console", "{8D2AD50B-DD4B-48A2-88EC-0E8E8236D883}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Encryption.Console", "modules\console\LINGYUN.Abp.Encryption.Console\LINGYUN.Abp.Encryption.Console.csproj", "{8FB74B18-CA5C-4DC3-8DFA-600133A05712}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Encryption.Console", "modules\console\LINGYUN.Abp.Encryption.Console\LINGYUN.Abp.Encryption.Console.csproj", "{8FB74B18-CA5C-4DC3-8DFA-600133A05712}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Aliyun.Tests", "tests\LINGYUN.Abp.Aliyun.Tests\LINGYUN.Abp.Aliyun.Tests.csproj", "{3DBF0975-B09D-49CA-9AF8-69175EDB9D52}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Aliyun.Tests", "tests\LINGYUN.Abp.Aliyun.Tests\LINGYUN.Abp.Aliyun.Tests.csproj", "{3DBF0975-B09D-49CA-9AF8-69175EDB9D52}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Sms.Aliyun.Tests", "tests\LINGYUN.Abp.Sms.Aliyun.Tests\LINGYUN.Abp.Sms.Aliyun.Tests.csproj", "{93DD5A05-B67A-4E11-BB56-F6B4E7F1489C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Sms.Aliyun.Tests", "tests\LINGYUN.Abp.Sms.Aliyun.Tests\LINGYUN.Abp.Sms.Aliyun.Tests.csproj", "{93DD5A05-B67A-4E11-BB56-F6B4E7F1489C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/vueJs/src/utils/request.ts b/vueJs/src/utils/request.ts index 48f06d5ea..9834183fa 100644 --- a/vueJs/src/utils/request.ts +++ b/vueJs/src/utils/request.ts @@ -16,17 +16,18 @@ service.interceptors.request.use( (config) => { if (AbpModule.configuration) { if (AbpModule.configuration.currentTenant.isAvailable) { - config.headers.__tenant = AbpModule.configuration.currentTenant.id + config.headers['__tenant'] = AbpModule.configuration.currentTenant.id } config.headers['Accept-Language'] = AbpModule.configuration.localization?.currentCulture?.cultureName - } - // abp官方类库用的 zh-Hans 的简体中文包 这里直接粗暴一点 - // 顺序调整到token之前 - const language = getLanguage() - if (language?.indexOf('zh') !== -1) { - config.headers['Accept-Language'] = 'zh-Hans' } else { - config.headers['Accept-Language'] = language + // abp官方类库用的 zh-Hans 的简体中文包 这里直接粗暴一点 + // 顺序调整到token之前 + const language = getLanguage() + if (language?.indexOf('zh') !== -1) { + config.headers['Accept-Language'] = 'zh-Hans' + } else { + config.headers['Accept-Language'] = language + } } if (config.url === '/connect/token') { return config @@ -46,11 +47,33 @@ function l(name: string) { return i18n.tc(name) } -function showError(response: any) { +function showError(error: any) { let message = '' let title = '' + let response = error.response + console.log(response) + // 特别处理返回数据为blob类型时的错误信息 + if (error.config.responseType && error.config.responseType === 'blob') { + const fileReader = new FileReader() + fileReader.onload = (e) => { + if (e.target?.result) { + const jsonError = JSON.parse(e.target.result.toString()) + Notification({ + title: l('AbpUi.DefaultErrorMessage'), + message: jsonError.error.message, + type: 'error', + duration: 5 * 1000 + }) + } + } + fileReader.readAsText(error.response.data, 'utf-8') + return + } if (response.data && response.data.error) { - if (response.data.error.details) { + if (response.data.error_description) { + title = response.data.error + message = response.data.error_description + } else if (response.data.error.details) { message = response.data.error.details title = response.data.error.message } else if (response.data.error.message) { @@ -58,10 +81,6 @@ function showError(response: any) { } } else { switch (response.status) { - case 400: - title = response.data.error - message = response.data.error_description - break case 401: title = l('AbpUi.DefaultErrorMessage401') message = l('AbpUi.DefaultErrorMessage401Detail') @@ -121,7 +140,7 @@ service.interceptors.response.use( }) }) } else { - showError(error.response) + showError(error) } return Promise.reject(error) }