菲鸽 2 anni fa
parent
commit
7e2cda4886
3 ha cambiato i file con 18 aggiunte e 9 eliminazioni
  1. 5 3
      src/pages/index/index.vue
  2. 0 6
      src/utils/http.ts
  3. 13 0
      src/utils/index.ts

+ 5 - 3
src/pages/index/index.vue

@@ -12,10 +12,10 @@
     class="bg-white h-full overflow-hidden pt-2 px-4"
     :style="{ marginTop: safeAreaInsets?.top + 'px' }"
   >
+    <view>{{ $t('app.name') }}</view>
     <view class="mt-12">
       <image src="/static/logo.svg" alt="" class="w-40 h-40 block mx-auto" />
     </view>
-    <view>{{ $t('app.name') }}</view>
     <view class="text-center text-4xl main-title-color mt-8">unibest</view>
     <view class="text-center text-2xl mt-2 mb-8">最好用的 uniapp 开发模板</view>
     <view class="text-justify max-w-100 m-auto">
@@ -38,9 +38,11 @@
 </template>
 
 <script lang="ts" setup>
-// 获取屏幕边界到安全区域距离
-import '@/utils/http'
+import { testI18n } from '@/utils/index'
 
+testI18n()
+
+// 获取屏幕边界到安全区域距离
 const { safeAreaInsets } = uni.getSystemInfoSync()
 
 const author = ref('菲鸽')

+ 0 - 6
src/utils/http.ts

@@ -1,7 +1,6 @@
 /* eslint-disable no-param-reassign */
 import { useUserStore } from '@/store'
 import { UserInfo } from '@/typings'
-import { translate as t } from '@/locales/index'
 
 type Data<T> = {
   code: number
@@ -9,11 +8,6 @@ type Data<T> = {
   result: T
 }
 
-uni.showModal({
-  title: '菲鸽',
-  content: t('app.name'),
-})
-
 // 请求基地址
 const baseURL = import.meta.env.VITE_SERVER_BASEURL
 // console.log(import.meta.env)

+ 13 - 0
src/utils/index.ts

@@ -0,0 +1,13 @@
+import { translate as t } from '@/locales/index'
+
+/**
+ * test i18n in not .vue file
+ */
+export const testI18n = () => {
+  console.log(t('app.name'))
+  // 下面同样生效
+  // uni.showModal({
+  //   title: 'i18n 测试',
+  //   content: t('app.name'),
+  // })
+}