fix: 修复天气及壁纸 API 无法使用的问题
This commit is contained in:
parent
6cd803db56
commit
f68fd55415
29
.gitignore
vendored
29
.gitignore
vendored
@ -1 +1,28 @@
|
|||||||
/.vscode/*
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
*.local
|
||||||
|
|
||||||
|
/cypress/videos/
|
||||||
|
/cypress/screenshots/
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
31
.hintrc
Normal file
31
.hintrc
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"development"
|
||||||
|
],
|
||||||
|
"hints": {
|
||||||
|
"compat-api/html": [
|
||||||
|
"default",
|
||||||
|
{
|
||||||
|
"ignore": [
|
||||||
|
"meta[name=theme-color]"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"highest-available-document-mode": "off",
|
||||||
|
"axe/text-alternatives": [
|
||||||
|
"default",
|
||||||
|
{
|
||||||
|
"image-alt": "off"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"apple-touch-icons": "off",
|
||||||
|
"axe/name-role-value": [
|
||||||
|
"default",
|
||||||
|
{
|
||||||
|
"link-name": "off"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-inline-styles": "off",
|
||||||
|
"disown-opener": "off"
|
||||||
|
}
|
||||||
|
}
|
10
README.md
10
README.md
@ -1,7 +1,7 @@
|
|||||||
简体中文 | [English](./README_EN.md)
|
简体中文 | [English](./README_EN.md)
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong><h2>無名の主页</h2></strong>
|
<strong><h2>無名の主页 - 静态版本</h2></strong>
|
||||||
简单的小主页,原来的看够了,重新弄了一个
|
简单的小主页,原来的看够了,重新弄了一个
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -32,10 +32,12 @@
|
|||||||
|
|
||||||
### 天气
|
### 天气
|
||||||
|
|
||||||
由于原天气 API 不稳定,已更换天气 API,现需要前往以下网站获取 key
|
天气及地区获取需要 `高德开放平台` 相关 API
|
||||||
|
|
||||||
|
- 前往 [高德开放平台控制台](https://console.amap.com/dev/index) 创建一个 `Web 服务` 类型的 `Key`,并将 `Key` 填入 `js/main.js` 中的 `mainKey` 中
|
||||||
|
|
||||||
|
也可自行更换其他方式
|
||||||
|
|
||||||
- 前往 [ROLL](https://www.mxnzp.com/doc/list) 获取 app_id 和 app_secret,用于获取城市信息
|
|
||||||
- 前往 [和风天气](https://dev.qweather.com/) 获取 key,用于获取天气信息
|
|
||||||
|
|
||||||
也可自行更换其他方式
|
也可自行更换其他方式
|
||||||
|
|
||||||
|
590
js/main.js
590
js/main.js
@ -7,20 +7,20 @@ GitHub:https://github.com/imsyy/home
|
|||||||
|
|
||||||
//弹窗样式
|
//弹窗样式
|
||||||
iziToast.settings({
|
iziToast.settings({
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
progressBar: false,
|
progressBar: false,
|
||||||
close: false,
|
close: false,
|
||||||
closeOnEscape: true,
|
closeOnEscape: true,
|
||||||
position: 'topCenter',
|
position: "topCenter",
|
||||||
transitionIn: 'bounceInDown',
|
transitionIn: "bounceInDown",
|
||||||
transitionOut: 'flipOutX',
|
transitionOut: "flipOutX",
|
||||||
displayMode: 'replace',
|
displayMode: "replace",
|
||||||
layout: '1',
|
layout: "1",
|
||||||
backgroundColor: '#00000040',
|
backgroundColor: "#00000040",
|
||||||
titleColor: '#efefef',
|
titleColor: "#efefef",
|
||||||
messageColor: '#efefef',
|
messageColor: "#efefef",
|
||||||
icon: 'Fontawesome',
|
icon: "Fontawesome",
|
||||||
iconColor: '#efefef',
|
iconColor: "#efefef",
|
||||||
});
|
});
|
||||||
|
|
||||||
/* 鼠标样式 */
|
/* 鼠标样式 */
|
||||||
@ -31,34 +31,41 @@ const halfAlementWidth = element.offsetWidth / 2;
|
|||||||
const halfAlementWidth2 = element2.offsetWidth / 2;
|
const halfAlementWidth2 = element2.offsetWidth / 2;
|
||||||
|
|
||||||
function setPosition(x, y) {
|
function setPosition(x, y) {
|
||||||
element2.style.transform = `translate(${x - halfAlementWidth2 + 1}px, ${y - halfAlementWidth2 + 1}px)`;
|
element2.style.transform = `translate(${x - halfAlementWidth2 + 1}px, ${
|
||||||
|
y - halfAlementWidth2 + 1
|
||||||
|
}px)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.addEventListener('mousemove', (e) => {
|
body.addEventListener("mousemove", (e) => {
|
||||||
window.requestAnimationFrame(function () {
|
window.requestAnimationFrame(function () {
|
||||||
setPosition(e.clientX, e.clientY);
|
setPosition(e.clientX, e.clientY);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//加载完成后执行
|
//加载完成后执行
|
||||||
window.addEventListener('load', function () {
|
window.addEventListener(
|
||||||
|
"load",
|
||||||
|
function () {
|
||||||
//载入动画
|
//载入动画
|
||||||
$('#loading-box').attr('class', 'loaded');
|
$("#loading-box").attr("class", "loaded");
|
||||||
$('#bg').css("cssText", "transform: scale(1);filter: blur(0px);transition: ease 1.5s;");
|
$("#bg").css(
|
||||||
$('.cover').css("cssText", "opacity: 1;transition: ease 1.5s;");
|
"cssText",
|
||||||
$('#section').css("cssText", "transform: scale(1) !important;opacity: 1 !important;filter: blur(0px) !important");
|
"transform: scale(1);filter: blur(0px);transition: ease 1.5s;"
|
||||||
|
);
|
||||||
|
$(".cover").css("cssText", "opacity: 1;transition: ease 1.5s;");
|
||||||
|
$("#section").css(
|
||||||
|
"cssText",
|
||||||
|
"transform: scale(1) !important;opacity: 1 !important;filter: blur(0px) !important"
|
||||||
|
);
|
||||||
|
|
||||||
//用户欢迎
|
//用户欢迎
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
iziToast.show({
|
iziToast.show({
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
icon: false,
|
icon: false,
|
||||||
title: hello,
|
title: hello,
|
||||||
message: '欢迎来到我的主页'
|
message: "欢迎来到我的主页",
|
||||||
});
|
});
|
||||||
}, 800);
|
}, 800);
|
||||||
|
|
||||||
//延迟加载音乐播放器
|
//延迟加载音乐播放器
|
||||||
@ -77,13 +84,14 @@ window.addEventListener('load', function () {
|
|||||||
|
|
||||||
//移动端去除鼠标样式
|
//移动端去除鼠标样式
|
||||||
if (Boolean(window.navigator.userAgent.match(/AppWebKit.*Mobile.*/))) {
|
if (Boolean(window.navigator.userAgent.match(/AppWebKit.*Mobile.*/))) {
|
||||||
$('#g-pointer-2').css("display", "none");
|
$("#g-pointer-2").css("display", "none");
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}, false)
|
false
|
||||||
|
);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$('#loading-text').html("字体及文件加载可能需要一定时间")
|
$("#loading-text").html("字体及文件加载可能需要一定时间");
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
||||||
// 新春灯笼 ( 需要时可取消注释 )
|
// 新春灯笼 ( 需要时可取消注释 )
|
||||||
@ -99,95 +107,104 @@ setTimeout(function () {
|
|||||||
// document.body.appendChild(new_element);
|
// document.body.appendChild(new_element);
|
||||||
|
|
||||||
//获取一言
|
//获取一言
|
||||||
fetch('https://v1.hitokoto.cn?max_length=24')
|
fetch("https://v1.hitokoto.cn?max_length=24")
|
||||||
.then(response => response.json())
|
.then((response) => response.json())
|
||||||
.then(data => {
|
.then((data) => {
|
||||||
$('#hitokoto_text').html(data.hitokoto)
|
$("#hitokoto_text").html(data.hitokoto);
|
||||||
$('#from_text').html(data.from)
|
$("#from_text").html(data.from);
|
||||||
})
|
})
|
||||||
.catch(console.error)
|
.catch(console.error);
|
||||||
|
|
||||||
let times = 0;
|
let times = 0;
|
||||||
$('#hitokoto').click(function () {
|
$("#hitokoto").click(function () {
|
||||||
if (times == 0) {
|
if (times == 0) {
|
||||||
times = 1;
|
times = 1;
|
||||||
let index = setInterval(function () {
|
let index = setInterval(function () {
|
||||||
times--;
|
times--;
|
||||||
if (times == 0) {
|
if (times == 0) {
|
||||||
clearInterval(index);
|
clearInterval(index);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
fetch('https://v1.hitokoto.cn?max_length=24')
|
fetch("https://v1.hitokoto.cn?max_length=24")
|
||||||
.then(response => response.json())
|
.then((response) => response.json())
|
||||||
.then(data => {
|
.then((data) => {
|
||||||
$('#hitokoto_text').html(data.hitokoto)
|
$("#hitokoto_text").html(data.hitokoto);
|
||||||
$('#from_text').html(data.from)
|
$("#from_text").html(data.from);
|
||||||
})
|
})
|
||||||
.catch(console.error)
|
.catch(console.error);
|
||||||
} else {
|
} else {
|
||||||
iziToast.show({
|
iziToast.show({
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
icon: "fa-solid fa-circle-exclamation",
|
icon: "fa-solid fa-circle-exclamation",
|
||||||
message: '你点太快了吧'
|
message: "你点太快了吧",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//获取天气
|
// 获取天气
|
||||||
//请前往 https://www.mxnzp.com/doc/list 申请 app_id 和 app_secret
|
// 请前往 https://www.mxnzp.com/doc/list 申请 app_id 和 app_secret
|
||||||
//请前往 https://dev.qweather.com/ 申请 key
|
const mainKey = "57eaea5833ff1616cfd1ff2c4cf9b58a"; // 高德开发者 Key
|
||||||
const add_id = "wrknltonr0foslhs"; // app_id
|
const getWeather = () => {
|
||||||
const app_secret = "Nlh1c0F6d0ZDU2pDR0J3YVBVbkhudz09"; // app_secret
|
fetch(`https://restapi.amap.com/v3/ip?key=${mainKey}`)
|
||||||
const key = "433f0c48615a48dfaf2f2b2444297e79" // key
|
.then((response) => response.json())
|
||||||
function getWeather() {
|
.then((res) => {
|
||||||
fetch("https://www.mxnzp.com/api/ip/self?app_id=" + add_id + "&app_secret=" + app_secret)
|
const adcode = res.adcode;
|
||||||
.then(response => response.json())
|
$("#city_text").html(res.city);
|
||||||
.then(data => {
|
fetch(
|
||||||
let str = data.data.city
|
`https://restapi.amap.com/v3/weather/weatherInfo?key=${mainKey}&city=${adcode}`
|
||||||
let city = str.replace(/市/g, '')
|
)
|
||||||
$('#city_text').html(city);
|
.then((response) => response.json())
|
||||||
fetch("https://geoapi.qweather.com/v2/city/lookup?location=" + city + "&number=1&key=" + key)
|
.then((res) => {
|
||||||
.then(response => response.json())
|
if (res.status) {
|
||||||
.then(location => {
|
$("#wea_text").html(res.lives[0].weather);
|
||||||
let id = location.location[0].id
|
$("#tem_text").html(res.lives[0].temperature + "°C ");
|
||||||
fetch("https://devapi.qweather.com/v7/weather/now?location=" + id + "&key=" + key)
|
$("#win_text").html(res.lives[0].winddirection + "风");
|
||||||
.then(response => response.json())
|
$("#win_speed").html(res.lives[0].windpower + "级");
|
||||||
.then(weather => {
|
} else {
|
||||||
$('#wea_text').html(weather.now.text)
|
console.error("天气信息获取失败");
|
||||||
$('#tem_text').html(weather.now.temp + "°C ")
|
iziToast.show({
|
||||||
$('#win_text').html(weather.now.windDir)
|
timeout: 2000,
|
||||||
$('#win_speed').html(weather.now.windScale + "级")
|
icon: "fa-solid fa-cloud-sun",
|
||||||
})
|
message: "天气信息获取失败",
|
||||||
})
|
});
|
||||||
})
|
}
|
||||||
.catch(console.error);
|
});
|
||||||
}
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("天气信息获取失败:" + err);
|
||||||
|
iziToast.show({
|
||||||
|
timeout: 2000,
|
||||||
|
icon: "fa-solid fa-cloud-sun",
|
||||||
|
message: "天气信息获取失败",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
getWeather();
|
getWeather();
|
||||||
|
|
||||||
let wea = 0;
|
let wea = 0;
|
||||||
$('#upWeather').click(function () {
|
$("#upWeather").click(function () {
|
||||||
if (wea == 0) {
|
if (wea == 0) {
|
||||||
wea = 1;
|
wea = 1;
|
||||||
let index = setInterval(function () {
|
let index = setInterval(function () {
|
||||||
wea--;
|
wea--;
|
||||||
if (wea == 0) {
|
if (wea == 0) {
|
||||||
clearInterval(index);
|
clearInterval(index);
|
||||||
}
|
}
|
||||||
}, 60000);
|
}, 60000);
|
||||||
getWeather();
|
getWeather();
|
||||||
iziToast.show({
|
iziToast.show({
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
icon: "fa-solid fa-cloud-sun",
|
icon: "fa-solid fa-cloud-sun",
|
||||||
message: '实时天气已更新'
|
message: "实时天气已更新",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
iziToast.show({
|
iziToast.show({
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
icon: "fa-solid fa-circle-exclamation",
|
icon: "fa-solid fa-circle-exclamation",
|
||||||
message: '请稍后再更新哦'
|
message: "请稍后再更新哦",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//获取时间
|
//获取时间
|
||||||
@ -195,198 +212,242 @@ let t = null;
|
|||||||
t = setTimeout(time, 1000);
|
t = setTimeout(time, 1000);
|
||||||
|
|
||||||
function time() {
|
function time() {
|
||||||
clearTimeout(t);
|
clearTimeout(t);
|
||||||
dt = new Date();
|
dt = new Date();
|
||||||
let y = dt.getYear() + 1900;
|
let y = dt.getYear() + 1900;
|
||||||
let mm = dt.getMonth() + 1;
|
let mm = dt.getMonth() + 1;
|
||||||
let d = dt.getDate();
|
let d = dt.getDate();
|
||||||
let weekday = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
let weekday = [
|
||||||
let day = dt.getDay();
|
"星期日",
|
||||||
let h = dt.getHours();
|
"星期一",
|
||||||
let m = dt.getMinutes();
|
"星期二",
|
||||||
let s = dt.getSeconds();
|
"星期三",
|
||||||
if (h < 10) {
|
"星期四",
|
||||||
h = "0" + h;
|
"星期五",
|
||||||
}
|
"星期六",
|
||||||
if (m < 10) {
|
];
|
||||||
m = "0" + m;
|
let day = dt.getDay();
|
||||||
}
|
let h = dt.getHours();
|
||||||
if (s < 10) {
|
let m = dt.getMinutes();
|
||||||
s = "0" + s;
|
let s = dt.getSeconds();
|
||||||
}
|
if (h < 10) {
|
||||||
$("#time").html(y + " 年 " + mm + " 月 " + d + " 日 " + "<span class='weekday'>" + weekday[day] + "</span><br>" + "<span class='time-text'>" + h + ":" + m + ":" + s + "</span>");
|
h = "0" + h;
|
||||||
t = setTimeout(time, 1000);
|
}
|
||||||
|
if (m < 10) {
|
||||||
|
m = "0" + m;
|
||||||
|
}
|
||||||
|
if (s < 10) {
|
||||||
|
s = "0" + s;
|
||||||
|
}
|
||||||
|
$("#time").html(
|
||||||
|
y +
|
||||||
|
" 年 " +
|
||||||
|
mm +
|
||||||
|
" 月 " +
|
||||||
|
d +
|
||||||
|
" 日 " +
|
||||||
|
"<span class='weekday'>" +
|
||||||
|
weekday[day] +
|
||||||
|
"</span><br>" +
|
||||||
|
"<span class='time-text'>" +
|
||||||
|
h +
|
||||||
|
":" +
|
||||||
|
m +
|
||||||
|
":" +
|
||||||
|
s +
|
||||||
|
"</span>"
|
||||||
|
);
|
||||||
|
t = setTimeout(time, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//链接提示文字
|
//链接提示文字
|
||||||
$("#social").mouseover(function () {
|
$("#social")
|
||||||
|
.mouseover(function () {
|
||||||
$("#social").css({
|
$("#social").css({
|
||||||
"background": "rgb(0 0 0 / 25%)",
|
background: "rgb(0 0 0 / 25%)",
|
||||||
'border-radius': '6px',
|
"border-radius": "6px",
|
||||||
"backdrop-filter": "blur(5px)"
|
"backdrop-filter": "blur(5px)",
|
||||||
});
|
});
|
||||||
$("#link-text").css({
|
$("#link-text").css({
|
||||||
"display": "block",
|
display: "block",
|
||||||
});
|
});
|
||||||
}).mouseout(function () {
|
})
|
||||||
|
.mouseout(function () {
|
||||||
$("#social").css({
|
$("#social").css({
|
||||||
"background": "none",
|
background: "none",
|
||||||
"border-radius": "6px",
|
"border-radius": "6px",
|
||||||
"backdrop-filter": "none"
|
"backdrop-filter": "none",
|
||||||
});
|
});
|
||||||
$("#link-text").css({
|
$("#link-text").css({
|
||||||
"display": "none"
|
display: "none",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#github").mouseover(function () {
|
$("#github")
|
||||||
|
.mouseover(function () {
|
||||||
$("#link-text").html("去 Github 看看");
|
$("#link-text").html("去 Github 看看");
|
||||||
}).mouseout(function () {
|
})
|
||||||
|
.mouseout(function () {
|
||||||
$("#link-text").html("通过这里联系我");
|
$("#link-text").html("通过这里联系我");
|
||||||
});
|
});
|
||||||
$("#qq").mouseover(function () {
|
$("#qq")
|
||||||
|
.mouseover(function () {
|
||||||
$("#link-text").html("有什么事吗");
|
$("#link-text").html("有什么事吗");
|
||||||
}).mouseout(function () {
|
})
|
||||||
|
.mouseout(function () {
|
||||||
$("#link-text").html("通过这里联系我");
|
$("#link-text").html("通过这里联系我");
|
||||||
});
|
});
|
||||||
$("#email").mouseover(function () {
|
$("#email")
|
||||||
|
.mouseover(function () {
|
||||||
$("#link-text").html("来封 Email");
|
$("#link-text").html("来封 Email");
|
||||||
}).mouseout(function () {
|
})
|
||||||
|
.mouseout(function () {
|
||||||
$("#link-text").html("通过这里联系我");
|
$("#link-text").html("通过这里联系我");
|
||||||
});
|
});
|
||||||
$("#bilibili").mouseover(function () {
|
$("#bilibili")
|
||||||
|
.mouseover(function () {
|
||||||
$("#link-text").html("来 B 站看看 ~");
|
$("#link-text").html("来 B 站看看 ~");
|
||||||
}).mouseout(function () {
|
})
|
||||||
|
.mouseout(function () {
|
||||||
$("#link-text").html("通过这里联系我");
|
$("#link-text").html("通过这里联系我");
|
||||||
});
|
});
|
||||||
$("#telegram").mouseover(function () {
|
$("#telegram")
|
||||||
|
.mouseover(function () {
|
||||||
$("#link-text").html("你懂的 ~");
|
$("#link-text").html("你懂的 ~");
|
||||||
}).mouseout(function () {
|
})
|
||||||
|
.mouseout(function () {
|
||||||
$("#link-text").html("通过这里联系我");
|
$("#link-text").html("通过这里联系我");
|
||||||
});
|
});
|
||||||
|
|
||||||
//自动变灰
|
//自动变灰
|
||||||
let myDate = new Date;
|
let myDate = new Date();
|
||||||
let mon = myDate.getMonth() + 1;
|
let mon = myDate.getMonth() + 1;
|
||||||
let date = myDate.getDate();
|
let date = myDate.getDate();
|
||||||
let days = ['4.4', '5.12', '7.7', '9.9', '9.18', '12.13'];
|
let days = ["4.4", "5.12", "7.7", "9.9", "9.18", "12.13"];
|
||||||
for (let day of days) {
|
for (let day of days) {
|
||||||
let d = day.split('.');
|
let d = day.split(".");
|
||||||
if (mon == d[0] && date == d[1]) {
|
if (mon == d[0] && date == d[1]) {
|
||||||
document.write(
|
document.write(
|
||||||
'<style>html{-webkit-filter:grayscale(100%);-moz-filter:grayscale(100%);-ms-filter:grayscale(100%);-o-filter:grayscale(100%);filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);_filter:none}</style>'
|
"<style>html{-webkit-filter:grayscale(100%);-moz-filter:grayscale(100%);-ms-filter:grayscale(100%);-o-filter:grayscale(100%);filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);_filter:none}</style>"
|
||||||
);
|
);
|
||||||
$("#change").html("Silence in silence");
|
$("#change").html("Silence in silence");
|
||||||
$("#change1").html("今天是中国国家纪念日,全站已切换为黑白模式");
|
$("#change1").html("今天是中国国家纪念日,全站已切换为黑白模式");
|
||||||
window.addEventListener('load', function () {
|
window.addEventListener(
|
||||||
setTimeout(function () {
|
"load",
|
||||||
iziToast.show({
|
function () {
|
||||||
timeout: 14000,
|
setTimeout(function () {
|
||||||
icon: "fa-solid fa-clock",
|
iziToast.show({
|
||||||
message: '今天是中国国家纪念日'
|
timeout: 14000,
|
||||||
});
|
icon: "fa-solid fa-clock",
|
||||||
}, 3800);
|
message: "今天是中国国家纪念日",
|
||||||
}, false);
|
});
|
||||||
}
|
}, 3800);
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//更多页面切换
|
//更多页面切换
|
||||||
let shoemore = false;
|
let shoemore = false;
|
||||||
$('#switchmore').on('click', function () {
|
$("#switchmore").on("click", function () {
|
||||||
shoemore = !shoemore;
|
shoemore = !shoemore;
|
||||||
if (shoemore && $(document).width() >= 990) {
|
if (shoemore && $(document).width() >= 990) {
|
||||||
$('#container').attr('class', 'container mores');
|
$("#container").attr("class", "container mores");
|
||||||
$("#change").html("Oops !");
|
$("#change").html("Oops !");
|
||||||
$("#change1").html("哎呀,这都被你发现了( 再点击一次可关闭 )");
|
$("#change1").html("哎呀,这都被你发现了( 再点击一次可关闭 )");
|
||||||
} else {
|
} else {
|
||||||
$('#container').attr('class', 'container');
|
$("#container").attr("class", "container");
|
||||||
$("#change").html("Hello World !");
|
$("#change").html("Hello World !");
|
||||||
$("#change1").html("一个建立于 21 世纪的小站,存活于互联网的边缘");
|
$("#change1").html("一个建立于 21 世纪的小站,存活于互联网的边缘");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//更多页面关闭按钮
|
//更多页面关闭按钮
|
||||||
$('#close').on('click', function () {
|
$("#close").on("click", function () {
|
||||||
$('#switchmore').click();
|
$("#switchmore").click();
|
||||||
});
|
});
|
||||||
|
|
||||||
//移动端菜单栏切换
|
//移动端菜单栏切换
|
||||||
let switchmenu = false;
|
let switchmenu = false;
|
||||||
$('#switchmenu').on('click', function () {
|
$("#switchmenu").on("click", function () {
|
||||||
switchmenu = !switchmenu;
|
switchmenu = !switchmenu;
|
||||||
if (switchmenu) {
|
if (switchmenu) {
|
||||||
$('#row').attr('class', 'row menus');
|
$("#row").attr("class", "row menus");
|
||||||
$("#menu").html("<i class='fa-solid fa-xmark'></i>");
|
$("#menu").html("<i class='fa-solid fa-xmark'></i>");
|
||||||
} else {
|
} else {
|
||||||
$('#row').attr('class', 'row');
|
$("#row").attr("class", "row");
|
||||||
$("#menu").html("<i class='fa-solid fa-bars'></i>");
|
$("#menu").html("<i class='fa-solid fa-bars'></i>");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//更多弹窗页面
|
//更多弹窗页面
|
||||||
$('#openmore').on('click', function () {
|
$("#openmore").on("click", function () {
|
||||||
$('#box').css("display", "block");
|
$("#box").css("display", "block");
|
||||||
$('#row').css("display", "none");
|
$("#row").css("display", "none");
|
||||||
$('#more').css("cssText", "display:none !important");
|
$("#more").css("cssText", "display:none !important");
|
||||||
});
|
});
|
||||||
$('#closemore').on('click', function () {
|
$("#closemore").on("click", function () {
|
||||||
$('#box').css("display", "none");
|
$("#box").css("display", "none");
|
||||||
$('#row').css("display", "flex");
|
$("#row").css("display", "flex");
|
||||||
$('#more').css("display", "flex");
|
$("#more").css("display", "flex");
|
||||||
});
|
});
|
||||||
|
|
||||||
//监听网页宽度
|
//监听网页宽度
|
||||||
window.addEventListener('load', function () {
|
window.addEventListener("load", function () {
|
||||||
window.addEventListener('resize', function () {
|
window.addEventListener("resize", function () {
|
||||||
//关闭移动端样式
|
//关闭移动端样式
|
||||||
if (window.innerWidth >= 600) {
|
if (window.innerWidth >= 600) {
|
||||||
$('#row').attr('class', 'row');
|
$("#row").attr("class", "row");
|
||||||
$("#menu").html("<i class='fa-solid fa-bars'></i>");
|
$("#menu").html("<i class='fa-solid fa-bars'></i>");
|
||||||
//移除移动端切换功能区
|
//移除移动端切换功能区
|
||||||
$('#rightone').attr('class', 'row rightone');
|
$("#rightone").attr("class", "row rightone");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.innerWidth <= 990) {
|
if (window.innerWidth <= 990) {
|
||||||
//移动端隐藏更多页面
|
//移动端隐藏更多页面
|
||||||
$('#container').attr('class', 'container');
|
$("#container").attr("class", "container");
|
||||||
$("#change").html("Hello World !");
|
$("#change").html("Hello World !");
|
||||||
$("#change1").html("一个建立于 21 世纪的小站,存活于互联网的边缘");
|
$("#change1").html("一个建立于 21 世纪的小站,存活于互联网的边缘");
|
||||||
|
|
||||||
//移动端隐藏弹窗页面
|
//移动端隐藏弹窗页面
|
||||||
$('#box').css("display", "none");
|
$("#box").css("display", "none");
|
||||||
$('#row').css("display", "flex");
|
$("#row").css("display", "flex");
|
||||||
$('#more').css("display", "flex");
|
$("#more").css("display", "flex");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
//移动端切换功能区
|
//移动端切换功能区
|
||||||
let changemore = false;
|
let changemore = false;
|
||||||
$('#changemore').on('click', function () {
|
$("#changemore").on("click", function () {
|
||||||
changemore = !changemore;
|
changemore = !changemore;
|
||||||
if (changemore) {
|
if (changemore) {
|
||||||
$('#rightone').attr('class', 'row menus mobile');
|
$("#rightone").attr("class", "row menus mobile");
|
||||||
} else {
|
} else {
|
||||||
$('#rightone').attr('class', 'row menus');
|
$("#rightone").attr("class", "row menus");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//更多页面显示关闭按钮
|
//更多页面显示关闭按钮
|
||||||
$("#more").hover(function () {
|
$("#more").hover(
|
||||||
$('#close').css("display", "block");
|
function () {
|
||||||
}, function () {
|
$("#close").css("display", "block");
|
||||||
$('#close').css("display", "none");
|
},
|
||||||
})
|
function () {
|
||||||
|
$("#close").css("display", "none");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
//屏蔽右键
|
//屏蔽右键
|
||||||
document.oncontextmenu = function () {
|
document.oncontextmenu = function () {
|
||||||
iziToast.show({
|
iziToast.show({
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
icon: "fa-solid fa-circle-exclamation",
|
icon: "fa-solid fa-circle-exclamation",
|
||||||
message: '为了浏览体验,本站禁用右键'
|
message: "为了浏览体验,本站禁用右键",
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
//控制台输出
|
//控制台输出
|
||||||
//console.clear();
|
//console.clear();
|
||||||
@ -394,15 +455,15 @@ let styleTitle1 = `
|
|||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: rgb(244,167,89);
|
color: rgb(244,167,89);
|
||||||
`
|
`;
|
||||||
let styleTitle2 = `
|
let styleTitle2 = `
|
||||||
font-size:12px;
|
font-size:12px;
|
||||||
color: rgb(244,167,89);
|
color: rgb(244,167,89);
|
||||||
`
|
`;
|
||||||
let styleContent = `
|
let styleContent = `
|
||||||
color: rgb(30,152,255);
|
color: rgb(30,152,255);
|
||||||
`
|
`;
|
||||||
let title1 = '無名の主页'
|
let title1 = "無名の主页";
|
||||||
let title2 = `
|
let title2 = `
|
||||||
_____ __ __ _______ ____ __
|
_____ __ __ _______ ____ __
|
||||||
|_ _| \\/ |/ ____\\ \\ / /\\ \\ / /
|
|_ _| \\/ |/ ____\\ \\ / /\\ \\ / /
|
||||||
@ -410,13 +471,18 @@ let title2 = `
|
|||||||
| | | |\\/| |\\___ \\ \\ / \\ /
|
| | | |\\/| |\\___ \\ \\ / \\ /
|
||||||
_| |_| | | |____) | | | | |
|
_| |_| | | |____) | | | | |
|
||||||
|_____|_| |_|_____/ |_| |_|
|
|_____|_| |_|_____/ |_| |_|
|
||||||
`
|
`;
|
||||||
let content = `
|
let content = `
|
||||||
版 本 号:3.4
|
版 本 号:3.4
|
||||||
更新日期:2022-07-24
|
更新日期:2022-07-24
|
||||||
|
|
||||||
主页: https://www.imsyy.top
|
主页: https://www.imsyy.top
|
||||||
Github: https://github.com/imsyy/home
|
Github: https://github.com/imsyy/home
|
||||||
`
|
`;
|
||||||
console.log(`%c${title1} %c${title2}
|
console.log(
|
||||||
%c${content}`, styleTitle1, styleTitle2, styleContent)
|
`%c${title1} %c${title2}
|
||||||
|
%c${content}`,
|
||||||
|
styleTitle1,
|
||||||
|
styleTitle2,
|
||||||
|
styleContent
|
||||||
|
);
|
||||||
|
105
js/set.js
105
js/set.js
@ -5,69 +5,72 @@ GitHub:https://github.com/imsyy/home
|
|||||||
版权所有,请勿删除
|
版权所有,请勿删除
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 背景图片 Cookies
|
// 背景图片 Cookies
|
||||||
function setBgImg(bg_img) {
|
function setBgImg(bg_img) {
|
||||||
if (bg_img) {
|
if (bg_img) {
|
||||||
Cookies.set('bg_img', bg_img, {
|
Cookies.set("bg_img", bg_img, {
|
||||||
expires: 36500
|
expires: 36500,
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
// 获取背景图片 Cookies
|
// 获取背景图片 Cookies
|
||||||
function getBgImg() {
|
function getBgImg() {
|
||||||
let bg_img_local = Cookies.get('bg_img');
|
let bg_img_local = Cookies.get("bg_img");
|
||||||
if (bg_img_local && bg_img_local !== "{}") {
|
if (bg_img_local && bg_img_local !== "{}") {
|
||||||
return JSON.parse(bg_img_local);
|
return JSON.parse(bg_img_local);
|
||||||
} else {
|
} else {
|
||||||
setBgImg(bg_img_preinstall);
|
setBgImg(bg_img_preinstall);
|
||||||
return bg_img_preinstall;
|
return bg_img_preinstall;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let bg_img_preinstall = {
|
let bg_img_preinstall = {
|
||||||
"type": "1", // 1:默认背景 2:每日一图 3:随机风景 4:随机动漫
|
type: "1", // 1:默认背景 2:每日一图 3:随机风景 4:随机动漫
|
||||||
"2": "https://api.dujin.org/bing/1920.php", // 每日一图
|
2: "https://api.dujin.org/bing/1920.php", // 每日一图
|
||||||
"3": "https://api.ixiaowai.cn/gqapi/gqapi.php", // 随机风景
|
3: "https://api.btstu.cn/sjbz/api.php?lx=fengjing&format=images", // 随机风景
|
||||||
"4": "https://api.ixiaowai.cn/api/api.php" // 随机动漫
|
4: "https://www.dmoe.cc/random.php", // 随机动漫
|
||||||
};
|
};
|
||||||
|
|
||||||
// 更改背景图片
|
// 更改背景图片
|
||||||
function setBgImgInit() {
|
function setBgImgInit() {
|
||||||
let bg_img = getBgImg();
|
let bg_img = getBgImg();
|
||||||
$("input[name='wallpaper-type'][value=" + bg_img["type"] + "]").click();
|
$("input[name='wallpaper-type'][value=" + bg_img["type"] + "]").click();
|
||||||
|
|
||||||
switch (bg_img["type"]) {
|
switch (bg_img["type"]) {
|
||||||
case "1":
|
case "1":
|
||||||
$('#bg').attr('src', `./img/background${1 + ~~(Math.random() * 10)}.webp`) //随机默认壁纸
|
$("#bg").attr(
|
||||||
break;
|
"src",
|
||||||
case "2":
|
`./img/background${1 + ~~(Math.random() * 10)}.webp`
|
||||||
$('#bg').attr('src', bg_img_preinstall[2]); //必应每日
|
); //随机默认壁纸
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "2":
|
||||||
$('#bg').attr('src', bg_img_preinstall[3]); //随机风景
|
$("#bg").attr("src", bg_img_preinstall[2]); //必应每日
|
||||||
break;
|
break;
|
||||||
case "4":
|
case "3":
|
||||||
$('#bg').attr('src', bg_img_preinstall[4]); //随机动漫
|
$("#bg").attr("src", bg_img_preinstall[3]); //随机风景
|
||||||
break;
|
break;
|
||||||
}
|
case "4":
|
||||||
};
|
$("#bg").attr("src", bg_img_preinstall[4]); //随机动漫
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// 壁纸数据加载
|
// 壁纸数据加载
|
||||||
setBgImgInit();
|
setBgImgInit();
|
||||||
// 设置背景图片
|
// 设置背景图片
|
||||||
$("#wallpaper").on("click", ".set-wallpaper", function () {
|
$("#wallpaper").on("click", ".set-wallpaper", function () {
|
||||||
let type = $(this).val();
|
let type = $(this).val();
|
||||||
let bg_img = getBgImg();
|
let bg_img = getBgImg();
|
||||||
bg_img["type"] = type;
|
bg_img["type"] = type;
|
||||||
iziToast.show({
|
iziToast.show({
|
||||||
icon: "fa-solid fa-image",
|
icon: "fa-solid fa-image",
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
message: '壁纸设置成功,刷新后生效',
|
message: "壁纸设置成功,刷新后生效",
|
||||||
});
|
|
||||||
setBgImg(bg_img);
|
|
||||||
});
|
});
|
||||||
});
|
setBgImg(bg_img);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user