mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Improve messages
This commit is contained in:
parent
89db59e600
commit
ed2645d254
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
min/custom-navbar.min.css
vendored
2
min/custom-navbar.min.css
vendored
File diff suppressed because one or more lines are too long
2
min/custom-navbar.min.js
vendored
2
min/custom-navbar.min.js
vendored
File diff suppressed because one or more lines are too long
@ -205,16 +205,18 @@
|
||||
transform: scaleX(1);
|
||||
}
|
||||
#custom-navbar-home-popup .category-item .popup a,
|
||||
#upload-actions a
|
||||
#upload-actions a,
|
||||
#message-list a
|
||||
{
|
||||
padding: 8px 16px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
justify-content: start;
|
||||
border-bottom: 2px solid transparent;
|
||||
font-size: 11pt;
|
||||
}
|
||||
#custom-navbar-home-popup .category-item .popup a:hover,
|
||||
#upload-actions a:hover
|
||||
#upload-actions a:hover,
|
||||
#message-list a:hover
|
||||
{
|
||||
border-bottom: 2px solid var(--theme-color);
|
||||
}
|
||||
@ -238,7 +240,8 @@ li.nav-item[report-id='playpage_dynamic'] .i-frame,
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
#upload-actions
|
||||
#upload-actions,
|
||||
#message-list
|
||||
{
|
||||
width: max-content;
|
||||
}
|
||||
@ -576,6 +579,24 @@ li.nav-item[report-id='playpage_dynamic'] .i-frame,
|
||||
{
|
||||
opacity: 1;
|
||||
}
|
||||
#message-list a
|
||||
{
|
||||
position: relative;
|
||||
}
|
||||
#message-list a[data-count]::after
|
||||
{
|
||||
content: attr(data-count);
|
||||
position: absolute;
|
||||
left: 100%;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background-color: var(--theme-color);
|
||||
padding: 0 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 11pt;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 1400px)
|
||||
|
||||
@ -81,11 +81,11 @@ class Upload extends NavbarComponent
|
||||
<div id="upload-button">投稿</div>`;
|
||||
this.popupHtml = /*html*/`
|
||||
<ul id="upload-actions">
|
||||
<li><a href="https://member.bilibili.com/v2#/upload/text/apply">专栏投稿</a></li>
|
||||
<li><a href="https://member.bilibili.com/v2#/upload/audio/">音频投稿</a></li>
|
||||
<li><a href="https://member.bilibili.com/v2#/upload/video/frame">视频投稿</a></li>
|
||||
<li><a href="https://member.bilibili.com/v2#/upload-manager/article">投稿管理</a></li>
|
||||
<li><a href="https://member.bilibili.com/v2#/home">创作中心</a></li>
|
||||
<li><a target="_blank" href="https://member.bilibili.com/v2#/upload/text/apply">专栏投稿</a></li>
|
||||
<li><a target="_blank" href="https://member.bilibili.com/v2#/upload/audio/">音频投稿</a></li>
|
||||
<li><a target="_blank" href="https://member.bilibili.com/v2#/upload/video/frame">视频投稿</a></li>
|
||||
<li><a target="_blank" href="https://member.bilibili.com/v2#/upload-manager/article">投稿管理</a></li>
|
||||
<li><a target="_blank" href="https://member.bilibili.com/v2#/home">创作中心</a></li>
|
||||
</ul>
|
||||
`;
|
||||
}
|
||||
@ -94,6 +94,66 @@ class Upload extends NavbarComponent
|
||||
return "投稿";
|
||||
}
|
||||
}
|
||||
class Messages extends NavbarComponent
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this.href = "https://message.bilibili.com/";
|
||||
this.html = "消息";
|
||||
this.popupHtml = /*html*/`
|
||||
<ul id="message-list">
|
||||
<li><a data-name="reply_me" target="_blank" href="https://message.bilibili.com/#/reply">回复我的</a></li>
|
||||
<li><a data-name="at_me" target="_blank" href="https://message.bilibili.com/#/at">@我的</a></li>
|
||||
<li><a data-name="praise_me" target="_blank" href="https://message.bilibili.com/#/love">收到的赞</a></li>
|
||||
<li><a data-name="notify_me" target="_blank" href="https://message.bilibili.com/#/system">系统通知</a></li>
|
||||
</ul>
|
||||
`;
|
||||
this.requestedPopup = true;
|
||||
this.init();
|
||||
}
|
||||
async init()
|
||||
{
|
||||
const json = await Ajax.getJsonWithCredentials("https://message.bilibili.com/api/notify/query.notify.count.do");
|
||||
const list = await SpinQuery.select("#message-list");
|
||||
const items = [...list.querySelectorAll("a[data-name]")];
|
||||
const names = items.map(it => it.getAttribute("data-name"));
|
||||
|
||||
if (json.code !== 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const notifyElement = await SpinQuery.select(`.custom-navbar li[data-name='${this.name}'] .notify-count`);
|
||||
let totalCount = names.reduce((acc, it) => acc + json.data[it], 0);
|
||||
if (totalCount === 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
notifyElement.innerHTML = totalCount;
|
||||
names.forEach((name, index) =>
|
||||
{
|
||||
const count = json.data[name];
|
||||
if (count > 0)
|
||||
{
|
||||
items[index].setAttribute("data-count", count);
|
||||
}
|
||||
else
|
||||
{
|
||||
items[index].removeAttribute("data-count");
|
||||
}
|
||||
});
|
||||
items.forEach(item =>
|
||||
{
|
||||
item.addEventListener("click", () =>
|
||||
{
|
||||
const count = item.getAttribute("data-count");
|
||||
item.removeAttribute("data-count");
|
||||
totalCount -= count;
|
||||
notifyElement.innerHTML = totalCount || "";
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
class Category extends NavbarComponent
|
||||
{
|
||||
constructor()
|
||||
@ -493,26 +553,26 @@ class Activities extends NotifyIframe
|
||||
return json.data.update_num;
|
||||
}
|
||||
}
|
||||
class Messages extends NotifyIframe
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super("消息", "https://message.bilibili.com/", {
|
||||
src: `https://message.bilibili.com/pages/nav/index`,
|
||||
width: `110px`,
|
||||
height: `210px`,
|
||||
lazy: false,
|
||||
});
|
||||
}
|
||||
getApiUrl()
|
||||
{
|
||||
return "https://message.bilibili.com/api/notify/query.notify.count.do";
|
||||
}
|
||||
getCount(json)
|
||||
{
|
||||
return Object.values(json.data).reduce((a, b) => a + b, 0);
|
||||
}
|
||||
}
|
||||
// class Messages extends NotifyIframe
|
||||
// {
|
||||
// constructor()
|
||||
// {
|
||||
// super("消息", "https://message.bilibili.com/", {
|
||||
// src: `https://message.bilibili.com/pages/nav/index`,
|
||||
// width: `110px`,
|
||||
// height: `210px`,
|
||||
// lazy: false,
|
||||
// });
|
||||
// }
|
||||
// getApiUrl()
|
||||
// {
|
||||
// return "https://message.bilibili.com/api/notify/query.notify.count.do";
|
||||
// }
|
||||
// getCount(json)
|
||||
// {
|
||||
// return Object.values(json.data).reduce((a, b) => a + b, 0);
|
||||
// }
|
||||
// }
|
||||
class VideoList extends NavbarComponent
|
||||
{
|
||||
constructor({ mainUrl, name, apiUrl, listName, listMap })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user