1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 19:29:56 +00:00

Merge pull request #5880 from haiwen/update-favicon

update-favicon
This commit is contained in:
杨顺强
2024-01-06 15:48:57 +08:00
committed by GitHub
4 changed files with 28 additions and 6 deletions

View File

@@ -14,7 +14,8 @@ const propTypes = {
docPerm: PropTypes.string.isRequired, docPerm: PropTypes.string.isRequired,
isStarred: PropTypes.bool.isRequired, isStarred: PropTypes.bool.isRequired,
toggleStar: PropTypes.func.isRequired, toggleStar: PropTypes.func.isRequired,
unmarkDraft: PropTypes.func.isRequired unmarkDraft: PropTypes.func.isRequired,
onNewNotification: PropTypes.func.isRequired
}; };
class ExternalOperations extends React.Component { class ExternalOperations extends React.Component {
@@ -34,8 +35,9 @@ class ExternalOperations extends React.Component {
this.unsubscribeStar = eventBus.subscribe(EXTERNAL_EVENT.TOGGLE_STAR, this.toggleStar); this.unsubscribeStar = eventBus.subscribe(EXTERNAL_EVENT.TOGGLE_STAR, this.toggleStar);
this.unsubscribeUnmark = eventBus.subscribe(EXTERNAL_EVENT.UNMARK_AS_DRAFT, this.unmark); this.unsubscribeUnmark = eventBus.subscribe(EXTERNAL_EVENT.UNMARK_AS_DRAFT, this.unmark);
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.SHARE_SDOC, this.onShareToggle); this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.SHARE_SDOC, this.onShareToggle);
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.FREEZE_DOCUMENT, this.onFreezeDocument); this.unsubscribeFreezeDocument = eventBus.subscribe(EXTERNAL_EVENT.FREEZE_DOCUMENT, this.onFreezeDocument);
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.UNFREEZE, this.unFreeze); this.unsubscribeUnfreeze = eventBus.subscribe(EXTERNAL_EVENT.UNFREEZE, this.unFreeze);
this.unsubscribeNewNotification = eventBus.subscribe(EXTERNAL_EVENT.NEW_NOTIFICATION, this.onNewNotification);
} }
componentWillUnmount() { componentWillUnmount() {
@@ -43,6 +45,9 @@ class ExternalOperations extends React.Component {
this.unsubscribeStar(); this.unsubscribeStar();
this.unsubscribeUnmark(); this.unsubscribeUnmark();
this.unsubscribeShare(); this.unsubscribeShare();
this.unsubscribeFreezeDocument();
this.unsubscribeUnfreeze();
this.unsubscribeNewNotification();
} }
onInternalLinkToggle = (options) => { onInternalLinkToggle = (options) => {
@@ -107,6 +112,10 @@ class ExternalOperations extends React.Component {
}); });
}; };
onNewNotification = () => {
this.props.onNewNotification();
};
render() { render() {
const { repoID, docPath, docName, docPerm } = this.props; const { repoID, docPath, docName, docPerm } = this.props;
const { isShowInternalLinkDialog, isShowShareDialog, internalLink } = this.state; const { isShowInternalLinkDialog, isShowShareDialog, internalLink } = this.state;

View File

@@ -15,9 +15,7 @@ export default class SdocEditor extends React.Component {
} }
componentDidMount() { componentDidMount() {
const { docName } = window.seafile; this.onSetFavicon();
const fileIcon = Utils.getFileIconUrl(docName, 192);
document.getElementById('favicon').href = fileIcon;
} }
toggleStar = (isStarred) => { toggleStar = (isStarred) => {
@@ -28,6 +26,19 @@ export default class SdocEditor extends React.Component {
this.setState({isDraft: false}); this.setState({isDraft: false});
}; };
onSetFavicon = (suffix) => {
let { docName } = window.seafile;
if (suffix) {
docName = docName + suffix;
}
const fileIcon = Utils.getFileIconUrl(docName, 192);
document.getElementById('favicon').href = fileIcon;
};
onNewNotification = () => {
this.onSetFavicon('_notification');
};
render() { render() {
const { repoID, docPath, docName, docPerm } = window.seafile; const { repoID, docPath, docName, docPerm } = window.seafile;
const { isStarred, isDraft } = this.state; const { isStarred, isDraft } = this.state;
@@ -42,6 +53,7 @@ export default class SdocEditor extends React.Component {
isStarred={isStarred} isStarred={isStarred}
toggleStar={this.toggleStar} toggleStar={this.toggleStar}
unmarkDraft={this.unmarkDraft} unmarkDraft={this.unmarkDraft}
onNewNotification={this.onNewNotification}
/> />
</Fragment> </Fragment>
); );

View File

@@ -106,6 +106,7 @@ export const Utils = {
// default // default
'default' : 'file.png', 'default' : 'file.png',
'sdoc': 'sdoc.png', 'sdoc': 'sdoc.png',
'sdoc_notification': 'sdoc_notification.ico'
}, },
// check if a file is an image // check if a file is an image

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB