更新状态

master
yutent 2023-05-09 17:51:20 +08:00
parent 4fafaee6ae
commit f4601ba16f
1 changed files with 21 additions and 4 deletions

View File

@ -13,7 +13,7 @@ class Bubble extends Component {
content: '', content: '',
voiceLength: 0, voiceLength: 0,
avatar: '', avatar: '',
readOnly: true status: 0 // -1: 失败, 0: 发送中, 1: 成功, 2:已读
} }
static styles = [ static styles = [
@ -87,10 +87,22 @@ class Bubble extends Component {
} }
.type-voice { .type-voice {
position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
user-select: none; user-select: none;
&.dot::after {
position: absolute;
right: -8px;
top: -2px;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--color-red-1);
content: '';
}
.wave { .wave {
position: relative; position: relative;
display: flex; display: flex;
@ -152,7 +164,8 @@ class Bubble extends Component {
` `
] ]
#playing = false #playing = false // 正在播放
#played = false // 是否已播放过
#drawContent() { #drawContent() {
switch (this.type) { switch (this.type) {
@ -167,7 +180,10 @@ class Bubble extends Component {
/>` />`
case 'voice': case 'voice':
return html`<div class="type-voice" @click=${this.playVoice}> return html`<div
class=${classMap({ 'type-voice': true, dot: !this.#played })}
@click=${this.playVoice}
>
<div class=${classMap({ wave: true, on: this.#playing })}> <div class=${classMap({ wave: true, on: this.#playing })}>
<i class="i"></i> <i class="i"></i>
<i class="i"></i> <i class="i"></i>
@ -183,10 +199,11 @@ class Bubble extends Component {
} }
previewImage() { previewImage() {
this.$emit('image-preview', { data: this.content }, true) this.$emit('image-preview', { data: this.content })
} }
playVoice() { playVoice() {
this.#played = true
this.#playing = !this.#playing this.#playing = !this.#playing
this.$requestUpdate() this.$requestUpdate()
} }