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 --> </div><!-- m-nav-center end -->
<a class="cd-top faa-float animated "></a> <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="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 --> <!-- search start -->
<form class="js-search search-form search-form--modal" method="get" action="<?php echo home_url(); ?>" role="search"> <form class="js-search search-form search-form--modal" method="get" action="<?php echo home_url(); ?>" role="search">
<div class="search-form__inner"> <div class="search-form__inner">

View File

@ -666,6 +666,7 @@ function akina_body_classes($classes)
/*if(!wp_is_mobile()) { /*if(!wp_is_mobile()) {
$classes[] = 'serif'; $classes[] = 'serif';
}*/ }*/
$classes[] = $_COOKIE['dark'.akina_option('cookie_version', '')] == '1' ? 'dark' : ' ';
return $classes; return $classes;
} }
add_filter('body_class', 'akina_body_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; ?>" /> <meta name="keywords" content="<?php echo $keywords; ?>" />
<?php } ?> <?php } ?>
<link rel="shortcut icon" href="<?php echo akina_option('favicon_link', ''); ?>"/> <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"> <meta http-equiv="x-dns-prefetch-control" content="on">
<?php wp_head(); ?> <?php wp_head(); ?>
<script type="text/javascript"> <script type="text/javascript">

View File

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

View File

@ -27,6 +27,7 @@ class Aplayer
case 'song': case 'song':
$data = $api->format(true)->song($id); $data = $api->format(true)->song($id);
$data = json_decode($data, true)["url"]; $data = json_decode($data, true)["url"];
$data = $this->song_url($data);
break; break;
// case 'album': // case 'album':
// $data = $api->format(true)->album($id); // $data = $api->format(true)->album($id);
@ -46,11 +47,12 @@ class Aplayer
break; break;
// case 'search': // case 'search':
// $data = $api->format(true)->search($id); // $data = $api->format(true)->search($id);
// $data=json_decode($data, true)["url"]; // $data=json_decode($data, true);
// break; // break;
default: default:
$data = $api->format(true)->url($id); $data = $api->format(true)->url($id);
$data = json_decode($data, true)["url"]; $data = json_decode($data, true)["url"];
$data = $this->song_url($data);
break; break;
} }
return $data; return $data;
@ -78,6 +80,24 @@ class Aplayer
return $playlist; 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) { private function format_lyric($data) {
$server = $this->server; $server = $this->server;
$data = json_decode($data, true); $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(); $("#" + bgurl).click();
} }
} }
if (document.body.clientWidth > 860) {
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 () { setTimeout(function () {
checkBgImgCookie(); checkBgImgCookie();
}, 100); }, 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() { function no_right_click() {
@ -338,13 +395,12 @@ $(document).ready(function () {
function checkskin_bg(a) { function checkskin_bg(a) {
return a == "none" ? "" : a return a == "none" ? "" : a
} }
function changeBG() { function changeBG() {
var cached = $(".menu-list"); var cached = $(".menu-list");
cached.find("li").each(function () { cached.find("li").each(function () {
var tagid = this.id; var tagid = this.id;
cached.on("click", "#" + tagid, function () { cached.on("click", "#" + tagid, function () {
if (tagid == "white-bg") { if (tagid == "white-bg" || tagid == "dark-bg") {
mashiro_global.variables.skinSecter = true; mashiro_global.variables.skinSecter = true;
checkskinSecter(); checkskinSecter();
} else { } else {
@ -352,36 +408,50 @@ $(document).ready(function () {
checkskinSecter(); checkskinSecter();
} }
if (tagid == "dark-bg") { if (tagid == "dark-bg") {
$("#night-mode-cover").css("visibility", "visible"); $("html").css("background", "#31363b");
} else $(".site-content").css("background-color", "#fff");
$("#night-mode-cover").css("visibility", "hidden"); $("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) { switch (tagid) {
case "white-bg": case "white-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg0) + ")"); $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg0) + ")");
$(".site-content").css("background-color", "#fff");
break; break;
case "sakura-bg": case "sakura-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg1) + ")"); $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg1) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break; break;
case "gribs-bg": case "gribs-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg2) + ")"); $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg2) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break; break;
case "pixiv-bg": case "pixiv-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg3) + ")"); $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg3) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break; break;
case "KAdots-bg": case "KAdots-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg4) + ")"); $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg4) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break; break;
case "totem-bg": case "totem-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg5) + ")"); $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg5) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break; break;
case "bing-bg": case "bing-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg6) + ")"); $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg6) + ")");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
break; break;
case "dark-bg": // case "dark-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg7) + ")"); // $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg7) + ")");
break; // break;
} }
setCookie("bgImgSetting", tagid, 30);
closeSkinMenu(); closeSkinMenu();
}); });
}); });
@ -423,13 +493,11 @@ $(document).ready(function () {
}); });
function topFunction() { function topFunction() {
if ('scrollBehavior' in document.documentElement.style) { window.scrollBy(0, -100)
window.scrollTo({ scrolldelay = setTimeout('topFunction()', 10)
top: 0, var sTop = document.documentElement.scrollTop + document.body.scrollTop
behavior: "smooth" if (sTop === 0) {
}) clearTimeout(scrolldelay)
} else {
window.scrollSmoothTo(0)
} }
} }
@ -1765,14 +1833,17 @@ var home = location.href,
cheight = window.innerHeight, cheight = window.innerHeight,
pc_to_top = document.querySelector(".cd-top"), pc_to_top = document.querySelector(".cd-top"),
mb_to_top = document.querySelector("#moblieGoTop"), mb_to_top = document.querySelector("#moblieGoTop"),
mb_dark_light = document.querySelector("#moblieDarkLight"),
changeskin = document.querySelector(".changeSkin-gear"); changeskin = document.querySelector(".changeSkin-gear");
$(window).scroll(function() { $(window).scroll(function() {
if (cwidth <= 860) { if (cwidth <= 860) {
if ($(this).scrollTop() > 20) { if ($(this).scrollTop() > 20) {
mb_to_top.style.transform = "scale(1)"; mb_to_top.style.transform = "scale(1)";
mb_dark_light.style.transform = "scale(1)";
} else { } else {
mb_to_top.style.transform = "scale(0)"; mb_to_top.style.transform = "scale(0)";
mb_dark_light.style.transform = "scale(0)";
} }
} else { } else {
if ($(this).scrollTop() > 100) { if ($(this).scrollTop() > 100) {
@ -1801,6 +1872,9 @@ var home = location.href,
mb_to_top.onclick = function() { mb_to_top.onclick = function() {
topFunction(); topFunction();
} }
mb_dark_light.onclick = function() {
mobile_dark_light();
}
} }
} }
$(function () { $(function () {

View File

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