Commit 4a17ae4e65e14dd8134f1cd1b3dc52076dff4d74

Authored by sanmu
1 parent bb673e6b

up

package.json
... ... @@ -21,6 +21,7 @@
21 21 "tailwindcss": "^3.3.2",
22 22 "vite-plugin-vuetify": "^1.0.2",
23 23 "vue": "^3.3.2",
  24 + "vue-i18n": "^9.2.2",
24 25 "vue-router": "^4.2.0",
25 26 "vuetify": "^3.3.1"
26 27 },
... ...
src/components/HomeCategoryList.vue
1 1 <template>
2 2 <v-container class="">
3   - <div class="text-blue-darken-2 text-h3 tw-text-center tw-mb-16">{{ title }}</div>
  3 + <div class="text-blue-darken-2 text-h3 tw-text-center tw-mb-8">{{ title }}</div>
  4 + <div class="text-body-1 tw-text-left tw-mb-8">{{ desc }}</div>
4 5 <v-item-group multiple>
5 6 <v-row>
6   - <v-col v-for="(item, index) in list" :key="index" cols="12" lg="3" md="4" sm="6">
  7 + <v-col
  8 + v-for="(item, index) in list"
  9 + :key="index"
  10 + cols="3"
  11 + :lg="lgCol"
  12 + md="4"
  13 + sm="6"
  14 + xs="12"
  15 + >
7 16 <v-hover v-slot="{ isHovering, props }" open-delay="200">
8 17 <v-card
9 18 :elevation="isHovering ? 16 : 2"
... ... @@ -28,10 +37,14 @@
28 37  
29 38 <script setup lang="ts">
30 39 import type { Category } from '@/type'
31   -import { onMounted, ref } from 'vue'
  40 +import { computed, ref } from 'vue'
