mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-23 09:20:44 +00:00
fix: 任务弹窗无法发送语音
This commit is contained in:
parent
e750d2ae80
commit
4853d5227b
@ -138,6 +138,10 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
disabledRecord: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@ -532,44 +536,46 @@ export default {
|
|||||||
return delta
|
return delta
|
||||||
})
|
})
|
||||||
|
|
||||||
// Load recorder
|
|
||||||
$A.loadScriptS([
|
|
||||||
'js/recorder/recorder.mp3.min.js',
|
|
||||||
'js/recorder/lib.fft.js',
|
|
||||||
'js/recorder/frequency.histogram.view.js',
|
|
||||||
], (e) => {
|
|
||||||
if (e !== null || typeof window.Recorder !== 'function') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.recordRec = window.Recorder({
|
|
||||||
type: "mp3",
|
|
||||||
bitRate: 32,
|
|
||||||
sampleRate: 16000,
|
|
||||||
onProcess: (buffers, powerLevel, duration, sampleRate, newBufferIdx, asyncEnd) => {
|
|
||||||
this.recordWave.input(buffers[buffers.length - 1], powerLevel, sampleRate);
|
|
||||||
this.recordDuration = duration;
|
|
||||||
if (duration >= 3 * 60 * 1000) {
|
|
||||||
// 最长录3分钟
|
|
||||||
this.stopRecord(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (window.Recorder.Support()) {
|
|
||||||
this.recordReady = true;
|
|
||||||
this.$nextTick(_ => {
|
|
||||||
this.recordWave = window.Recorder.FrequencyHistogramView({
|
|
||||||
elem: this.$refs.recwave,
|
|
||||||
lineCount: 90,
|
|
||||||
position: 0,
|
|
||||||
minHeight: 1,
|
|
||||||
stripeEnable: false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ready event
|
// Ready event
|
||||||
this.$emit('on-ready', this.quill)
|
this.$emit('on-ready', this.quill)
|
||||||
|
|
||||||
|
// Load recorder
|
||||||
|
if (!this.disabledRecord) {
|
||||||
|
$A.loadScriptS([
|
||||||
|
'js/recorder/recorder.mp3.min.js',
|
||||||
|
'js/recorder/lib.fft.js',
|
||||||
|
'js/recorder/frequency.histogram.view.js',
|
||||||
|
], (e) => {
|
||||||
|
if (e !== null || typeof window.Recorder !== 'function') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.recordRec = window.Recorder({
|
||||||
|
type: "mp3",
|
||||||
|
bitRate: 32,
|
||||||
|
sampleRate: 16000,
|
||||||
|
onProcess: (buffers, powerLevel, duration, sampleRate, newBufferIdx, asyncEnd) => {
|
||||||
|
this.recordWave.input(buffers[buffers.length - 1], powerLevel, sampleRate);
|
||||||
|
this.recordDuration = duration;
|
||||||
|
if (duration >= 3 * 60 * 1000) {
|
||||||
|
// 最长录3分钟
|
||||||
|
this.stopRecord(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (window.Recorder.Support()) {
|
||||||
|
this.recordReady = true;
|
||||||
|
this.$nextTick(_ => {
|
||||||
|
this.recordWave = window.Recorder.FrequencyHistogramView({
|
||||||
|
elem: this.$refs.recwave,
|
||||||
|
lineCount: 90,
|
||||||
|
position: 0,
|
||||||
|
minHeight: 1,
|
||||||
|
stripeEnable: false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setText(value) {
|
setText(value) {
|
||||||
@ -721,13 +727,10 @@ export default {
|
|||||||
}
|
}
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onloadend = () => {
|
reader.onloadend = () => {
|
||||||
this.$emit('on-send', {
|
this.$emit('on-record', {
|
||||||
type: 'record',
|
type: this.recordBlob.type,
|
||||||
data: {
|
base64: reader.result,
|
||||||
type: this.recordBlob.type,
|
duration,
|
||||||
base64: reader.result,
|
|
||||||
duration,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(this.recordBlob);
|
reader.readAsDataURL(this.recordBlob);
|
||||||
|
|||||||
@ -120,6 +120,7 @@
|
|||||||
@on-blur="onEventBlur"
|
@on-blur="onEventBlur"
|
||||||
@on-more="onEventMore"
|
@on-more="onEventMore"
|
||||||
@on-file="sendFileMsg"
|
@on-file="sendFileMsg"
|
||||||
|
@on-record="sendRecord"
|
||||||
@on-send="sendMsg"
|
@on-send="sendMsg"
|
||||||
@on-emoji-visible-change="onEventEmojiVisibleChange"
|
@on-emoji-visible-change="onEventEmojiVisibleChange"
|
||||||
:placeholder="$L('输入消息...')"/>
|
:placeholder="$L('输入消息...')"/>
|
||||||
@ -330,11 +331,13 @@ export default {
|
|||||||
'$route': {
|
'$route': {
|
||||||
handler (route) {
|
handler (route) {
|
||||||
if ($A.isJson(window.__sendDialogMsg) && window.__sendDialogMsg.time > $A.Time()) {
|
if ($A.isJson(window.__sendDialogMsg) && window.__sendDialogMsg.time > $A.Time()) {
|
||||||
const {msgFile, msgText} = window.__sendDialogMsg;
|
const {msgFile, msgRecord, msgText} = window.__sendDialogMsg;
|
||||||
window.__sendDialogMsg = null;
|
window.__sendDialogMsg = null;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if ($A.isArray(msgFile) && msgFile.length > 0) {
|
if ($A.isArray(msgFile) && msgFile.length > 0) {
|
||||||
this.sendFileMsg(msgFile);
|
this.sendFileMsg(msgFile);
|
||||||
|
} else if ($A.isJson(msgRecord) && msgRecord.duration > 0) {
|
||||||
|
this.sendRecord(msgRecord);
|
||||||
} else if (msgText) {
|
} else if (msgText) {
|
||||||
this.sendMsg(msgText);
|
this.sendMsg(msgText);
|
||||||
}
|
}
|
||||||
@ -411,13 +414,6 @@ export default {
|
|||||||
* @param text
|
* @param text
|
||||||
*/
|
*/
|
||||||
sendMsg(text) {
|
sendMsg(text) {
|
||||||
if ($A.isJson(text)) {
|
|
||||||
if (text.type === 'record') {
|
|
||||||
// 发送录音 text.record
|
|
||||||
this.sendRecordMsg(text.data);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let msgText;
|
let msgText;
|
||||||
if (typeof text === "string" && text) {
|
if (typeof text === "string" && text) {
|
||||||
msgText = text;
|
msgText = text;
|
||||||
@ -465,7 +461,7 @@ export default {
|
|||||||
* 发送录音
|
* 发送录音
|
||||||
* @param msg {base64, duration}
|
* @param msg {base64, duration}
|
||||||
*/
|
*/
|
||||||
sendRecordMsg(msg) {
|
sendRecord(msg) {
|
||||||
this.onToBottom();
|
this.onToBottom();
|
||||||
this.onActive();
|
this.onActive();
|
||||||
//
|
//
|
||||||
|
|||||||
@ -409,8 +409,9 @@
|
|||||||
:placeholder="$L('输入消息...')"
|
:placeholder="$L('输入消息...')"
|
||||||
@on-more="onEventMore"
|
@on-more="onEventMore"
|
||||||
@on-file="onSelectFile"
|
@on-file="onSelectFile"
|
||||||
|
@on-record="onRecord"
|
||||||
@on-send="onSend"/>
|
@on-send="onSend"/>
|
||||||
<Badge class="input-badge" :count="taskDetail.msg_num"/>
|
<div v-if="taskDetail.msg_num" class="input-badge" @click.stop="onSend">{{taskDetail.msg_num > 99 ? '99+' : taskDetail.msg_num}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="dialogDrag" class="drag-over" @click="dialogDrag=false">
|
<div v-if="dialogDrag" class="drag-over" @click="dialogDrag=false">
|
||||||
<div class="drag-text">{{$L('拖动到这里发送')}}</div>
|
<div class="drag-text">{{$L('拖动到这里发送')}}</div>
|
||||||
@ -492,6 +493,7 @@ export default {
|
|||||||
|
|
||||||
msgText: '',
|
msgText: '',
|
||||||
msgFile: [],
|
msgFile: [],
|
||||||
|
msgRecord: {},
|
||||||
navActive: 'dialog',
|
navActive: 'dialog',
|
||||||
logLoadIng: false,
|
logLoadIng: false,
|
||||||
|
|
||||||
@ -1106,8 +1108,10 @@ export default {
|
|||||||
window.__sendDialogMsg = {
|
window.__sendDialogMsg = {
|
||||||
time: $A.Time() + 10,
|
time: $A.Time() + 10,
|
||||||
msgText: this.msgText,
|
msgText: this.msgText,
|
||||||
msgFile: this.msgFile
|
msgFile: this.msgFile,
|
||||||
|
msgRecord: this.msgRecord
|
||||||
};
|
};
|
||||||
|
this.msgRecord = {};
|
||||||
this.msgFile = [];
|
this.msgFile = [];
|
||||||
this.msgText = "";
|
this.msgText = "";
|
||||||
this.goForward({name: 'manage-messenger', params: {dialogId: data.dialog_id}, query: {_: $A.randomString(6)}});
|
this.goForward({name: 'manage-messenger', params: {dialogId: data.dialog_id}, query: {_: $A.randomString(6)}});
|
||||||
@ -1173,6 +1177,11 @@ export default {
|
|||||||
this.msgDialog()
|
this.msgDialog()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRecord(row) {
|
||||||
|
this.msgRecord = row;
|
||||||
|
this.msgDialog()
|
||||||
|
},
|
||||||
|
|
||||||
onSend() {
|
onSend() {
|
||||||
this.$refs.chatInput && this.$refs.chatInput.hidePopover();
|
this.$refs.chatInput && this.$refs.chatInput.hidePopover();
|
||||||
this.msgDialog();
|
this.msgDialog();
|
||||||
|
|||||||
@ -571,7 +571,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
margin: 22px 0 0 36px;
|
margin: 22px 0 0 36px;
|
||||||
background-color: #F4F5F7;
|
background-color: #F4F5F7;
|
||||||
padding: 10px 8px;
|
padding: 10px 4px 10px 6px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
.chat-input-box {
|
.chat-input-box {
|
||||||
.chat-input-wrapper {
|
.chat-input-wrapper {
|
||||||
@ -588,11 +588,21 @@
|
|||||||
}
|
}
|
||||||
.input-badge {
|
.input-badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
transform: scale(0.6) translateX(100%);
|
transform: scale(0.8) translateX(100%);
|
||||||
transform-origin: right center;
|
transform-origin: right center;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
right: 25px;
|
right: 22px;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
min-width: 20px;
|
||||||
|
background: #ed4014;
|
||||||
|
color: #fff;
|
||||||
|
line-height: 20px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.drag-over {
|
.drag-over {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user