From 12898f6228673bc9a827c3272b6136537d43a597 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Thu, 6 Apr 2023 04:54:10 -0400 Subject: [PATCH] Implement loading dumped data for the handbook --- src/handbook/.gitignore | 3 +++ src/handbook/data/README.md | 7 +++++++ src/handbook/package.json | 1 + src/handbook/src/backend/data.ts | 5 +++++ src/handbook/src/backend/{icons.d.ts => files.d.ts} | 5 +++++ src/handbook/tsconfig.json | 3 ++- src/handbook/vite.config.ts | 4 +++- 7 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/handbook/data/README.md create mode 100644 src/handbook/src/backend/data.ts rename src/handbook/src/backend/{icons.d.ts => files.d.ts} (59%) diff --git a/src/handbook/.gitignore b/src/handbook/.gitignore index a547bf36d..c74de08b8 100644 --- a/src/handbook/.gitignore +++ b/src/handbook/.gitignore @@ -22,3 +22,6 @@ dist-ssr *.njsproj *.sln *.sw? + +# Handbook data +data/ diff --git a/src/handbook/data/README.md b/src/handbook/data/README.md new file mode 100644 index 000000000..5935b04b9 --- /dev/null +++ b/src/handbook/data/README.md @@ -0,0 +1,7 @@ +# Handbook Data +Use Grasscutter's dumpers to generate the data to put here. + +## Files Required +- `avatars.json` +- `commands.json` +- `items.csv` diff --git a/src/handbook/package.json b/src/handbook/package.json index dd44a0801..15252f733 100644 --- a/src/handbook/package.json +++ b/src/handbook/package.json @@ -28,6 +28,7 @@ "vite-tsconfig-paths": "^4.0.7", "vite-plugin-singlefile": "^0.13.5", "@vitejs/plugin-react-swc": "^3.0.0", + "@rollup/plugin-dsv": "^3.0.2", "sass": "^1.58.3", "cssnano": "^5.1.15", diff --git a/src/handbook/src/backend/data.ts b/src/handbook/src/backend/data.ts new file mode 100644 index 000000000..e0526d0e6 --- /dev/null +++ b/src/handbook/src/backend/data.ts @@ -0,0 +1,5 @@ +import avatars from "@data/avatars.json"; +import commands from "@data/commands.json"; +import items from "@data/items.csv"; + +console.log(avatars, commands, items); diff --git a/src/handbook/src/backend/icons.d.ts b/src/handbook/src/backend/files.d.ts similarity index 59% rename from src/handbook/src/backend/icons.d.ts rename to src/handbook/src/backend/files.d.ts index fb004d0d2..205989139 100644 --- a/src/handbook/src/backend/icons.d.ts +++ b/src/handbook/src/backend/files.d.ts @@ -1,3 +1,8 @@ declare module "*.svg" { export const ReactComponent: React.FunctionComponent>; } + +declare module "*.csv" { + const content: any[]; + export default content; +} diff --git a/src/handbook/tsconfig.json b/src/handbook/tsconfig.json index cc3f783f9..cd1b0613f 100644 --- a/src/handbook/tsconfig.json +++ b/src/handbook/tsconfig.json @@ -24,7 +24,8 @@ "@components/*": ["src/ui/*"], "@icons/*": ["src/icons/*"], "@views/*": ["src/ui/views/*"], - "@pages/*": ["src/ui/pages/*"] + "@pages/*": ["src/ui/pages/*"], + "@data/*": ["data/*"] } }, "include": ["src"], diff --git a/src/handbook/vite.config.ts b/src/handbook/vite.config.ts index 0059d4eca..82184b601 100644 --- a/src/handbook/vite.config.ts +++ b/src/handbook/vite.config.ts @@ -5,6 +5,7 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import tsconfigPaths from "vite-tsconfig-paths"; +import dsv from "@rollup/plugin-dsv"; import viteSvgr from "vite-plugin-svgr"; import { viteSingleFile } from "vite-plugin-singlefile"; @@ -12,6 +13,7 @@ import postcss from "./cfg/postcss.config.js"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [ react(), tsconfigPaths(), viteSvgr(), viteSingleFile() ], + plugins: [ react(), tsconfigPaths(), dsv(), + viteSvgr(), viteSingleFile() ], css: { postcss } });