lockScreen.js 920 B

12345678910111213141516171819202122232425262728293031323334
  1. // lockScreen.js
  2. (function() {
  3. // 始终使用顶层窗口的命名空间
  4. var targetWindow = window.top || window;
  5. targetWindow.SS = targetWindow.SS || {};
  6. targetWindow.SS.lockScreenService = {
  7. _homeInstance: null,
  8. init(homeInstance) {
  9. this._homeInstance = homeInstance;
  10. },
  11. get isLocked() {
  12. return this._homeInstance?.isLockScreen || false;
  13. },
  14. async lock() {
  15. if(!this._homeInstance) {
  16. console.error('LockScreenService: home instance not initialized');
  17. return;
  18. }
  19. return this._homeInstance.lockScreenFun();
  20. },
  21. async unlock(password) {
  22. if(!this._homeInstance) {
  23. console.error('LockScreenService: home instance not initialized');
  24. return;
  25. }
  26. return this._homeInstance.unlockSessionByPassword(password);
  27. }
  28. };
  29. })();