diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..cc83a70 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "bradlc.vscode-tailwindcss", + "ms-vscode.vscode-typescript-next", + "esbenp.prettier-vscode", + "ms-vscode.vscode-eslint" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..635ffe5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "tailwindCSS.includeLanguages": { + "typescript": "html", + "typescriptreact": "html", + "javascript": "html", + "javascriptreact": "html" + }, + "tailwindCSS.experimental.classRegex": [ + ["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"], + ["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"], + ["cn\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"] + ], + "tailwindCSS.validate": true, + "tailwindCSS.lint.cssConflict": "warning", + "tailwindCSS.lint.invalidApply": "error", + "tailwindCSS.lint.invalidConfigPath": "error", + "tailwindCSS.lint.invalidScreen": "error", + "tailwindCSS.lint.invalidTailwindDirective": "error", + "tailwindCSS.lint.invalidVariant": "error", + "tailwindCSS.lint.recommendedVariantOrder": "warning", + "editor.quickSuggestions": { + "strings": true + }, + "css.validate": false, + "scss.validate": false +} diff --git a/src/api/layout/index.ts b/src/api/layout/index.ts index 591b046..d2c1437 100644 --- a/src/api/layout/index.ts +++ b/src/api/layout/index.ts @@ -6,7 +6,6 @@ import {MODULES_API_URL, SERVER_API_URL} from '@/config/setting'; import { Company } from '@/api/system/company/model'; import { CmsWebsite } from '@/api/cms/cmsWebsite/model'; import {Menu} from "@/api/system/menu/model"; -import {getLang} from "@/utils/common"; /** * 获取当前登录的用户信息、菜单、权限、角色 @@ -26,12 +25,7 @@ export async function getTenantInfo(): Promise { */ export async function getSiteInfo(): Promise { const res = await request.get>( - MODULES_API_URL + '/cms/cms-website/getSiteInfo', - { - params: { - lang: getLang() - } - } + MODULES_API_URL + '/cms/cms-website/getSiteInfo' ); if (res.data.code === 0 && res.data.data) { return res.data.data as unknown as CmsWebsite; diff --git a/src/components/layout/Header_bak.tsx b/src/components/layout/Header_bak.tsx new file mode 100644 index 0000000..e37f380 --- /dev/null +++ b/src/components/layout/Header_bak.tsx @@ -0,0 +1,165 @@ +'use client'; +import { useState, useEffect } from 'react'; +import Link from 'next/link'; +import { usePathname } from 'next/navigation'; +import {getSiteInfo} from "@/api/layout"; +import {CmsWebsite} from "@/api/cms/cmsWebsite/model"; + + +const Header = () => { + const [config, setConfig] = useState({}) + const [isMenuOpen, setIsMenuOpen] = useState(false); + const pathname = usePathname(); + + const navigation = [ + { name: '首页', href: '/' }, + { name: '产品', href: '/products' }, + { name: '解决方案', href: '/solutions' }, + { name: '案例', href: '/cases' }, + { name: '关于', href: '/about' }, + { name: '联系', href: '/contact' }, + ]; + + const isActive = (href: string) => { + if (href === '/') { + return pathname === '/'; + } + return pathname.startsWith(href); + }; + + const reload = () => { + getSiteInfo().then(data => { + console.log(data,'data') + if(data){ + setConfig(data); + } + }) + } + + useEffect(() => { + reload(); + }, []); + + return ( +
+
+
+ {/* Logo */} +
+ + = {config?.websiteName} = + +
+ + {/* Desktop Navigation */} + + + {/* Language Switch & CTA */} +
+
+ 中文 + | + EN +
+ + 免费咨询 + +
+ + {/* Mobile menu button */} +
+ +
+
+ + {/* Mobile Navigation */} + {isMenuOpen && ( +
+
+ {navigation.map((item) => ( + setIsMenuOpen(false)} + > + {item.name} + + ))} +
+ setIsMenuOpen(false)} + > + 免费咨询 + +
+
+
+ )} +
+
+ ); +}; + +export default Header; diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..7cf40ac --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,12 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [ + './src/pages/**/*.{js,ts,jsx,tsx,mdx}', + './src/components/**/*.{js,ts,jsx,tsx,mdx}', + './src/app/**/*.{js,ts,jsx,tsx,mdx}', + ], + theme: { + extend: {}, + }, + plugins: [], +}