mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 02:20:19 +08:00
feat(core): bettery save mode (#12996)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced a battery save mode that can pause background sync and processing to conserve energy. * Battery save mode is automatically enabled when the app window loses focus and disabled when the window regains focus or is interacted with. * Available in both web and desktop (Electron) versions. * **Improvements** * Added user activity detection to optimize background operations for better battery efficiency. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -46,6 +46,15 @@ export function setupStoreManager(framework: Framework) {
|
||||
window.addEventListener('beforeunload', () => {
|
||||
storeManagerClient.dispose();
|
||||
});
|
||||
window.addEventListener('focus', () => {
|
||||
storeManagerClient.disableBatterySaveMode();
|
||||
});
|
||||
window.addEventListener('click', () => {
|
||||
storeManagerClient.disableBatterySaveMode();
|
||||
});
|
||||
window.addEventListener('blur', () => {
|
||||
storeManagerClient.enableBatterySaveMode();
|
||||
});
|
||||
|
||||
framework.impl(NbstoreProvider, {
|
||||
openStore(key, options) {
|
||||
|
||||
Reference in New Issue
Block a user