使搜索框在存在输入内容时mousedown不会造成拖动

This commit is contained in:
tcsnzh 2021-09-20 18:56:16 +08:00
parent 1eeb0fad9a
commit 9d3e7fc4a5
3 changed files with 72 additions and 54 deletions

11
.gitignore vendored
View File

@ -1,12 +1,21 @@
.DS_Store
dist/
dist/electron/*
dist/web/*
build/*
!build/icons/
node_modules/
npm-debug.log
npm-debug.log.*
.pnpm-debug.log
thumbs.db
!.gitkeep
.idea
dist/
.vscode

View File

@ -1,5 +0,0 @@
{
"0 debug pnpm:scope": {
"selected": 1
}
}

View File

@ -20,11 +20,14 @@
? subPlaceHolder
: 'Hi, Rubick'
"
@mousedown.stop="dragWhenInput"
class="main-input"
@change="(e) => search({ value: e.target.value })"
@keydown.ctrl.86="shouldPaste"
:value="searchValue"
:maxLength="selected && selected.key !== 'plugin-container' ? 0 : 1000"
:maxLength="
selected && selected.key !== 'plugin-container' ? 0 : 1000
"
@keydown.down="(e) => changeCurrent(1)"
@keydown.up="() => changeCurrent(-1)"
@keypress.enter="
@ -42,12 +45,14 @@
/>
<div v-if="selected && selected.icon" style="position: relative">
<a-spin v-show="pluginLoading" class="loading">
<a-icon slot="indicator" type="loading" style="font-size: 42px" spin />
</a-spin>
<img
class="icon-tool"
:src="selected.icon"
<a-icon
slot="indicator"
type="loading"
style="font-size: 42px"
spin
/>
</a-spin>
<img class="icon-tool" :src="selected.icon" />
</div>
<div v-else class="rubick-logo">
<img src="./assets/imgs/logo.png" />
@ -167,11 +172,13 @@ export default {
const feature = plugin.features;
feature.forEach((fe) => {
const cmd = searchKeyValues(fe.cmds, args)[0];
const systemPlugin = fileLists.filter(
(plugin) => {
const systemPlugin = fileLists.filter((plugin) => {
let has = false;
plugin.keyWords.some(keyWord => {
if (keyWord.toLocaleUpperCase().indexOf(args.toLocaleUpperCase()) >= 0) {
plugin.keyWords.some((keyWord) => {
if (
keyWord.toLocaleUpperCase().indexOf(args.toLocaleUpperCase()) >=
0
) {
has = keyWord;
plugin.name = keyWord;
return true;
@ -179,8 +186,7 @@ export default {
return false;
});
return has;
}
)[0];
})[0];
if (cmd) {
config = {
cmd: cmd,
@ -210,11 +216,14 @@ export default {
...mapActions("main", ["onSearch", "showMainUI", "openPlugin"]),
...mapMutations("main", ["commonUpdate"]),
shouldPaste(e) {
let filePath = '';
if (process.platform === 'win32') {
const rawFilePath = clipboard.read('FileNameW');
filePath = rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
if (filePath.indexOf('plugin.json') >= 0) {
let filePath = "";
if (process.platform === "win32") {
const rawFilePath = clipboard.read("FileNameW");
filePath = rawFilePath.replace(
new RegExp(String.fromCharCode(0), "g"),
""
);
if (filePath.indexOf("plugin.json") >= 0) {
this.search({
filePath,
});
@ -340,9 +349,14 @@ export default {
this.changePath({ key: "market" });
},
drag() {
ipcRenderer.send('window-move');
ipcRenderer.send("window-move");
},
dragWhenInput(e) {
if (this.searchValue == "") {
ipcRenderer.send("window-move");
}
},
},
computed: {
...mapState("main", [
"showMain",