diff --git a/app/components/voice-input.tsx b/app/components/voice-input.tsx index 3aeff5c01..f89e989d9 100644 --- a/app/components/voice-input.tsx +++ b/app/components/voice-input.tsx @@ -1,4 +1,3 @@ -// "use client"; import { Button, Input, Space } from "antd"; import { Dispatch, @@ -41,7 +40,11 @@ export default function VoiceInput({ setAccessToken(result.result); }; if (accessToken === "") { - get_access_token(); + try { + get_access_token(); + } catch (e) { + console.log("[get_access_token]", e); + } } }, [accessToken]); @@ -61,15 +64,6 @@ export default function VoiceInput({ if (intentJson) { setVoiceInputText(voiceInputText + `${intentJson}`); } - - // setTempUserInput(""); - // if (result?.translations) { - // let resultJson = JSON.parse(result.json); - // resultJson['privTranslationPhrase']['Translation']['Translations'].forEach( - // function (translation: { Language: any; Text: any; }) { - // setVoiceInputText(voiceInputText + ` [${translation.Language}] ${translation.Text}\r\n`); - // }); - // } } function onCanceled( sender: Recognizer, @@ -177,11 +171,3 @@ export default function VoiceInput({ ); } - -// export const getServerSideProps: GetServerSideProps = async context => { -// const serverConfig = getServerSideConfig(); -// console.log('66666', serverConfig, ) -// return { -// props: {} -// }; -// }; diff --git a/lib/auth_list.ts b/lib/auth_list.ts index 69cd07bf6..7de35c63a 100644 --- a/lib/auth_list.ts +++ b/lib/auth_list.ts @@ -1,6 +1,8 @@ +import * as pinyin from "tiny-pinyin"; export const DENY_LIST: string[] = [ "suibian", "某某", "张三", "李四", "啊实打实", "官方回复电话", "笑死", "观化听风", "null", "undefined", + "zhangsan", ] export const ADMIN_LIST: string[] = [ "司金辉", "sijinhui", "sijinhui@qq.com", @@ -91,8 +93,12 @@ export function isName(input: string): boolean { if (!input || input === "") { return false; } - if (DENY_LIST.includes(input)) { - return false; + try { + if (DENY_LIST.includes(input.toLowerCase()) || pinyin.convertToPinyin(input).toLowerCase()) { + return false; + } + } catch (e) { + console.log('[isName]', e) } return isEmail(input) || (input.length >= 2 && isHanZi(input)) || (isPinYin(input) >= 2); } diff --git a/package.json b/package.json index 3010ab2a6..d2db34318 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "spark-md5": "^3.0.2", "tailwind-merge": "^2.2.1", "tiktoken": "^1.0.13", + "tiny-pinyin": "^1.3.2", "use-debounce": "^10.0.0", "zustand": "^4.5.0" },