更新文档结构并补充Sharp图片处理说明
This commit is contained in:
@@ -31,13 +31,29 @@ pnpm astro <command> # Run any astro command directly
|
||||
|
||||
```
|
||||
src/
|
||||
├── layouts/Layout.astro # Main layout with navigation
|
||||
├── layouts/Layout.astro # Main layout with desktop/mobile navigation
|
||||
├── pages/ # Route pages (use .astro files)
|
||||
│ ├── index.astro # Home page
|
||||
│ └── [route]/index.astro
|
||||
│ ├── qazk/index.astro # Product center - industrial safety
|
||||
│ ├── elderly/index.astro # Product center - smart elderly care
|
||||
│ ├── construction/index.astro # Product center - smart construction
|
||||
│ ├── education/index.astro # Product center - smart campus
|
||||
│ ├── kitchen/index.astro # Product center - smart kitchen
|
||||
│ ├── customization/index.astro
|
||||
│ ├── partnership/index.astro
|
||||
│ └── intro/*/index.astro # Intro/detail pages
|
||||
├── components/
|
||||
│ └── sections/ # Reusable section components
|
||||
│ └── sections/ # Reusable section components
|
||||
└── styles/styles.css # Global styles
|
||||
|
||||
public/
|
||||
├── img/
|
||||
│ ├── elderly/ # Smart elderly care page assets (webp preferred)
|
||||
│ ├── construction/ # Smart construction page assets (webp preferred)
|
||||
│ ├── education/ # Smart campus page assets (webp + svg)
|
||||
│ ├── kitchen/ # Smart kitchen page assets (webp)
|
||||
│ └── ...
|
||||
└── js/script.js
|
||||
```
|
||||
|
||||
## Code Style Guidelines
|
||||
@@ -89,7 +105,8 @@ const { title, activeNav = 'home' } = Astro.props;
|
||||
### Layout Pattern
|
||||
|
||||
- All pages use `<Layout>` component with `activeNav` prop for navigation highlighting
|
||||
- Navigation items defined in Layout.astro: home, qazk, customization, partnership
|
||||
- Product center uses dropdown/submenu in `Layout.astro`
|
||||
- Current product nav IDs: `qazk`, `elderly`, `construction`, `kitchen`, `education`
|
||||
- Main content wrapped in `<main>` tag
|
||||
|
||||
```astro
|
||||
@@ -128,6 +145,16 @@ const { title, activeNav = 'home' } = Astro.props;
|
||||
- Reference with absolute paths: `/img/image.webp`
|
||||
- Use responsive sizing classes: `w-full h-full object-cover`
|
||||
|
||||
#### Image optimization with Sharp
|
||||
|
||||
- Use Sharp for converting newly added PNG/JPG/JPEG assets to WebP before commit.
|
||||
- Keep original design/source assets outside `public/` when possible; only optimized assets should be used by the website.
|
||||
- Example (single folder conversion):
|
||||
|
||||
```bash
|
||||
node --input-type=module -e "import sharp from 'sharp'; import { promises as fs } from 'node:fs'; import path from 'node:path'; const dir='public/img/kitchen'; const files=await fs.readdir(dir); for (const name of files){ const ext=path.extname(name).toLowerCase(); if(!['.png','.jpg','.jpeg'].includes(ext)) continue; const src=path.join(dir,name); const out=path.join(dir,path.basename(name,ext)+'.webp'); await sharp(src).webp({quality:82,effort:6}).toFile(out);}"
|
||||
```
|
||||
|
||||
### Color Usage
|
||||
|
||||
- Primary actions: `bg-primary` (#165DFF)
|
||||
|
||||
Reference in New Issue
Block a user