forked from 77media/video-flow
图片上传
This commit is contained in:
parent
1d756f7f6e
commit
d1c9112648
@ -80,6 +80,64 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => {
|
|||||||
}
|
}
|
||||||
}, [templateStoryUseCase]);
|
}, [templateStoryUseCase]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新指定角色的图片
|
||||||
|
* @param {string} roleName - 角色名称
|
||||||
|
* @param {string} imageUrl - 新的图片URL
|
||||||
|
*/
|
||||||
|
const updateRoleImage = useCallback(
|
||||||
|
(roleName: string, imageUrl: string): void => {
|
||||||
|
if (!selectedTemplate) {
|
||||||
|
console.warn("updateRoleImage: selectedTemplate 为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`更新角色 ${roleName} 的图片:`, imageUrl);
|
||||||
|
|
||||||
|
const updatedTemplate = {
|
||||||
|
...selectedTemplate,
|
||||||
|
storyRole: selectedTemplate.storyRole.map((role) =>
|
||||||
|
role.role_name === roleName
|
||||||
|
? { ...role, photo_url: imageUrl }
|
||||||
|
: role
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("更新后的模板:", updatedTemplate);
|
||||||
|
setSelectedTemplate(updatedTemplate);
|
||||||
|
},
|
||||||
|
[selectedTemplate]
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新指定道具的图片
|
||||||
|
* @param {string} itemName - 道具名称
|
||||||
|
* @param {string} imageUrl - 新的图片URL
|
||||||
|
*/
|
||||||
|
const updateItemImage = useCallback(
|
||||||
|
(itemName: string, imageUrl: string): void => {
|
||||||
|
if (!selectedTemplate) {
|
||||||
|
console.warn("updateItemImage: selectedTemplate 为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`更新道具 ${itemName} 的图片:`, imageUrl);
|
||||||
|
|
||||||
|
const updatedTemplate = {
|
||||||
|
...selectedTemplate,
|
||||||
|
storyItem: selectedTemplate.storyItem.map((item) =>
|
||||||
|
item.item_name === itemName
|
||||||
|
? { ...item, photo_url: imageUrl }
|
||||||
|
: item
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("更新后的模板:", updatedTemplate);
|
||||||
|
setSelectedTemplate(updatedTemplate);
|
||||||
|
},
|
||||||
|
[selectedTemplate]
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传人物头像并分析特征,替换旧的角色数据
|
* 上传人物头像并分析特征,替换旧的角色数据
|
||||||
* @param {string} imageUrl - 图片URL
|
* @param {string} imageUrl - 图片URL
|
||||||
@ -98,53 +156,7 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => {
|
|||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[]
|
[updateRoleImage]
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新指定角色的图片
|
|
||||||
* @param {string} roleName - 角色名称
|
|
||||||
* @param {string} imageUrl - 新的图片URL
|
|
||||||
*/
|
|
||||||
const updateRoleImage = useCallback(
|
|
||||||
(roleName: string, imageUrl: string): void => {
|
|
||||||
if (!selectedTemplate) return;
|
|
||||||
|
|
||||||
const updatedTemplate = {
|
|
||||||
...selectedTemplate,
|
|
||||||
storyRole: selectedTemplate.storyRole.map((role) =>
|
|
||||||
role.role_name === roleName
|
|
||||||
? { ...role, photo_url: imageUrl }
|
|
||||||
: role
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
setSelectedTemplate(updatedTemplate);
|
|
||||||
},
|
|
||||||
[selectedTemplate]
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新指定道具的图片
|
|
||||||
* @param {string} itemName - 道具名称
|
|
||||||
* @param {string} imageUrl - 新的图片URL
|
|
||||||
*/
|
|
||||||
const updateItemImage = useCallback(
|
|
||||||
(itemName: string, imageUrl: string): void => {
|
|
||||||
if (!selectedTemplate) return;
|
|
||||||
|
|
||||||
const updatedTemplate = {
|
|
||||||
...selectedTemplate,
|
|
||||||
storyItem: selectedTemplate.storyItem.map((item) =>
|
|
||||||
item.item_name === itemName
|
|
||||||
? { ...item, photo_url: imageUrl }
|
|
||||||
: item
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
setSelectedTemplate(updatedTemplate);
|
|
||||||
},
|
|
||||||
[selectedTemplate]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -124,7 +124,7 @@ export default function SignupPage() {
|
|||||||
router.push("/login?registered=true");
|
router.push("/login?registered=true");
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Signup error:", error);
|
console.error("Signup error:", error);
|
||||||
setFormError(error.message || "Registration failed, please try again");
|
setFormError(error.message||error.msg || "Registration failed, please try again");
|
||||||
} finally {
|
} finally {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -393,7 +393,7 @@ export const registerUser = async ({
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log('data', data)
|
console.log('data', data)
|
||||||
if(!data.success){
|
if(!data.success){
|
||||||
throw new Error(data.message)
|
throw new Error(data.message||data.msg)
|
||||||
}
|
}
|
||||||
return data as {
|
return data as {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user