bugfix: #32,#31

This commit is contained in:
muwoo 2021-08-31 20:53:20 +08:00
parent 0991d0ad64
commit 57504ab1eb
3 changed files with 18 additions and 4 deletions

View File

@ -194,6 +194,7 @@ class Listener {
}
initTouchBar(mainWindow) {
if (!commonConst.macOS()) return;
const { TouchBarButton, TouchBarGroup, TouchBarPopover } = TouchBar;
let items = [];
let system = [];

View File

@ -22,6 +22,7 @@
"
class="main-input"
@change="(e) => search({ value: e.target.value })"
@keydown.ctrl.86="shouldPaste"
:value="searchValue"
:maxLength="selected && selected.key !== 'plugin-container' ? 0 : 1000"
@keydown.down="(e) => changeCurrent(1)"
@ -113,7 +114,7 @@
</template>
<script>
import { mapActions, mapMutations, mapState } from "vuex";
import { ipcRenderer, remote } from "electron";
import { ipcRenderer, remote, clipboard } from "electron";
import {
getWindowHeight,
debounce,
@ -208,6 +209,18 @@ export default {
methods: {
...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'), ''); } else {
if (filePath.indexOf('plugin.json') >= 0) {
this.search({
filePath,
});
}
}
},
search(v) {
if (!this.searchFn) {
this.searchFn = debounce(this.onSearch, 200);

View File

@ -107,10 +107,10 @@ const actions = {
commit('commonUpdate', { searchValue: value });
return;
}
const fileUrl = clipboard.read('public.file-url').replace('file://', '');
const fileUrl = paylpad.filePath || clipboard.read('public.file-url').replace('file://', '');
commit('commonUpdate', { searchValue: value });
// 复制文件
if (fileUrl && value === 'plugin.json') {
if (paylpad.filePath || (fileUrl && value === 'plugin.json')) {
const config = JSON.parse(fs.readFileSync(fileUrl, 'utf-8'));
const pluginConfig = {
@ -132,7 +132,6 @@ const actions = {
name: 'plugin.json'
},
searchValue: '',
devPlugins: [pluginConfig, ...state.devPlugins],
options: [
{
name: '新建rubick开发插件',
@ -142,6 +141,7 @@ const actions = {
click: (router) => {
commit('commonUpdate', {
showMain: true,
devPlugins: [pluginConfig, ...state.devPlugins],
selected: {
key: 'plugin',
name: '新建rubick开发插件'