Skip to content

Commit

Permalink
✨ 支持新API:getCopyFiles simulateKeyboardTap
Browse files Browse the repository at this point in the history
  • Loading branch information
muwoo committed Aug 16, 2023
1 parent c2a23f0 commit 2008b62
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubick",
"version": "2.4.1",
"version": "2.4.2",
"author": "muwoo <[email protected]>",
"private": true,
"scripts": {
Expand Down Expand Up @@ -30,6 +30,7 @@
"get-mac-apps": "^1.0.2",
"got": "^11.8.3",
"lodash.throttle": "^4.1.1",
"node-key-sender": "^1.0.11",
"pouchdb": "^7.2.2",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
Expand Down
10 changes: 9 additions & 1 deletion public/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,16 @@ window.rubick = {
shellBeep: () => {
ipcSend('shellBeep');
},

getFileIcon: (path) => {
return ipcSendSync('getFileIcon', { path });
},

getCopyedFiles: () => {
return ipcSendSync('getCopyFiles');
},

simulateKeyboardTap: (key, ...modifier) => {
ipcSend('simulateKeyboardTap', { key, modifier });
},
};
18 changes: 18 additions & 0 deletions src/main/common/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { runner, detach } from '../browsers';
import fs from 'fs';
import { LocalDb, screenCapture } from '@/core';
import plist from 'plist';
import ks from 'node-key-sender';

import { DECODE_KEY } from '@/common/constans/main';
import getCopyFiles from '@/common/utils/getCopyFiles';

import mainInstance from '../index';
const runnerInstance = runner();
const detachInstance = detach();
Expand Down Expand Up @@ -324,6 +328,20 @@ class API {
});
});
}

public getCopyFiles() {
return getCopyFiles();
}

public simulateKeyboardTap({ data: { key, modifier } }) {
let keys = [key.toLowerCase()];
if (modifier && Array.isArray(modifier) && modifier.length > 0) {
keys = modifier.concat(keys);
ks.sendCombination(keys);
} else {
ks.sendKeys(keys);
}
}
}

export default new API();
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8070,6 +8070,11 @@ node-gyp-build@~4.1.0:
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.1.1.tgz#d7270b5d86717068d114cc57fff352f96d745feb"
integrity sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==

node-key-sender@^1.0.11:
version "1.0.11"
resolved "https://registry.npmmirror.com/node-key-sender/-/node-key-sender-1.0.11.tgz#93210f07163607d8daf2874f1a29567d0acdb94c"
integrity sha512-vv2IXd8QdZBFYXaIy02uy2rK6EKj+tOTEuoTxJKS9l8zw8Cz6DeLffR8ompj7N2A3h6XK7aiy+YAcTaeOqwp2Q==

node-libs-browser@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425"
Expand Down

0 comments on commit 2008b62

Please sign in to comment.