Browse Source

feat: 完善多语言

Jack Zhou 1 week ago
parent
commit
15b82c49c4
2 changed files with 6 additions and 9 deletions
  1. 5 3
      src/utils/table.ts
  2. 1 6
      src/views/Booking/src/BookingView.vue

+ 5 - 3
src/utils/table.ts

@@ -16,13 +16,15 @@ export const autoWidth = (tableData: VxeGridProps, grid: VxeGridInstance, custom
     let curStr = ''
     let width = 0
     const field = column.field
+    const language = localStorage.getItem('lang') || 'English'
+    const isChinese = language === 'Chinese (Simplified)' || language === 'Chinese (Traditional)'
     // 判断表头的宽度
     if (column.title.length < 12) {
-      width = column.title.length * 11 + 40
+      width = column.title.length * (isChinese ? 14 : 11) + 40
     } else if (column.title.length < 20) {
-      width = column.title.length * 10 + 30
+      width = column.title.length * (isChinese ? 13 : 10) + 30
     } else {
-      width = column.title.length * 7 + 40
+      width = column.title.length * (isChinese ? 10 : 7) + 40
     }
     const curData = data.length > 1000 ? data.slice(0, 1000) : data
     // 判断表格内容的宽度

+ 1 - 6
src/views/Booking/src/BookingView.vue

@@ -116,12 +116,7 @@ const getBookingData = () => {
       if (res.code === 200) {
         transportListItem.value = res.data.TransportList
 
-        tabList.value = res.data.tagsList.map((item) => {
-          return {
-            ...item,
-            name: t(`booking.${item.name}`)
-          }
-        })
+        tabList.value = res.data.tagsList
         const checkedTabNames = tabList.value
           .filter((item) => item.checked)
           .map((item) => item.name)