Skip to content

Commit

Permalink
feat: update theme
Browse files Browse the repository at this point in the history
  • Loading branch information
sukbearai committed Oct 31, 2024
1 parent 0900bd8 commit 6762024
Show file tree
Hide file tree
Showing 89 changed files with 3,677 additions and 2,677 deletions.
29 changes: 29 additions & 0 deletions app/app.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
<script setup lang="ts">
import { DataType, PAGE_SIGN, PAGE_SYNC } from './types/qt'
import { appName } from '~/constants'
const { connect, disconnect } = useWebChannel()
// 监听路由跳转
const cbId = connect((data) => {
if (data.type === DataType.PAGE_JUMP) {
if (data.screen === PAGE_SIGN.BIG_SCREEN) {
if (data.index === PAGE_SYNC.LOGIN) {
navigateTo('/v-screen')
}
else if (data.index === PAGE_SYNC.HOME) {
navigateTo('/v-screen/data')
}
}
else if (data.screen === PAGE_SIGN.SMALL_SCREEN) {
if (data.index === PAGE_SYNC.LOGIN) {
navigateTo('/s-screen')
}
else if (data.index === PAGE_SYNC.HOME) {
navigateTo('/s-screen/task')
}
}
}
})
onBeforeUnmount(() => {
disconnect(cbId)
})
useHead({
title: appName,
})
Expand Down
68 changes: 60 additions & 8 deletions app/components/AiAssistant.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import { CircleCloseFilled } from '@element-plus/icons-vue'
import { Vue3Lottie } from 'vue3-lottie'
import chatData from '~/services/chat'
// import ChatInput from './ChatPanel/components/ChatInput.vue'
import ChatItem from './ChatPanel/components/ChatItem.vue'
import ChatPanel from './ChatPanel/index.vue'
import chatData from '~/services/chat'
import { QTClientSDK } from '~/services/qt'
import { DataType, type QTResponseType, ReturnCode, State } from '~/types/qt'
const props = defineProps({
modelValue: {
Expand All @@ -15,6 +17,48 @@ const props = defineProps({
const emit = defineEmits(['close', 'open', 'update:model-value'])
const sdk = new QTClientSDK()
async function handleAIAssistantData(data: QTResponseType): Promise<void> {
if (data.type === DataType.AI_ASSISTANT) {
switch (data.ret) {
case ReturnCode.RECORDING_STATUS:
handleRecordingStatus(data)
break
case ReturnCode.VOICE_TO_TEXT:
await handleVoiceToText(data)
break
case ReturnCode.AI_INFERENCE:
await handleAIInference(data)
break
default:
console.warn(`Unknown return code: ${data.ret}`)
}
}
}
function handleRecordingStatus(data: QTResponseType): void {
window.console.log('录音状态', data.state)
}
async function handleVoiceToText(data: QTResponseType): Promise<void> {
if (data.state === State.COMPLETED && data.text) {
await sendMessage(data.text)
}
}
async function handleAIInference(data: QTResponseType): Promise<void> {
if (data.state === State.COMPLETED && data.text) {
await sendMessage(data.text, false)
}
}
const { sendMessageToCpp, connect, disconnect } = useWebChannel()
const cbId = connect((data: QTResponseType) => {
handleAIAssistantData(data)
})
const chatWrapEl = ref()
const { height } = useElementSize(chatWrapEl)
const lottieContainerOne = ref<any>(null)
Expand Down Expand Up @@ -115,7 +159,7 @@ function handleReachTop() {
queryList(pageNo.value, pageSize.value)
}
function sendMessage(msg: string, isStudent: boolean) {
function sendMessage(msg: string, isStudent: boolean = true) {
return new Promise((resolve) => {
btnLoading.value = true
setTimeout(() => {
Expand Down Expand Up @@ -143,29 +187,37 @@ function onSwitchAnimation() {
lottieContainerOne.value!.play()
lottieContainerTwo.value!.play()
isRecording.value = true
window.console.log('开始录音', sdk.createMicrophoneControlDTO('0'))
sendMessageToCpp(sdk.createMicrophoneControlDTO('0'))
}
else {
lottieContainerOne.value!.stop()
lottieContainerTwo.value!.stop()
isRecording.value = false
window.console.log('结束录音', sdk.createMicrophoneControlDTO('1'))
sendMessageToCpp(sdk.createMicrophoneControlDTO('1'))
}
}
const debounceOnSwitchAnimation = useDebounceFn(onSwitchAnimation, 500)
watch(isRecording, async (val) => {
if (!val) {
await sendMessage('你好,AI助教', true)
await sendMessage('你好,我可以帮助你什么?', false)
}
})
// watch(isRecording, async (val) => {
// if (!val) {
// await sendMessage('你好,AI助教', true)
// await sendMessage('你好,我可以帮助你什么?', false)
// }
// })
// 打开弹出框加载数据
function onOpen() {
// 分页加载
queryList(pageNo.value, pageSize.value)
emit('open')
}
onBeforeUnmount(() => {
disconnect(cbId)
})
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion app/components/ChatPanel/components/VirtualList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { ScrollOptions } from '../types'
import { useSize } from '../hooks/useSize'
import { isNumber } from '../utils/is'
import type { ScrollOptions } from '../types'
import VirtualListItem from './VirtualListItem'
const props = defineProps({
Expand Down
2 changes: 1 addition & 1 deletion app/components/ChatPanel/hooks/useSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function useSize({
let offsetIndex = 0
while (offset > 0) {
offset -= getItemSize(_start + offsetIndex)!

// eslint-disable-next-line ts/no-unused-expressions
isForward ? offsetIndex++ : offsetIndex--
}
return offsetIndex
Expand Down
2 changes: 1 addition & 1 deletion app/components/ChatPanel/index.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts" setup>
import type { ScrollbarProps } from '@arco-design/web-vue'
import VirtualList from './components/VirtualList.vue'
import { useComponentRef } from './hooks/useComponentRef'
import { useScrollbar } from './hooks/useScrollbar'
import { isNumber } from './utils/is'
import VirtualList from './components/VirtualList.vue'
const props = defineProps({
/**
Expand Down
2 changes: 1 addition & 1 deletion app/components/ChatPanel/utils/is.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Dayjs } from 'dayjs'
/* eslint-disable regexp/no-super-linear-backtracking */
/* eslint-disable regexp/no-unused-capturing-group */
/* eslint-disable eslint-comments/no-unlimited-disable */
import type { ComponentPublicInstance, VNode, VNodeNormalizedChildren } from 'vue'
import type { Dayjs } from 'dayjs'

const opt = Object.prototype.toString

Expand Down
49 changes: 0 additions & 49 deletions app/components/NavBar.vue

This file was deleted.

1 change: 1 addition & 0 deletions app/components/RichText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const conf = {
:id="tinymceId"
ref="editorRef"
v-model="modelValue"
disabled
:init="conf"
tinymce-script-src="/plugins/tinymce/tinymce.min.js"
/>
Expand Down
Loading

0 comments on commit 6762024

Please sign in to comment.