feat(ip-geo): full-chain IP 归属地 on comments, user home, center, post
This commit is contained in:
@@ -33,10 +33,11 @@ class SchemaExtensionsIP {
|
||||
['key' => 'ip_addr_sdk_amap_secretkey', 'label' => '高德 SecretKey', 'type' => 'input', 'default' => ''],
|
||||
]],
|
||||
['key' => 'display', 'title' => '展示设置', 'fields' => [
|
||||
['key' => 'ip_geo_display', 'label' => '展示位置', 'type' => 'checkbox', 'default' => ['comment'], 'sanitize_type' => 'array', 'options' => [
|
||||
['key' => 'ip_geo_display', 'label' => '展示位置', 'type' => 'checkbox', 'default' => ['comment', 'user_home', 'user_center', 'post'], 'sanitize_type' => 'array', 'options' => [
|
||||
['label' => '评论区', 'value' => 'comment'],
|
||||
['label' => '用户主页', 'value' => 'user_home'],
|
||||
['label' => '文章页', 'value' => 'post'],
|
||||
['label' => '用户中心', 'value' => 'user_center'],
|
||||
['label' => '文章详细页', 'value' => 'post'],
|
||||
]],
|
||||
['key' => 'ip_geo_format', 'label' => '显示格式', 'type' => 'radio', 'default' => 'province_city', 'options' => [
|
||||
['label' => '省份+城市', 'value' => 'province_city'],
|
||||
|
||||
@@ -520,7 +520,12 @@ class SchemaUsers {
|
||||
['key' => 'user_cover_upload', 'label' => '封面上传', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'user_social_links', 'label' => '社交链接', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'user_desc_std', 'label' => '默认签名', 'type' => 'input', 'default' => '这家伙很懒…', 'desc' => '用户未设置个人简介时显示的默认文案'],
|
||||
['key' => 'user_city_s', 'label' => '显示城市', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'user_city_s', 'label' => '显示城市(IP 归属地)', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'user_city_type', 'label' => '位置精度', 'type' => 'radio', 'default' => 'province', 'options' => [
|
||||
['label' => '省份', 'value' => 'province'],
|
||||
['label' => '省份+城市', 'value' => 'province_city'],
|
||||
['label' => '国家+省份', 'value' => 'country_province'],
|
||||
]],
|
||||
['key' => 'user_join_day_my_name', 'label' => '站名', 'type' => 'input', 'default' => '本站', 'desc' => '用于「已加入 X 天」显示中的站点名称'],
|
||||
['key' => 'user_avatar_default', 'label' => '默认头像', 'type' => 'media', 'default' => ''],
|
||||
['key' => 'user_cover_img', 'label' => '默认封面', 'type' => 'media', 'default' => ''],
|
||||
|
||||
@@ -53,8 +53,14 @@ class ExtensionRuntime {
|
||||
$provider = 'null';
|
||||
}
|
||||
|
||||
$display_raw = $settings['ip_geo_display'] ?? ['comment'];
|
||||
$display_raw = $settings['ip_geo_display'] ?? ['comment', 'user_home', 'user_center', 'post'];
|
||||
$display = is_array($display_raw) ? $display_raw : [$display_raw];
|
||||
$display = array_values(array_unique(array_filter(array_map('sanitize_key', $display))));
|
||||
$allowed_display = ['comment', 'user_home', 'user_center', 'post'];
|
||||
$display = array_values(array_filter($display, static fn($v) => in_array($v, $allowed_display, true)));
|
||||
if ($display === []) {
|
||||
$display = ['comment', 'user_home', 'user_center', 'post'];
|
||||
}
|
||||
|
||||
$format = sanitize_key((string) ($settings['ip_geo_format'] ?? 'province_city'));
|
||||
if (!in_array($format, ['province_city', 'province', 'country_province'], true)) {
|
||||
|
||||
Reference in New Issue
Block a user