feat: 更新 ESLint 和 Prettier 配置,增强代码质量管理

- 在 .gitignore 中添加 public/audio/* 以忽略音频文件。
- 更新 bun.lock,添加 eslint-config-prettier 和 eslint-plugin-prettier 依赖,确保 ESLint 与 Prettier 的兼容性。
- 修改 eslint.config.ts,整合 Prettier 规则,优化代码风格一致性。
- 在 package.json 中添加 lint:fix 和 format 脚本,简化代码格式化和修复流程。
- 更新 tailwind.config.ts 和其他组件文件,统一代码风格,提升可读性。
This commit is contained in:
zhongyidian committed 2026-03-05 13:50:47 +08:00
1 parent 5d00adc1a5
commit 76c67b492e
216 files changed
+12454 -13976

No files matched your search

+26 -29
View File
@@ -1,56 +1,53 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import { type ClassValue, clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
return twMerge(clsx(inputs))
}
// 图片资源映射 - 使用静态导入确保构建时包含所有图片
const imageModules = import.meta.glob(
"../../assets/images/**/*.{png,jpg,jpeg,gif,svg,webp}",
{
eager: true,
}
);
const imageModules = import.meta.glob('../../assets/images/**/*.{png,jpg,jpeg,gif,svg,webp}', {
eager: true,
})
//访问静态图片 - 使用静态导入确保构建后路径正确
export const getStaticImage = (path: string) => {
try {
// 确保路径以正确的格式结尾
const imagePath =
path.endsWith(".png") ||
path.endsWith(".jpg") ||
path.endsWith(".jpeg") ||
path.endsWith(".gif") ||
path.endsWith(".svg") ||
path.endsWith(".webp")
path.endsWith('.png') ||
path.endsWith('.jpg') ||
path.endsWith('.jpeg') ||
path.endsWith('.gif') ||
path.endsWith('.svg') ||
path.endsWith('.webp')
? `../../assets/images/${path}`
: `../../assets/images/${path}.png`;
: `../../assets/images/${path}.png`
// 使用静态导入的模块
const module = imageModules[imagePath];
if (module && typeof module === "object" && "default" in module) {
return module.default as string;
const module = imageModules[imagePath]
if (module && typeof module === 'object' && 'default' in module) {
return module.default as string
}
// 回退到URL方式
return new URL(imagePath, import.meta.url).href;
return new URL(imagePath, import.meta.url).href
} catch (error) {
console.error("Failed to load image:", path, error);
return "";
console.error('Failed to load image:', path, error)
return ''
}
};
}
// 获取背景图片的专用函数
export const getBackgroundImage = (path: string) => {
const imageUrl = getStaticImage(path);
return imageUrl ? `url(${imageUrl})` : "none";
};
const imageUrl = getStaticImage(path)
return imageUrl ? `url(${imageUrl})` : 'none'
}
// 获取 public 文件夹中的资源路径(用于 Word 文档等)
export const getPublicPath = (path: string) => {
// 移除开头的斜杠(如果有)
const cleanPath = path.startsWith("/") ? path.slice(1) : path;
const cleanPath = path.startsWith('/') ? path.slice(1) : path
// 使用 Vite 的 BASE_URL 环境变量来处理基础路径
return `${import.meta.env.BASE_URL}${cleanPath}`;
};
return `${import.meta.env.BASE_URL}${cleanPath}`
}