Improve toast

This commit is contained in:
the1812 2018-09-25 20:51:31 +08:00
parent 36310e7c8f
commit 06adc135d2
9 changed files with 28 additions and 17 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{return(t,e)=>{const s={less:-1,equal:0,greater:1,incomparable:NaN};class r{constructor(t){this.parts=t.split(".");this.versionString=t}isPositiveInteger(t){return/^\d+$/.test(t)}validateParts(){for(var t=0;t<this.parts.length;++t){if(!this.isPositiveInteger(this.parts[t])){return false}}return true}compareTo(t){if(!this.validateParts()||!t.validateParts()){return s.incomparable}for(let e=0;e<this.parts.length;++e){if(t.parts.length===e){return s.greater}if(this.parts[e]===t.parts[e]){continue}if(this.parts[e]>t.parts[e]){return s.greater}return s.less}if(this.parts.length!==t.parts.length){return s.less}return s.equal}greaterThan(t){return this.compareTo(t)===s.greater}lessThan(t){return this.compareTo(t)===s.less}equals(t){return this.compareTo(t)===s.equal}}const n=new r(e.data.latestVersion.text);const a=new r(t.currentVersion);if(n.greaterThan(a)){SpinQuery.any(()=>$(".gui-settings"),e=>{e.addClass("gui-settings-notification");const s=$(".gui-settings-footer");const r=`新版本${n.versionString}已发布.`;s.after(`\n <div class="gui-settings-footer">\n <span class="gui-settings-label">${r}</span>\n <a>\n <button\n class="gui-settings-button"\n id="new-version-update">\n 更新\n </button>\n </a>\n </div>`);$("#new-version-update").parent().attr("href",t.latestVersionLink);Toast.show(r,"检查更新",1e4)})}return{ajaxReload:false}}})(); (()=>{return(t,e)=>{const s={less:-1,equal:0,greater:1,incomparable:NaN};class r{constructor(t){this.parts=t.split(".");this.versionString=t}isPositiveInteger(t){return/^\d+$/.test(t)}validateParts(){for(var t=0;t<this.parts.length;++t){if(!this.isPositiveInteger(this.parts[t])){return false}}return true}compareTo(t){if(!this.validateParts()||!t.validateParts()){return s.incomparable}for(let e=0;e<this.parts.length;++e){if(t.parts.length===e){return s.greater}if(this.parts[e]===t.parts[e]){continue}if(this.parts[e]>t.parts[e]){return s.greater}return s.less}if(this.parts.length!==t.parts.length){return s.less}return s.equal}greaterThan(t){return this.compareTo(t)===s.greater}lessThan(t){return this.compareTo(t)===s.less}equals(t){return this.compareTo(t)===s.equal}}const n=new r(e.data.latestVersion.text);const a=new r(t.currentVersion);if(n.greaterThan(a)){SpinQuery.any(()=>$(".gui-settings"),s=>{s.addClass("gui-settings-notification");const r=$(".gui-settings-footer");r.after(`\n <div class="gui-settings-footer">\n <span class="gui-settings-label">${e}</span>\n <a>\n <button\n class="gui-settings-button"\n id="new-version-update">\n 更新\n </button>\n </a>\n </div>`);$("#new-version-update").parent().attr("href",t.latestVersionLink)});const e=`新版本${n.versionString}已发布. <a class="link" href="${t.latestVersionLink}">更新</a>`;Toast.show(e,"检查更新",1e4)}return{ajaxReload:false}}})();

View File

