89 lines
4.2 KiB
JavaScript
89 lines
4.2 KiB
JavaScript
export const ipSchema = {
|
|
key: 'extensions.ip',
|
|
title: 'IP归属地',
|
|
icon: 'fa fas fa-map-marker-alt',
|
|
description: '配置 IP 数据源、缓存策略和前台归属地展示。',
|
|
defaults: {
|
|
ip_geo_enabled: false,
|
|
ip_addr_sdk: 'null',
|
|
ip_geo_cache_ttl: 86400,
|
|
ip_geo_display: ['comment', 'user_home', 'user_center', 'post'],
|
|
ip_geo_format: 'province_city',
|
|
ip_geo_fallback_text: '',
|
|
ip_addr_sdk_qq_appkey: '',
|
|
ip_addr_sdk_qq_secretkey: '',
|
|
ip_addr_sdk_amap_appkey: '',
|
|
ip_addr_sdk_amap_secretkey: '',
|
|
},
|
|
groups: [
|
|
{
|
|
key: 'basic',
|
|
title: '基础配置',
|
|
icon: 'fa fas fa-globe',
|
|
fields: [
|
|
{ key: 'ip_geo_enabled', label: '启用 IP 归属地', type: 'switch', default: false, help: '开启后将在评论、用户主页等位置显示 IP 归属地信息' },
|
|
{
|
|
key: 'ip_addr_sdk',
|
|
label: 'IP 接口服务商',
|
|
type: 'radio',
|
|
default: 'null',
|
|
options: [
|
|
{ label: '轮流查询', value: 'polling' },
|
|
{ label: '腾讯位置服务', value: 'qq' },
|
|
{ label: '高德位置服务', value: 'amap' },
|
|
{ label: '太平洋公共接口', value: 'null' },
|
|
],
|
|
dependsOn: { key: 'ip_geo_enabled', value: true },
|
|
help: '优先使用国内接口,轮流查询会按腾讯→高德→公共接口顺序回退。',
|
|
},
|
|
{ key: 'ip_geo_cache_ttl', label: '缓存时间 (秒)', type: 'number', default: 86400, min: 3600, max: 604800, dependsOn: { key: 'ip_geo_enabled', value: true }, help: 'IP 查询结果缓存时长,避免频繁请求外部接口' },
|
|
],
|
|
},
|
|
{
|
|
key: 'providers',
|
|
title: '接口凭据',
|
|
icon: 'fa fas fa-key',
|
|
fields: [
|
|
{ key: 'ip_addr_sdk_qq_appkey', label: '腾讯 AppKey', type: 'input', default: '', dependsOn: { key: 'ip_addr_sdk', values: ['qq', 'polling'] }, help: '「腾讯位置服务」或「轮流查询」时填写;未填则轮询会跳过腾讯。' },
|
|
{ key: 'ip_addr_sdk_qq_secretkey', label: '腾讯 SecretKey', type: 'input', default: '', dependsOn: { key: 'ip_addr_sdk', values: ['qq', 'polling'] }, help: '启用 SK 签名时必填;未启用可留空。' },
|
|
{ key: 'ip_addr_sdk_amap_appkey', label: '高德 AppKey', type: 'input', default: '', dependsOn: { key: 'ip_addr_sdk', values: ['amap', 'polling'] }, help: '必须在高德开放平台创建「Web服务」类型 Key,并开通 IP 定位。选错平台会报 USERKEY_PLAT_NOMATCH。「轮流查询」时未填则跳过高德。' },
|
|
{ key: 'ip_addr_sdk_amap_secretkey', label: '高德 SecretKey', type: 'input', default: '', dependsOn: { key: 'ip_addr_sdk', values: ['amap', 'polling'] }, help: '若控制台启用了「数字签名」,必填安全密钥;未启用可留空。' },
|
|
],
|
|
},
|
|
{
|
|
key: 'display',
|
|
title: '展示设置',
|
|
icon: 'fa fas fa-eye',
|
|
fields: [
|
|
{
|
|
key: 'ip_geo_display',
|
|
label: '展示位置',
|
|
type: 'checkbox',
|
|
default: ['comment', 'user_home', 'user_center', 'post'],
|
|
options: [
|
|
{ label: '评论区', value: 'comment' },
|
|
{ label: '用户主页', value: 'user_home' },
|
|
{ label: '用户中心', value: 'user_center' },
|
|
{ label: '文章详细页', value: 'post' },
|
|
],
|
|
dependsOn: { key: 'ip_geo_enabled', value: true },
|
|
help: '用户主页/用户中心还需在「用户 → 用户功能」开启「显示城市」;评论区还需在评论设置开启「评论城市」。',
|
|
},
|
|
{
|
|
key: 'ip_geo_format',
|
|
label: '显示格式',
|
|
type: 'radio',
|
|
default: 'province_city',
|
|
options: [
|
|
{ label: '省份+城市', value: 'province_city' },
|
|
{ label: '仅省份', value: 'province' },
|
|
{ label: '国家+省份', value: 'country_province' },
|
|
],
|
|
dependsOn: { key: 'ip_geo_enabled', value: true },
|
|
},
|
|
{ key: 'ip_geo_fallback_text', label: '查询失败时文案', type: 'input', default: '', placeholder: '留空则不显示', dependsOn: { key: 'ip_geo_enabled', value: true } },
|
|
],
|
|
},
|
|
],
|
|
}
|