Browse Source
新增 doc_url_helper.dart 工具文件,提供 docLangPath、privacyPolicyUrl 和 userAgreementUrl 函数 根据当前语言环境动态生成对应的文档链接,支持多种语言版本 替换登录页、个人资料页和隐私政策弹窗中的硬编码URL,提高代码复用性和可维护性weicu
4 changed files with 36 additions and 45 deletions
@ -0,0 +1,27 @@ |
|||
import 'package:get/get.dart'; |
|||
|
|||
/// 根据当前语言返回 doc 目录名,如 "zh_cn"、"en"、"fr" |
|||
String docLangPath() { |
|||
final lang = Get.locale?.languageCode ?? 'en'; |
|||
final country = Get.locale?.countryCode?.toUpperCase() ?? ''; |
|||
if (lang == 'zh') { |
|||
if (country == 'CN') return 'zh_cn'; |
|||
if (country == 'HK') return 'zh_hk'; |
|||
return 'zh_tw'; |
|||
} |
|||
const supported = [ |
|||
'ar', 'bg', 'cs', 'da', 'de', 'el', 'es', 'et', 'fa', 'fi', 'fr', |
|||
'hi', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ko', 'lt', 'lv', 'ms', |
|||
'nb', 'nl', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'th', |
|||
'tl', 'tr', 'uk', 'vi', |
|||
]; |
|||
return supported.contains(lang) ? lang : 'en'; |
|||
} |
|||
|
|||
/// 构建隐私政策 URL |
|||
String privacyPolicyUrl() => |
|||
'https://www.voitrans.net/doc/${docLangPath()}/privacy_policy.html'; |
|||
|
|||
/// 构建用户协议 URL |
|||
String userAgreementUrl() => |
|||
'https://www.voitrans.net/doc/${docLangPath()}/user_agreement.html'; |
|||
Loading…
Reference in new issue