Yansen 1 year ago
parent
commit
12f1e193ba

+ 4
- 2
src/components/MediaCard/MediaCard1.astro View File

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

+ 1
- 6
src/components/NavMenu/index.jsx View File

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

+ 10
- 0
src/components/NavMenu/main.astro View File

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 View File

1
 ---
1
 ---
2
 import Request from '@/components/Request.astro'
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
 <!doctype html>
8
 <!doctype html>
88
     </style>
90
     </style>
89
   </head>
91
   </head>
90
   <body>
92
   <body>
93
+    { !!menu && <NavMenu /> }
91
     <!-- <Request client:load /> -->
94
     <!-- <Request client:load /> -->
92
     <slot />
95
     <slot />
93
   </body>
96
   </body>

+ 0
- 3
src/pages/[lang]/index.astro View File

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