Created
May 29, 2020 09:04
-
-
Save languanghao/d1b9fd7bc0fbbd44fecb359b13fcce8c to your computer and use it in GitHub Desktop.
AddApiEventListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onWindowActive = () => { | |
}; | |
window.onDocumentSave = () => { | |
}; | |
window.onDocumentBeforeClose = () => { | |
}; | |
window.onDocumentAfterClose = () => { | |
}; | |
window.onDocumentBeforePrint = () => { | |
}; | |
window.onDocumentOpen = () => { | |
}; | |
window.onDocumentNew = () => { | |
alert(333); | |
}; | |
const EVENT_MAP = { | |
WindowActivate: window.onWindowActive, | |
DocumentBeforeSave: window.onDocumentSave, | |
DocumentBeforeClose: window.onDocumentBeforeClose, | |
DocumentAfterClose: window.onDocumentAfterClose, | |
DocumentBeforePrint: window.onDocumentBeforePrint, | |
DocumentOpen: window.onDocumentOpen, | |
DocumentNew: window.onDocumentNew, | |
}; | |
export const registerDocumentEvents = () => { | |
for (const [key, value] of Object.entries(EVENT_MAP)) { | |
console.log(`注册事件: ${key}`); | |
wps.ApiEvent.AddApiEventListener(key, value); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment