优化认证

This commit is contained in:
sijinhui 2024-04-01 22:30:35 +08:00
parent 070f143541
commit f5874a4d3d
3 changed files with 14 additions and 21 deletions

View File

@ -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({
</div>
);
}
// export const getServerSideProps: GetServerSideProps = async context => {
// const serverConfig = getServerSideConfig();
// console.log('66666', serverConfig, )
// return {
// props: {}
// };
// };

View File

@ -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);
}

View File

@ -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"
},