Skip to content

Commit

Permalink
Opti. feed列表添加通知项
Browse files Browse the repository at this point in the history
  • Loading branch information
RavelloH committed Nov 23, 2024
1 parent 951f2a8 commit e3108bd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
43 changes: 22 additions & 21 deletions src/assets/js/i18n.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Image from 'next/image.js';

import FooterIcon from '../../components/FooterIcon.jsx';
import message from '@/utils/message.js';
import notice from '@/utils/notice.js';

const collator = new Intl.Collator('zh-Hans-CN', {
numeric: true,
Expand Down Expand Up @@ -186,8 +187,7 @@ function structureInfobarShare() {
this.parentNode,
)
}
className='i ri-file-copy-2-fill'
></span>
className='i ri-file-copy-2-fill'></span>
</span>
</div>
</div>
Expand All @@ -203,8 +203,7 @@ function structureInfobarShare() {
this.parentNode,
)
}
className='i ri-file-copy-2-fill'
></span>
className='i ri-file-copy-2-fill'></span>
</span>
</div>
</div>
Expand Down Expand Up @@ -297,15 +296,13 @@ function getstructureMusicSearchResult(name, url, artist, pic, album) {
data-album={album}
data-url={url}
data-artist={artist}
data-pic={pic}
></span>
data-pic={pic}></span>
</span>
<span
className='i ri-play-fill'
onClick={() => {
global.musicChange(`${name} - ${artist}`, url);
}}
></span>
}}></span>
</div>
</div>
<hr />
Expand All @@ -331,8 +328,7 @@ function structureMusicExport(e) {
album +
'</span>'
}
src={pic}
>
src={pic}>
{name}
</a>
);
Expand All @@ -344,8 +340,7 @@ function getMailFeedbackButton() {
href={
'mailto:ravelloh@outlook.com?subject=[错误反馈]网站资源错误&body=错误地址:' +
window.location.pathname
}
>
}>
邮件反馈
</a>
);
Expand Down Expand Up @@ -442,8 +437,7 @@ function structureShareInput(id, path) {
this.parentNode,
);
}}
className='i ri-file-copy-2-fill'
></span>
className='i ri-file-copy-2-fill'></span>
</span>
</div>
</div>
Expand Down Expand Up @@ -763,19 +757,26 @@ function structureInfobarFeed() {
return (
<>
<div className='full' id='feed-list'>
<a href={config.siteURL+"feed.xml"} className='no-effect' target='_blank'>
<a href={config.siteURL + 'feed.xml'} className='no-effect' target='_blank'>
<div>
<span className='i ri-rss-fill'></span> <span>RSS</span>
</div>
</a>
<a href={config.siteURL+"sitemap.xml"} className='no-effect' target='_blank'>
<a href={config.siteURL + 'sitemap.xml'} className='no-effect' target='_blank'>
<div>
<span className='i ri-road-map-fill'></span> <span>Sitemap</span>
</div>
</a>
<a onClick={()=>{addToFavorites(config.siteURL)}} className='no-effect' target='_blank'>
<a
onClick={() => {
if (!notice.check()) {
notice.request();
}
}}
className='no-effect'
target='_blank'>
<div>
<span className='i ri-star-fill'></span> <span>收藏本站</span>
<span className='i ri-notification-2-fill'></span> <span>启用通知</span>
</div>
</a>
</div>
Expand All @@ -800,9 +801,9 @@ function addToFavorites() {
window.external.addFavorite(url, title);
} catch (e) {
try {
window.sidebar.addPanel(title, url, "");
window.sidebar.addPanel(title, url, '');
} catch (e) {
message.error("请使用Ctrl+D添加到收藏夹");
message.error('请使用Ctrl+D添加到收藏夹');
}
}
}
Expand Down Expand Up @@ -860,4 +861,4 @@ const i18nModule = {
structureUptime,
};

export default i18nModule;
export default i18nModule;
4 changes: 2 additions & 2 deletions src/utils/notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const notice = {
request: () => {
Notification.requestPermission().then((permission) => {
if (permission === 'granted') {
this.send('通知', '通知功能已成功开启', '/icon/512x');
notice.send('通知开启成功', '通知功能已成功开启,可在设置中随时关闭', '/icon/512x');
} else {
return false;
}
});
},
send: (title, body, icon) => {
send: (title, body, icon = "/icon/512x") => {
const options = {
body: body,
icon: icon,
Expand Down

0 comments on commit e3108bd

Please sign in to comment.