diff --git a/src/mobile/views/auth/AuthCallback.vue b/src/mobile/views/auth/AuthCallback.vue index d3b520a..f937201 100644 --- a/src/mobile/views/auth/AuthCallback.vue +++ b/src/mobile/views/auth/AuthCallback.vue @@ -29,21 +29,16 @@ interface ChannelConfig { codeField: 'code' | 'auth_code' /** 品牌色(loading 圈色 + 调试卡片 value 色) */ brandColor: string - /** i18n 命名空间(对应 auth.json 中的 wechat/alipay/douyin 组) */ + /** i18n 命名空间(对应 auth.json 中的 wechat/alipay/douyin 组, 仅取差异 key) */ i18nNs: string - /** - * 标识字段名(用于调试卡片 label i18n key 拼接) - * wechat/douyin 用 openId, alipay 用 userId(C 方案 i18n 重组后统一为 identifierLabel) - */ - identifierKey: 'openId' | 'userId' } const props = defineProps<{ channel: AuthChannel }>() const CHANNEL_CONFIG: Record = { - wechat: { codeField: 'code', brandColor: '#07c160', i18nNs: 'wechat', identifierKey: 'openId' }, - alipay: { codeField: 'auth_code', brandColor: '#1677ff', i18nNs: 'alipay', identifierKey: 'userId' }, - douyin: { codeField: 'code', brandColor: '#161823', i18nNs: 'douyin', identifierKey: 'openId' }, + wechat: { codeField: 'code', brandColor: '#07c160', i18nNs: 'wechat' }, + alipay: { codeField: 'auth_code', brandColor: '#1677ff', i18nNs: 'alipay' }, + douyin: { codeField: 'code', brandColor: '#161823', i18nNs: 'douyin' }, } const cfg = computed(() => CHANNEL_CONFIG[props.channel]) @@ -90,7 +85,7 @@ function markFailed(msg: string) { */ function init() { if (!authToken || !code) { - markFailed(t(`auth.${cfg.value.i18nNs}.codeMissing`)) + markFailed(t('auth.common.codeMissing')) return } authAndGet({ @@ -110,10 +105,10 @@ function init() { return } // 真正失败: 既无 returnPath 也无标识 - markFailed(t(`auth.${cfg.value.i18nNs}.authFail`)) + markFailed(t('auth.common.authFail')) }) .catch((err: Error) => { - markFailed(err?.message || t(`auth.${cfg.value.i18nNs}.authFail`)) + markFailed(err?.message || t('auth.common.authFail')) }) } @@ -142,10 +137,10 @@ async function copyIdentifier() { document.execCommand('copy') document.body.removeChild(textarea) } - showSuccessToast(t(`auth.${cfg.value.i18nNs}.copySuccess`)) + showSuccessToast(t('auth.common.copySuccess')) } catch { - showFailToast(t(`auth.${cfg.value.i18nNs}.copyFail`)) + showFailToast(t('auth.common.copyFail')) } } @@ -168,18 +163,18 @@ async function copyIdentifier() {

- {{ t(`auth.${cfg.i18nNs}.successTitle`) }} + {{ t('auth.common.successTitle') }}

- {{ t(`auth.${cfg.i18nNs}.${cfg.identifierKey}`) }} + {{ t(`auth.${cfg.i18nNs}.identifierLabel`) }}
{{ identifierValue }}
- {{ t(`auth.${cfg.i18nNs}.copy`) }} + {{ t('auth.common.copy') }}
- {{ t(`auth.${cfg.i18nNs}.close`) }} + {{ t('auth.common.close') }}
@@ -193,14 +188,14 @@ async function copyIdentifier() {

- {{ t(`auth.${cfg.i18nNs}.failTitle`) }} + {{ t('auth.common.failTitle') }}

{{ failMsg }}

- {{ t(`auth.${cfg.i18nNs}.close`) }} + {{ t('auth.common.close') }}
diff --git a/src/pc/views/auth/wechat/Index.vue b/src/pc/views/auth/wechat/Index.vue index 11bcbc6..20fe7b4 100644 --- a/src/pc/views/auth/wechat/Index.vue +++ b/src/pc/views/auth/wechat/Index.vue @@ -44,7 +44,7 @@ function markFailed(msg: string) { */ function init() { if (!authToken || !code) { - markFailed(t('auth.wechat.codeMissing')) + markFailed(t('auth.common.codeMissing')) return } authAndGet({ @@ -57,10 +57,10 @@ function init() { if (finishGatewayAuthAndRedirect(data ?? {})) { return } - markFailed(t('auth.wechat.authFail')) + markFailed(t('auth.common.authFail')) }) .catch((err: Error) => { - markFailed(err?.message || t('auth.wechat.authFail')) + markFailed(err?.message || t('auth.common.authFail')) }) } @@ -96,13 +96,13 @@ function handleBack() {

- {{ t('auth.wechat.failTitle') }} + {{ t('auth.common.failTitle') }}

{{ failMsg }}

diff --git a/src/shared/locales/en-US/auth.json b/src/shared/locales/en-US/auth.json index 4a06083..749c34b 100644 --- a/src/shared/locales/en-US/auth.json +++ b/src/shared/locales/en-US/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "Fetching authorization...", - "secureTip": "Alipay secure auth", "successTitle": "Success", "failTitle": "Failed", - "userId": "Alipay User ID", "copy": "Copy", "close": "Close", "copySuccess": "Copied", @@ -13,29 +11,15 @@ "authFail": "Failed to get user id" }, "wechat": { - "loading": "Fetching authorization...", "secureTip": "WeChat secure auth", - "successTitle": "Success", - "failTitle": "Failed", - "openId": "WeChat OpenId", - "copy": "Copy", - "close": "Close", - "copySuccess": "Copied", - "copyFail": "Copy failed", - "codeMissing": "No auth code received, please retry", - "authFail": "Failed to get user id" + "identifierLabel": "WeChat OpenId" + }, + "alipay": { + "secureTip": "Alipay secure auth", + "identifierLabel": "Alipay User ID" }, "douyin": { - "loading": "Fetching authorization...", "secureTip": "Douyin secure auth", - "successTitle": "Success", - "failTitle": "Failed", - "openId": "Douyin OpenId", - "copy": "Copy", - "close": "Close", - "copySuccess": "Copied", - "copyFail": "Copy failed", - "codeMissing": "No auth code received, please retry", - "authFail": "Failed to get user id" + "identifierLabel": "Douyin OpenId" } } diff --git a/src/shared/locales/id-ID/auth.json b/src/shared/locales/id-ID/auth.json index 88ad6a5..937ef35 100644 --- a/src/shared/locales/id-ID/auth.json +++ b/src/shared/locales/id-ID/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "Mengambil otorisasi...", - "secureTip": "Alipay mengamankan autentikasi", "successTitle": "Kesuksesan", "failTitle": "Gagal", - "userId": "ID Pengguna Alipay", "copy": "Menyalin", "close": "Menutup", "copySuccess": "Disalin", @@ -13,29 +11,15 @@ "authFail": "Gagal mendapatkan id pengguna" }, "wechat": { - "loading": "Mengambil otorisasi...", "secureTip": "Otentikasi aman WeChat", - "successTitle": "Kesuksesan", - "failTitle": "Gagal", - "openId": "WeChat OpenId", - "copy": "Menyalin", - "close": "Menutup", - "copySuccess": "Disalin", - "copyFail": "Penyalinan gagal", - "codeMissing": "Tidak ada kode autentikasi yang diterima, silakan coba lagi", - "authFail": "Gagal mendapatkan id pengguna" + "identifierLabel": "WeChat OpenId" + }, + "alipay": { + "secureTip": "Alipay mengamankan autentikasi", + "identifierLabel": "ID Pengguna Alipay" }, "douyin": { - "loading": "Mengambil otorisasi...", "secureTip": "Douyin mengamankan autentikasi", - "successTitle": "Kesuksesan", - "failTitle": "Gagal", - "openId": "Douyin OpenId", - "copy": "Menyalin", - "close": "Menutup", - "copySuccess": "Disalin", - "copyFail": "Penyalinan gagal", - "codeMissing": "Tidak ada kode autentikasi yang diterima, silakan coba lagi", - "authFail": "Gagal mendapatkan id pengguna" + "identifierLabel": "Douyin OpenId" } } diff --git a/src/shared/locales/ja-JP/auth.json b/src/shared/locales/ja-JP/auth.json index 6dab134..15ae46d 100644 --- a/src/shared/locales/ja-JP/auth.json +++ b/src/shared/locales/ja-JP/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "認証を取得中...", - "secureTip": "Alipayの安全な認証", "successTitle": "成功", "failTitle": "失敗した", - "userId": "Alipay ユーザー ID", "copy": "コピー", "close": "近い", "copySuccess": "コピーされました", @@ -13,29 +11,15 @@ "authFail": "ユーザーIDの取得に失敗しました" }, "wechat": { - "loading": "認証を取得中...", "secureTip": "WeChat の安全な認証", - "successTitle": "成功", - "failTitle": "失敗した", - "openId": "WeChat オープン ID", - "copy": "コピー", - "close": "近い", - "copySuccess": "コピーされました", - "copyFail": "コピーに失敗しました", - "codeMissing": "認証コードを受信しませんでした。再試行してください", - "authFail": "ユーザーIDの取得に失敗しました" + "identifierLabel": "WeChat オープン ID" + }, + "alipay": { + "secureTip": "Alipayの安全な認証", + "identifierLabel": "Alipay ユーザー ID" }, "douyin": { - "loading": "認証を取得中...", "secureTip": "Douyin の安全な認証", - "successTitle": "成功", - "failTitle": "失敗した", - "openId": "Douyin OpenId", - "copy": "コピー", - "close": "近い", - "copySuccess": "コピーされました", - "copyFail": "コピーに失敗しました", - "codeMissing": "認証コードを受信しませんでした。再試行してください", - "authFail": "ユーザーIDの取得に失敗しました" + "identifierLabel": "Douyin OpenId" } } diff --git a/src/shared/locales/ko-KR/auth.json b/src/shared/locales/ko-KR/auth.json index e6e082c..3c33286 100644 --- a/src/shared/locales/ko-KR/auth.json +++ b/src/shared/locales/ko-KR/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "승인을 가져오는 중...", - "secureTip": "Alipay 보안 인증", "successTitle": "성공", "failTitle": "실패한", - "userId": "알리페이 사용자 ID", "copy": "복사", "close": "닫다", "copySuccess": "복사됨", @@ -13,29 +11,15 @@ "authFail": "사용자 ID를 가져오지 못했습니다." }, "wechat": { - "loading": "승인을 가져오는 중...", "secureTip": "WeChat 보안 인증", - "successTitle": "성공", - "failTitle": "실패한", - "openId": "위챗 오픈아이디", - "copy": "복사", - "close": "닫다", - "copySuccess": "복사됨", - "copyFail": "복사 실패", - "codeMissing": "인증 코드가 수신되지 않았습니다. 다시 시도해 주세요.", - "authFail": "사용자 ID를 가져오지 못했습니다." + "identifierLabel": "위챗 오픈아이디" + }, + "alipay": { + "secureTip": "Alipay 보안 인증", + "identifierLabel": "알리페이 사용자 ID" }, "douyin": { - "loading": "승인을 가져오는 중...", "secureTip": "Douyin 보안 인증", - "successTitle": "성공", - "failTitle": "실패한", - "openId": "Douyin OpenId", - "copy": "복사", - "close": "닫다", - "copySuccess": "복사됨", - "copyFail": "복사 실패", - "codeMissing": "인증 코드가 수신되지 않았습니다. 다시 시도해 주세요.", - "authFail": "사용자 ID를 가져오지 못했습니다." + "identifierLabel": "Douyin OpenId" } } diff --git a/src/shared/locales/ms-MY/auth.json b/src/shared/locales/ms-MY/auth.json index 658764b..af1b078 100644 --- a/src/shared/locales/ms-MY/auth.json +++ b/src/shared/locales/ms-MY/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "Mengambil kebenaran...", - "secureTip": "Pengesahan selamat Alipay", "successTitle": "Kejayaan", "failTitle": "gagal", - "userId": "ID Pengguna Alipay", "copy": "salin", "close": "tutup", "copySuccess": "disalin", @@ -13,29 +11,15 @@ "authFail": "Gagal mendapatkan id pengguna" }, "wechat": { - "loading": "Mengambil kebenaran...", "secureTip": "Pengesahan selamat WeChat", - "successTitle": "Kejayaan", - "failTitle": "gagal", - "openId": "WeChat OpenId", - "copy": "salin", - "close": "tutup", - "copySuccess": "disalin", - "copyFail": "Salinan gagal", - "codeMissing": "Tiada kod pengesahan diterima, sila cuba semula", - "authFail": "Gagal mendapatkan id pengguna" + "identifierLabel": "WeChat OpenId" + }, + "alipay": { + "secureTip": "Pengesahan selamat Alipay", + "identifierLabel": "ID Pengguna Alipay" }, "douyin": { - "loading": "Mengambil kebenaran...", "secureTip": "Pengesahan selamat Douyin", - "successTitle": "Kejayaan", - "failTitle": "gagal", - "openId": "Douyin OpenId", - "copy": "salin", - "close": "tutup", - "copySuccess": "disalin", - "copyFail": "Salinan gagal", - "codeMissing": "Tiada kod pengesahan diterima, sila cuba semula", - "authFail": "Gagal mendapatkan id pengguna" + "identifierLabel": "Douyin OpenId" } } diff --git a/src/shared/locales/th-TH/auth.json b/src/shared/locales/th-TH/auth.json index e89174f..f5737f3 100644 --- a/src/shared/locales/th-TH/auth.json +++ b/src/shared/locales/th-TH/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "กำลังดึงข้อมูลการอนุญาต...", - "secureTip": "Alipay รับรองความถูกต้องอย่างปลอดภัย", "successTitle": "ความสำเร็จ", "failTitle": "ล้มเหลว", - "userId": "รหัสผู้ใช้อาลีเพย์", "copy": "สำเนา", "close": "ปิด", "copySuccess": "คัดลอกแล้ว", @@ -13,29 +11,15 @@ "authFail": "ไม่สามารถรับ ID ผู้ใช้" }, "wechat": { - "loading": "กำลังดึงข้อมูลการอนุญาต...", "secureTip": "การตรวจสอบสิทธิ์ที่ปลอดภัยของ WeChat", - "successTitle": "ความสำเร็จ", - "failTitle": "ล้มเหลว", - "openId": "วีแชต โอเพ่นไอดี", - "copy": "สำเนา", - "close": "ปิด", - "copySuccess": "คัดลอกแล้ว", - "copyFail": "การคัดลอกล้มเหลว", - "codeMissing": "ไม่ได้รับรหัสรับรองความถูกต้อง โปรดลองอีกครั้ง", - "authFail": "ไม่สามารถรับ ID ผู้ใช้" + "identifierLabel": "วีแชต โอเพ่นไอดี" + }, + "alipay": { + "secureTip": "Alipay รับรองความถูกต้องอย่างปลอดภัย", + "identifierLabel": "รหัสผู้ใช้อาลีเพย์" }, "douyin": { - "loading": "กำลังดึงข้อมูลการอนุญาต...", "secureTip": "Douyin รับรองความถูกต้องที่ปลอดภัย", - "successTitle": "ความสำเร็จ", - "failTitle": "ล้มเหลว", - "openId": "Douyin OpenId", - "copy": "สำเนา", - "close": "ปิด", - "copySuccess": "คัดลอกแล้ว", - "copyFail": "การคัดลอกล้มเหลว", - "codeMissing": "ไม่ได้รับรหัสรับรองความถูกต้อง โปรดลองอีกครั้ง", - "authFail": "ไม่สามารถรับ ID ผู้ใช้" + "identifierLabel": "Douyin OpenId" } } diff --git a/src/shared/locales/vi-VN/auth.json b/src/shared/locales/vi-VN/auth.json index 79e59ed..a7d4cce 100644 --- a/src/shared/locales/vi-VN/auth.json +++ b/src/shared/locales/vi-VN/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "Đang tìm nạp ủy quyền...", - "secureTip": "Xác thực an toàn của Alipay", "successTitle": "Thành công", "failTitle": "Thất bại", - "userId": "ID người dùng Alipay", "copy": "Sao chép", "close": "Đóng", "copySuccess": "Đã sao chép", @@ -13,29 +11,15 @@ "authFail": "Không lấy được id người dùng" }, "wechat": { - "loading": "Đang tìm nạp ủy quyền...", "secureTip": "Xác thực bảo mật WeChat", - "successTitle": "Thành công", - "failTitle": "Thất bại", - "openId": "ID mở WeChat", - "copy": "Sao chép", - "close": "Đóng", - "copySuccess": "Đã sao chép", - "copyFail": "Sao chép không thành công", - "codeMissing": "Không nhận được mã xác thực, vui lòng thử lại", - "authFail": "Không lấy được id người dùng" + "identifierLabel": "ID mở WeChat" + }, + "alipay": { + "secureTip": "Xác thực an toàn của Alipay", + "identifierLabel": "ID người dùng Alipay" }, "douyin": { - "loading": "Đang tìm nạp ủy quyền...", "secureTip": "Xác thực an toàn Douyin", - "successTitle": "Thành công", - "failTitle": "Thất bại", - "openId": "Id mở Douyin", - "copy": "Sao chép", - "close": "Đóng", - "copySuccess": "Đã sao chép", - "copyFail": "Sao chép không thành công", - "codeMissing": "Không nhận được mã xác thực, vui lòng thử lại", - "authFail": "Không lấy được id người dùng" + "identifierLabel": "Id mở Douyin" } } diff --git a/src/shared/locales/zh-CN/auth.json b/src/shared/locales/zh-CN/auth.json index a6923b8..92bd193 100644 --- a/src/shared/locales/zh-CN/auth.json +++ b/src/shared/locales/zh-CN/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "正在获取授权信息...", - "secureTip": "支付宝安全认证", "successTitle": "获取成功", "failTitle": "获取失败", - "userId": "支付宝用户ID", "copy": "复制信息", "close": "关闭页面", "copySuccess": "复制成功", @@ -13,29 +11,15 @@ "authFail": "获取用户标识失败" }, "wechat": { - "loading": "正在获取授权信息...", "secureTip": "微信安全认证", - "successTitle": "获取成功", - "failTitle": "获取失败", - "openId": "微信OpenId", - "copy": "复制信息", - "close": "关闭页面", - "copySuccess": "复制成功", - "copyFail": "复制失败", - "codeMissing": "未获取到授权码,请重新发起认证", - "authFail": "获取用户标识失败" + "identifierLabel": "微信OpenId" + }, + "alipay": { + "secureTip": "支付宝安全认证", + "identifierLabel": "支付宝用户ID" }, "douyin": { - "loading": "正在获取授权信息...", "secureTip": "抖音安全认证", - "successTitle": "获取成功", - "failTitle": "获取失败", - "openId": "抖音OpenId", - "copy": "复制信息", - "close": "关闭页面", - "copySuccess": "复制成功", - "copyFail": "复制失败", - "codeMissing": "未获取到授权码,请重新发起认证", - "authFail": "获取用户标识失败" + "identifierLabel": "抖音OpenId" } } diff --git a/src/shared/locales/zh-HK/auth.json b/src/shared/locales/zh-HK/auth.json index 355f275..857b738 100644 --- a/src/shared/locales/zh-HK/auth.json +++ b/src/shared/locales/zh-HK/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "正在獲取授權信息...", - "secureTip": "支付寶安全認證", "successTitle": "獲取成功", "failTitle": "獲取失敗", - "userId": "支付寶用户ID", "copy": "複製信息", "close": "關閉頁面", "copySuccess": "複製成功", @@ -13,29 +11,15 @@ "authFail": "獲取用户標識失敗" }, "wechat": { - "loading": "正在獲取授權信息...", "secureTip": "微信安全認證", - "successTitle": "獲取成功", - "failTitle": "獲取失敗", - "openId": "微信OpenId", - "copy": "複製信息", - "close": "關閉頁面", - "copySuccess": "複製成功", - "copyFail": "複製失敗", - "codeMissing": "未獲取到授權碼,請重新發起認證", - "authFail": "獲取用户標識失敗" + "identifierLabel": "微信OpenId" + }, + "alipay": { + "secureTip": "支付寶安全認證", + "identifierLabel": "支付寶用户ID" }, "douyin": { - "loading": "正在獲取授權信息...", "secureTip": "抖音安全認證", - "successTitle": "獲取成功", - "failTitle": "獲取失敗", - "openId": "抖音OpenId", - "copy": "複製信息", - "close": "關閉頁面", - "copySuccess": "複製成功", - "copyFail": "複製失敗", - "codeMissing": "未獲取到授權碼,請重新發起認證", - "authFail": "獲取用户標識失敗" + "identifierLabel": "抖音OpenId" } } diff --git a/src/shared/locales/zh-TW/auth.json b/src/shared/locales/zh-TW/auth.json index 7136932..cac05eb 100644 --- a/src/shared/locales/zh-TW/auth.json +++ b/src/shared/locales/zh-TW/auth.json @@ -1,10 +1,8 @@ { - "alipay": { + "common": { "loading": "正在獲取授權資訊...", - "secureTip": "支付寶安全認證", "successTitle": "獲取成功", "failTitle": "獲取失敗", - "userId": "支付寶使用者ID", "copy": "複製資訊", "close": "關閉頁面", "copySuccess": "複製成功", @@ -13,29 +11,15 @@ "authFail": "獲取使用者標識失敗" }, "wechat": { - "loading": "正在獲取授權資訊...", "secureTip": "微信安全認證", - "successTitle": "獲取成功", - "failTitle": "獲取失敗", - "openId": "微信OpenId", - "copy": "複製資訊", - "close": "關閉頁面", - "copySuccess": "複製成功", - "copyFail": "複製失敗", - "codeMissing": "未獲取到授權碼,請重新發起認證", - "authFail": "獲取使用者標識失敗" + "identifierLabel": "微信OpenId" + }, + "alipay": { + "secureTip": "支付寶安全認證", + "identifierLabel": "支付寶使用者ID" }, "douyin": { - "loading": "正在獲取授權資訊...", "secureTip": "抖音安全認證", - "successTitle": "獲取成功", - "failTitle": "獲取失敗", - "openId": "抖音OpenId", - "copy": "複製資訊", - "close": "關閉頁面", - "copySuccess": "複製成功", - "copyFail": "複製失敗", - "codeMissing": "未獲取到授權碼,請重新發起認證", - "authFail": "獲取使用者標識失敗" + "identifierLabel": "抖音OpenId" } }