新增字典映射功能,支持有限枚举值转换;更新相关组件和文档以提升用户体验
This commit is contained in:
34
CLAUDE.md
34
CLAUDE.md
@@ -4,14 +4,15 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Project Overview
|
||||
|
||||
**excel2json** — a SvelteKit web application for converting Excel files to JSON. Built with Svelte 5, SvelteKit 2, TypeScript, and Tailwind CSS 4.
|
||||
**excel2json** — a SvelteKit web application for converting Excel files to JSON with visual mapping configuration. Built with Svelte 5, SvelteKit 2, TypeScript, and Tailwind CSS 4.
|
||||
|
||||
## Commands
|
||||
|
||||
- `npm run dev` — start dev server
|
||||
- `npm run dev` — start dev server (typically http://localhost:5173)
|
||||
- `npm run build` — production build
|
||||
- `npm run preview` — preview production build
|
||||
- `npm run check` — type-check with svelte-check
|
||||
- `npm run check:watch` — type-check in watch mode
|
||||
- `npm run test` — run all tests once
|
||||
- `npm run test:unit` — run tests in watch mode
|
||||
- `npm run test:unit -- --run --testNamePattern="pattern"` — run a single test by name
|
||||
@@ -22,10 +23,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
- **Styling**: Tailwind CSS 4 with `@tailwindcss/forms` and `@tailwindcss/typography` plugins, configured via `src/routes/layout.css`
|
||||
- **Adapter**: `@sveltejs/adapter-auto`
|
||||
- **TypeScript**: strict mode enabled
|
||||
- **Dependencies**: `xlsx` (SheetJS) for Excel parsing, `dayjs` for date handling
|
||||
|
||||
### Testing
|
||||
|
||||
Two Vitest project configurations in `vite.config.ts`:
|
||||
Two Vitest project configurations in `vitest.config.ts`:
|
||||
|
||||
- **`client`** — browser tests using Playwright (headless Chromium). Files matching `src/**/*.svelte.{test,spec}.{js,ts}`. Uses `vitest-browser-svelte` for component rendering.
|
||||
- **`server`** — Node.js unit tests. Files matching `src/**/*.{test,spec}.{js,ts}` (excluding `.svelte.` test files).
|
||||
@@ -38,6 +40,32 @@ All tests require assertions (`expect.requireAssertions: true`).
|
||||
- Shared library code goes in `src/lib/` (aliased as `$lib`)
|
||||
- Use Svelte 5 runes syntax, not legacy Svelte 4 patterns
|
||||
|
||||
### Core Application Structure
|
||||
|
||||
**Single-page application** with split-pane layout:
|
||||
|
||||
- `src/routes/+page.svelte` — Main page containing all application logic
|
||||
- `src/lib/components/ExcelTable.svelte` — Left panel showing Excel data with column configuration
|
||||
- `src/lib/components/JsonPreview.svelte` — Right panel showing JSON output with syntax highlighting
|
||||
- `src/lib/components/ColumnConfig.svelte` — Modal for column mapping configuration
|
||||
- `src/lib/components/ApiConfigModal.svelte` — API enrichment rules configuration
|
||||
- `src/lib/components/SubmissionSettings.svelte` — Data submission settings
|
||||
|
||||
**Core libraries:**
|
||||
|
||||
- `src/lib/excel.ts` — Excel/CSV reading and parsing
|
||||
- `src/lib/converter.ts` — Mapping conversion core logic
|
||||
- `src/lib/types.ts` — TypeScript type definitions (`MappingConfig`, `RowData`, etc.)
|
||||
|
||||
**Data flow:** File upload → Excel parsing → Mapping configuration → JSON conversion → Preview/Export
|
||||
|
||||
**Key features:**
|
||||
- Nested object support via dot notation (e.g., `user.address.city`)
|
||||
- Date formatting including Excel serial date compatibility
|
||||
- Empty value handling (exclude field or use default value)
|
||||
- Template import/export for mapping configurations
|
||||
- API enrichment for dynamic data fetching
|
||||
|
||||
## Svelte MCP Server
|
||||
|
||||
A Svelte MCP server is available for Svelte 5 / SvelteKit documentation lookup and code validation. When writing Svelte code:
|
||||
|
||||
Reference in New Issue
Block a user