From 9a0840bc93f5d656640e49862dd8c81017dcf7d4 Mon Sep 17 00:00:00 2001 From: Spirit Date: Mon, 19 Aug 2019 17:47:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/decorate.php | 4 ++ inc/swicher.php | 20 ++++++ js/sakura-app.js | 180 +++++++++++++++++++++-------------------------- options.php | 27 +++++++ 4 files changed, 131 insertions(+), 100 deletions(-) diff --git a/inc/decorate.php b/inc/decorate.php index 4256c92..6389b26 100644 --- a/inc/decorate.php +++ b/inc/decorate.php @@ -45,6 +45,10 @@ if ( akina_option('theme_skin') ) { ?> background: } +.changeSkin-gear,.toc{ + background:rgba(255,255,255,); +} + .entry-content th { background-color: diff --git a/inc/swicher.php b/inc/swicher.php index 3e76965..030814f 100644 --- a/inc/swicher.php +++ b/inc/swicher.php @@ -17,6 +17,26 @@ mashiro_option.qq_api_url = "https://api.2heng.xin/qqinfo/"; mashiro_option.qq_avatar_api_url = "https://api.2heng.xin/qqinfo/"; mashiro_option.live_search = ; + +mashiro_option.skin_bg0 = ""; +mashiro_option.skin_bg1 = ""; +mashiro_option.skin_bg2 = ""; +mashiro_option.skin_bg3 = ""; +mashiro_option.skin_bg4 = ""; +mashiro_option.skin_bg5 = ""; +mashiro_option.skin_bg6 = ""; +mashiro_option.skin_bg7 = ""; + +mashiro_option.skin_bg0 = "none"; +mashiro_option.skin_bg1 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/sakura.png"; +mashiro_option.skin_bg2 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/plaid2dbf8.jpg"; +mashiro_option.skin_bg3 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/star02.png"; +mashiro_option.skin_bg4 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/kyotoanimation.png"; +mashiro_option.skin_bg5 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/dot_orange.gif"; +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.land_at_home = true; diff --git a/js/sakura-app.js b/js/sakura-app.js index e1ee193..ab5b14d 100644 --- a/js/sakura-app.js +++ b/js/sakura-app.js @@ -5,9 +5,7 @@ * @date 2019.8.3 */ mashiro_global.variables = new function () { - this.has_bot_ui = false; - this.isNight = false; - this.skinSecter = false; + this.skinSecter = true; } mashiro_global.ini = new function () { this.normalize = function () { @@ -16,6 +14,7 @@ mashiro_global.ini = new function () { mashiro_global.post_list_show_animation.ini(); copy_code_block(); coverVideoIni(); + checkskinSecter(); } this.pjax = function () { pjaxInit(); @@ -23,6 +22,7 @@ mashiro_global.ini = new function () { mashiro_global.post_list_show_animation.ini(); copy_code_block(); coverVideoIni(); + checkskinSecter(); } } @@ -288,29 +288,27 @@ function scrollBar() { } scrollBar(); +function checkskinSecter() { + if (mashiro_global.variables.skinSecter === false) { + $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); + $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); + } else { + $(".pattern-center-sakura").removeClass('pattern-center-sakura').addClass('pattern-center'); + $(".headertop-bar-sakura").removeClass('headertop-bar-sakura').addClass('headertop-bar'); + } +} function checkBgImgCookie() { var bgurl = getCookie("bgImgSetting"); if (bgurl != "") { - if (bgurl == "https://view.moezx.cc/images/2018/01/03/sakura.png" || bgurl == "https://view.moezx.cc/images/2018/01/03/plaid2dbf8.jpg" || bgurl == "https://view.moezx.cc/images/2018/01/10/star02.png" || bgurl == "https://view.moezx.cc/images/2018/01/24/kyotoanimation.png" || bgurl == "https://view.moezx.cc/images/2018/03/27/dot_orange.gif") { - mashiro_global.variables.skinSecter = true; - mashiro_global.variables.isNight = false; - $("#night-mode-cover").css("visibility", "hidden"); - $("body").css("background-image", "url(" + bgurl + ")"); - $(".blank").css("background-color", "rgba(255,255,255,1)"); - $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); - $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); - } else if (bgurl == "https://api.shino.cc/bing/") { - mashiro_global.variables.skinSecter = true; - mashiro_global.variables.isNight = true; - $("#night-mode-cover").css("visibility", "hidden"); - $("body").css("background-image", "url(" + bgurl + ")"); - $(".blank").css("background-color", "rgba(255,255,255,1)"); - $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); - $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); - } else {} - } else {} + $(".skin-menu #" + bgurl + "-bg").click(); + } else { + $(".skin-menu #white-bg").click(); + } } if (document.body.clientWidth > 860) { + setTimeout(function() { + checkBgImgCookie(); + }, 100); checkBgImgCookie(); } @@ -320,87 +318,77 @@ function no_right_click() { }); } no_right_click(); -if (mashiro_global.variables.isNight) { - $(".changeSkin-gear, .toc").css("background", "rgba(255,255,255,0.8)"); -} else { - $(".changeSkin-gear, .toc").css("background", "none"); -} -$(document).ready(function () { - function changeBG(tagid, url) { - $(".skin-menu " + tagid).click(function () { - mashiro_global.variables.skinSecter = true; - mashiro_global.variables.isNight = false; - $("#night-mode-cover").css("visibility", "hidden"); - $("body").css("background-image", "url(" + url + ")"); - $(".blank").css("background-color", "rgba(255,255,255,1)"); - $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); - $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); - closeSkinMenu(); - setCookie("bgImgSetting", url, 30); +$(document).ready(function() { + function checkskin_bg(a){ + return a == "none" ? "" : a + } + function changeBG() { + $(".menu-list li").each(function() { + var tagid = this.id; + $(".skin-menu #" + tagid).click(function() { + if (tagid == "white-bg") { + mashiro_global.variables.skinSecter = true; + $(".pattern-center-sakura").removeClass('pattern-center-sakura').addClass('pattern-center'); + $(".headertop-bar-sakura").removeClass('headertop-bar-sakura').addClass('headertop-bar'); + } else { + mashiro_global.variables.skinSecter = false; + $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); + $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); + } + if (tagid == "dark-bg") { + $("#night-mode-cover").css("visibility", "visible"); + } else + $("#night-mode-cover").css("visibility", "hidden"); + switch (tagid) { + case "white-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg0) + ")"); + setCookie("bgImgSetting", "white", 30); + break; + case "sakura-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg1) + ")"); + setCookie("bgImgSetting", "sakura", 30); + break; + case "gribs-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg2) + ")"); + setCookie("bgImgSetting", "gribs", 30); + break; + case "pixiv-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg3) + ")"); + setCookie("bgImgSetting", "pixiv", 30); + break; + case "KAdots-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg4) + ")"); + setCookie("bgImgSetting", "KAdots", 30); + break; + case "totem-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg5) + ")"); + setCookie("bgImgSetting", "totem", 30); + break; + case "bing-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg6) + ")"); + setCookie("bgImgSetting", "bing", 30); + break; + case "dark-bg": + $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg7) + ")"); + setCookie("bgImgSetting", "dark", 30); + break; + } + closeSkinMenu(); + }); }); } - - function changeBGnoTrans(tagid, url) { - $(".skin-menu " + tagid).click(function () { - mashiro_global.variables.skinSecter = true; - mashiro_global.variables.isNight = true; - $("#night-mode-cover").css("visibility", "hidden"); - $("body").css("background-image", "url(" + url + ")"); - $(".blank").css("background-color", "rgba(255,255,255,1)"); - $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); - $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); - closeSkinMenu(); - setCookie("bgImgSetting", url, 30); - }); - } - changeBG("#sakura-bg", "https://view.moezx.cc/images/2018/01/03/sakura.png"); - changeBG("#gribs-bg", "https://view.moezx.cc/images/2018/01/03/plaid2dbf8.jpg"); - changeBG("#pixiv-bg", "https://view.moezx.cc/images/2018/01/10/star02.png"); - changeBG("#KAdots-bg", "https://view.moezx.cc/images/2018/01/24/kyotoanimation.png"); - changeBG("#totem-bg", "https://view.moezx.cc/images/2018/03/27/dot_orange.gif"); - changeBGnoTrans("#bing-bg", "https://api.shino.cc/bing/"); - $(".skin-menu #white-bg").click(function () { - mashiro_global.variables.skinSecter = false; - mashiro_global.variables.isNight = false; - $("#night-mode-cover").css("visibility", "hidden"); - $("body").css("background-image", "none"); - $(".blank").css("background-color", "rgba(255,255,255,.0)"); - $(".pattern-center-sakura").removeClass('pattern-center-sakura').addClass('pattern-center'); - $(".headertop-bar-sakura").removeClass('headertop-bar-sakura').addClass('headertop-bar'); - closeSkinMenu(); - setCookie("bgImgSetting", "Hello World!", 30); - }); - $(".skin-menu #dark-bg").click(function () { - mashiro_global.variables.skinSecter = true; - mashiro_global.variables.isNight = true; - $("body").css("background-image", "url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png)"); - $(".blank").css("background-color", "rgba(255,255,255,.8)"); - $("#night-mode-cover").css("visibility", "visible"); - $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); - $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); - closeSkinMenu(); - }); + changeBG(); function closeSkinMenu() { $(".skin-menu").removeClass('show'); - setTimeout(function () { + setTimeout(function() { $(".changeSkin-gear").css("visibility", "visible"); }, 300); - if (mashiro_global.variables.isNight) { - $(".changeSkin-gear, .toc").css("background", "rgba(255,255,255,0.8)"); - } else { - $(".changeSkin-gear, .toc").css("background", "none"); - } } - $(".changeSkin-gear").click(function () { + $(".changeSkin-gear").click(function() { $(".skin-menu").toggleClass('show'); - if (mashiro_global.variables.isNight) { - $(".changeSkin").css("background", "rgba(255,255,255,0.8)"); - } else { - $(".changeSkin").css("background", "none"); - } }) - $(".skin-menu #close-skinMenu").click(function () { + $(".skin-menu #close-skinMenu").click(function() { closeSkinMenu(); }); add_upload_tips(); @@ -617,14 +605,6 @@ var pjaxInit = function () { reloadHermit(); } catch (e) {}; } - if (mashiro_global.variables.skinSecter === true) { - $(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura'); - $(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura'); - if (mashiro_global.variables.isNight) { - $(".blank").css("background-color", "rgba(255,255,255,1)"); - $(".toc").css("background-color", "rgba(255,255,255,0.8)"); - } - } $('.iconflat').css('width', '50px').css('height', '50px'); $('.openNav').css('height', '50px'); $("#bg-next").click(function () { diff --git a/options.php b/options.php index 27c1488..b01c9c6 100644 --- a/options.php +++ b/options.php @@ -134,6 +134,33 @@ function optionsframework_options() { 'type' => "color" ); + $options[] = array( + 'name' => __('切换主题菜单透明度', 'options_framework_theme'), + 'desc' => __('调整切换主题菜单透明度,值越小越透明,默认透明度0.8', 'options_framework_theme'), + 'id' => 'sakura_skin_alpha', + 'std' => '0.8', + 'type' => 'select', + 'options'=>array( + '0'=> __('全透明',''), + '0.1'=> __('透明度0.1',''), + '0.2'=> __('透明度0.2',''), + '0.3'=> __('透明度0.3',''), + '0.4'=> __('透明度0.4',''), + '0.5'=> __('透明度0.5',''), + '0.6'=> __('透明度0.6',''), + '0.7'=> __('透明度0.7',''), + '0.8'=> __('透明度0.8',''), + '0.9'=> __('透明度0.9',''), + '1'=> __('不透明',''), + )); + + $options[] = array( + 'name' => __('切换网页背景', 'options_framework_theme'), + 'desc' => __('前台切换网页背景,共8个url,使用空格分隔,顺序对应前台切换主题按钮位置(按钮顺序从左至右,从上至下),如不需要背景则填写对应位置为none', 'options_framework_theme'), + 'id' => 'sakura_skin_bg', + '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'); + $options[] = array( 'name' => __('个人头像', 'options_framework_theme'), 'desc' => __('最佳高度尺寸130*130px。', 'options_framework_theme'),