Add files via upload

合并了部分重复代码,并且可以更快的应用更新后的配置
This commit is contained in:
52Hz 2022-07-01 23:09:19 +08:00 committed by GitHub
parent b96e55d632
commit 1c53f3023f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 75 deletions

View File

@ -2,6 +2,7 @@
/* /*
homepage config homepage config
author: XYZ-dragon author: XYZ-dragon
默认应该是不支持短标签的,所以就没写那种
*/ */
class Site class Site
@ -13,34 +14,21 @@ class Site
$this->$key = $value; $this->$key = $value;
} }
} }
function get_linklist(int $index, string $type)
/**
* @return key|value
**/
function get_kv(string $name, int $index, string $type): string
{ {
/* 键名不确定 */
switch ($type) { switch ($type) {
case 'name':
return array_keys($this->$name)[$index];
case 'url': case 'url':
return $this->link_list[array_keys($this->link_list)[$index]][0]; if (gettype($this->$name[array_keys($this->$name)[$index]]) == 'string') return $this->$name[array_keys($this->$name)[$index]];
return $this->$name[array_keys($this->$name)[$index]][0];
case 'icon': case 'icon':
return $this->link_list[array_keys($this->link_list)[$index]][1]; // 如果不存在直接报错
case 'name': return $this->$name[array_keys($this->$name)[$index]][1];
return array_keys($this->link_list)[$index];
}
}
function get_linklist_without_icon(int $index, string $type)
{
switch ($type) {
case 'url':
return $this->z7z8[array_keys($this->z7z8)[$index]];
case 'name':
return array_keys($this->z7z8)[$index];
}
}
function get_wallpaperapi(int $index, string $type)
{
switch ($type) {
case 'url':
return $this->wallpaper_api[array_keys($this->wallpaper_api)[$index]];
case 'name':
return array_keys($this->wallpaper_api)[$index];
} }
} }
} }
@ -58,7 +46,7 @@ $setting = [
'Hello world!', 'System.out.print("Hello world!");' 'Hello world!', 'System.out.print("Hello world!");'
], ],
'des_title_change' => [ 'des_title_change' => [
'Oops !', '哎呀,这都被你发现了 ( 再次点击可切换 )' // 还没用上 'Oops !', '哎呀,这都被你发现了 ( 再次点击可切换 )'
], ],
'social_contact' => [ 'social_contact' => [
'github' => 'https://github.com/XYZ-dragon', 'github' => 'https://github.com/XYZ-dragon',
@ -68,7 +56,7 @@ $setting = [
'twitter' => 'https://twitter.com/zuotun0226' 'twitter' => 'https://twitter.com/zuotun0226'
], ],
'link_list' => [ 'link_list' => [
'博客' => ['https://blueeyeswhitedragon.xyz/', 'fa-solid fa-blog',], '博客' => ['https://blueeyeswhitedragon.xyz/', 'fa-solid fa-blog'],
'兰空图床' => ['http://localhost:8080/', 'fa-solid fa-cloud'], '兰空图床' => ['http://localhost:8080/', 'fa-solid fa-cloud'],
'Null' => ['', 'fa-solid fa-music'], 'Null' => ['', 'fa-solid fa-music'],
'导航站' => ['', 'fa-solid fa-compass'], '导航站' => ['', 'fa-solid fa-compass'],
@ -76,15 +64,16 @@ $setting = [
'Lab' => ['', 'fa-solid fa-flask'] 'Lab' => ['', 'fa-solid fa-flask']
], ],
'z7z8' => ['站点监控' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5'], 'z7z8' => ['站点监控' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5'],
'weather_api' => 'https://www.yiketianqi.com/free/day?appid=43656176&appsecret=I42og6Lm&unescape=1', // 没用上 'weather_api' => 'https://www.yiketianqi.com/free/day?appid=43656176&appsecret=I42og6Lm&unescape=1',
'wallpaper_api' => [ 'wallpaper_api' => [
'游戏王' => 'https://blueeyeswhitedragon.xyz/api/ygo/', '游戏王' => 'https://blueeyeswhitedragon.xyz/api/ygo/',
'Bing' => 'https://blueeyeswhitedragon.xyz/api/bing/', 'Bing' => 'https://blueeyeswhitedragon.xyz/api/bing/',
'随机风景' => 'https://api.ixiaowai.cn/gqapi/gqapi.php', '随机风景' => 'https://api.ixiaowai.cn/gqapi/gqapi.php',
'随机动漫' => 'https://api.ixiaowai.cn/api/api.php' '随机动漫' => 'https://api.ixiaowai.cn/api/api.php'
], ],
'Copyright_year' => '2020', 'copyright' => ['2020', '酢豚'],
'Copyright_text' => '酢豚'
]; ];
$site = new Site($setting); $site = new Site($setting);
// echo $site->des_title[0];
// echo $site->get_kv('z7z8', 0, 'url');

