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