32 41  
33   -defineProps<{
  42 +const props = defineProps<{
34 43 title: string
35   - list: Category[]
  44 + desc?: string
  45 + list: Category[] | { name: string }[]
  46 + cardNum?: number
36 47 }>()
  48 +
  49 +const lgCol = computed(() => (props.cardNum === 3 ? 4 : 3))
37 50 </script>
... ...
src/main.ts
... ... @@ -8,9 +8,11 @@ import &#39;@mdi/font/css/materialdesignicons.css&#39; // Ensure you are using css-loade
8 8  
9 9 import { createApp } from 'vue'
10 10 import { createPinia } from 'pinia'
  11 +import { createI18n } from 'vue-i18n'
11 12  
12 13 import App from './App.vue'
13 14 import router from './router'
  15 +import messages from './message'
14 16  
15 17 const app = createApp(App)
16 18  
... ... @@ -21,4 +23,16 @@ app.use(router)
21 23  
22 24 app.use(vuetify)
23 25  
  26 +const i18n = createI18n({
  27 + legacy: false,
  28 + allowComposition: true,
  29 + locale: 'en', // set locale
  30 + // fallbackLocale: 'en', // set fallback locale
  31 + messages, // set locale messages
  32 + globalInjection: true
  33 +})
  34 +
  35 +app.use(i18n)
  36 +console.log('%c [ messages ]-32', 'font-size:13px; background:pink; color:#bf2c9f;', messages)
  37 +
24 38 app.mount('#app')
... ...
src/message.ts 0 → 100644
  1 +const messages = {
  2 + cn: {
  3 + // 优势: 'Strengths',
  4 + hello: 'sssss'
  5 + },
  6 + en: {
  7 + 优势: 'Strengths',
  8 + 材料试剂: 'Material Reagents',
  9 + 优势1: 'Energy materials',
  10 + 优势2: 'Universal consumables',
  11 + 优势3: 'low-dimensional materials',
  12 + 设备: 'Lab Device'
  13 + // 优势1: ''
  14 + // hello: 'sssss'
  15 + }
  16 +}
  17 +const materials = [{ name: '能源材料' }, { name: '实验耗材' }, { name: '低维材料' }]
  18 +export default messages
... ...
src/service.ts
... ... @@ -2,6 +2,8 @@ import axios from &#39;axios&#39;
2 2 import type { ProductListQuery } from './type'
3 3  
4 4 export const getCategoryList = () => {
  5 + // http://39.108.227.113:3000/mock/11/shop/product/category
  6 + // return axios.post('/mock/11/shop/product/category', {})
5 7 return axios.post('/shop/product/category', {})
6 8 }
7 9  
... ...
src/views/Home.vue
... ... @@ -5,8 +5,57 @@
5 5 <v-carousel-item src="/banner2.jpeg" cover> </v-carousel-item>
6 6 <v-carousel-item src="/banner3.jpeg" cover> </v-carousel-item>
7 7 </v-carousel>
8   - <div v-for="item in store.list" :key="item.categoryDisplayName" class="tw-mb-[64px]">
9   - <HomeProductList :title="item.categoryDisplayName" :list="item.list" />
  8 + <!-- 优势 -->
  9 + <div class="tw-mb-[64px]">
  10 + <HomeProductList
  11 + :cardNum="3"
  12 + :title="t('优势')"
  13 + :list="strengths"
  14 + desc="Canrd is aimed to be the world's top one-stop service provider in the field of new energy research Dedicated, professional, and quick response/solution"
  15 + />
  16 + </div>
  17 + <!-- 能源材料 -->
  18 + <div class="tw-mb-[64px]">
  19 + <HomeProductList
  20 + :cardNum="3"
  21 + :title="t('材料试剂')"
  22 + :list="materials"
  23 + desc="Leading global provider of energy storage research materials and providing other professional/universal experimental materials"
  24 + />
  25 + </div>
  26 + <!-- 设备 -->
  27 + <div class="tw-mb-[64px]">
  28 + <HomeProductList
  29 + :title="t(store.list[3].categoryDisplayName)"
  30 + :list="store.list[3].list"
  31 + desc="Leading global provider of energy storage research materials and providing other professional/universal experimental materials
  32 +"
  33 + />
  34 + </div>
  35 + <!-- Customized Battery -->
  36 + <div class="tw-mb-[64px]">
  37 + <HomeProductList
  38 + :title="t('Customized Battery')"
  39 + :list="batteries"
  40 + desc="200mAh~10Ah, winding/laminating, non liquid filled cell/liquid filled cell/three electrode, etc"
  41 + />
  42 + </div>
  43 + <!-- Testing -->
  44 + <div class="tw-mb-[64px]">
  45 + <HomeProductList
  46 + :title="t('Testing')"
  47 + :list="tests"
  48 + desc="Self built testing center and signed strategic cooperation with ATL, Tsinghua and other units"
  49 + />
  50 + </div>
  51 + <!-- Pack -->
  52 + <div class="tw-mb-[64px]">
  53 + <HomeProductList
  54 + :cardNum="3"
  55 + :title="t('Pack')"
  56 + :list="packs"
  57 + desc="200mAh~10Ah, winding/laminating, non liquid filled cell/liquid filled cell/three electrode, etc"
  58 + />
10 59 </div>
11 60 </v-container>
12 61 </template>
... ... @@ -14,8 +63,32 @@
14 63 <script setup lang="ts">
15 64 import HomeProductList from '@/components/HomeCategoryList.vue'
16 65 import { useCategoryStore } from '@/stores/category'
  66 +import { useI18n } from 'vue-i18n'
  67 +import { computed } from 'vue'
  68 +
  69 +const { t } = useI18n()
17 70  
18 71 const store = useCategoryStore()
  72 +
  73 +const strengths = [{ name: t('优势1') }, { name: t('优势2') }, { name: t('优势3') }]
  74 +const materials = [{ name: '能源材料' }, { name: '实验耗材' }, { name: '低维材料' }]
  75 +const tests = [
  76 + { name: 'Electrochemical performance' },
  77 + { name: 'Reliability testing' },
  78 + { name: 'Material testing' },
  79 + { name: 'Calibration' }
  80 +]
  81 +const batteries = [
  82 + { name: 'Material evaluation' },
  83 + { name: 'R&D foundry' },
  84 + { name: 'Chemical system' },
  85 + { name: 'Semi product customization' }
  86 +]
  87 +const packs = [
  88 + { name: 'Power bank' },
  89 + { name: 'Energy storage' },
  90 + { name: 'low-dimensional materials' }
  91 +]
19 92 </script>
20 93  
21 94 <style lang="scss" scoped>
... ...
vite.config.ts
... ... @@ -18,6 +18,9 @@ export default defineConfig({
18 18 proxy: {
19 19 '/shop': {
20 20 target: 'http://39.108.227.113:8002'
  21 + },
  22 + '/mock': {
  23 + target: 'http://39.108.227.113:3000'
21 24 }
22 25 }
23 26 }
... ...
yarn.lock
... ... @@ -441,6 +441,44 @@
441 441 resolved "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
442 442 integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
443 443  
  444 +"@intlify/core-base@9.2.2":
  445 + version "9.2.2"
  446 + resolved "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.2.2.tgz#5353369b05cc9fe35cab95fe20afeb8a4481f939"
  447 + integrity sha512-JjUpQtNfn+joMbrXvpR4hTF8iJQ2sEFzzK3KIESOx+f+uwIjgw20igOyaIdhfsVVBCds8ZM64MoeNSx+PHQMkA==
  448 + dependencies:
  449 + "@intlify/devtools-if" "9.2.2"
  450 + "@intlify/message-compiler" "9.2.2"
  451 + "@intlify/shared" "9.2.2"
  452 + "@intlify/vue-devtools" "9.2.2"
  453 +
  454 +"@intlify/devtools-if@9.2.2":
  455 + version "9.2.2"
  456 + resolved "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.2.2.tgz#b13d9ac4b4e2fe6d2e7daa556517a8061fe8bd39"
  457 + integrity sha512-4ttr/FNO29w+kBbU7HZ/U0Lzuh2cRDhP8UlWOtV9ERcjHzuyXVZmjyleESK6eVP60tGC9QtQW9yZE+JeRhDHkg==
  458 + dependencies:
  459 + "@intlify/shared" "9.2.2"
  460 +
  461 +"@intlify/message-compiler@9.2.2":
  462 + version "9.2.2"
  463 + resolved "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.2.2.tgz#e42ab6939b8ae5b3d21faf6a44045667a18bba1c"
  464 + integrity sha512-IUrQW7byAKN2fMBe8z6sK6riG1pue95e5jfokn8hA5Q3Bqy4MBJ5lJAofUsawQJYHeoPJ7svMDyBaVJ4d0GTtA==
  465 + dependencies:
  466 + "@intlify/shared" "9.2.2"
  467 + source-map "0.6.1"
  468 +
  469 +"@intlify/shared@9.2.2":
  470 + version "9.2.2"
  471 + resolved "https://registry.npmjs.org/@intlify/shared/-/shared-9.2.2.tgz#5011be9ca2b4ab86f8660739286e2707f9abb4a5"
  472 + integrity sha512-wRwTpsslgZS5HNyM7uDQYZtxnbI12aGiBZURX3BTR9RFIKKRWpllTsgzHWvj3HKm3Y2Sh5LPC1r0PDCKEhVn9Q==
  473 +
  474 +"@intlify/vue-devtools@9.2.2":
  475 + version "9.2.2"
  476 + resolved "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.2.2.tgz#b95701556daf7ebb3a2d45aa3ae9e6415aed8317"
  477 + integrity sha512-+dUyqyCHWHb/UcvY1MlIpO87munedm3Gn6E9WWYdWrMuYLcoIoOEVDWSS8xSwtlPU+kA+MEQTP6Q1iI/ocusJg==
  478 + dependencies:
  479 + "@intlify/core-base" "9.2.2"
  480 + "@intlify/shared" "9.2.2"
  481 +
444 482 "@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2":
445 483 version "0.3.3"
446 484 resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098"
... ... @@ -813,7 +851,7 @@
813 851 "@vue/compiler-dom" "3.3.4"
814 852 "@vue/shared" "3.3.4"
815 853  
816   -"@vue/devtools-api@^6.5.0":
  854 +"@vue/devtools-api@^6.2.1", "@vue/devtools-api@^6.5.0":
817 855 version "6.5.0"
818 856 resolved "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.5.0.tgz#98b99425edee70b4c992692628fa1ea2c1e57d07"
819 857 integrity sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==
... ... @@ -3089,6 +3127,11 @@ slash@^3.0.0:
3089 3127 resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
3090 3128 integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
3091 3129  
  3130 +source-map@0.6.1:
  3131 + version "0.6.1"
  3132 + resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
  3133 + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
  3134 +
3092 3135 spdx-correct@^3.0.0:
3093 3136 version "3.2.0"
3094 3137 resolved "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz#4f5ab0668f0059e34f9c00dce331784a12de4e9c"
... ... @@ -3514,6 +3557,16 @@ vue-eslint-parser@^9.1.1, vue-eslint-parser@^9.3.0:
3514 3557 lodash "^4.17.21"
3515 3558 semver "^7.3.6"
3516 3559  
  3560 +vue-i18n@^9.2.2:
  3561 + version "9.2.2"
  3562 + resolved "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.2.2.tgz#aeb49d9424923c77e0d6441e3f21dafcecd0e666"
  3563 + integrity sha512-yswpwtj89rTBhegUAv9Mu37LNznyu3NpyLQmozF3i1hYOhwpG8RjcjIFIIfnu+2MDZJGSZPXaKWvnQA71Yv9TQ==
  3564 + dependencies:
  3565 + "@intlify/core-base" "9.2.2"
  3566 + "@intlify/shared" "9.2.2"
  3567 + "@intlify/vue-devtools" "9.2.2"
  3568 + "@vue/devtools-api" "^6.2.1"
  3569 +
3517 3570 vue-router@^4.2.0:
3518 3571 version "4.2.1"
3519 3572 resolved "https://registry.npmjs.org/vue-router/-/vue-router-4.2.1.tgz#f8ab85c89e74682cad71519480fdf2b855e8c9e0"
... ...