使搜索框在存在输入内容时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 .DS_Store
dist/
dist/electron/* dist/electron/*
dist/web/* dist/web/*
build/* build/*
!build/icons/ !build/icons/
node_modules/ node_modules/
npm-debug.log npm-debug.log
npm-debug.log.* npm-debug.log.*
.pnpm-debug.log
thumbs.db thumbs.db
!.gitkeep !.gitkeep
.idea .idea
dist/ .vscode

View File

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

View File

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