Merge pull request #215 from mashirozx/issue-213

Issue #213
This commit is contained in:
Spirit 2020-04-09 15:12:09 +08:00 committed by GitHub
commit 0ddfcad236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 149 additions and 41 deletions

View File

@ -66,6 +66,7 @@
</div><!-- m-nav-center end -->
<a class="cd-top faa-float animated "></a>
<button id="moblieGoTop" title="Go to top"><i class="fa fa-chevron-up" aria-hidden="true"></i></button>
<button id="moblieDarkLight"><i class="fa fa-moon-o" aria-hidden="true"></i></button>
<!-- search start -->
<form class="js-search search-form search-form--modal" method="get" action="<?php echo home_url(); ?>" role="search">
<div class="search-form__inner">

View File

@ -666,6 +666,7 @@ function akina_body_classes($classes)
/*if(!wp_is_mobile()) {
$classes[] = 'serif';
}*/
$classes[] = $_COOKIE['dark'.akina_option('cookie_version', '')] == '1' ? 'dark' : ' ';
return $classes;
}
add_filter('body_class', 'akina_body_classes');

View File

@ -62,6 +62,7 @@ if (akina_option('akina_meta') == true) {
<meta name="keywords" content="<?php echo $keywords; ?>" />
<?php } ?>
<link rel="shortcut icon" href="<?php echo akina_option('favicon_link', ''); ?>"/>
<meta name="theme-color" content="#31363b">
<meta http-equiv="x-dns-prefetch-control" content="on">
<?php wp_head(); ?>
<script type="text/javascript">

View File

