Ship the page-focused follow reply with the news and shop updates.

Replace the subscribe welcome with page-generation examples, add the trial news003 WeChat share card, and let OneShop checkout return to an order or recharge page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-11-25 14:30:20 +08:00
parent 59f85fb5f9
commit 7f06361bd3
13 changed files with 522 additions and 146 deletions
+48 -29
View File
@@ -1,6 +1,4 @@
import { resolveWechatAddressName } from '../user/display-name.mjs';
import { buildPushSubscriptionMenuLines } from '../push-subscription-catalog.mjs';
import { buildSubscribeMorningReminderPromptLines } from '../subscribe-morning-reminder.mjs';
export const DEFAULT_SUBSCRIBE_INTRO_URL =
'https://m.tkmind.cn/MindSpace/a70ff537-8908-486e-9b6c-042e07cc25db/public/tkmind-deep-intro.html';
@@ -11,6 +9,33 @@ export const DEFAULT_PRODUCTION_BIND_URL =
export const DEFAULT_PLAZA_HOME_URL = 'https://plaza.tkmind.cn/plaza';
const SUBSCRIBE_EXAMPLE_ORIGIN =
'https://m.tkmind.cn/MindSpace/a70ff537-8908-486e-9b6c-042e07cc25db/public';
/** 关注欢迎语里的可点开案例。提示句都必须包含「生成页面」。 */
export const DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES = Object.freeze([
{
prompt: '生成页面:某产品调研分析报告,含用户痛点、竞品对比和结论',
label: '产品调研 · 竞品地图',
url: `${SUBSCRIBE_EXAMPLE_ORIGIN}/chenkeming-map.html`,
},
{
prompt: '生成页面:季度数据分析报告,用图表讲清变化',
label: '分析报告 · 数据仪表盘',
url: `${SUBSCRIBE_EXAMPLE_ORIGIN}/zhixing-data-dashboard.html`,
},
{
prompt: '生成页面:苏州一日游攻略,含路线和美食',
label: '旅行攻略 · 新疆亲子游',
url: `${SUBSCRIBE_EXAMPLE_ORIGIN}/xinjiang-travel.html`,
},
{
prompt: '生成页面:周末市集活动页,含时间、地点和报名',
label: '活动页面 · 餐厅招牌',
url: `${SUBSCRIBE_EXAMPLE_ORIGIN}/changsha-restaurant-promo.html`,
},
]);
/** 关注欢迎语里推荐的 M发现精选入口(示例页/广场作品,便于长期维护)。 */
export const DEFAULT_SUBSCRIBE_PLAZA_PICKS = Object.freeze([
{
@@ -59,43 +84,37 @@ export function buildPlazaDiscoveryLines({
export function buildSubscribeWelcomeText({
bindUrl,
introUrl = DEFAULT_SUBSCRIBE_INTRO_URL,
plazaHomeUrl = DEFAULT_PLAZA_HOME_URL,
plazaPicks = DEFAULT_SUBSCRIBE_PLAZA_PICKS,
pushSubscriptionEnabled = true,
morningReminderEnabled = true,
morningReminderHour = 8,
morningReminderMinute = 0,
examples = DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES,
} = {}) {
const normalizedBindUrl = String(bindUrl ?? '').trim();
const normalizedIntroUrl = String(introUrl ?? '').trim();
const lines = [
'欢迎关注 TKMind 智趣 👋',
'',
'在微信里直接发消息即可:',
'· 问答、写作、翻译',
'· 生成精美网页并给链接',
'· 发图解读报告/截图',
'· 设置定时提醒与每日推送',
...buildPlazaDiscoveryLines({ plazaHomeUrl, plazaPicks }),
'你想做的页面,直接说给我。',
'带上「生成页面」,我做好后回你链接,马上就能分享。',
'',
'例如:',
];
if (pushSubscriptionEnabled) {
lines.push(...buildPushSubscriptionMenuLines());
} else if (morningReminderEnabled) {
lines.push(
...buildSubscribeMorningReminderPromptLines({
hour: morningReminderHour,
minute: morningReminderMinute,
}),
);
const picks = Array.isArray(examples) ? examples : DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES;
const visible = [];
for (const example of picks) {
const prompt = String(example?.prompt ?? '').trim();
const url = String(example?.url ?? '').trim();
const label = String(example?.label ?? '').trim();
if (!prompt.includes('生成页面')) continue;
lines.push(`· 「${prompt}」`);
if (url && label) visible.push({ url, label });
}
if (normalizedIntroUrl) {
lines.push('', '📖 了解 TKMind 能做什么:', buildWechatTextLink(normalizedIntroUrl, '看功能介绍'));
if (visible.length) {
lines.push('', '点开看看做好的页面:');
for (const pick of visible) {
lines.push(`· ${buildWechatTextLink(pick.url, pick.label)}`);
}
}
lines.push('', '链接转给朋友,对方点开就能看。');
if (normalizedBindUrl) {
lines.push('', '👉 先完成绑定再开始对话:', buildWechatTextLink(normalizedBindUrl, '点我绑定'));
lines.push('', `👉 先${buildWechatTextLink(normalizedBindUrl, '点我绑定')},再发一句「生成页面:…」`);
}
lines.push('', '绑定后回复「你好」,或试试:', '「帮我做一个苏州游玩攻略页面」');
return lines.join('\n');
}
+18 -69
View File
@@ -5,10 +5,9 @@ import {
buildPlazaDiscoveryLines,
buildSubscribeWelcomeText,
buildWechatTextLink,
DEFAULT_PLAZA_HOME_URL,
DEFAULT_PRODUCTION_BIND_URL,
DEFAULT_SUBSCRIBE_INTRO_URL,
DEFAULT_SUBSCRIBE_PLAZA_PICKS,
DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES,
} from './sync-replies.mjs';
test('buildWechatTextLink renders WeChat anchor without exposing raw url', () => {
@@ -18,35 +17,27 @@ test('buildWechatTextLink renders WeChat anchor without exposing raw url', () =>
);
});
test('buildSubscribeWelcomeText uses clickable anchors instead of raw urls', () => {
test('buildSubscribeWelcomeText asks for a page and a shareable link', () => {
const text = buildSubscribeWelcomeText({ bindUrl: DEFAULT_PRODUCTION_BIND_URL });
assert.match(text, /欢迎关注 TKMind 智趣/);
assert.match(text, /生成精美网页并给链接/);
assert.match(text, /🎯 M发现 · 精选作品广场/);
assert.match(text, /旅行攻略/);
assert.match(text, /深夜食堂/);
assert.match(
text,
new RegExp(`<a href="${DEFAULT_PLAZA_HOME_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}">进入 M发现,逛热门作品</a>`),
);
assert.match(text, /📖 了解 TKMind 能做什么:/);
assert.match(
text,
/<a href="[^"]*tkmind-deep-intro\.html">看功能介绍<\/a>/,
);
assert.match(text, /👉 先完成绑定再开始对话:/);
assert.match(text, /你想做的页面/);
assert.match(text, /马上就能分享/);
assert.match(text, /对方点开就能看/);
assert.match(text, /点开看看做好的页面/);
for (const example of DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES) {
assert.ok(example.prompt.includes('生成页面'));
assert.ok(text.includes(`「${example.prompt}」`));
assert.ok(text.includes(`<a href="${example.url}">${example.label}</a>`));
}
assert.match(
text,
/<a href="[^"]*auth\/wechat\/authorize\?intent=login">点我绑定<\/a>/,
);
assert.doesNotMatch(text, /\nhttps:\/\/m\.tkmind\.cn/);
assert.doesNotMatch(text, /\nhttps:\/\/plaza\.tkmind\.cn/);
assert.match(text, /帮我做一个苏州游玩攻略页面/);
assert.match(text, /📬 每日推送订阅/);
assert.match(text, /1 ☀️ 早安问候/);
assert.match(text, /2 📰 每日新闻早报/);
assert.match(text, /我的订阅/);
assert.doesNotMatch(text, /每日推送订阅/);
assert.doesNotMatch(text, /M发现/);
assert.doesNotMatch(text, /问答、写作、翻译/);
});
test('buildPlazaDiscoveryLines renders curated plaza category links', () => {
@@ -59,51 +50,9 @@ test('buildPlazaDiscoveryLines renders curated plaza category links', () => {
}
});
test('buildSubscribeWelcomeText omits intro section when introUrl is empty', () => {
const text = buildSubscribeWelcomeText({
bindUrl: 'https://m.tkmind.cn/bind',
introUrl: '',
});
test('buildSubscribeWelcomeText omits the bind line when bindUrl is empty', () => {
const text = buildSubscribeWelcomeText({ bindUrl: '' });
assert.doesNotMatch(text, /📖 了解 TKMind 能做什么:/);
assert.doesNotMatch(text, /tkmind-deep-intro\.html/);
});
test('buildSubscribeWelcomeText omits plaza section when plazaHomeUrl is empty', () => {
const text = buildSubscribeWelcomeText({
bindUrl: 'https://m.tkmind.cn/bind',
introUrl: '',
plazaHomeUrl: '',
plazaPicks: [],
});
assert.doesNotMatch(text, /M发现/);
});
test('buildSubscribeWelcomeText omits push subscription menu when disabled', () => {
const text = buildSubscribeWelcomeText({
bindUrl: 'https://m.tkmind.cn/bind',
introUrl: '',
plazaHomeUrl: '',
plazaPicks: [],
pushSubscriptionEnabled: false,
morningReminderEnabled: false,
});
assert.doesNotMatch(text, /每日推送订阅/);
assert.doesNotMatch(text, /回复 1 确认/);
});
test('buildSubscribeWelcomeText falls back to legacy morning prompt when push subscription disabled', () => {
const text = buildSubscribeWelcomeText({
bindUrl: 'https://m.tkmind.cn/bind',
introUrl: '',
plazaHomeUrl: '',
plazaPicks: [],
pushSubscriptionEnabled: false,
morningReminderEnabled: true,
});
assert.match(text, /☀️ 每日早安提醒/);
assert.match(text, /回复 1 确认/);
assert.match(text, /生成页面/);
assert.doesNotMatch(text, /点我绑定/);
});