🐛 fix(core): 修复台湾地区旗帜在部分客户端的显示问题

* 新增 REGION_FLAG_DISPLAY_OVERRIDES 配置项用于处理地区旗帜回退逻辑
* 将台湾地区 (TW) 的显示旗帜回退至中国国旗 (CN) 以解决兼容性渲染问题
* 保持地区识别代码仍为 TW,仅在显示层进行覆盖处理
* 优化代码结构,确保 flag 覆盖逻辑在工具类加载前正确初始化
This commit is contained in:
orion committed 2026-08-06 00:15:11 +08:00
1 parent 72f09f039a
commit f601a0155a
1 file changed
+7 -2
+7 -2
View File
@@ -8,6 +8,10 @@
// noinspection JSUnusedGlobalSymbols
const COMMON_SCRIPT_VERSION = '20260702-1';
const COMMON_SCRIPT_URL = `https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=${COMMON_SCRIPT_VERSION}`;
// 部分客户端无法渲染台湾地区旗帜,显示层回退到中国国旗;地区识别仍保留为 TW。
const REGION_FLAG_DISPLAY_OVERRIDES = {
TW: 'CN'
};
const hasCurrentRenameUtils = utils => Boolean(
utils && utils.version === COMMON_SCRIPT_VERSION
);
@@ -53,7 +57,7 @@ const EXTRA_REGION_ALIASES = [
['North Korea', 'KP'], ['DPRK', 'KP'], ['朝鲜', 'KP'], ['北韩', 'KP'], ['北韓', 'KP'],
['Hong Kong', 'HK'], ['香港', 'HK'],
['Macau', 'MO'], ['Macao', 'MO'], ['澳门', 'MO'], ['澳門', 'MO'],
['Taiwan', 'TW'], ['台湾', 'TW'], ['台灣', 'TW'],
['Taiwan', 'TW'], ['台湾', 'TW'], ['台灣', 'TW'], ['臺灣', 'TW'],
['Singapore', 'SG'], ['新加坡', 'SG'], ['狮城', 'SG'], ['獅城', 'SG'],
['Japan', 'JP'], ['日本', 'JP'],
['China', 'CN'], ['中国', 'CN'], ['中國', 'CN'],
@@ -179,7 +183,8 @@ async function operator(proxies) {
const regionCode = firstCountryCodeOf(splitName.text || cleanName);
if (!regionCode) return name;
const flag = utils.regionCodeToFlag(regionCode);
const displayRegionCode = REGION_FLAG_DISPLAY_OVERRIDES[regionCode] || regionCode;
const flag = utils.regionCodeToFlag(displayRegionCode);
return flag ? `${flag} ${splitName.text}`.trim() : name;
};
const nameCounts = Object.create(null);