refactor: 国际化文本迁移至全局 locales/messages.js
将组件级 i18n 对象重构为统一由全局 locales/messages.js 管理,确保中英文语言切换时正确显示对应文本。 - 新增 utils/i18n.js 国际化工具函数 - 更新 store/$t.mixin.js 翻译混入逻辑 - 迁移 pkgService、pkgBooking、pkgAccount、pkgExplore、pages 等共 58 个组件的中英文文本至全局消息表
This commit is contained in:
@@ -57,24 +57,24 @@
|
||||
<view class="contract-sign-dialog__toolbar">
|
||||
<view class="tool-btn tool-btn--soft" :class="{ disabled: !canUndo }" @tap="handleUndo">
|
||||
<text class="ri-play-reverse-line"></text>
|
||||
<text>{{ t('undo') }}</text>
|
||||
<text>{{ $tr('撤销') }}</text>
|
||||
</view>
|
||||
<view class="tool-btn tool-btn--soft" :class="{ disabled: !hasSignature }" @tap="handleClear">
|
||||
<text class="ri-delete-bin-line"></text>
|
||||
<text>{{ t('rewrite') }}</text>
|
||||
<text>{{ $tr('重写') }}</text>
|
||||
</view>
|
||||
<view class="tool-btn tool-btn--ghost" @tap="handleRequestClose">
|
||||
<text class="ri-close-line"></text>
|
||||
<text>{{ t('close') }}</text>
|
||||
<text>{{ $tr('关闭') }}</text>
|
||||
</view>
|
||||
<view class="tool-btn tool-btn--primary" :class="{ disabled: !hasSignature }" @tap="handleSave">
|
||||
<text class="ri-check-line-circle"></text>
|
||||
{{ t('confirmSignature') }}
|
||||
{{ $tr('确认签名') }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="!isLandscape" class="contract-sign-dialog__footer-tip">
|
||||
<text class="ri-shield-check-line-fill"></text>
|
||||
<text>{{ t('footerTip') }}</text>
|
||||
<text>{{ $tr('签名前请确认您已完整阅读合同内容') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
@@ -84,13 +84,13 @@
|
||||
>
|
||||
<view class="contract-sign-dialog__confirm-mask"></view>
|
||||
<view class="contract-sign-dialog__confirm-card">
|
||||
<view class="contract-sign-dialog__confirm-title">{{ t('closeBoardTitle') }}</view>
|
||||
<view class="contract-sign-dialog__confirm-title">{{ $tr('关闭提示') }}</view>
|
||||
<view class="contract-sign-dialog__confirm-desc">
|
||||
{{ t('closeBoardDesc') }}
|
||||
{{ $tr('您还未完成签名,确认要关闭吗?') }}
|
||||
</view>
|
||||
<view class="contract-sign-dialog__confirm-actions">
|
||||
<view class="contract-sign-dialog__confirm-btn is-cancel" @tap="cancelRequestClose">{{ t('continueSigning') }}</view>
|
||||
<view class="contract-sign-dialog__confirm-btn is-confirm" @tap="confirmRequestClose">{{ t('continueClosing') }}</view>
|
||||
<view class="contract-sign-dialog__confirm-btn is-cancel" @tap="cancelRequestClose">{{ $tr('继续签名') }}</view>
|
||||
<view class="contract-sign-dialog__confirm-btn is-confirm" @tap="confirmRequestClose">{{ $tr('确认关闭') }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -116,46 +116,6 @@ export default {
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
i18n: {
|
||||
zh: {
|
||||
undo: '撤销',
|
||||
rewrite: '重写',
|
||||
close: '关闭',
|
||||
confirmSignature: '确认签名',
|
||||
footerTip: '签名前请确认您已完整阅读合同内容',
|
||||
closeBoardTitle: '关闭提示',
|
||||
closeBoardDesc: '您还未完成签名,确认要关闭吗?',
|
||||
continueSigning: '继续签名',
|
||||
continueClosing: '确认关闭',
|
||||
missingSignerName: '签名人缺失',
|
||||
writingHintZh: '请在此处手写中文正楷签名',
|
||||
writingHintEn: 'Please write your signature here',
|
||||
signerNameMissingToast: '签名人信息缺失',
|
||||
signatureRequiredToast: '请先完成签名',
|
||||
boundsFailedToast: '获取签名范围失败',
|
||||
signatureTooSmallToast: '签名范围太小,请重新签名',
|
||||
exportFailedToast: '导出签名失败,请重试'
|
||||
},
|
||||
en: {
|
||||
undo: 'Undo',
|
||||
rewrite: 'Rewrite',
|
||||
close: 'Close',
|
||||
confirmSignature: 'Confirm',
|
||||
footerTip: 'Please confirm that you have fully read the contract before signing',
|
||||
closeBoardTitle: 'Notice',
|
||||
closeBoardDesc: 'You have not finished signing. Are you sure to close?',
|
||||
continueSigning: 'Continue Signing',
|
||||
continueClosing: 'Close',
|
||||
missingSignerName: 'Missing Signer',
|
||||
writingHintZh: 'Please write your Chinese signature here',
|
||||
writingHintEn: 'Please write your signature here',
|
||||
signerNameMissingToast: 'Missing signer name',
|
||||
signatureRequiredToast: 'Please sign first',
|
||||
boundsFailedToast: 'Failed to get signature bounds',
|
||||
signatureTooSmallToast: 'Signature is too small, please try again',
|
||||
exportFailedToast: 'Failed to export signature, please try again'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
canvasId: 'contract-sign-canvas',
|
||||
@@ -179,7 +139,7 @@ export default {
|
||||
},
|
||||
displaySignerName() {
|
||||
const name = String(this.signerName || '').trim()
|
||||
return name || this.t('missingSignerName')
|
||||
return name || this.$tr('签名人缺失')
|
||||
},
|
||||
hasSignerName() {
|
||||
return !!String(this.signerName || '').trim()
|
||||
@@ -199,7 +159,7 @@ export default {
|
||||
return this.strokes.length > 0
|
||||
},
|
||||
writingHint() {
|
||||
return this.isChineseName ? this.t('writingHintZh') : this.t('writingHintEn')
|
||||
return this.isChineseName ? this.$tr('请在此处手写中文正楷签名') : this.$tr('Please write your signature here')
|
||||
},
|
||||
guideFontSize() {
|
||||
const length = this.displaySignerName.length
|
||||
@@ -281,9 +241,6 @@ export default {
|
||||
this.ctx = null
|
||||
},
|
||||
methods: {
|
||||
t(key) {
|
||||
return this.$translate(this.$options.i18n, key)
|
||||
},
|
||||
clearSignatureContent() {
|
||||
this.strokes = []
|
||||
this.currentStroke = []
|
||||
@@ -561,14 +518,14 @@ export default {
|
||||
handleSave() {
|
||||
if (!this.hasSignerName) {
|
||||
uni.showToast({
|
||||
title: this.t('signerNameMissingToast'),
|
||||
title: this.$tr('签名人信息缺失'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!this.hasSignature) {
|
||||
uni.showToast({
|
||||
title: this.t('signatureRequiredToast'),
|
||||
title: this.$tr('请先完成签名'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
@@ -576,14 +533,14 @@ export default {
|
||||
const cropRect = this.getSignatureBounds()
|
||||
if (!cropRect) {
|
||||
uni.showToast({
|
||||
title: this.t('boundsFailedToast'),
|
||||
title: this.$tr('获取签名范围失败'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!this.isSignatureQualified(cropRect)) {
|
||||
uni.showToast({
|
||||
title: this.t('signatureTooSmallToast'),
|
||||
title: this.$tr('签名范围太小,请重新签名'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
@@ -601,7 +558,7 @@ export default {
|
||||
.catch(error => {
|
||||
console.error('导出签名图片失败', error)
|
||||
uni.showToast({
|
||||
title: this.t('exportFailedToast'),
|
||||
title: this.$tr('导出签名失败,请重试'),
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -36,9 +36,9 @@ export default {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
title: this.t('pendingTitle'),
|
||||
desc: this.t('pendingDesc', { count: this.pendingContracts.length }),
|
||||
actionText: this.t('actionText')
|
||||
title: this.$tr('待签合同提醒'),
|
||||
desc: this.$tr('您有 {count} 份合同待签署', { count: this.pendingContracts.length }),
|
||||
actionText: this.$tr('去签署')
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -59,9 +59,6 @@ export default {
|
||||
this.clearCollapseTimer()
|
||||
},
|
||||
methods: {
|
||||
t(key, params) {
|
||||
return this.$translate(this.i18n, key, params)
|
||||
},
|
||||
clearCollapseTimer() {
|
||||
if (this.collapseTimer) {
|
||||
clearTimeout(this.collapseTimer)
|
||||
|
||||
Reference in New Issue
Block a user