优化上传接口返回值的问题
This commit is contained in:
parent
cc62f3cb60
commit
dbf9e42cf3
@ -29,7 +29,7 @@
|
|||||||
"1201": "Please keep at least one",
|
"1201": "Please keep at least one",
|
||||||
"1202": "Data record not found",
|
"1202": "Data record not found",
|
||||||
"1300": "Upload failed",
|
"1300": "Upload failed",
|
||||||
"1301": "Unsupported file format",
|
"1301": "Upload failed, unsupported file format",
|
||||||
"1400": "Parameter format error"
|
"1400": "Parameter format error"
|
||||||
},
|
},
|
||||||
"appLauncher": {
|
"appLauncher": {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
"1201": "请至少保留一个",
|
"1201": "请至少保留一个",
|
||||||
"1202": "未找到数据记录",
|
"1202": "未找到数据记录",
|
||||||
"1300": "上传失败",
|
"1300": "上传失败",
|
||||||
"1301": "不被支持的文件格式",
|
"1301": "上传失败,不被支持的文件格式",
|
||||||
"1400": "参数格式错误"
|
"1400": "参数格式错误"
|
||||||
},
|
},
|
||||||
"appLauncher": {
|
"appLauncher": {
|
||||||
|
@ -9,7 +9,7 @@ const themeRef = ref<'light' | 'dark'>('light')
|
|||||||
const configProviderPropsRef = computed<ConfigProviderProps>(() => ({
|
const configProviderPropsRef = computed<ConfigProviderProps>(() => ({
|
||||||
theme: themeRef.value === 'light' ? lightTheme : darkTheme,
|
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 {
|
export function apiRespErrMsg(res: Response): boolean {
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { AxiosProgressEvent, AxiosResponse, GenericAbortSignal } from 'axios'
|
import type { AxiosProgressEvent, AxiosResponse, GenericAbortSignal } from 'axios'
|
||||||
import request from './axios'
|
import request from './axios'
|
||||||
import { apiRespErrMsg } from './apiMessage'
|
import { apiRespErrMsg, message } from './apiMessage'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
import { useAppStore, useAuthStore } from '@/store'
|
import { useAppStore, useAuthStore } from '@/store'
|
||||||
import { router } from '@/router'
|
import { router } from '@/router'
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<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 type { UploadFileInfo } from 'naive-ui'
|
||||||
import { computed, defineProps } from 'vue'
|
import { computed, defineProps } from 'vue'
|
||||||
import { ItemIcon } from '@/components/common'
|
import { ItemIcon } from '@/components/common'
|
||||||
import { useAuthStore } from '@/store'
|
import { useAuthStore } from '@/store'
|
||||||
import { t } from '@/locales'
|
import { apiRespErrMsg } from '@/utils/request/apiMessage'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
itemIcon: Panel.ItemIcon | null
|
itemIcon: Panel.ItemIcon | null
|
||||||
@ -13,7 +13,6 @@ const emit = defineEmits<{
|
|||||||
(e: 'update:itemIcon', visible: Panel.ItemIcon): void // 定义修改父组件(prop内)的值的事件
|
(e: 'update:itemIcon', visible: Panel.ItemIcon): void // 定义修改父组件(prop内)的值的事件
|
||||||
}>()
|
}>()
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const ms = useMessage()
|
|
||||||
|
|
||||||
// 默认图标背景色
|
// 默认图标背景色
|
||||||
const defautSwatchesBackground = [
|
const defautSwatchesBackground = [
|
||||||
@ -75,7 +74,8 @@ const handleUploadFinish = ({
|
|||||||
emit('update:itemIcon', itemIconInfo.value || null)
|
emit('update:itemIcon', itemIconInfo.value || null)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ms.error(`${t('common.uploadFail')}:${res.msg}`)
|
apiRespErrMsg(res)
|
||||||
|
// ms.error(`${t('common.uploadFail')}:${res.msg}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return file
|
return file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user