Skip to content

Commit

Permalink
优化上传接口返回值的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hslr-s committed Jan 15, 2024
1 parent cc62f3c commit dbf9e42
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"1201": "Please keep at least one",
"1202": "Data record not found",
"1300": "Upload failed",
"1301": "Unsupported file format",
"1301": "Upload failed, unsupported file format",
"1400": "Parameter format error"
},
"appLauncher": {
Expand Down
2 changes: 1 addition & 1 deletion src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"1201": "请至少保留一个",
"1202": "未找到数据记录",
"1300": "上传失败",
"1301": "不被支持的文件格式",
"1301": "上传失败,不被支持的文件格式",
"1400": "参数格式错误"
},
"appLauncher": {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/request/apiMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const themeRef = ref<'light' | 'dark'>('light')
const configProviderPropsRef = computed<ConfigProviderProps>(() => ({
theme: themeRef.value === 'light' ? lightTheme : darkTheme,
}))
const { message } = createDiscreteApi(['message'], { configProviderProps: configProviderPropsRef })
export const { message } = createDiscreteApi(['message'], { configProviderProps: configProviderPropsRef })

export function apiRespErrMsg(res: Response): boolean {
const appStore = useAppStore()
Expand Down
2 changes: 1 addition & 1 deletion src/utils/request/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AxiosProgressEvent, AxiosResponse, GenericAbortSignal } from 'axios'
import request from './axios'
import { apiRespErrMsg } from './apiMessage'
import { apiRespErrMsg, message } from './apiMessage'
import { t } from '@/locales'
import { useAppStore, useAuthStore } from '@/store'
import { router } from '@/router'
Expand Down
8 changes: 4 additions & 4 deletions src/views/home/components/EditItem/IconEditor.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { NButton, NColorPicker, NInput, NRadio, NUpload, useMessage } from 'naive-ui'
import { NButton, NColorPicker, NInput, NRadio, NUpload } from 'naive-ui'
import type { UploadFileInfo } from 'naive-ui'
import { computed, defineProps } from 'vue'
import { ItemIcon } from '@/components/common'
import { useAuthStore } from '@/store'
import { t } from '@/locales'
import { apiRespErrMsg } from '@/utils/request/apiMessage'
const props = defineProps<{
itemIcon: Panel.ItemIcon | null
Expand All @@ -13,7 +13,6 @@ const emit = defineEmits<{
(e: 'update:itemIcon', visible: Panel.ItemIcon): void // 定义修改父组件(prop内)的值的事件
}>()
const authStore = useAuthStore()
const ms = useMessage()
// 默认图标背景色
const defautSwatchesBackground = [
Expand Down Expand Up @@ -75,7 +74,8 @@ const handleUploadFinish = ({
emit('update:itemIcon', itemIconInfo.value || null)
}
else {
ms.error(`${t('common.uploadFail')}:${res.msg}`)
apiRespErrMsg(res)
// ms.error(`${t('common.uploadFail')}:${res.msg}`)
}
return file
Expand Down

0 comments on commit dbf9e42

Please sign in to comment.