feat: 参数的解析

This commit is contained in:
2026-04-06 13:57:22 +08:00
parent efbcb70213
commit dd5d3230db

View File

@@ -131,22 +131,35 @@ const uploadImage = () => {
} }
} }
window.onUploadResult = function(imageUrl) { window.addEventListener('hashchange', () => {
console.log('上传结果:', imageUrl); const imageUrl = getHashParam('imageUrl')
console.log('从 hash 中获取的 imageUrl:', imageUrl)
if (!imageUrl || imageUrl === 'error') { if (imageUrl) {
showFailToast('获取图片地址失败,请重试。'); sendGeneratorPhotoTask(imageUrl)
return;
} }
})
sendGeneratorPhotoTask(imageUrl); const getHashParam = (key) => {
}; const hash = window.location.hash
console.log('hash URL:', hash)
const queryStr = hash.split('?')[1] || ''
const params = queryStr.split('&')
for (let i = 0; i < params.length; i++) {
const [k, v] = params[i].split('=')
if (k === key) {
return decodeURIComponent(v || '')
}
}
return null
}
/// 发送生成任务 /// 发送生成任务
const sendGeneratorPhotoTask = async (photoUrl: string) => { const sendGeneratorPhotoTask = async (photoUrl: string) => {
const photoUrlList = [photoUrl]; const photoUrlList = [photoUrl];
try { try {
const response = await createGeneratorPhotoTask({ photoUrlList: photoUrlList, sceneId: activeScene.value.sceneCode }); const response = await createGeneratorPhotoTask({ photoUrlList: photoUrlList, sceneId: activeScene.value.sceneStyleId });
if (response) { if (response) {
showSuccessToast('生成任务创建成功!'); showSuccessToast('生成任务创建成功!');
router.push('/generate'); router.push('/generate');