Commit 8f6e6fdb by cherishsince

【优化】hasChinese 抽离 utils

parent ed786b2d
...@@ -121,6 +121,7 @@ ...@@ -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) => { ...@@ -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 () => {
// 二次确认 // 二次确认
......
/**
* 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)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment