mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-06 21:34:08 +08:00
refactor: 移除添加监听时对Mac的特殊判断 移除了缺少监听器的报错通知
This commit is contained in:
parent
18cbab4bda
commit
bb83b2c4ff
@ -12,7 +12,8 @@ class ClipboardEventListener extends EventEmitter {
|
|||||||
startListening(dbPath) {
|
startListening(dbPath) {
|
||||||
const targetMap = {
|
const targetMap = {
|
||||||
win32: 'clipboard-event-handler-win32.exe',
|
win32: 'clipboard-event-handler-win32.exe',
|
||||||
linux: 'clipboard-event-handler-linux'
|
linux: 'clipboard-event-handler-linux',
|
||||||
|
darwin: 'clipboard-event-handler-mac'
|
||||||
}
|
}
|
||||||
const { platform } = process
|
const { platform } = process
|
||||||
const target = path.resolve(
|
const target = path.resolve(
|
||||||
@ -25,7 +26,7 @@ class ClipboardEventListener extends EventEmitter {
|
|||||||
}
|
}
|
||||||
if (platform === 'win32') {
|
if (platform === 'win32') {
|
||||||
this.child = execFile(target)
|
this.child = execFile(target)
|
||||||
} else if (platform === 'linux') {
|
} else if (platform === 'linux' || platform === 'darwin') {
|
||||||
chmodSync(target, 0o755)
|
chmodSync(target, 0o755)
|
||||||
this.child = execFile(target)
|
this.child = execFile(target)
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,8 +217,8 @@ export default function initPlugin() {
|
|||||||
utools.outPlugin()
|
utools.outPlugin()
|
||||||
}
|
}
|
||||||
const errorHandler = (error) => {
|
const errorHandler = (error) => {
|
||||||
const info = '请到设置页检查剪贴板监听程序状态'
|
// const info = '请到设置页检查剪贴板监听程序状态'
|
||||||
utools.showNotification('启动剪贴板监听程序启动出错: ' + error + info)
|
// utools.showNotification('启动剪贴板监听程序启动出错: ' + error + info)
|
||||||
addCommonListener()
|
addCommonListener()
|
||||||
}
|
}
|
||||||
listener
|
listener
|
||||||
@ -228,17 +228,13 @@ export default function initPlugin() {
|
|||||||
.on('error', (error) => errorHandler(error))
|
.on('error', (error) => errorHandler(error))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!utools.isMacOs()) {
|
// 首次启动插件 即开启监听
|
||||||
// 首次启动插件 即开启监听
|
// 如果监听程序异常退出 则会在errorHandler中开启常规监听
|
||||||
registerClipEvent(listener)
|
registerClipEvent(listener)
|
||||||
listener.startListening(setting.database.path[nativeId])
|
listener.startListening(setting.database.path[nativeId])
|
||||||
} else {
|
|
||||||
// macos 由于无法执行 clipboard-event-handler-mac 所以使用旧方法
|
|
||||||
addCommonListener()
|
|
||||||
}
|
|
||||||
|
|
||||||
utools.onPluginEnter(() => {
|
utools.onPluginEnter(() => {
|
||||||
if (!listener.listening && !utools.isMacOs()) {
|
if (!listener.listening) {
|
||||||
// 进入插件后 如果监听已关闭 则重新开启监听
|
// 进入插件后 如果监听已关闭 则重新开启监听
|
||||||
registerClipEvent(listener)
|
registerClipEvent(listener)
|
||||||
listener.startListening(setting.database.path[nativeId])
|
listener.startListening(setting.database.path[nativeId])
|
||||||
|
@ -226,14 +226,14 @@ onMounted(() => {
|
|||||||
updateShowList(activeTab.value)
|
updateShowList(activeTab.value)
|
||||||
|
|
||||||
// 定期检查更新
|
// 定期检查更新
|
||||||
if (!utools.isMacOs() && window.listener.listening) {
|
if (window.listener.listening) {
|
||||||
// 非macOS系统且监听器开启时
|
// 监听器开启时
|
||||||
window.listener.on('change', () => {
|
window.listener.on('change', () => {
|
||||||
list.value = window.db.dataBase.data
|
list.value = window.db.dataBase.data
|
||||||
updateShowList(activeTab.value)
|
updateShowList(activeTab.value)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// macOS或监听器启动失败时
|
// 监听器启动失败时
|
||||||
let prev = {}
|
let prev = {}
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const now = window.db.dataBase.data[0]
|
const now = window.db.dataBase.data[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user