|
|
@@ -3,15 +3,15 @@
|
|
|
<span class="app-uploader__button" @click="onClickUpload" v-if="!hasPermission"></span>
|
|
|
<Uploader ref="uploaderRef" v-model="fileList" :max-count="maxCount" :max-size="5 * 1024 * 1024"
|
|
|
@oversize="onOversize" :after-read="onAfterRead" @delete="onDelete" reupload />
|
|
|
- <Notify v-model:show="showNotify" :duration="0" title="存储空间/照片权限说明"
|
|
|
- content="用于在添加、制作、上传、发布、分享、下载、搜索、识别图片和视频等场景中读取和写入相册和文件内容" />
|
|
|
+ <Notify v-model:show="showNotify" :duration="0" :title="$t('common.tips30')"
|
|
|
+ :content="$t('common.tips31')" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { ref } from 'vue'
|
|
|
import { showFailToast, Uploader, UploaderFileListItem } from 'vant'
|
|
|
-import { useGlobalStore } from '@/stores'
|
|
|
+import { useGlobalStore, i18n } from '@/stores'
|
|
|
import plus from '@/utils/h5plus'
|
|
|
import service from '@/services'
|
|
|
import axios from 'axios'
|
|
|
@@ -24,6 +24,8 @@ defineProps({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+const { global: { t } } = i18n
|
|
|
+
|
|
|
const emit = defineEmits(['success', 'delete'])
|
|
|
const globalStore = useGlobalStore()
|
|
|
const uploaderRef = ref()
|
|
|
@@ -34,7 +36,7 @@ const storagePermission = globalStore.getAndroidPermissions('READ_EXTERNAL_STORA
|
|
|
const hasPermission = ref(storagePermission === 1) // 是否已授权存储权限
|
|
|
|
|
|
const onOversize = () => {
|
|
|
- showFailToast('图片大小不能超过 5Mb')
|
|
|
+ showFailToast(t('common.tips29'))
|
|
|
}
|
|
|
|
|
|
const onClickUpload = () => {
|
|
|
@@ -60,7 +62,7 @@ const onClickUpload = () => {
|
|
|
break
|
|
|
}
|
|
|
default: {
|
|
|
- showFailToast('相册权限未授权')
|
|
|
+ showFailToast(t('common.tips25'))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -71,17 +73,17 @@ const onAfterRead = (file: any) => {
|
|
|
data.append('file', file.file)
|
|
|
|
|
|
file.status = 'uploading'
|
|
|
- file.message = '上传中...'
|
|
|
+ file.message = t('common.tips28')
|
|
|
axios.post(service.getConfig('uploadUrl'), data).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
file.status = 'success'
|
|
|
- file.message = '上传成功'
|
|
|
+ file.message = t('common.tips26')
|
|
|
if (res.data.length) {
|
|
|
emit('success', res.data[0].filePath)
|
|
|
}
|
|
|
} else {
|
|
|
file.status = 'failed'
|
|
|
- file.message = '上传失败'
|
|
|
+ file.message = t('common.tips27')
|
|
|
}
|
|
|
})
|
|
|
}
|