更改下载图片名字
This commit is contained in:
@@ -108,7 +108,7 @@ export function FormatDate(value: Date | number | string, format: string = 'yyyy
|
||||
* @param onError 下载错误回调
|
||||
* @param onSuccess 下载成功回调
|
||||
*/
|
||||
export async function DownloadImages(list: Array<{ url: string, name: string }>, onProgress?: (count: number, total: number, item: any) => void, onError?: (count: number, total: number, item: any) => void, onSuccess?: (successCount: number, errCount: number) => void) {
|
||||
export async function DownloadImages(list: Array<{ url: string, name?: string }>, onProgress?: (count: number, total: number, item: any) => void, onError?: (count: number, total: number, item: any) => void, onSuccess?: (successCount: number, errCount: number) => void) {
|
||||
const total = list.length;
|
||||
let count = 0;
|
||||
let successCount = 0;
|
||||
@@ -124,7 +124,7 @@ export async function DownloadImages(list: Array<{ url: string, name: string }>,
|
||||
const blob = this.response;
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = list[i].name || list[i].url;
|
||||
a.download = list[i].name || list[i].url.split('/').pop().split('?').shift();
|
||||
a.click();
|
||||
successCount++;
|
||||
typeof onProgress === "function" && onProgress(count, total, list[i]);
|
||||
|
||||
@@ -4,15 +4,12 @@
|
||||
import { DownloadImages } from '@/utils/tools'
|
||||
const router = useRouter()
|
||||
const query = computed(() => router.currentRoute.value.query)
|
||||
const styleUrl = computed(() => query.value.styleUrl)
|
||||
const styleUrl = computed(() => query.value.styleUrl as string)
|
||||
|
||||
onMounted(() => {})
|
||||
const loading = ref(false)
|
||||
const onDownload = () => {
|
||||
DownloadImages([{
|
||||
url: styleUrl.value,
|
||||
name: 'lane-crawford.png'
|
||||
}])
|
||||
DownloadImages([{ url: styleUrl.value }])
|
||||
}
|
||||
const onEdit = () => {
|
||||
console.log('edit')
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
const router = useRouter()
|
||||
const emit = defineEmits(['view-type'])
|
||||
const query = computed(() => router.currentRoute.value.query)
|
||||
const visitRecordId = computed(() => query.value.visitRecordId)
|
||||
const visitRecordId = computed(() => query.value.visitRecordId)// 访问记录ID
|
||||
import { useGenerateStore } from '@/stores'
|
||||
const generateStore = useGenerateStore()
|
||||
|
||||
@@ -85,11 +85,7 @@
|
||||
if (v.loading) return
|
||||
v.loading = true
|
||||
v.selected = false
|
||||
const obj = {
|
||||
url: v.tryOnUrl,
|
||||
name: v.tryOnUrl.split('/').pop()
|
||||
}
|
||||
DownloadImages([obj], null, null, () => {
|
||||
DownloadImages([{ url: v.tryOnUrl }], null, null, () => {
|
||||
v.loading = false
|
||||
v.downloaded = true
|
||||
})
|
||||
@@ -114,8 +110,7 @@
|
||||
v.loading = true
|
||||
downloadList.push({
|
||||
index: i,
|
||||
url: v.tryOnUrl,
|
||||
name: v.tryOnUrl.split('/').pop()
|
||||
url: v.tryOnUrl
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user