@ -214,7 +214,7 @@ function get_qq_avatar() {
}
function bgm_bilibili() {
if (!check_ajax_referer('wp_rest', 'r', false)) {
if (!check_ajax_referer('wp_rest', '_wpnonce', false)) {
$output = array(
'status' => 403,
'success' => false,
@ -233,7 +233,16 @@ function bgm_bilibili() {
function meting_aplayer() {
$type = $_GET['type'];
$id = $_GET['id'];
if (check_ajax_referer('wp_rest', '_wpnonce', false) || !wp_verify_nonce($_GET['meting_pnonce'], $type . '#:' . $id)) {
$wpnonce = $_GET['_wpnonce'];
$meting_pnonce = $_GET['meting_pnonce'];
if ((isset($wpnonce) && !check_ajax_referer('wp_rest', $wpnonce, false)) || (isset($nonce) && !wp_verify_nonce($nonce, $type . '#:' . $id))) {
$output = array(
'status' => 403,
'success' => false,
'message' => 'Unauthorized client.'
);
$response = new WP_REST_Response($output, 403);
} else {
$Meting_API = new \Sakura\API\Aplayer();
$data = $Meting_API->get_data($type, $id);
if ($type === 'playlist') {
@ -244,18 +253,10 @@ function meting_aplayer() {
$response->set_headers(array('cache-control' => 'max-age=3600'));
echo $data;
} else {
$data = str_replace('http://', 'https://', $data);
$response = new WP_REST_Response();
$response->set_status(301);
$response->header('Location', $data);
}
} else {
$output = array(
'status' => 403,
'success' => false,
'message' => 'Unauthorized client.'
);
$response = new WP_REST_Response($output, 403);
}
return $response;
}

View File

@ -27,6 +27,7 @@ class Aplayer
case 'song':
$data = $api->format(true)->song($id);
$data = json_decode($data, true)["url"];
$data = $this->song_url($data);
break;
// case 'album':
// $data = $api->format(true)->album($id);
@ -46,11 +47,12 @@ class Aplayer
break;
// case 'search':
// $data = $api->format(true)->search($id);
// $data=json_decode($data, true)["url"];
// $data=json_decode($data, true);
// break;
default:
$data = $api->format(true)->url($id);
$data = json_decode($data, true)["url"];
$data = $this->song_url($data);
break;
}
return $data;
@ -78,6 +80,24 @@ class Aplayer
return $playlist;
}
private function song_url($url){
$server = $this->server;
if ($server == 'netease') {
$url = str_replace('://m7c.', '://m7.', $url);
$url = str_replace('://m8c.', '://m8.', $url);
$url = str_replace('http://m8.', 'https://m9.', $url);
$url = str_replace('http://m7.', 'https://m9.', $url);
$url = str_replace('http://m10.', 'https://m10.', $url);
}elseif ($server == 'xiami') {
$url = str_replace('http://', 'https://', $url);
}elseif ($server == 'baidu') {
$url = str_replace('http://zhangmenshiting.qianqian.com', 'https://gss3.baidu.com/y0s1hSulBw92lNKgpU_Z2jR7b2w6buu', $url);
}else{
$url = $url;
}
return $url;
}
private function format_lyric($data) {
$server = $this->server;
$data = json_decode($data, true);

File diff suppressed because one or more lines are too long

View File

@ -322,10 +322,67 @@ function checkBgImgCookie() {
$("#" + bgurl).click();
}
}
if (document.body.clientWidth > 860) {
setTimeout(function () {
checkBgImgCookie();
}, 100);
function checkDarkModeCookie() {
var night = getCookie("night"),
today = new Date()
cWidth = document.body.clientWidth;
if (!night) {
if ((today.getHours() > 21 || today.getHours() < 7) && cWidth > 1200) {
$("#dark-bg").click();
console.log('夜间模式开启');
} else {
if (cWidth > 860) {
setTimeout(function () {
checkBgImgCookie();
}, 1000);
console.log('夜间模式关闭');
} else {
$("html").css("background", "unset");
$("body").removeClass("dark");
$("#moblieDarkLight").html('<i class="fa fa-moon-o" aria-hidden="true"></i>');
setCookie("dark", "0", 0.33);
}
}
} else {
if (night == '1' && (today.getHours() >= 22 || today.getHours() <= 6) && cWidth > 1200) {
$("#dark-bg").click();
console.log('夜间模式开启');
} else if (night == '0' || today.getHours() < 22 || today.getHours() > 6) {
if (cWidth > 860) {
setTimeout(function () {
checkBgImgCookie();
}, 1000);
console.log('夜间模式关闭');
} else {
$("html").css("background", "unset");
$("body").removeClass("dark");
$("#moblieDarkLight").html('<i class="fa fa-moon-o" aria-hidden="true"></i>');
setCookie("dark", "0", 0.33);
}
}
}
}
if (!getCookie("darkcache") && (new Date().getHours() > 21 || new Date().getHours() < 7)) {
removeCookie("dark");
setCookie("darkcache", "cached", 0.4);
}
setTimeout(function() {
checkDarkModeCookie();
}, 100);
function mobile_dark_light() {
if ($("body").hasClass("dark")) {
$("html").css("background", "unset");
$("body").removeClass("dark");
$("#moblieDarkLight").html('<i class="fa fa-moon-o" aria-hidden="true"></i>');
setCookie("dark", "0", 0.33);
} else {
$("html").css("background", "#31363b");
$("#moblieDarkLight").html('<i class="fa fa-sun-o" aria-hidden="true"></i>');
$("body").addClass("dark");
setCookie("dark", "1", 0.33);
}
}
function no_right_click() {
@ -338,13 +395,12 @@ $(document).ready(function () {
function checkskin_bg(a) {
return a == "none" ? "" : a
}
function changeBG() {
var cached = $(".menu-list");
cached.find("li").each(function () {
var tagid = this.id;
cached.on("click", "#" + tagid, function () {
if (tagid == "white-bg") {
if (tagid == "white-bg" || tagid == "dark-bg") {
mashiro_global.variables.skinSecter = true;
checkskinSecter();
} else {
@ -352,36 +408,50 @@ $(document).ready(function () {
checkskinSecter();
}
if (tagid == "dark-bg") {
$("#night-mode-cover").css("visibility", "visible");
} else
$("#night-mode-cover").css("visibility", "hidden");
$("html").css("background", "#31363b");
$(".site-content").css("background-color", "#fff");
$("body").addClass("dark");
setCookie("dark", "1", 0.33);
} else{
$("html").css("background", "unset");
$("body").removeClass("dark");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
setCookie("dark", "0", 0.33);
setCookie("bgImgSetting", tagid, 30);
}
switch (tagid) {
case "white-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg0) + ")");
$(".site-content").css("background-color", "#fff");
break;
case "sakura-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg1) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break;
case "gribs-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg2) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break;
case "pixiv-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg3) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break;
case "KAdots-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg4) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break;
case "totem-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg5) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break;
case "bing-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg6) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break;
case "dark-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg7) + ")");
break;
// case "dark-bg":
// $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg7) + ")");
// break;
}
setCookie("bgImgSetting", tagid, 30);
closeSkinMenu();
});
});
@ -423,13 +493,11 @@ $(document).ready(function () {
});
function topFunction() {
if ('scrollBehavior' in document.documentElement.style) {
window.scrollTo({
top: 0,
behavior: "smooth"
})
} else {
window.scrollSmoothTo(0)
window.scrollBy(0, -100)
scrolldelay = setTimeout('topFunction()', 10)
var sTop = document.documentElement.scrollTop + document.body.scrollTop
if (sTop === 0) {
clearTimeout(scrolldelay)
}
}
@ -1765,14 +1833,17 @@ var home = location.href,
cheight = window.innerHeight,
pc_to_top = document.querySelector(".cd-top"),
mb_to_top = document.querySelector("#moblieGoTop"),
mb_dark_light = document.querySelector("#moblieDarkLight"),
changeskin = document.querySelector(".changeSkin-gear");
$(window).scroll(function() {
if (cwidth <= 860) {
if ($(this).scrollTop() > 20) {
mb_to_top.style.transform = "scale(1)";
mb_dark_light.style.transform = "scale(1)";
} else {
mb_to_top.style.transform = "scale(0)";
mb_dark_light.style.transform = "scale(0)";
}
} else {
if ($(this).scrollTop() > 100) {
@ -1801,6 +1872,9 @@ var home = location.href,
mb_to_top.onclick = function() {
topFunction();
}
mb_dark_light.onclick = function() {
mobile_dark_light();
}
}
}
$(function () {

View File

@ -1283,7 +1283,7 @@ a:hover {
padding: 0 10px;
margin-left: auto;
margin-right: auto;
background-color: rgba(255, 255, 255, .8)
background-color: #fff
}
.post-list {
@ -1889,9 +1889,9 @@ h1.page-title.mb- {
}
}
#moblieGoTop {
#moblieGoTop,#moblieDarkLight {
position: fixed;
bottom: 10px;
bottom: 60px;
right: 10px;
z-index: 99;
border: 0;
@ -1906,11 +1906,14 @@ h1.page-title.mb- {
transform: scale(0);
transition:transform .3s
}
#moblieGoTop:hover {
#moblieGoTop:hover,#moblieDarkLight:hover {
background-color: #fff;
opacity: .8
}
#moblieDarkLight{
bottom: 10px;
}
.post-footer {
padding: 20px 0;
border-bottom: 1px dashed #ddd;
@ -4369,7 +4372,9 @@ i.iconfont.js-toggle-search.iconsearch {
margin-top: -3px;
line-height: unset;
}
body.dark .ins-section .fa{
color: #ccc;
}
.ins-section .ins-section-header,.ins-section .ins-search-item {
padding: 8px 15px;
cursor: url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/cursor/ayuda.cur),auto;
@ -5222,7 +5227,7 @@ i.iconfont.down {
@media (max-width:860px) {
#main-container {
transition-duration: .5s;
transition: background,transform .5s !important;
position: relative;
overflow: hidden;
z-index: 2
@ -5309,7 +5314,7 @@ i.iconfont.down {
top: 8px
}
.openNav.open .icon {
background-color: transparent
background-color: transparent !important
}
.openNav.open .icon:after,
.openNav.open .icon:before {
@ -5815,7 +5820,8 @@ i.iconfont.down {
}
.header-user-avatar:hover .header-user-menu {
display: block
display: block;
background: #fff;
}
.header-user-menu {
@ -5846,7 +5852,6 @@ i.iconfont.down {
.herder-user-name {
font-size: 12px;
background: #fff;
padding: 10px 10px;
border-radius: 4px 4px 0 0
}
@ -5862,7 +5867,6 @@ i.iconfont.down {
.header-user-menu .user-menu-option {
padding: 5px 0;
background: #fff;
border-radius: 0 0 4px 4px;
width: 130px
}
@ -8282,6 +8286,8 @@ td.hljs-ln-numbers {
--widthB: calc(var(--widthA) - 30px);
height: var(--widthB);
min-height: 99%;
white-space: pre-wrap;
word-wrap: break-word;
overflow-y: hidden;
overflow-x: auto;
height: auto
@ -8744,6 +8750,9 @@ h1[id*=toc-head]::before,h2[id*=toc-head]::before,h3[id*=toc-head]::before,h4[id
.bangumi-item:hover img{
filter: blur(3px);
}
body.dark .bangumi-item:hover img{
filter: brightness(0.8) blur(3px);
}
.bangumi-title {
height: 15%;
}