Yansen 1 year ago
parent
commit
0f057eada2
5 changed files with 131 additions and 6 deletions
  1. 8
    1
      astro.config.mjs
  2. 3
    0
      src/components/NavMenu/index.jsx
  3. 113
    0
      src/content/zh/menu.json
  4. 5
    3
      src/middleware.js
  5. 2
    2
      src/pages/index.astro

+ 8
- 1
astro.config.mjs View File

@@ -22,5 +22,12 @@ export default defineConfig({
22 22
   //     }
23 23
   //   },
24 24
   // },
25
-  integrations: [react(), sitemap()]
25
+  integrations: [react(), sitemap()],
26
+  i18n: {
27
+    defaultLocale: 'zh',
28
+    locales: ['zh'],
29
+    routing: {
30
+      prefixDefaultLocale: true
31
+    }
32
+  },
26 33
 });

+ 3
- 0
src/components/NavMenu/index.jsx View File

@@ -1,10 +1,13 @@
1 1
 import React, { Fragment, useEffect, useRef } from 'react';
2
+import * as Astro from 'astro';
2 3
 import menus from '@/data/menu'
3 4
 import SubMenu from './SubMenu';
4 5
 import './style.less';
5 6
 
6 7
 export default function NavMenu (props) {
7 8
 
9
+  console.log('-------currentLocale------', Astro.currentLocale);
10
+
8 11
   const { lang } = props;
9 12
   const pathPrefix = `/${lang}`;
10 13
 

+ 113
- 0
src/content/zh/menu.json View File

@@ -0,0 +1,113 @@
1
+[
2
+  {
3
+    "path": "/",
4
+    "name": "首页"
5
+  },
6
+  {
7
+    "path": "/products-solutions",
8
+    "name": "产品与解决方案",
9
+    "children": [
10
+      {
11
+        "path": "/products-solutions/lot",
12
+        "name": "智慧物联",
13
+        "children": [
14
+          {
15
+            "path": "/products-solutions/lot/building",
16
+            "name": "智慧楼宇"
17
+          },
18
+          {
19
+            "path": "/products-solutions/lot/agriculture",
20
+            "name": "智慧农业"
21
+          },
22
+          {
23
+            "path": "/products-solutions/lot/community",
24
+            "name": "智慧社区"
25
+          },
26
+          {
27
+            "path": "/products-solutions/lot/exhibition-all",
28
+            "name": "智慧展馆"
29
+          }
30
+        ]
31
+      },
32
+      {
33
+        "path": "/products-solutions/industrial-internet",
34
+        "name": "工业互联网",
35
+        "children": [
36
+          {
37
+            "path": "/products-solutions/industrial-internet/mes",
38
+            "name": "云致MES"
39
+          },
40
+          {
41
+            "path": "/products-solutions/industrial-internet/erp",
42
+            "name": "ERP"
43
+          }
44
+        ]
45
+      },
46
+      {
47
+        "path": "/product/gov-ent-health",
48
+        "name": "政企医疗",
49
+        "levelDeep": 3,
50
+        "children": [
51
+          {
52
+            "path": "/products-solutions/gov-ent-health/gov",
53
+            "name": "政务服务",
54
+            "children": [
55
+              {
56
+                "path": "/products-solutions/gov-ent-health/gov/civilized-city",
57
+                "name": "文明创城"
58
+              }
59
+            ]
60
+          },
61
+          {
62
+            "path": "/products-solutions/gov-ent-health/bank",
63
+            "name": "银行业务",
64
+            "children": [
65
+              {
66
+                "path": "/products-solutions/gov-ent-health/bank/custom",
67
+                "name": "定制开发"
68
+              }
69
+            ]
70
+          },
71
+          {
72
+            "path": "/products-solutions/gov-ent-health/healthcare",
73
+            "name": "医院医疗"
74
+          }
75
+        ]
76
+      },
77
+      {
78
+        "path": "/product/others",
79
+        "name": "其他业务",
80
+        "children": [
81
+          {
82
+            "path": "/products-solutions/others/eshop",
83
+            "name": "电商系统"
84
+          },
85
+          {
86
+            "path": "/products-solutions/others/shigongli",
87
+            "name": "旅游住宿"
88
+          },
89
+          {
90
+            "path": "/products-solutions/others/house",
91
+            "name": "房源交易"
92
+          },
93
+          {
94
+            "path": "/products-solutions/others/crm",
95
+            "name": "CRM管理"
96
+          }
97
+        ]
98
+      }
99
+    ]
100
+  },
101
+  {
102
+    "path": "/news",
103
+    "name": "最新资讯"
104
+  },
105
+  {
106
+    "path": "/about",
107
+    "name": "关于云致"
108
+  },
109
+  {
110
+    "path": "/concat-us",
111
+    "name": "联系我们"
112
+  }
113
+]

+ 5
- 3
src/middleware.js View File

@@ -1,10 +1,12 @@
1 1
 // import { sequence } from "astro:middleware";
2
-// import { getCategary } from "./services/apis";
3
-
2
+// // import { getCategary } from "./services/apis";
3
+// import menus from './data/menu';
4 4
 
5 5
 // async function getGloalData(context, next) {
6
-//   const menus = await getCategary();
6
+//   // const menus = await getCategary();
7 7
 //   context.locals._menus = menus;
8
+
9
+//   context.data = { ...(context.data || {}), menus };
8 10
   
9 11
 //   return next();
10 12
 // }

+ 2
- 2
src/pages/index.astro View File

@@ -10,7 +10,7 @@ import Layout from '@/layouts/Layout.astro'
10 10
   </div>
11 11
 </Layout>
12 12
 
13
-<script>
13
+<!-- <script>
14 14
   let lang = window.localStorage.getItem('lang')
15 15
   if (!lang) {
16 16
     lang = window.navigator.language.toLocaleLowerCase().includes('zh')
@@ -20,4 +20,4 @@ import Layout from '@/layouts/Layout.astro'
20 20
   }
21 21
 
22 22
   window.location.replace(`${window.location.origin}/${lang}/`)
23
-</script>
23
+</script> -->