View File

@ -204,26 +204,26 @@ require_once './config.php';
<!--第一组--> <!--第一组-->
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<a id="link-url-1" href="<?php echo $site->get_linklist(0, 'url'); ?>" target="_blank"> <a id="link-url-1" href="<?php echo $site->get_kv('link_list', 0, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<i id="link-icon-1" class="<?php echo $site->get_linklist(0, 'icon'); ?>"></i> <i id="link-icon-1" class="<?php echo $site->get_kv('link_list', 0, 'icon'); ?>"></i>
<span class="link-name" id="link-name-1"><?php echo $site->get_linklist(0, 'name'); ?></span> <span class="link-name" id="link-name-1"><?php echo $site->get_kv('link_list', 0, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
<div class="col 2"> <div class="col 2">
<a id="link-url-2" href="<?php echo $site->get_linklist(1, 'url'); ?>" target="_blank"> <a id="link-url-2" href="<?php echo $site->get_kv('link_list', 1, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<i id="link-icon-2" class="<?php echo $site->get_linklist(1, 'icon'); ?>"></i> <i id="link-icon-2" class="<?php echo $site->get_kv('link_list', 1, 'icon'); ?>"></i>
<span class="link-name" id="link-name-2"><?php echo $site->get_linklist(1, 'name'); ?></span> <span class="link-name" id="link-name-2"><?php echo $site->get_kv('link_list', 1, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
<div class="col"> <div class="col">
<a id="link-url-3" href="<?php echo $site->get_linklist(2, 'url'); ?>" target="_blank"> <a id="link-url-3" href="<?php echo $site->get_kv('link_list', 2, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<i id="link-icon-3" class="<?php echo $site->get_linklist(2, 'icon'); ?>"></i> <i id="link-icon-3" class="<?php echo $site->get_kv('link_list', 2, 'icon'); ?>"></i>
<span class="link-name" id="link-name-3"><?php echo $site->get_linklist(2, 'name'); ?></span> <span class="link-name" id="link-name-3"><?php echo $site->get_kv('link_list', 2, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
@ -231,26 +231,26 @@ require_once './config.php';
<!--第二组--> <!--第二组-->
<div class="row" style="margin-top: 1.5rem;"> <div class="row" style="margin-top: 1.5rem;">
<div class="col"> <div class="col">
<a id="link-url-4" href="<?php echo $site->get_linklist(3, 'url'); ?>" target="_blank"> <a id="link-url-4" href="<?php echo $site->get_kv('link_list', 3, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<i id="link-icon-4" class="<?php echo $site->get_linklist(3, 'icon'); ?>"></i> <i id="link-icon-4" class="<?php echo $site->get_kv('link_list', 3, 'icon'); ?>"></i>
<span class="link-name" id="link-name-4"><?php echo $site->get_linklist(3, 'name'); ?></span> <span class="link-name" id="link-name-4"><?php echo $site->get_kv('link_list', 3, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
<div class="col 2"> <div class="col 2">
<a id="link-url-5" href="<?php echo $site->get_linklist(4, 'url'); ?>" target="_blank"> <a id="link-url-5" href="<?php echo $site->get_kv('link_list', 4, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<i id="link-icon-5" class="<?php echo $site->get_linklist(4, 'icon'); ?>"></i> <i id="link-icon-5" class="<?php echo $site->get_kv('link_list', 4, 'icon'); ?>"></i>
<span class="link-name" id="link-name-5"><?php echo $site->get_linklist(4, 'name'); ?></span> <span class="link-name" id="link-name-5"><?php echo $site->get_kv('link_list', 4, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
<div class="col"> <div class="col">
<a id="link-url-6" href="<?php echo $site->get_linklist(5, 'url'); ?>" target="_blank"> <a id="link-url-6" href="<?php echo $site->get_kv('link_list', 5, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<i id="link-icon-6" class="<?php echo $site->get_linklist(5, 'icon'); ?>"></i> <i id="link-icon-6" class="<?php echo $site->get_kv('link_list', 5, 'icon'); ?>"></i>
<span class="link-name" id="link-name-6"><?php echo $site->get_linklist(5, 'name'); ?></span> <span class="link-name" id="link-name-6"><?php echo $site->get_kv('link_list', 5, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
@ -310,39 +310,39 @@ require_once './config.php';
<!--网站链接--> <!--网站链接-->
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<a href="<?php echo $site->get_linklist_without_icon(0, 'url'); ?>" target="_blank"> <a href="<?php echo $site->get_kv('z7z8', 0, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<span class="link-name"><?php echo $site->get_linklist_without_icon(0, 'name'); ?></span> <span class="link-name"><?php echo $site->get_kv('z7z8', 0, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
<div class="col 2"> <div class="col 2">
<a href="<?php echo $site->get_linklist_without_icon(1, 'url'); ?>" target="_blank"> <a href="<?php echo $site->get_kv('z7z8', 1, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<span class="link-name"><?php echo $site->get_linklist_without_icon(1, 'name'); ?></span> <span class="link-name"><?php echo $site->get_kv('z7z8', 1, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
<div class="col"> <div class="col">
<a href="<?php echo $site->get_linklist_without_icon(2, 'url'); ?>" target="_blank"> <a href="<?php echo $site->get_kv('z7z8', 2, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<span class="link-name"><?php echo $site->get_linklist_without_icon(2, 'name'); ?></span> <span class="link-name"><?php echo $site->get_kv('z7z8', 2, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
</div> </div>
<div class="row" style="margin-top: 1.5rem;"> <div class="row" style="margin-top: 1.5rem;">
<div class="col"> <div class="col">
<a href="<?php echo $site->get_linklist_without_icon(3, 'url'); ?>" target="_blank"> <a href="<?php echo $site->get_kv('z7z8', 3, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<span class="link-name"><?php echo $site->get_linklist_without_icon(3, 'name'); ?></span> <span class="link-name"><?php echo $site->get_kv('z7z8', 3, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
<div class="col 2"> <div class="col 2">
<a href="<?php echo $site->get_linklist_without_icon(4, 'url'); ?>" target="_blank"> <a href="<?php echo $site->get_kv('z7z8', 4, 'url'); ?>" target="_blank">
<div class="link-card cards"> <div class="link-card cards">
<span class="link-name"><?php echo $site->get_linklist_without_icon(4, 'name'); ?></span> <span class="link-name"><?php echo $site->get_kv('z7z8', 4, 'name'); ?></span>
</div> </div>
</a> </a>
</div> </div>
@ -390,19 +390,19 @@ require_once './config.php';
</div> </div>
<div class="form-radio"> <div class="form-radio">
<input type="radio" class="set-wallpaper" style="display: none;" id="radio2" value="2" name="wallpaper-type"> <input type="radio" class="set-wallpaper" style="display: none;" id="radio2" value="2" name="wallpaper-type">
<label for="radio2" id="wallpaper_text1"><?php echo $site->get_wallpaperapi(0, 'name'); ?></label> <label for="radio2" id="wallpaper_text1"><?php echo $site->get_kv('wallpaper_api', 0, 'name'); ?></label>
</div> </div>
<div class="form-radio"> <div class="form-radio">
<input type="radio" class="set-wallpaper" style="display: none;" id="radio3" value="3" name="wallpaper-type"> <input type="radio" class="set-wallpaper" style="display: none;" id="radio3" value="3" name="wallpaper-type">
<label for="radio3" id="wallpaper_text2"><?php echo $site->get_wallpaperapi(1, 'name'); ?></label> <label for="radio3" id="wallpaper_text2"><?php echo $site->get_kv('wallpaper_api', 1, 'name'); ?></label>
</div> </div>
<div class="form-radio"> <div class="form-radio">
<input type="radio" class="set-wallpaper" style="display: none;" id="radio4" value="4" name="wallpaper-type"> <input type="radio" class="set-wallpaper" style="display: none;" id="radio4" value="4" name="wallpaper-type">
<label for="radio4" id="wallpaper_text3"><?php echo $site->get_wallpaperapi(2, 'name'); ?></label> <label for="radio4" id="wallpaper_text3"><?php echo $site->get_kv('wallpaper_api', 2, 'name'); ?></label>
</div> </div>
<div class="form-radio"> <div class="form-radio">
<input type="radio" class="set-wallpaper" style="display: none;" id="radio5" value="5" name="wallpaper-type"> <input type="radio" class="set-wallpaper" style="display: none;" id="radio5" value="5" name="wallpaper-type">
<label for="radio5" id="wallpaper_text4"><?php echo $site->get_wallpaperapi(3, 'name'); ?></label> <label for="radio5" id="wallpaper_text4"><?php echo $site->get_kv('wallpaper_api', 3, 'name'); ?></label>
</div> </div>
</div> </div>
</div> </div>
@ -433,11 +433,10 @@ require_once './config.php';
<span class="uptext"> <span class="uptext">
<i class="fa-solid fa-screwdriver-wrench"></i>&nbsp;移动端动画及细节</span> <i class="fa-solid fa-screwdriver-wrench"></i>&nbsp;移动端动画及细节</span>
<span class="uptext"> <span class="uptext">
<i class="fa-solid fa-screwdriver-wrench"></i>&nbsp;图标更换为 Font <i class="fa-solid fa-screwdriver-wrench"></i>&nbsp;图标更换为 FontAwesome</span>
Awesome</span>
<span class="uptext"> <span class="uptext">
<i class="fa-solid fa-rotate-left"></i> <i class="fa-solid fa-rotate-left"></i>
<a href="<?php echo $site->domain; ?>/old/" style="color:#efefef">返回旧版站点</a> <a href="<?php echo $site->domain; ?>/" style="color:#efefef">返回旧版站点(X)</a>
</span> </span>
</div> </div>
</div> </div>
@ -457,10 +456,9 @@ require_once './config.php';
</main> </main>
<!-- 版权信息 --> <!-- 版权信息 -->
<footer id="footer" class="fixed-bottom footer"> <footer id="footer" class="fixed-bottom footer">
<div class="power">Copyright&nbsp;&copy;&nbsp;<span id="power-year">2020</span> <div class="power">Copyright&nbsp;&copy;&nbsp;
<script> <span id="power-year"><?php echo $site->copyright[0] . '&nbsp;-&nbsp;' . date('Y');; ?></span>
document.write(' - ' + (new Date()).getFullYear()) <a href="<?php echo $site->domain; ?>" id="power-text"><?php echo $site->copyright[1]; ?></a>&nbsp;&amp;&nbsp;
</script>&nbsp;<a href="https://imsyy.top" id="power-text">無名</a>&nbsp;&amp;&nbsp;
<!-- 以下信息请不要修改哦 --> <!-- 以下信息请不要修改哦 -->
Made&nbsp;by&nbsp;<a href="https://github.com/imsyy/home" target="_blank">imsyy</a> Made&nbsp;by&nbsp;<a href="https://github.com/imsyy/home" target="_blank">imsyy</a>
</div> </div>
@ -482,8 +480,7 @@ require_once './config.php';
</noscript> </noscript>
<!-- JS --> <!-- JS -->
<script type="text/javascript" src="<?php echo $site->domain; ?>/js/main.js"></script> <script type="text/javascript" src="<?php echo $site->domain; ?>/js/main.js"></script>
<!-- <script type="text/javascript" src="<?php //echo $site->domain; <!-- <script type="text/javascript" src="/js/set.js"></script> -->
?>/js/set.js"></script> -->
<script type="text/javascript" src="<?php echo $site->domain; ?>/js/time.js"></script> <script type="text/javascript" src="<?php echo $site->domain; ?>/js/time.js"></script>
<script type="text/javascript" src="<?php echo $site->domain; ?>/js/js.cookie.js"></script> <script type="text/javascript" src="<?php echo $site->domain; ?>/js/js.cookie.js"></script>
<script type="text/javascript" src="<?php echo $site->domain; ?>/js/cursor.js"></script> <script type="text/javascript" src="<?php echo $site->domain; ?>/js/cursor.js"></script>
@ -498,10 +495,10 @@ require_once './config.php';
/* 天气 API */ /* 天气 API */
localStorage.setItem('weather_api', '<?php echo $site->weather_api; ?>'); localStorage.setItem('weather_api', '<?php echo $site->weather_api; ?>');
// 壁纸 API // 壁纸 API
localStorage.setItem('wallpaper_api_1', '<?php echo $site->get_wallpaperapi(0, 'url'); ?>'); localStorage.setItem('wallpaper_api_1', '<?php echo $site->get_kv('wallpaper_api', 0, 'url'); ?>');
localStorage.setItem('wallpaper_api_2', '<?php echo $site->get_wallpaperapi(1, 'url'); ?>'); localStorage.setItem('wallpaper_api_2', '<?php echo $site->get_kv('wallpaper_api', 1, 'url'); ?>');
localStorage.setItem('wallpaper_api_3', '<?php echo $site->get_wallpaperapi(2, 'url'); ?>'); localStorage.setItem('wallpaper_api_3', '<?php echo $site->get_kv('wallpaper_api', 2, 'url'); ?>');
localStorage.setItem('wallpaper_api_4', '<?php echo $site->get_wallpaperapi(3, 'url'); ?>'); localStorage.setItem('wallpaper_api_4', '<?php echo $site->get_kv('wallpaper_api', 3, 'url'); ?>');
/* 添加了一个壁纸 API, 其他未动 */ /* 添加了一个壁纸 API, 其他未动 */