feat(分享): 新增分享模板风格选择与访客反馈功能
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
新增分享模板风格选择功能,支持编辑、电影和剪贴簿三种风格 添加访客反馈系统,包括查看次数统计和留言功能 优化分享状态管理,区分公开、草稿和预览状态 扩展分享配置数据模型,支持模板风格和反馈统计 重构分享页面样式,根据模板风格应用不同主题
This commit is contained in:
72
src/pages/story/utils/shareState.ts
Normal file
72
src/pages/story/utils/shareState.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
export type StoryShareMeta = {
|
||||
instanceId?: string;
|
||||
publicShareId?: string;
|
||||
shareId?: string;
|
||||
shareConfigured?: boolean;
|
||||
sharePublished?: boolean;
|
||||
};
|
||||
|
||||
export type StoryShareState = 'public' | 'draft' | 'preview';
|
||||
|
||||
export const getStoryPublicShareId = (story?: StoryShareMeta) =>
|
||||
story?.publicShareId || story?.shareId;
|
||||
|
||||
export const getStoryShareState = (story?: StoryShareMeta): StoryShareState => {
|
||||
const publicShareId = getStoryPublicShareId(story);
|
||||
|
||||
if (story?.sharePublished || publicShareId) {
|
||||
return 'public';
|
||||
}
|
||||
|
||||
if (story?.shareConfigured) {
|
||||
return 'draft';
|
||||
}
|
||||
|
||||
return 'preview';
|
||||
};
|
||||
|
||||
export const getStoryShareStatusText = (story?: StoryShareMeta) => {
|
||||
switch (getStoryShareState(story)) {
|
||||
case 'public':
|
||||
return 'Public share is live';
|
||||
case 'draft':
|
||||
return 'Share draft is ready';
|
||||
default:
|
||||
return 'Preview available';
|
||||
}
|
||||
};
|
||||
|
||||
export const getStoryShareActionLabel = (story?: StoryShareMeta) => {
|
||||
switch (getStoryShareState(story)) {
|
||||
case 'public':
|
||||
return 'Copy Link';
|
||||
case 'draft':
|
||||
return 'Draft Preview';
|
||||
default:
|
||||
return 'Preview';
|
||||
}
|
||||
};
|
||||
|
||||
export const getStoryShareMenuLabel = (story?: StoryShareMeta) => {
|
||||
switch (getStoryShareState(story)) {
|
||||
case 'public':
|
||||
return 'Copy share link';
|
||||
case 'draft':
|
||||
return 'Open draft preview';
|
||||
default:
|
||||
return 'Open preview';
|
||||
}
|
||||
};
|
||||
|
||||
export const getStorySharePath = (story?: StoryShareMeta) => {
|
||||
const publicShareId = getStoryPublicShareId(story);
|
||||
if (publicShareId) {
|
||||
return `/share/${publicShareId}`;
|
||||
}
|
||||
|
||||
if (story?.instanceId) {
|
||||
return `/share/preview/${story.instanceId}`;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
Reference in New Issue
Block a user