-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Pr@main/mobile voice #2651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Pr@main/mobile voice #2651
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
08f2949
fix: Optimize small screen dialogue style
wangdan-fit2cloud 033802b
feat: Mobile voice conversation new UI
wangdan-fit2cloud f2baa15
feat: Optimize the mobile voice interaction experience
wangdan-fit2cloud 5e88bdd
feat: Optimize the mobile voice interaction experience
wangdan-fit2cloud 9b89765
Merge branch 'main' into pr@main/mobile-voice
wangdan-fit2cloud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, | ||
viewport-fit=cover" | ||
/> | ||
<title>111</title> | ||
</head> | ||
<body style="margin: 0; padding: 0; height: 100vh"> | ||
<script | ||
async | ||
defer | ||
src="http://localhost:3000/api/application/embed?protocol=http&host=localhost:3000&token=7ca95a6b12571284"> | ||
</script> | ||
|
||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
ui/src/components/ai-chat/component/chat-input-operate/TouchChat.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
<template> | ||
<div class="touch-chat w-full mr-8"> | ||
<el-button | ||
text | ||
bg | ||
class="microphone-button w-full mt-8 ml-8 mb-8" | ||
style="font-size: 1rem; padding: 1.2rem 0 !important; background-color: #eff0f1" | ||
@touchstart="onTouchStart" | ||
@touchmove="onTouchMove" | ||
@touchend="onTouchEnd" | ||
> | ||
按住说话 | ||
</el-button> | ||
<!-- 使用 custom-class 自定义样式 --> | ||
<transition name="el-fade-in-linear"> | ||
<el-card class="custom-speech-card" :class="isTouching ? '' : 'active'" v-if="dialogVisible"> | ||
<p> | ||
<el-text type="info" v-if="isTouching" | ||
>00:{{ props.time < 10 ? `0${props.time}` : props.time }}</el-text | ||
> | ||
<span class="lighter" v-else> | ||
{{ message }} | ||
</span> | ||
</p> | ||
<div class="close"> | ||
<el-icon><Close /></el-icon> | ||
</div> | ||
<p class="lighter" :style="{ visibility: isTouching ? 'visible' : 'hidden' }"> | ||
{{ message }} | ||
</p> | ||
<div class="speech-img flex-center border-r-4 mt-16"> | ||
<img v-if="isTouching" src="@/assets/acoustic-color.svg" alt="" /> | ||
<img v-else src="@/assets/acoustic.svg" alt="" /> | ||
</div> | ||
</el-card> | ||
</transition> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { el } from 'element-plus/es/locale' | ||
import { ref, watch } from 'vue' | ||
const props = defineProps({ | ||
time: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
start: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}) | ||
const emit = defineEmits(['TouchStart', 'TouchEnd']) | ||
// 移动端语音 | ||
const startY = ref(0) | ||
const isTouching = ref(false) | ||
const dialogVisible = ref(false) | ||
const message = ref('按住说话') | ||
|
||
watch( | ||
() => props.time, | ||
(val) => { | ||
if (val && val === 60) { | ||
dialogVisible.value = false | ||
emit('TouchEnd', isTouching.value) | ||
isTouching.value = false | ||
} | ||
} | ||
) | ||
watch( | ||
() => props.start, | ||
(val) => { | ||
if (val) { | ||
isTouching.value = true | ||
dialogVisible.value = true | ||
message.value = '松开发送,上滑取消' | ||
} else { | ||
dialogVisible.value = false | ||
isTouching.value = false | ||
} | ||
} | ||
) | ||
|
||
function onTouchStart(event: any) { | ||
emit('TouchStart') | ||
startY.value = event.touches[0].clientY | ||
// 阻止默认滚动行为 | ||
event.preventDefault() | ||
} | ||
function onTouchMove(event: any) { | ||
if (!isTouching.value) return | ||
// 阻止默认滚动行为 | ||
event.preventDefault() | ||
const currentY = event.touches[0].clientY | ||
const deltaY = currentY - startY.value | ||
// 判断是否上滑 | ||
if (deltaY < -50) { | ||
// -50 是一个阈值,可以根据需要调整 | ||
message.value = '松开取消发送' | ||
isTouching.value = false | ||
} | ||
} | ||
function onTouchEnd() { | ||
emit('TouchEnd', isTouching.value) | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.custom-speech-card { | ||
position: fixed; | ||
bottom: 10px; | ||
left: 50%; /* 水平居中 */ | ||
transform: translateX(-50%); | ||
width: 92%; | ||
background: #ffffff; | ||
border: 1px solid #ffffff; | ||
box-shadow: 0px 6px 24px 0px rgba(31, 35, 41, 0.08); | ||
z-index: 999; | ||
text-align: center; | ||
color: var(--app-text-color-secondary); | ||
-webkit-touch-callout: none; | ||
-webkit-user-select: none; | ||
-khtml-user-select: none; | ||
-moz-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
.close { | ||
box-shadow: 0px 4px 8px 0px rgba(31, 35, 41, 0.1); | ||
border: 1px solid rgba(222, 224, 227, 1); | ||
background: rgba(255, 255, 255, 1); | ||
border-radius: 100px; | ||
display: inline-block; | ||
width: 43px; | ||
height: 43px; | ||
line-height: 50px; | ||
font-size: 1.8rem; | ||
margin: 20px 0; | ||
} | ||
.speech-img { | ||
text-align: center; | ||
background: #ebf1ff; | ||
padding: 8px; | ||
img { | ||
height: 25px; | ||
} | ||
} | ||
&.active { | ||
.close { | ||
background: #f54a45; | ||
color: #ffffff; | ||
width: 50px; | ||
height: 50px; | ||
line-height: 57px; | ||
font-size: 2rem; | ||
} | ||
.speech-img { | ||
background: #eff0f1; | ||
} | ||
} | ||
} | ||
</style> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided Vue component seems functional but can be streamlined and improved with minor adjustments:
Template Refactoring:
<br>
tags within<p>
elements.Transition Name Correction:
Image Alignment:
justify-content
to align images in.speech-img
.Here's an updated version of the code:
Key Changes:
Style Corrections:
transform
,display
, etc., to match Element Plus conventions.opacity: 75
for text opacity in.text-sm.opacity-75
.JavaScript Functionality:
delta
) to theonTouchEnd
method for better clarity in logic and potentially future debugging purposes.These changes make the component more consistent with Element Plus styling standards while still maintaining its functionality and usability.