Yansen vor 1 Jahr
Ursprung
Commit
12f1e193ba

+ 4
- 2
src/components/MediaCard/MediaCard1.astro Datei anzeigen

@@ -11,8 +11,10 @@ const {
11 11
   title,
12 12
   subTitle,
13 13
   link = "javascript:;",
14
+  hoverBackColor = '#ddd',
14 15
   more = false,
15 16
 } = Astro.props;
17
+
16 18
 ---
17 19
 
18 20
 <Wrapper class={className} thumb={thumb} imgRatio={imgRatio}>
@@ -29,10 +31,10 @@ const {
29 31
   </div>
30 32
 </Wrapper>
31 33
 
32
-<style lang="less">
34
+<style lang="less" define:vars={{ backy9kovh: hoverBackColor }}>
33 35
 .card-body {
34 36
   &:hover {
35
-    background-color: #ddd;
37
+    background-color: var(--backy9kovh);
36 38
   }
37 39
   
38 40
   .title-link {

+ 1
- 6
src/components/NavMenu/index.jsx Datei anzeigen

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

+ 10
- 0
src/components/NavMenu/main.astro Datei anzeigen

@@ -0,0 +1,10 @@
1
+---
2
+import { getEntry } from 'astro:content';
3
+import NavMenu from "./index.jsx"
4
+
5
+const lang = Astro.currentLocale || 'zh';
6
+const menus = await getEntry(lang, 'menu');
7
+---
8
+
9
+<NavMenu lang={lang} menus={menus?.data} client:load />
10
+

+ 4
- 1
src/layouts/Layout.astro Datei anzeigen

@@ -1,6 +1,8 @@
1 1
 ---
2 2
 import Request from '@/components/Request.astro'
3
-const { title } = Astro.props
3
+import NavMenu from '@/components/NavMenu/main.astro'
4
+
5
+const { title, menu = true } = Astro.props
4 6
 ---
5 7
 
6 8
 <!doctype html>
@@ -88,6 +90,7 @@ const { title } = Astro.props
88 90
     </style>
89 91
   </head>
90 92
   <body>
93
+    { !!menu && <NavMenu /> }
91 94
     <!-- <Request client:load /> -->
92 95
     <slot />
93 96
   </body>

+ 0
- 3
src/pages/[lang]/index.astro Datei anzeigen

@@ -9,7 +9,6 @@ import Carousel from '@/components/children/Carousel.astro'
9 9
 import LeftRightCarousel from '@/components/LeftRightCarousel.astro'
10 10
 import VerticalNavigationContent from '@/components/VerticalNavigationContent.astro'
11 11
 import LeftImgRightText from '@/components/LeftImgRightText.astro'
12
-import NavMenu from '@/components/NavMenu/index.jsx'
13 12
 import FooterMenu from '@/components/NavMenu/FooterMenu.jsx'
14 13
 import menus from '@/data/menu'
15 14
 import pageData from '@/data/homepage'
@@ -191,8 +190,6 @@ const informationList = [
191 190
 ---
192 191
 
193 192
 <Layout title="官网">
194
-  <NavMenu lang={lang} client:load />
195
-
196 193
   <ImgPro
197 194
     titleHeight="2.5"
198 195
     contentLineHeight="1.5"