Commit 485212a1 authored by 崔佳豪's avatar 崔佳豪

fix: 切换站点重新加载订阅消息铃铛

parent bb2b5beb
...@@ -36,6 +36,10 @@ class NoticeIconView extends Component { ...@@ -36,6 +36,10 @@ class NoticeIconView extends Component {
videoMessage: {}, videoMessage: {},
}; };
// this.renderPlatform // this.renderPlatform
try {
window.share && window.share.event && window.share.event.removeAllListeners('reloadNotice');
} catch (error) {
}
this.notifier = new Notifier( this.notifier = new Notifier(
this.props.global.userInfo, this.props.global.userInfo,
this.renderVideo, this.renderVideo,
...@@ -48,6 +52,24 @@ class NoticeIconView extends Component { ...@@ -48,6 +52,24 @@ class NoticeIconView extends Component {
async componentDidMount() { async componentDidMount() {
this.notifier.subscribe(NEW_MESSAGE, this.onNewMessage.bind(this)); this.notifier.subscribe(NEW_MESSAGE, this.onNewMessage.bind(this));
this.notifier.start(); this.notifier.start();
window.share && window.share.event && window.share.event.on('reloadNotice', () => {
try {
// eslint-disable-next-line no-unused-expressions
this.notifier && this.notifier.stop();
} catch (error) {
// eslint-disable-next-line no-empty
} finally {
this.notifier = new Notifier(
this.props.global.userInfo,
this.renderVideo,
this.renderPlatform,
this.renderSysPlatform,
this.props,
);
this.notifier.subscribe(NEW_MESSAGE, this.onNewMessage.bind(this));
this.notifier.start();
}
});
} }
componentWillUnmount() { componentWillUnmount() {
...@@ -57,6 +79,7 @@ class NoticeIconView extends Component { ...@@ -57,6 +79,7 @@ class NoticeIconView extends Component {
} catch (error) { } catch (error) {
// eslint-disable-next-line no-empty // eslint-disable-next-line no-empty
} finally { } finally {
window.share.event.removeAllListeners('reloadNotice');
} }
} }
......
...@@ -350,13 +350,16 @@ class Site { ...@@ -350,13 +350,16 @@ class Site {
? self.globalConfig.homepage.startsWith(homeType) ? self.globalConfig.homepage.startsWith(homeType)
? self.globalConfig.homepage ? self.globalConfig.homepage
: `/${homeType}/${self.globalConfig.homepage}` : `/${homeType}/${self.globalConfig.homepage}`
: `/homeType`; : `/${homeType}`;
window.share && window.share.event && window.share.event.emit('event:favitor', { window.share && window.share.event && window.share.event.emit('event:favitor', {
name: "首页", name: "首页",
path: homePath, path: homePath,
icon: null, icon: null,
}); });
// 重新加载订阅消息铃铛
window.share && window.share.event && window.share.event.emit('reloadNotice');
// window.history.replaceState( // window.history.replaceState(
// '', // '',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment