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) {
console.log('上传结果:', imageUrl);
if (!imageUrl || imageUrl === 'error') {
showFailToast('获取图片地址失败,请重试。');
return;
window.addEventListener('hashchange', () => {
const imageUrl = getHashParam('imageUrl')
console.log('从 hash 中获取的 imageUrl:', imageUrl)
if (imageUrl) {
sendGeneratorPhotoTask(imageUrl)
}
})
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 photoUrlList = [photoUrl];
try {
const response = await createGeneratorPhotoTask({ photoUrlList: photoUrlList, sceneId: activeScene.value.sceneCode });
const response = await createGeneratorPhotoTask({ photoUrlList: photoUrlList, sceneId: activeScene.value.sceneStyleId });
if (response) {
showSuccessToast('生成任务创建成功!');
router.push('/generate');