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:
1 parent
5d00adc1a5
commit
76c67b492e
216 files changed
+12454
-13976
No files matched your search
@@ -5,12 +5,12 @@
|
||||
|
||||
// 敏感词库(可根据实际需求扩展)
|
||||
const SENSITIVE_WORDS = [
|
||||
"敏感词1",
|
||||
"敏感词2",
|
||||
"测试",
|
||||
"垃圾",
|
||||
'敏感词1',
|
||||
'敏感词2',
|
||||
'测试',
|
||||
'垃圾',
|
||||
// 可以根据实际需求添加更多敏感词
|
||||
];
|
||||
]
|
||||
|
||||
/**
|
||||
* 检查文本中是否包含敏感词
|
||||
@@ -18,13 +18,11 @@ const SENSITIVE_WORDS = [
|
||||
* @returns 是否包含敏感词
|
||||
*/
|
||||
export function containsSensitiveWord(text: string): boolean {
|
||||
if (!text) return false;
|
||||
if (!text) return false
|
||||
|
||||
const normalizedText = text.toLowerCase().trim();
|
||||
const normalizedText = text.toLowerCase().trim()
|
||||
|
||||
return SENSITIVE_WORDS.some((word) =>
|
||||
normalizedText.includes(word.toLowerCase())
|
||||
);
|
||||
return SENSITIVE_WORDS.some((word) => normalizedText.includes(word.toLowerCase()))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,16 +31,16 @@ export function containsSensitiveWord(text: string): boolean {
|
||||
* @returns 处理后的文本
|
||||
*/
|
||||
export function filterSensitiveWords(text: string): string {
|
||||
if (!text) return text;
|
||||
if (!text) return text
|
||||
|
||||
let result = text;
|
||||
let result = text
|
||||
|
||||
SENSITIVE_WORDS.forEach((word) => {
|
||||
const regex = new RegExp(word, "gi");
|
||||
result = result.replace(regex, "*".repeat(word.length));
|
||||
});
|
||||
const regex = new RegExp(word, 'gi')
|
||||
result = result.replace(regex, '*'.repeat(word.length))
|
||||
})
|
||||
|
||||
return result;
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,10 +49,10 @@ export function filterSensitiveWords(text: string): string {
|
||||
* @returns 过滤后的内容
|
||||
*/
|
||||
export function filterInput(input: string): string {
|
||||
if (!input) return input;
|
||||
if (!input) return input
|
||||
|
||||
// 先进行敏感词过滤
|
||||
const filtered = filterSensitiveWords(input);
|
||||
const filtered = filterSensitiveWords(input)
|
||||
|
||||
return filtered;
|
||||
return filtered
|
||||
}
|
||||
Reference in new issue
Block a user