mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-09-27 13:53:21 +08:00
feat: 添加监听状态标志 进入插件重启监听 仅在首次运行时执行copy
This commit is contained in:
16
public/node_modules/clipboard-event/index.js
generated
vendored
16
public/node_modules/clipboard-event/index.js
generated
vendored
@@ -8,6 +8,7 @@ class ClipboardEventListener extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
this.child = null;
|
||||
this.listening = false;
|
||||
}
|
||||
startListening() {
|
||||
const { platform } = process;
|
||||
@@ -17,14 +18,15 @@ class ClipboardEventListener extends EventEmitter {
|
||||
else if (platform === 'linux') {
|
||||
// linux: cant execFile without chmod, and cant chmod in app.asar
|
||||
// so we need to copy the file to /usr/bin
|
||||
const target = path.resolve(homeDir, '.local', 'bin')
|
||||
const targetPath = path.resolve(homeDir, '.local', 'bin')
|
||||
const target = path.resolve(targetPath, 'clipboard-event-handler-linux')
|
||||
const p = path.join(__dirname, 'platform/clipboard-event-handler-linux')
|
||||
if(!existsSync(target)) {
|
||||
mkdirSync(target)
|
||||
mkdirSync(targetPath)
|
||||
copyFileSync(p, target)
|
||||
chmodSync(target, 0o755)
|
||||
}
|
||||
copyFileSync(p, path.join(target, 'clipboard-event-handler-linux'))
|
||||
chmodSync(path.join(target, 'clipboard-event-handler-linux'), 0o755)
|
||||
this.child = execFile(path.join(target, 'clipboard-event-handler-linux'));
|
||||
this.child = execFile(target);
|
||||
}
|
||||
else if (platform === 'darwin') {
|
||||
this.child = execFile(path.join(__dirname, 'platform/clipboard-event-handler-mac'));
|
||||
@@ -39,13 +41,17 @@ class ClipboardEventListener extends EventEmitter {
|
||||
});
|
||||
this.child.stdout.on('close', () => {
|
||||
this.emit('close');
|
||||
this.listening = false;
|
||||
});
|
||||
this.child.stdout.on('exit', () => {
|
||||
this.emit('exit');
|
||||
this.listening = false;
|
||||
});
|
||||
this.listening = true;
|
||||
}
|
||||
stopListening() {
|
||||
const res = this.child.kill();
|
||||
this.listening = false;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user