新增在搜索框鼠标右击时自动粘贴剪贴板的文本到搜索框中
parent
b811227c41
commit
a9e3723764
|
@ -2,6 +2,7 @@
|
|||
|
||||
- 允许选中列表内歌曲名、歌手名、专辑名内的文字,选中后可使用键盘快捷键进行复制
|
||||
- 新增在列表可选内容区域鼠标右击时自动复制列表已选文字的功能
|
||||
- 新增在搜索框鼠标右击时自动粘贴剪贴板的文本到搜索框中
|
||||
- 任务下载失败时将显示搜索按钮,方便在其他源搜索该歌曲
|
||||
|
||||
### 优化
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<template lang="pug">
|
||||
div(:class="[$style.search, focus ? $style.active : '', big ? $style.big : '', small ? $style.small : '']")
|
||||
div(:class="$style.form")
|
||||
input(:placeholder="placeholder" v-model.trim="text"
|
||||
input(:placeholder="placeholder" v-model.trim="text" ref="dom_input"
|
||||
@focus="handleFocus" @blur="handleBlur" @input="$emit('input', text)"
|
||||
@change="sendEvent('change')"
|
||||
@keyup.enter="handleSearch"
|
||||
@keyup.40.prevent="handleKeyDown"
|
||||
@keyup.38.prevent="handleKeyUp")
|
||||
@keyup.38.prevent="handleKeyUp"
|
||||
@contextmenu="handleContextMenu")
|
||||
button(type="button" @click="handleSearch")
|
||||
slot
|
||||
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 30.239 30.239' space='preserve')
|
||||
|
@ -21,6 +22,7 @@ div(:class="[$style.search, focus ? $style.active : '', big ? $style.big : '', s
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { clipboardReadText } from '../../utils'
|
||||
export default {
|
||||
props: {
|
||||
placeholder: {
|
||||
|
@ -113,6 +115,14 @@ export default {
|
|||
handleKeyUp() {
|
||||
this.selectIndex = this.selectIndex - 1 < -1 ? this.list.length - 1 : this.selectIndex - 1
|
||||
},
|
||||
handleContextMenu() {
|
||||
let str = clipboardReadText()
|
||||
str = str.trim()
|
||||
str = str.replace(/\t|\r\n|\n|\r/g, ' ')
|
||||
let dom_input = this.$refs.dom_input
|
||||
this.text = `${this.text.substring(0, dom_input.selectionStart)}${str}${this.text.substring(dom_input.selectionEnd, this.text.length)}`
|
||||
this.$emit('input', this.text)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -291,6 +291,12 @@ export const toMD5 = str => crypto.createHash('md5').update(str).digest('hex')
|
|||
*/
|
||||
export const clipboardWriteText = str => clipboard.writeText(str)
|
||||
|
||||
/**
|
||||
* 从剪贴板读取文本
|
||||
* @param {*} str
|
||||
*/
|
||||
export const clipboardReadText = str => clipboard.readText()
|
||||
|
||||
/**
|
||||
* 设置音频 meta 信息
|
||||
* @param {*} filePath
|
||||
|
|
Loading…
Reference in New Issue