@ -1 +1 @@
.toast-card-container{position:fixed;left:16px;bottom:16px;display:flex;flex-direction:column;align-items:start;z-index:99999;}.toast-card{background:#444;min-width:240px;border-radius:8px;box-shadow:0 1px 20px rgba(0,0,0,.1);height:0;transition:all 0.3s cubic-bezier(0.18,0.89,0.32,1.28);transform:translateY(16px);transform-origin:bottom;opacity:0;overflow:hidden;display:flex;flex-direction:column;}.toast-card.visible{height:96px;transform:scale(1) translateY(0);opacity:0.95;margin-top:16px;}.toast-card-header{display:flex;align-items:center;}.toast-card-title{font-size:18px;color:#fff6;margin:16px;font-weight:bold;flex:1 1 auto;}svg.toast-card-dismiss{height:24px;width:24px;flex:0 0 auto;padding:16px;cursor:pointer;-webkit-tap-highlight-color:transparent;}svg.toast-card-dismiss path{fill:#fff6;}.toast-card-message{color:#eeed;font-size:14px;margin:16px;margin-top:0;}.toast-card.toast-default{background:#444;}.toast-card.toast-error{background:#652020;}.toast-card.toast-info{background:#303d61;}.toast-card.toast-success{background:#274227;} .toast-card-container{position:fixed;left:16px;bottom:16px;display:flex;flex-direction:column;align-items:start;z-index:99999;}.toast-card{background:#444;min-width:240px;border-radius:8px;box-shadow:0 1px 20px rgba(0,0,0,.1);height:0;transition:all 0.3s cubic-bezier(0.18,0.89,0.32,1.28);transform:translateY(16px);transform-origin:bottom;opacity:0;overflow:hidden;display:flex;flex-direction:column;}.toast-card.visible{height:96px;transform:scale(1) translateY(0);opacity:0.95;margin-top:16px;}.toast-card-header{display:flex;align-items:center;}.toast-card-title{font-size:18px;color:#fff6;margin:16px;font-weight:bold;flex:1 1 auto;}svg.toast-card-dismiss{height:24px;width:24px;flex:0 0 auto;padding:16px;cursor:pointer;-webkit-tap-highlight-color:transparent;}svg.toast-card-dismiss path{fill:#fff6;}.toast-card-message{color:#eeed;font-size:14px;margin:16px;margin-top:0;}.toast-card.toast-default{background:#444;}.toast-card.toast-error{background:#652020;}.toast-card.toast-info{background:#303d61;}.toast-card.toast-success{background:#274227;}.toast-card .link{display:inline-block;padding:4px 8px;background-color:rgba(0,0,0,.1);border-radius:4px;}

View File

@ -160,7 +160,8 @@ body>div.to-top.on,
.box .content .item, .box .content .item,
.uploader-info .info .follow .num, .uploader-info .info .follow .num,
.video-list-wrapper .title .text .num, .video-list-wrapper .title .text .num,
.danmu-hot .tab-list .tab .danmu-hot .tab-list .tab,
.rank-item .content .info .bangumi-info
{ {
color: #aaa !important; color: #aaa !important;
} }
@ -518,7 +519,8 @@ body>div.to-top.on
.video-list-wrapper .video-list .icon-font:hover, .video-list-wrapper .video-list .icon-font:hover,
.danmu-hot .tab-list .tab.active, .danmu-hot .tab-list .tab.active,
.danmu-hot .video-list .video-wrapper .video:hover .title, .danmu-hot .video-list .video-wrapper .video:hover .title,
.rank-item .content .info .title:hover .rank-item .content .info .title:hover,
.rank-item .content .info .bangumi-num
{ {
color: $customStyleColor !important; color: $customStyleColor !important;
} }

View File

@ -4203,7 +4203,8 @@ body>div.to-top.on,
.box .content .item, .box .content .item,
.uploader-info .info .follow .num, .uploader-info .info .follow .num,
.video-list-wrapper .title .text .num, .video-list-wrapper .title .text .num,
.danmu-hot .tab-list .tab .danmu-hot .tab-list .tab,
.rank-item .content .info .bangumi-info
{ {
color: #aaa !important; color: #aaa !important;
} }
@ -4561,7 +4562,8 @@ body>div.to-top.on
.video-list-wrapper .video-list .icon-font:hover, .video-list-wrapper .video-list .icon-font:hover,
.danmu-hot .tab-list .tab.active, .danmu-hot .tab-list .tab.active,
.danmu-hot .video-list .video-wrapper .video:hover .title, .danmu-hot .video-list .video-wrapper .video:hover .title,
.rank-item .content .info .title:hover .rank-item .content .info .title:hover,
.rank-item .content .info .bangumi-num
{ {
color: $customStyleColor !important; color: $customStyleColor !important;
} }

View File

@ -77,4 +77,11 @@ svg.toast-card-dismiss path
.toast-card.toast-success .toast-card.toast-success
{ {
background: #274227; background: #274227;
}
.toast-card .link
{
display: inline-block;
padding: 4px 8px;
background-color: rgba(0,0,0,.1);
border-radius: 4px;
} }

View File

@ -82,7 +82,6 @@
{ {
it.addClass("gui-settings-notification"); it.addClass("gui-settings-notification");
const footer = $(".gui-settings-footer"); const footer = $(".gui-settings-footer");
const message = `新版本${latestVersion.versionString}已发布.`;
footer.after(` footer.after(`
<div class="gui-settings-footer"> <div class="gui-settings-footer">
<span class="gui-settings-label">${message}</span> <span class="gui-settings-label">${message}</span>
@ -95,8 +94,9 @@
</a> </a>
</div>`); </div>`);
$("#new-version-update").parent().attr("href", settings.latestVersionLink); $("#new-version-update").parent().attr("href", settings.latestVersionLink);
Toast.show(message, "检查更新", 10000);
}); });
const message = `新版本${latestVersion.versionString}已发布. <a class="link" href="${settings.latestVersionLink}">更新</a>`;
Toast.show(message, "检查更新", 10000);
} }
return { return {