zhaifanhua 1 год назад
Родитель
Сommit
03fb56e294
4 измененных файлов с 60 добавлено и 3 удалено
  1. 12 3
      Web/package.json
  2. 16 0
      Web/scripts/clean-dist.js
  3. 16 0
      Web/scripts/clean-lock.js
  4. 16 0
      Web/scripts/clean-modules.js

+ 12 - 3
Web/package.json

@@ -7,10 +7,19 @@
 	"author": "zuohuaijun",
 	"license": "MIT",
 	"scripts": {
-		"dev": "vite",
-		"build": "node --max-old-space-size=8192 ./node_modules/vite/bin/vite build",
+		"bootstrap": "pnpm install",
+		"dev": "vite dev",
+		"build": "vite build",
+		"preview": "vite preview",
+		"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,vue,css,scss,less,json,md}\"",
+		"update-pkg": "ncu -u",
+		"cache-verify": "npm cache verify",
+		"clean-lock": "node ./scripts/clean-lock.js",
+		"clean-modules": "node ./scripts/clean-modules.js",
+		"clean-dist": "node ./scripts/clean-dist.js",
+		"clean-node": "pnpm run clean-lock && pnpm run clean-modules && pnpm run clean-dist",
+		"reinstall": "pnpm run clean-node && pnpm run bootstrap",
 		"lint-fix": "eslint --fix src/",
-		"format": "prettier --write .",
 		"build-api": "cd api_build/ && build.bat"
 	},
 	"dependencies": {

+ 16 - 0
Web/scripts/clean-dist.js

@@ -0,0 +1,16 @@
+// clean.js
+import fs from 'fs';
+import path from 'path';
+
+const directoriesToDelete = ['dist'];
+
+// 删除文件夹
+directoriesToDelete.forEach((dir) => {
+	const dirPath = path.join(process.cwd(), dir);
+	if (fs.existsSync(dirPath)) {
+		fs.rmSync(dirPath, { recursive: true, force: true });
+		console.log(`Deleted directory: ${dirPath}`);
+	} else {
+		console.log(`Directory not found: ${dirPath}`);
+	}
+});

+ 16 - 0
Web/scripts/clean-lock.js

@@ -0,0 +1,16 @@
+// clean.js
+import fs from "fs";
+import path from "path";
+
+const filesToDelete = ["pnpm-lock.yaml", "package-lock.json"];
+
+// 删除文件
+filesToDelete.forEach(file => {
+  const filePath = path.join(process.cwd(), file);
+  if (fs.existsSync(filePath)) {
+    fs.unlinkSync(filePath);
+    console.log(`Deleted file: ${filePath}`);
+  } else {
+    console.log(`File not found: ${filePath}`);
+  }
+});

+ 16 - 0
Web/scripts/clean-modules.js

@@ -0,0 +1,16 @@
+// clean.js
+import fs from 'fs';
+import path from 'path';
+
+const directoriesToDelete = ['node_modules'];
+
+// 删除文件夹
+directoriesToDelete.forEach((dir) => {
+	const dirPath = path.join(process.cwd(), dir);
+	if (fs.existsSync(dirPath)) {
+		fs.rmSync(dirPath, { recursive: true, force: true });
+		console.log(`Deleted directory: ${dirPath}`);
+	} else {
+		console.log(`Directory not found: ${dirPath}`);
+	}
+});