perf: optimize

bug fix, update darkmode option
This commit is contained in:
Spirit 2020-04-19 00:43:35 +08:00
parent 85f010d6aa
commit 467818c5f6
11 changed files with 994 additions and 982 deletions

View File

@ -801,7 +801,7 @@ function custom_login()
//echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_directory') . '/inc/login.css" />'."\n"; //echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_directory') . '/inc/login.css" />'."\n";
echo '<link rel="stylesheet" type="text/css" href="' . get_template_directory_uri() . '/inc/login.css?' . SAKURA_VERSION . '" />' . "\n"; echo '<link rel="stylesheet" type="text/css" href="' . get_template_directory_uri() . '/inc/login.css?' . SAKURA_VERSION . '" />' . "\n";
//echo '<script type="text/javascript" src="'.get_bloginfo('template_directory').'/js/jquery.min.js"></script>'."\n"; //echo '<script type="text/javascript" src="'.get_bloginfo('template_directory').'/js/jquery.min.js"></script>'."\n";
echo '<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/jquery/jquery@1.8.2/jquery.min.js"></script>' . "\n"; echo '<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/jquery/jquery@1.9.0/jquery.min.js"></script>' . "\n";
} }
add_action('login_head', 'custom_login'); add_action('login_head', 'custom_login');

View File

@ -188,9 +188,7 @@ color: #676767 !important}
} }
input[type=checkbox]:checked:before { input[type=checkbox]:checked:before {
content: "\f147";
margin: -2px 0 0 -2px; margin: -2px 0 0 -2px;
color: #FF5656;
} }
/* loading */ /* loading */

View File

