feat(share): align social sharing runtime

This commit is contained in:
kate522 committed 2026-09-27 13:49:32 +08:00
1 parent 26ac8167f3
commit cf6c11852e
33 files changed
+802 -1919

No files matched your search

@@ -14,6 +14,7 @@ import { customCodeSchema } from './custom-code.js'
import { seoSchema } from './seo.js'
import { codeHighlightSchema } from './code-highlight.js'
import { systemNoticeSchema } from './system-notice.js'
import { shareSchema } from './share.js'
export const globalSchemas = {
logo: logoSchema,
@@ -0,0 +1,98 @@
const themeRoot = typeof window !== 'undefined' && window.aksrtAdminData?.themeUri
? String(window.aksrtAdminData.themeUri).replace(/\/$/, '')
: ''
const shareOptions = [
{ label: 'QQ空间', value: 'qzone', icon: 'fa fab fa-qq' },
{ label: '微博', value: 'weibo', icon: 'fa fab fa-weibo' },
{ label: 'QQ好友', value: 'qq', icon: 'fa fab fa-qq' },
{ label: 'Facebook', value: 'facebook', icon: 'fa fab fa-facebook-f' },
{ label: 'X', value: 'twitter', icon: 'fa fab fa-twitter' },
{ label: 'Telegram', value: 'telegram', icon: 'fa fab fa-telegram-plane' },
{ label: 'WhatsApp', value: 'whatsapp', icon: 'fa fab fa-whatsapp' },
{ label: 'LinkedIn', value: 'linkedin', icon: 'fa fab fa-linkedin-in' },
{ label: 'Reddit', value: 'reddit', icon: 'fa fab fa-reddit-alien' },
{ label: 'LINE', value: 'line', icon: 'fa fab fa-line' },
{ label: 'VK', value: 'vk', icon: 'fa fab fa-vk' },
{ label: '邮件', value: 'email', icon: 'fa fas fa-envelope' },
{ label: '海报分享', value: 'poster', icon: 'fa fas fa-image' },
{ label: '复制链接', value: 'copy', icon: 'fa fas fa-link' },
]
const defaultShareItems = {
enabled: { qzone: 'QQ空间', weibo: '微博', qq: 'QQ好友', poster: '海报分享', copy: '复制链接' },
disabled: { facebook: 'Facebook', twitter: 'X', telegram: 'Telegram', whatsapp: 'WhatsApp', linkedin: 'LinkedIn', reddit: 'Reddit', line: 'LINE', vk: 'VK', email: '邮件' },
}
export const shareSchema = {
key: 'global.share',
title: '社交分享',
icon: 'fa fas fa-share-alt',
description: '配置文章分享平台、微信 JSAPI 分享和海报分享。',
defaults: {
share_s: true,
share_items: defaultShareItems,
wechat_share_s: false,
wechat_share_option: { appid: '', app_secret: '', only_logo: false },
share_img: true,
share_img_compatible_s: false,
share_img_byimg: themeRoot ? `${themeRoot}/assets/img/slider-bg.jpg` : '',
share_logo: themeRoot ? `${themeRoot}/assets/img/logo.png` : '',
share_desc: '扫一扫 立即查看',
},
groups: [
{
key: 'share',
title: '社交分享',
icon: 'fa fas fa-share-alt',
fields: [
{ key: 'share_s', label: '文章分享功能', type: 'switcher', default: true, help: '关闭后,在文章页面将不显示分享按钮。' },
{
key: 'share_items',
label: '分享平台',
type: 'custom',
renderer: 'sorter',
sanitize_type: 'array',
default: defaultShareItems,
options: shareOptions,
description: '左侧启用并拖拽排序,右侧为未启用项(同时启用的数量不建议超过 6 个)。若开启海外平台,用户网络必须能正常访问对应服务。',
},
{ key: 'wechat_share_s', label: '微信分享有图', type: 'switcher', default: false, help: '使用微信 JSAPI 在微信 App 内分享。' },
{
key: 'wechat_share_hint',
label: '',
type: 'content',
ui_only: true,
dependsOn: { key: 'wechat_share_s', value: true },
content: '<p><strong>微信分享有图配置</strong></p><p>此功能用于用户从公众号进入页面后调用微信默认分享能力,并不会额外显示分享按钮。请在公众号后台将当前站点域名配置为 JS 接口安全域名。</p><p><a href="https://mp.weixin.qq.com/" target="_blank" rel="noopener noreferrer">前往微信公众平台</a></p>',
},
{
key: 'wechat_share_option',
label: '微信分享有图配置',
type: 'fieldset',
default: { appid: '', app_secret: '', only_logo: false },
dependsOn: { key: 'wechat_share_s', value: true },
fields: [
{ key: 'appid', label: 'AppID', type: 'input', default: '' },
{ key: 'app_secret', label: 'AppSecret', type: 'input', default: '' },
{ key: 'only_logo', label: '全部使用网站图标', type: 'switcher', default: false, help: '默认自动使用页面封面图;开启后所有页面均使用网站图标。图片启用防盗链时建议开启。' },
],
},
{ key: 'share_img', label: '生成海报分享', type: 'switcher', default: true, help: '网站图片使用 OSS 等云存储时,请先配置允许本站 Canvas 读取图片的跨域规则。' },
{
key: 'share_img_warning',
label: '',
type: 'notice',
ui_only: true,
alertType: 'warning',
content: '海报图片加载失败时,请检查图片 CDN/OSS 的跨域响应头。',
dependsOn: { key: 'share_img', value: true },
},
{ key: 'share_img_compatible_s', label: '海报分享兼容模式', type: 'switcher', default: false, dependsOn: { key: 'share_img', value: true }, help: '通过服务端代理读取海报图片,改善跨域兼容性;会增加服务器图片处理开销。' },
{ key: 'share_img_byimg', label: '海报分享默认图片', type: 'media', default: themeRoot ? `${themeRoot}/assets/img/slider-bg.jpg` : '', dependsOn: { key: 'share_img', value: true }, help: '文章没有图片时使用,建议尺寸 800×500。' },
{ key: 'share_logo', label: '海报分享 LOGO', type: 'media', default: themeRoot ? `${themeRoot}/assets/img/logo.png` : '', dependsOn: { key: 'share_img', value: true }, help: '显示在海报底部,建议尺寸 300×100、大小 50KB 以内。' },
{ key: 'share_desc', label: '海报分享底部文案', type: 'input', default: '扫一扫 立即查看', dependsOn: { key: 'share_img', value: true } },
],
},
],
}
@@ -8,7 +8,6 @@ import { pageSchema } from './page.js'
import { filterSchema } from './filter.js'
import { featureSchema } from './feature.js'
import { paySchema } from './pay.js'
import { shareSchema } from './share.js'
import { commentSchema } from './comment.js'
import { submitSchema } from './submit.js'
@@ -19,7 +18,6 @@ export const postListSchemas = {
filter: filterSchema,
feature: featureSchema,
pay: paySchema,
share: shareSchema,
comment: commentSchema,
submit: submitSchema,
}
@@ -1,51 +0,0 @@
export const shareSchema = {
key: 'post_list.share',
title: '分享设置',
icon: 'fa fas fa-share-alt',
description: '配置微信分享凭据、海报分享和社交分享选项。',
defaults: {
share_s: true,
share_wechat_s: false,
share_wechat_appid: '',
share_wechat_app_secret: '',
share_only_logo: false,
share_img_compatible_s: false,
share_img_byimg: '',
share_logo: '',
share_img: '',
share_desc: '扫一扫 立即查看',
},
groups: [
{
key: 'basic',
title: '分享按钮',
icon: 'fa fas fa-share-alt',
fields: [
{ key: 'share_s', label: '分享按钮', type: 'switch', default: true, help: '关闭后,在文章页面将不显示分享按钮,论坛及商城不受影响' },
],
},
{
key: 'wechat',
title: '微信分享',
icon: 'fa fab fa-weixin',
fields: [
{ key: 'share_wechat_s', label: '启用微信分享', type: 'switch', default: false, help: '启用后文章页将支持微信 JSAPI 分享' },
{ key: 'share_wechat_appid', label: 'AppID', type: 'input', default: '', dependsOn: { key: 'share_wechat_s', value: true }, help: '微信公众号 AppID' },
{ key: 'share_wechat_app_secret', label: 'AppSecret', type: 'input', default: '', dependsOn: { key: 'share_wechat_s', value: true }, help: '微信公众号 AppSecret(请确保 JS 安全域名已配置)' },
{ key: 'share_only_logo', label: '仅显示 Logo', type: 'switch', default: false, help: '分享时仅显示站点 Logo' },
],
},
{
key: 'poster',
title: '海报分享',
icon: 'fa fas fa-image',
fields: [
{ key: 'share_img_compatible_s', label: '兼容模式', type: 'switch', default: false, help: '启用后使用兼容模式生成分享海报' },
{ key: 'share_img_byimg', label: '海报默认图', type: 'media', default: '', help: '海报分享使用的默认背景图' },
{ key: 'share_logo', label: '海报 LOGO', type: 'media', default: '', help: '海报上叠加的站点 LOGO' },
{ key: 'share_img', label: '分享图片', type: 'media', default: '', help: '社交平台分享预览图' },
{ key: 'share_desc', label: '分享描述', type: 'textarea', default: '扫一扫 立即查看', help: '海报或分享卡片的描述文案' },
],
},
],
}