feat(share): 抽出 buildShareText 纯函数 title\ndescription 单换行无url(分享重构 §5.1)
This commit is contained in:
@@ -23,3 +23,6 @@ export { NavProvider } from './src/main/ets/providers/NavProvider';
|
||||
|
||||
// 微信 SDK 封装(EntryAbility 处理回调 want 需用)
|
||||
export { WeChatApi, WX_APP_ID } from './src/main/ets/wx/WeChatApi';
|
||||
|
||||
// 分享文本拼接纯函数(供单测)
|
||||
export { buildShareText } from './src/main/ets/share/ShareText';
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 分享文本拼接(纯函数,可单测)。
|
||||
* 规则(对齐原工程 + 用户确认):`title\ndescription`,**单换行、三端一致、不含 url**;空字段跳过。
|
||||
*/
|
||||
export function buildShareText(title: string, description: string): string {
|
||||
const parts: string[] = [];
|
||||
if (title !== '') {
|
||||
parts.push(title);
|
||||
}
|
||||
if (description !== '') {
|
||||
parts.push(description);
|
||||
}
|
||||
return parts.join('\n');
|
||||
}
|
||||
Reference in New Issue
Block a user