CustomPage.js 758 B

1234567891011121314151617181920212223242526
  1. import themeMixin from './behaviors/theme'
  2. const CustomPage = function (options) {
  3. return Page(
  4. Object.assign({}, options, {
  5. behaviors: [themeMixin].concat(options.behaviors || []),
  6. onLoad(query) {
  7. const app = getApp()
  8. if (this.themeChanged) {
  9. this.themeChanged(app.globalData.theme)
  10. app.watchThemeChange && app.watchThemeChange(this.themeChanged)
  11. options.onLoad && options.onLoad.call(this, query)
  12. }
  13. },
  14. onUnload() {
  15. const app = getApp()
  16. if (this.themeChanged) {
  17. app.unWatchThemeChange && app.unWatchThemeChange(this.themeChanged)
  18. options.onUnload && options.onUnload.call(this)
  19. }
  20. }
  21. })
  22. )
  23. }
  24. export default CustomPage