Initial commit: Memind H5 portal with MindSpace, Plaza, and agent jobs.
Track application source and tests; exclude local env, user workspaces, and runtime data via .gitignore. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
import { resolveMindSpaceHomeUrl } from './publicUrl';
|
||||
|
||||
export type SharePayload = {
|
||||
title: string;
|
||||
url: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type ShareChannel = {
|
||||
id: string;
|
||||
label: string;
|
||||
hint: string;
|
||||
buildText: (payload: SharePayload) => string;
|
||||
};
|
||||
|
||||
export const SHARE_CHANNELS: ShareChannel[] = [
|
||||
{
|
||||
id: 'wechat_moments',
|
||||
label: '微信朋友圈',
|
||||
hint: '文案已复制,请打开微信粘贴到朋友圈',
|
||||
buildText: ({ title, url, description }) =>
|
||||
[title, description, url].filter(Boolean).join('\n'),
|
||||
},
|
||||
{
|
||||
id: 'xiaohongshu',
|
||||
label: '小红书',
|
||||
hint: '文案已复制,请打开小红书发布笔记并粘贴',
|
||||
buildText: ({ title, url, description }) =>
|
||||
[`${title}`, description ?? '分享自我的 MindSpace', url, '#TKMind #创作分享'].join('\n'),
|
||||
},
|
||||
{
|
||||
id: 'toutiao',
|
||||
label: '今日头条',
|
||||
hint: '文案已复制,请打开今日头条发布并粘贴',
|
||||
buildText: ({ title, url, description }) =>
|
||||
[`【${title}】`, description, url].filter(Boolean).join('\n'),
|
||||
},
|
||||
{
|
||||
id: 'weibo',
|
||||
label: '微博',
|
||||
hint: '文案已复制,请打开微博发布并粘贴',
|
||||
buildText: ({ title, url }) => `${title} ${url} #TKMind#`,
|
||||
},
|
||||
{
|
||||
id: 'douyin',
|
||||
label: '抖音',
|
||||
hint: '链接已复制,可粘贴到抖音个人简介或私信',
|
||||
buildText: ({ title, url }) => `${title}\n${url}`,
|
||||
},
|
||||
{
|
||||
id: 'copy_link',
|
||||
label: '复制链接',
|
||||
hint: '链接已复制',
|
||||
buildText: ({ url }) => url,
|
||||
},
|
||||
];
|
||||
|
||||
export async function copyShareText(text: string) {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return;
|
||||
}
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = text;
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.opacity = '0';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
||||
export function canUseNativeShare() {
|
||||
return typeof navigator.share === 'function';
|
||||
}
|
||||
|
||||
export async function nativeShare(payload: SharePayload) {
|
||||
await navigator.share({
|
||||
title: payload.title,
|
||||
text: payload.description ?? payload.title,
|
||||
url: payload.url,
|
||||
});
|
||||
}
|
||||
|
||||
export function buildAssetSharePayload(
|
||||
asset: { displayName: string },
|
||||
categoryCode?: string,
|
||||
): SharePayload {
|
||||
const url = new URL(resolveMindSpaceHomeUrl());
|
||||
if (categoryCode) {
|
||||
url.searchParams.set('category', categoryCode);
|
||||
}
|
||||
return {
|
||||
title: asset.displayName,
|
||||
url: url.toString(),
|
||||
description: `看看我在 TKMind 空间里的作品「${asset.displayName}」`,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user