feat(share): align social sharing runtime

This commit is contained in:
2026-09-27 13:49:32 +08:00
parent 26ac8167f3
commit cf6c11852e
33 changed files with 802 additions and 1919 deletions
@@ -33,8 +33,8 @@ const metaBox = fs.readFileSync(path.join(root, 'src/Core/PostMetaBox.php'), 'ut
const frontendTags = fs.readFileSync(path.join(root, 'inc/helpers/aksrt-frontend-tags.php'), 'utf8');
const singleRender = fs.readFileSync(path.join(root, 'inc/helpers/aksrt-single-render.php'), 'utf8');
const contentCss = fs.readFileSync(path.join(root, 'assets/css/frontend/single-post/content.css'), 'utf8');
const shareJs = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections/post-list/share.js'), 'utf8');
const sharePhp = php;
const shareJs = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections/global/share.js'), 'utf8');
const sharePhp = fs.readFileSync(path.join(root, 'src/Admin/Schema/GlobalSchema.php'), 'utf8');
const featuresJs = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections/users/features.js'), 'utf8');
const usersPhp = fs.readFileSync(path.join(root, 'src/Admin/Schema/SchemaUsers.php'), 'utf8');
@@ -233,11 +233,22 @@ test('JS schema 默认值与依赖对齐参考主题', () => {
assert.match(js, /key:\s*'interval',[\s\S]*?dependsOn:\s*\{\s*key:\s*'autoplay',\s*value:\s*true\s*\}/);
});
test('share_s 迁移至分享设置页 basic 组(键不变,无双路)', () => {
assert.match(sharePhp, /\['key' => 'basic', 'title' => '分享按钮', 'fields' => \[\s*\['key' => 'share_s', 'label' => '分享按钮', 'type' => 'switcher', 'default' => true, 'help' => '关闭后,在文章页面将不显示分享按钮,论坛及商城不受影响'\]/);
assert.match(shareJs, /key: 'basic',/);
test('社交分享位于全局功能并使用参考主题唯一键集', () => {
assert.match(sharePhp, /'share' => \[\s*'key'\s*=> 'share',\s*'title'\s*=> '社交分享'/);
assert.match(sharePhp, /'share_s', 'label' => '文章分享功能', 'type' => 'switcher', 'default' => true/);
assert.match(sharePhp, /'share_items', 'label' => '分享平台', 'type' => 'custom', 'renderer' => 'sorter', 'sanitize_type' => 'array'/);
assert.match(shareJs, /key: 'share_items',[\s\S]*?type: 'custom',[\s\S]*?renderer: 'sorter'/);
assert.match(sharePhp, /'wechat_share_s', 'label' => '微信分享有图'/);
assert.match(sharePhp, /'wechat_share_option', 'label' => '微信分享有图配置', 'type' => 'fieldset'/);
assert.match(sharePhp, /'share_img', 'label' => '生成海报分享', 'type' => 'switcher', 'default' => true/);
for (const key of ['share_img_compatible_s', 'share_img_byimg', 'share_logo', 'share_desc']) {
assert.ok(sharePhp.includes(`'${key}'`), `PHP 社交分享缺少 ${key}`);
assert.ok(shareJs.includes(`key: '${key}'`), `JS 社交分享缺少 ${key}`);
}
assert.match(shareJs, /key: 'global\.share'/);
assert.match(shareJs, /share_s: true/);
assert.match(shareJs, /key: 'share_s', label: '分享按钮', type: 'switch', default: true, help: '关闭后,在文章页面将不显示分享按钮,论坛及商城不受影响'/);
assert.doesNotMatch(sharePhp, /share_wechat_s|share_wechat_appid|share_wechat_app_secret|share_only_logo/);
assert.doesNotMatch(shareJs, /share_wechat_s|share_wechat_appid|share_wechat_app_secret|share_only_logo/);
});
test('post_rewards_* 迁移至用户功能页 rewards 组(对齐参考主题 8977 行)', () => {