【优化】hasChinese 抽离 utils

pull/470/MERGE
cherishsince 2024-07-04 09:51:39 +08:00
parent ed786b2db6
commit 8f6e6fdb54
2 changed files with 14 additions and 5 deletions

View File

@ -121,6 +121,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ImageApi, ImageDrawReqVO, ImageVO} from '@/api/ai/image' import {ImageApi, ImageDrawReqVO, ImageVO} from '@/api/ai/image'
import {hasChinese} from '../../utils/common-utils'
// image // image
interface ImageModelVO { interface ImageModelVO {
@ -329,11 +330,6 @@ const handleHotWordClick = async (hotWord: string) => {
prompt.value = hotWord prompt.value = hotWord
} }
/** 判断字符串是否包含中文 */
function hasChinese(str) {
return /[\u4E00-\u9FA5]+/g.test(str)
}
/** 图片生产 */ /** 图片生产 */
const handleGenerateImage = async () => { const handleGenerateImage = async () => {
// //

View File

@ -0,0 +1,13 @@
/**
* Created by
*
* AI
*
* src/utils/common-utils.ts
* AI /views/ai/utils/common-utils.ts
*/
/** 判断字符串是否包含中文 */
export const hasChinese = async (str) => {
return /[\u4E00-\u9FA5]+/g.test(str)
}