mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add user info
This commit is contained in:
parent
fca24029b4
commit
573b522a02
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
@ -1 +1 @@
|
||||
@font-face{font-family:custom-navbar-font;src:url(//s1.hdslb.com/bfs/seed/jinkela/header/asserts/iconfont.ttf) format('truetype')}.custom-navbar-iconfont{color:inherit;font-family:custom-navbar-font!important;font-size:24px;font-style:normal}.custom-navbar-icon-logo::before{content:"\\E725"}.custom-navbar{--navbar-height:50px;--navbar-foreground:black;--navbar-background:white;position:absolute;top:0;left:0;height:var(--navbar-height);width:100%;background-color:var(--navbar-background);color:var(--navbar-foreground);z-index:10001}.custom-navbar:not(.fill) .custom-navbar-iconfont{color:var(--theme-color)}.custom-navbar path{fill:#000}.custom-navbar.dark:not(.fill) path{fill:#eee}.custom-navbar.fill path{fill:#fffd}.custom-navbar.shadow{box-shadow:#0004 0 2px 10px 1px}.custom-navbar.dark:not(.fill){--navbar-background:#222;--navbar-foreground:#eee}.custom-navbar,.custom-navbar *{transition:.2s ease-out}.custom-navbar.fill{--navbar-background:var(--theme-color);--navbar-foreground:#fffd}.custom-navbar.fill.shadow{box-shadow:var(--theme-color-30) 0 2px 10px 1px}.custom-navbar>ul{display:flex;align-items:center;justify-content:space-between;margin:0 5%;height:100%}.custom-navbar ul{list-style:none}.custom-navbar>ul>li{position:relative;height:100%;display:flex;align-items:center}.custom-navbar>ul>li:not(.disabled){cursor:pointer}.custom-navbar>ul>li:not(.disabled):hover{background:rgba(0,0,0,.1)}.custom-navbar .main-content{font-size:10pt;height:100%;display:flex;align-items:center;padding:0 16px}.custom-navbar .popup{color:#eee;background:#222;position:absolute;top:100%;left:50%;padding:16px;box-shadow:#0002 0 4px 8px 8px;pointer-events:none;opacity:0;transform:translateX(-50%)}.custom-navbar .popup.no-padding{padding:0}#custom-navbar-home-popup .category-item:hover .popup,.custom-navbar>ul>li:not(.disabled):hover>.popup{pointer-events:initial;opacity:1}.custom-navbar a,.custom-navbar a:hover{color:inherit}#custom-navbar-home-popup{max-height:50vh;display:flex;flex-direction:column;flex-wrap:wrap;width:300px}#custom-navbar-home-popup .category-item{font-size:12pt;padding:8px 16px;cursor:pointer;position:relative}#custom-navbar-home-popup .category-item:hover{background-color:#0001}#custom-navbar-home-popup .category-item a{display:flex;justify-content:space-between}#custom-navbar-home-popup .category-item .popup{z-index:10002;width:max-content}#custom-navbar-home-popup .category-item .popup a,#upload-actions a{padding:8px 16px;display:flex;justify-content:center;border-bottom:2px solid transparent;font-size:11pt}#custom-navbar-home-popup .category-item .popup a:hover,#upload-actions a:hover{border-bottom:2px solid var(--theme-color)}#custom-navbar-home-popup .category-item span{opacity:.5}.im-list-box{border-radius:0!important}li.nav-item[report-id=playpage_dynamic] .i-frame,li.nav-item[report-id=playpage_dynamic] iframe{display:none!important}#upload-button{padding-left:4px;font-size:12pt;font-weight:700}#upload-actions{width:max-content}.custom-navbar form{height:100%;display:flex;align-items:center;position:relative;--submit-button-size:30px}.custom-navbar form input{border:none;height:60%;background:0 0;border-bottom:1.5px solid!important;color:var(--navbar-foreground);box-sizing:border-box;width:250px;padding-right:var(--submit-button-size);padding-left:4px}.custom-navbar form input:focus{border-bottom-color:var(--navbar-foreground)!important}.custom-navbar form button[type=submit]{background:0 0;border:none;padding:4px;cursor:pointer;height:var(--submit-button-size);width:var(--submit-button-size);position:absolute;right:0;top:50%;transform:translateY(-50%)}.custom-navbar form input[type=text]::placeholder{color:var(--navbar-foreground)!important;opacity:.9}
|
||||
@font-face{font-family:custom-navbar-font;src:url(//s1.hdslb.com/bfs/seed/jinkela/header/asserts/iconfont.ttf) format('truetype')}.custom-navbar-iconfont{color:inherit;font-family:custom-navbar-font!important;font-size:24px;font-style:normal}.custom-navbar-icon-logo::before{content:"\\E725"}.custom-navbar{--navbar-height:50px;--navbar-foreground:black;--navbar-background:white;position:absolute;top:0;left:0;height:var(--navbar-height);width:100%;background-color:var(--navbar-background);color:var(--navbar-foreground);z-index:10001}.custom-navbar:not(.fill) .custom-navbar-iconfont{color:var(--theme-color)}.custom-navbar path{fill:#000}.custom-navbar.dark:not(.fill) path{fill:#eee}.custom-navbar.fill path{fill:#fffd}.custom-navbar.shadow{box-shadow:#0004 0 2px 10px 1px}.custom-navbar.dark:not(.fill){--navbar-background:#222;--navbar-foreground:#eee}.custom-navbar,.custom-navbar *{transition:.2s ease-out}.custom-navbar.fill{--navbar-background:var(--theme-color);--navbar-foreground:#fffd}.custom-navbar.fill.shadow{box-shadow:var(--theme-color-30) 0 2px 10px 1px}.custom-navbar>ul{display:flex;align-items:center;justify-content:space-between;margin:0 5%;height:100%}.custom-navbar ul{list-style:none}.custom-navbar>ul>li{position:relative;height:100%;display:flex;align-items:center}.custom-navbar>ul>li:not(.disabled){cursor:pointer}.custom-navbar>ul>li:not(.disabled):hover{background:rgba(0,0,0,.1)}.custom-navbar .main-content{font-size:10pt;height:100%;display:flex;align-items:center;padding:0 16px}.custom-navbar .popup{color:#eee;background:#222;position:absolute;top:100%;left:50%;padding:16px;box-shadow:#0002 0 4px 8px 8px;pointer-events:none;opacity:0;transform:translateX(-50%)}.custom-navbar .popup.no-padding{padding:0}#custom-navbar-home-popup .category-item:hover .popup,.custom-navbar>ul>li:not(.disabled):hover>.popup{pointer-events:initial;opacity:1}.custom-navbar a,.custom-navbar a:hover{color:inherit}#custom-navbar-home-popup{max-height:50vh;display:flex;flex-direction:column;flex-wrap:wrap;width:300px}#custom-navbar-home-popup .category-item{font-size:12pt;padding:8px 16px;cursor:pointer;position:relative}#custom-navbar-home-popup .category-item:hover{background-color:#0001}#custom-navbar-home-popup .category-item a{display:flex;justify-content:space-between}#custom-navbar-home-popup .category-item .popup{z-index:10002;width:max-content}#custom-navbar-home-popup .category-item .popup a,#upload-actions a{padding:8px 16px;display:flex;justify-content:center;border-bottom:2px solid transparent;font-size:11pt}#custom-navbar-home-popup .category-item .popup a:hover,#upload-actions a:hover{border-bottom:2px solid var(--theme-color)}#custom-navbar-home-popup .category-item span{opacity:.5}.im-list-box{border-radius:0!important}li.nav-item[report-id=playpage_dynamic] .i-frame,li.nav-item[report-id=playpage_dynamic] iframe{display:none!important}#upload-button{padding-left:4px;font-size:12pt;font-weight:700}#upload-actions{width:max-content}.custom-navbar form{height:100%;display:flex;align-items:center;position:relative;--submit-button-size:30px}.custom-navbar form input{border:none;height:60%;background:0 0;border-bottom:1.5px solid!important;color:var(--navbar-foreground);box-sizing:border-box;width:250px;padding-right:var(--submit-button-size);padding-left:4px}.custom-navbar form input:focus{border-bottom-color:var(--navbar-foreground)!important}.custom-navbar form button[type=submit]{background:0 0;border:none;padding:4px;cursor:pointer;height:var(--submit-button-size);width:var(--submit-button-size);position:absolute;right:0;top:50%;transform:translateY(-50%)}.custom-navbar form input[type=text]::placeholder{color:var(--navbar-foreground)!important;opacity:.9}.user-face{background-color:var(--navbar-background);background-size:contain;border-radius:50%;height:calc(var(--navbar-height) - 16px);width:calc(var(--navbar-height) - 16px)}.user-info-panel{width:200px}.user-info-panel>*{display:flex;flex-direction:column;align-items:center;justify-content:space-between}.user-info-panel .row{display:flex;justify-content:space-between;align-items:center}.user-info-panel .name{font-size:16pt}.user-info-panel .type{padding:4px;background:var(--theme-color);color:var(--foreground-color)}.user-info-panel .coins::before{content:"硬币";color:var(--theme-color);margin-right:4px}.user-info-panel .b-coins::before{content:"B币";color:var(--theme-color);margin-right:4px}
|
||||
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
@ -245,4 +245,59 @@ li.nav-item[report-id='playpage_dynamic'] .i-frame
|
||||
{
|
||||
color: var(--navbar-foreground) !important;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.user-face
|
||||
{
|
||||
background-color: var(--navbar-background);
|
||||
background-size: contain;
|
||||
border-radius: 50%;
|
||||
height: calc(var(--navbar-height) - 16px);
|
||||
width: calc(var(--navbar-height) - 16px);
|
||||
}
|
||||
.user-info-panel
|
||||
{
|
||||
width: 200px;
|
||||
}
|
||||
.user-info-panel>*
|
||||
{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 300px;
|
||||
}
|
||||
.user-info-panel .row
|
||||
{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.user-info-panel .name
|
||||
{
|
||||
font-size: 14pt;
|
||||
}
|
||||
.user-info-panel .type
|
||||
{
|
||||
padding: 4px;
|
||||
background: var(--theme-color);
|
||||
color: var(--foreground-color);
|
||||
}
|
||||
.user-info-panel .coins,
|
||||
.user-info-panel .b-coins,
|
||||
.user-info-panel .verifications
|
||||
{
|
||||
display: flex;
|
||||
flex: 1 0 33.3%;
|
||||
}
|
||||
.user-info-panel .coins::before
|
||||
{
|
||||
content: "硬币";
|
||||
color: var(--theme-color);
|
||||
margin-right: 4px;
|
||||
}
|
||||
.user-info-panel .b-coins::before
|
||||
{
|
||||
content: "B币";
|
||||
color: var(--theme-color);
|
||||
margin-right: 4px;
|
||||
}
|
||||
@ -193,7 +193,77 @@ class Category extends NavbarComponent
|
||||
}
|
||||
class UserInfo extends NavbarComponent
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this.html = /*html*/`
|
||||
<div class="user-face"></div>
|
||||
`;
|
||||
this.popupHtml = /*html*/`
|
||||
<div class="user-info-panel">
|
||||
<div v-if="isLogin" class="logged-in">
|
||||
<span class="name">{{uname}}</span>
|
||||
<span class="type">{{userType}}</span>
|
||||
<div class="row">
|
||||
<span class="coins">{{money}}</span>
|
||||
<span class="b-coins">{{wallet.bcoin_balance}}</span>
|
||||
<div class="verifications">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="not-logged-in">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
this.requestedPopup = true;
|
||||
this.init();
|
||||
}
|
||||
async init()
|
||||
{
|
||||
const panel = await SpinQuery.select(".user-info-panel");
|
||||
const face = await SpinQuery.select(".user-face");
|
||||
const json = await Ajax.getJsonWithCredentials("https://api.bilibili.com/x/web-interface/nav");
|
||||
// if (json.code !== 0 || json.code !== -101)
|
||||
// {
|
||||
// logError("[自定义顶栏] 获取用户登录信息失败.");
|
||||
// return;
|
||||
// }
|
||||
const userInfo = json.data;
|
||||
face.style.backgroundImage = `url('${userInfo.face}')`;
|
||||
new Vue({
|
||||
el: panel,
|
||||
data: {
|
||||
...userInfo
|
||||
},
|
||||
computed: {
|
||||
userType()
|
||||
{
|
||||
if (!this.isLogin)
|
||||
{
|
||||
return "未登录";
|
||||
}
|
||||
if (this.level_info.current_level === 0)
|
||||
{
|
||||
return "注册会员";
|
||||
}
|
||||
if (this.vipStatus === 1)
|
||||
{
|
||||
if (this.vipType === 1)
|
||||
{
|
||||
return this.vip_theme_type ? "小会员" : "大会员";
|
||||
}
|
||||
else if (this.vipType === 2)
|
||||
{
|
||||
return this.vip_theme_type ? "年度小会员" : "年度大会员";
|
||||
}
|
||||
}
|
||||
return "正式会员";
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
class SearchBox extends NavbarComponent
|
||||
{
|
||||
@ -300,6 +370,7 @@ class Iframe extends NavbarComponent
|
||||
new SimpleLink("漫画", "https://manga.bilibili.com"),
|
||||
new Blank,
|
||||
new SearchBox,
|
||||
new UserInfo,
|
||||
new Iframe("消息", "https://message.bilibili.com/", {
|
||||
src: `https://message.bilibili.com/pages/nav/index`,
|
||||
width: `110px`,
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
"vipStatus": 1, // 1 - 大会员在有效期内 2 - 大会员已过期?
|
||||
"vipType": 2, // 1 - 大会员 2 - 年度大会员
|
||||
"vip_pay_type": 0, // ?
|
||||
"vip_theme_type": 0, // 小会员活动
|
||||
"vip_theme_type": 0, // 0 - 无活动 1 - 小会员活动
|
||||
"wallet": {
|
||||
"mid": 39717974,
|
||||
"bcoin_balance": 5, // B币余额
|
||||
|
||||
Loading…
Reference in New Issue
Block a user