@ -37,6 +37,8 @@ mashiro_option.skin_bg6 = "https://api.mashiro.top/bing/";
mashiro_option.skin_bg7 = "https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png"; mashiro_option.skin_bg7 = "https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png";
<?php } ?> <?php } ?>
mashiro_option.darkmode = <?php if ( akina_option('darkmode') ){ echo 'true'; } else { echo 'false'; } ?>;
<?php if( is_home() ){ ?> <?php if( is_home() ){ ?>
mashiro_option.land_at_home = true; mashiro_option.land_at_home = true;
<?php }else {?> <?php }else {?>

View File

@ -334,12 +334,11 @@ function checkDarkModeCookie() {
var dark = getCookie("dark"), var dark = getCookie("dark"),
today = new Date(), today = new Date(),
hour = today.getHours(); hour = today.getHours();
if ((!dark && (hour > 21 || hour < 7) ) || (dark == '1' && (hour >= 22 || hour <= 6))) { if (mashiro_option.darkmode && ((!dark && (hour > 21 || hour < 7) ) || (dark == '1' && (hour >= 22 || hour <= 6)))) {
setTimeout(function () { setTimeout(function () {
$("#dark-bg").click(); $("#dark-bg").click();
}, 100); }, 100);
$("#moblieDarkLight").html('<i class="fa fa-sun-o" aria-hidden="true"></i>'); $("#moblieDarkLight").html('<i class="fa fa-sun-o" aria-hidden="true"></i>');
console.log('夜间模式开启');
} else { } else {
if (document.body.clientWidth > 860) { if (document.body.clientWidth > 860) {
setTimeout(function () { setTimeout(function () {
@ -351,7 +350,6 @@ function checkDarkModeCookie() {
$("#moblieDarkLight").html('<i class="fa fa-moon-o" aria-hidden="true"></i>'); $("#moblieDarkLight").html('<i class="fa fa-moon-o" aria-hidden="true"></i>');
setCookie("dark", "0", 0.33); setCookie("dark", "0", 0.33);
} }
console.log('夜间模式关闭');
} }
} }
if (!getCookie("darkcache") && (new Date().getHours() > 21 || new Date().getHours() < 7)) { if (!getCookie("darkcache") && (new Date().getHours() > 21 || new Date().getHours() < 7)) {
@ -399,45 +397,43 @@ $(document).ready(function () {
checkskinSecter(); checkskinSecter();
} }
if (tagid == "dark-bg") { if (tagid == "dark-bg") {
addComment.I("content").classList.add('notransition');
addComment.I("content").style.backgroundColor = "#fff";
addComment.I("content").offsetHeight;
addComment.I("content").classList.remove('notransition');
$("html").css("background", "#31363b"); $("html").css("background", "#31363b");
$(".site-content").css("background-color", "#fff");
$("body").addClass("dark"); $("body").addClass("dark");
setCookie("dark", "1", 0.33); setCookie("dark", "1", 0.33);
} else{ } else{
$("html").css("background", "unset"); $("html").css("background", "unset");
$("body").removeClass("dark"); $("body").removeClass("dark");
$(".site-content").css("background-color", "rgba(255, 255, 255, .8)");
setCookie("dark", "0", 0.33); setCookie("dark", "0", 0.33);
setCookie("bgImgSetting", tagid, 30); setCookie("bgImgSetting", tagid, 30);
setTimeout(function () {
addComment.I("content").style.backgroundColor = "rgba(255, 255, 255, 0.8)";
}, 1000);
} }
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) + ")");

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -134,23 +134,10 @@ function optionsframework_options()
$options[] = array( $options[] = array(
'name' => __('Theme scheme tool transparency', 'sakura'), /*切换主题菜单透明度*/ 'name' => __('Theme scheme tool transparency', 'sakura'), /*切换主题菜单透明度*/
'desc' => __('Adjust the theme scheme menu transparency, the smaller the value, the more transparent. The default value is 0.8', 'sakura'), /*调整切换主题菜单透明度值越小越透明。默认透明度0.8*/ 'desc' => __('Adjust the theme scheme menu transparency, fill in decimals between 0 and 1, the smaller the value, the more transparent. The default value is 0.8', 'sakura'), /*调整切换主题菜单透明度值越小越透明。默认透明度0.8*/
'id' => 'sakura_skin_alpha', 'id' => 'sakura_skin_alpha',
'std' => '0.8', 'std' => '0.8',
'type' => 'select', 'type' => 'text');
'options' => array(
'0' => __('Transparent', 'sakura'), /*全透明*/
'0.1' => __('Transparency 0.1', 'sakura'), /*透明度0.1*/
'0.2' => __('Transparency 0.2', 'sakura'), /*透明度0.2*/
'0.3' => __('Transparency 0.3', 'sakura'), /*透明度0.3*/
'0.4' => __('Transparency 0.4', 'sakura'), /*透明度0.4*/
'0.5' => __('Transparency 0.5', 'sakura'), /*透明度0.5*/
'0.6' => __('Transparency 0.6', 'sakura'), /*透明度0.6*/
'0.7' => __('Transparency 0.7', 'sakura'), /*透明度0.7*/
'0.8' => __('Transparency 0.8', 'sakura'), /*透明度0.8*/
'0.9' => __('Transparency 0.9', 'sakura'), /*透明度0.9*/
'1' => __('Opaque', 'sakura'), /*不透明*/
));
$options[] = array( $options[] = array(
'name' => __('Change web background', 'sakura'), /*切换网页背景*/ 'name' => __('Change web background', 'sakura'), /*切换网页背景*/
@ -159,6 +146,13 @@ function optionsframework_options()
'std' => 'none,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/sakura.png,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/plaid2dbf8.jpg,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/star02.png,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/kyotoanimation.png,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/dot_orange.gif,https://api.mashiro.top/bing/,https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png', 'std' => 'none,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/sakura.png,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/plaid2dbf8.jpg,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/star02.png,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/kyotoanimation.png,https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/dot_orange.gif,https://api.mashiro.top/bing/,https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png',
'type' => 'textarea'); 'type' => 'textarea');
$options[] = array(
'name' => __('Darkmode', 'sakura'),
'desc' => __('Automatically turn on dark mode from 10:00 p.m. to 06:00 a.m.', 'sakura'),
'id' => 'darkmode',
'std' => '1',
'type' => 'checkbox');
$options[] = array( $options[] = array(
'name' => __('Personal avatar', 'sakura'), /*个人头像*/ 'name' => __('Personal avatar', 'sakura'), /*个人头像*/
'desc' => __('The best size is 130px*130px.', 'sakura'), /*最佳尺寸130px*130px。*/ 'desc' => __('The best size is 130px*130px.', 'sakura'), /*最佳尺寸130px*130px。*/

View File

@ -1278,12 +1278,20 @@ a:hover {
padding: 40px 0 0 padding: 40px 0 0
} }
.site-content.notransition {
-webkit-transition: none !important;
-moz-transition: none !important;
-o-transition: none !important;
-ms-transition: none !important;
transition: none !important;
}
.site-content { .site-content {
max-width: 800px; max-width: 800px;
padding: 0 10px; padding: 0 10px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
background-color: #fff background-color: rgba(255, 255, 255, .8)
} }
.post-list { .post-list {