支付方式根据当前界面语言构建,中文版只显示支付宝和微信

This commit is contained in:
jingrow 2026-01-10 02:31:17 +08:00
parent e6348d51e5
commit a057c12acc
4 changed files with 164 additions and 135 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="h-full overflow-hidden" lang="zh"> <html class="h-full overflow-hidden">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />

View File

@ -24,6 +24,7 @@
<label <label
class="payment-option" class="payment-option"
:class="{'payment-option-active': paymentGateway === 'Alipay'}" :class="{'payment-option-active': paymentGateway === 'Alipay'}"
v-if="isChineseLocale"
> >
<div class="payment-icon"> <div class="payment-icon">
<AlipayLogo /> <AlipayLogo />
@ -39,6 +40,7 @@
<label <label
class="payment-option" class="payment-option"
:class="{'payment-option-active': paymentGateway === 'WeChatPay'}" :class="{'payment-option-active': paymentGateway === 'WeChatPay'}"
v-if="isChineseLocale"
> >
<div class="payment-icon"> <div class="payment-icon">
<WeChatPayLogo /> <WeChatPayLogo />
@ -54,6 +56,7 @@
<label <label
class="payment-option" class="payment-option"
:class="{'payment-option-active': paymentGateway === 'Stripe'}" :class="{'payment-option-active': paymentGateway === 'Stripe'}"
v-if="!isChineseLocale"
> >
<div class="payment-icon"> <div class="payment-icon">
<StripeLogo /> <StripeLogo />
@ -69,6 +72,7 @@
<label <label
class="payment-option" class="payment-option"
:class="{'payment-option-active': paymentGateway === 'PayPal'}" :class="{'payment-option-active': paymentGateway === 'PayPal'}"
v-if="!isChineseLocale"
> >
<div class="payment-icon"> <div class="payment-icon">
<!-- PayPal SVG Logo --> <!-- PayPal SVG Logo -->
@ -187,6 +191,7 @@ import BuyPrepaidCreditsPayPal from './BuyPrepaidCreditsPayPal.vue';
import AlipayLogo from '../logo/AlipayLogo.vue'; import AlipayLogo from '../logo/AlipayLogo.vue';
import WeChatPayLogo from '../logo/WeChatPayLogo.vue'; import WeChatPayLogo from '../logo/WeChatPayLogo.vue';
import StripeLogo from './StripeLogo.vue'; import StripeLogo from './StripeLogo.vue';
import { getLocale } from '../utils/i18n';
export default { export default {
name: 'BuyPrepaidCreditsForm', name: 'BuyPrepaidCreditsForm',
@ -201,11 +206,27 @@ export default {
}, },
data() { data() {
return { return {
paymentGateway: 'Alipay', // Default to Alipay _paymentGateway: null,
creditsToBuy: this.minimumAmount || 0, creditsToBuy: this.minimumAmount || 0,
amountError: '' amountError: ''
}; };
}, },
computed: {
isChineseLocale() {
return getLocale() === 'zh';
},
defaultPaymentGateway() {
return this.isChineseLocale ? 'Alipay' : 'Stripe';
},
paymentGateway: {
get() {
return this._paymentGateway || this.defaultPaymentGateway;
},
set(value) {
this._paymentGateway = value;
}
}
},
props: { props: {
modelValue: { modelValue: {
default: false default: false
@ -347,7 +368,7 @@ export default {
min-width: 50px; min-width: 50px;
} }
.alipay-svg, .wechat-svg { .alipay-svg, .wechat-svg, .stripe-svg, .paypal-svg {
max-height: 24px; max-height: 24px;
} }

View File

@ -162,6 +162,14 @@ function vitePluginTranslate(options = {}) {
} }
}, },
transform(code, id) { transform(code, id) {
if (id.endsWith('index.html')) {
const lang = locale;
return {
code: code.replace(/<html([^>]*)>/i, `<html$1 lang="${lang}">`),
map: null
};
}
const fileMatches = CONSTANTS.FILE_EXTENSIONS.test(id); const fileMatches = CONSTANTS.FILE_EXTENSIONS.test(id);
if (!fileMatches || locale === defaultLocale || Object.keys(translations).length === 0) { if (!fileMatches || locale === defaultLocale || Object.keys(translations).length === 0) {
return null; return null;

View File

@ -11,7 +11,7 @@ import { sentryVitePlugin } from '@sentry/vite-plugin';
import vitePluginTranslate from './vite-plugin-translate.mjs'; import vitePluginTranslate from './vite-plugin-translate.mjs';
// 语言配置:设置目标语言,默认为 'en'(英文),可设置为 'zh'(中文)等 // 语言配置:设置目标语言,默认为 'en'(英文),可设置为 'zh'(中文)等
const locale = process.env.DASHBOARD_LOCALE || 'en'; const locale = process.env.DASHBOARD_LOCALE || 'zh';
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [