Merge pull request #52 from imsyy/dev

社交链接添加配置文件
This commit is contained in:
底层用户 2023-01-30 18:49:00 +08:00 committed by GitHub
commit 431f3732f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 102 additions and 212 deletions

11
.env
View File

@ -1,6 +1,7 @@
# 站点名称 # 站点名称
VITE_SITE_NAME = "無名の主页" VITE_SITE_NAME = "無名の主页"
VITE_SITE_URL = "imsyy.top" VITE_SITE_URL = "imsyy.top"
VITE_SITE_LOGO = "/images/icon/logo.png"
# 简介文本 # 简介文本
VITE_DESC_HELLO = "Hello World !" VITE_DESC_HELLO = "Hello World !"
@ -9,17 +10,13 @@ VITE_DESC_HELLO_OTHER = "Oops !"
VITE_DESC_TEXT_OTHER = "哎呀,这都被你发现了( 再点击一次可关闭 " VITE_DESC_TEXT_OTHER = "哎呀,这都被你发现了( 再点击一次可关闭 "
# 社交链接 # 社交链接
VITE_SOCIAL_GITHUB = "imsyy" ## 请在根目录下的 socialLinks.json 文件中配置
VITE_SOCIAL_QQ = "1539250352"
VITE_SOCIAL_EMAIL = "one@imsyy.top"
VITE_SOCIAL_TELEGRAM = "bottom_user"
VITE_SOCIAL_TWITTER = "iimmsyy"
# 网站链接 # 网站链接
## 请在 src/components/Links/index.vue 中设 ## 请在 src/components/Links/index.vue 文件中配置
# 天气 Key # 天气 Key
## 请前往高德开放平台注册 Web服务 Key ## 请前往高德开放平台注册 Web服务 Key(免费的)
## 请各位大佬行行好,别再让我超量了 ## 请各位大佬行行好,别再让我超量了
VITE_WEATHER_KEY = "57eaea5833ff1616cfd1ff2c4cf9b58a" VITE_WEATHER_KEY = "57eaea5833ff1616cfd1ff2c4cf9b58a"

9
.hintrc Normal file
View File

@ -0,0 +1,9 @@
{
"extends": [
"development"
],
"hints": {
"compat-api/html": "off",
"no-protocol-relative-urls": "off"
}
}

View File

@ -1,92 +1 @@
/** if(!self.define){let e,s={};const t=(t,i)=>(t=new URL(t+".js",i).href,s[t]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=s,document.head.appendChild(e)}else e=t,importScripts(t),s()})).then((()=>{let e=s[t];if(!e)throw new Error(`Module ${t} didnt register its module`);return e})));self.define=(i,n)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let r={};const c=e=>t(e,o),l={module:{uri:o},exports:r,require:c};s[o]=Promise.all(i.map((e=>l[e]||c(e)))).then((e=>(n(...e),r)))}}define(["./workbox-082d0e8a"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"3ca0b8505b4bec776b69afdba2768812"},{revision:null,url:"index.html"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"),{allowlist:[/^\/$/]})),e.registerRoute(/(.*?)\.(js|css|woff2|woff|ttf)/,new e.CacheFirst({cacheName:"js-css-cache",plugins:[]}),"GET"),e.registerRoute(/(.*?)\.(png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps)/,new e.CacheFirst({cacheName:"image-cache",plugins:[]}),"GET")}));
* Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// If the loader is already loaded, just stop.
if (!self.define) {
let registry = {};
// Used for `eval` and `importScripts` where we can't get script URL by other means.
// In both cases, it's safe to use a global var because those functions are synchronous.
let nextDefineUri;
const singleRequire = (uri, parentUri) => {
uri = new URL(uri + ".js", parentUri).href;
return registry[uri] || (
new Promise(resolve => {
if ("document" in self) {
const script = document.createElement("script");
script.src = uri;
script.onload = resolve;
document.head.appendChild(script);
} else {
nextDefineUri = uri;
importScripts(uri);
resolve();
}
})
.then(() => {
let promise = registry[uri];
if (!promise) {
throw new Error(`Module ${uri} didnt register its module`);
}
return promise;
})
);
};
self.define = (depsNames, factory) => {
const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
if (registry[uri]) {
// Module is already loading or loaded.
return;
}
let exports = {};
const require = depUri => singleRequire(depUri, uri);
const specialDeps = {
module: { uri },
exports,
require
};
registry[uri] = Promise.all(depsNames.map(
depName => specialDeps[depName] || require(depName)
)).then(deps => {
factory(...deps);
return exports;
});
};
}
define(['./workbox-148cb7e5'], (function (workbox) { 'use strict';
self.skipWaiting();
workbox.clientsClaim();
/**
* The precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
workbox.precacheAndRoute([{
"url": "registerSW.js",
"revision": "3ca0b8505b4bec776b69afdba2768812"
}, {
"revision": null,
"url": "index.html"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
allowlist: [/^\/$/]
}));
}));

File diff suppressed because one or more lines are too long

View File

@ -23,6 +23,16 @@
window.location.href = window.location.href =
"https://support.dmeng.net/upgrade-your-browser.html?referrer=" + encodeURIComponent(window.location.href) "https://support.dmeng.net/upgrade-your-browser.html?referrer=" + encodeURIComponent(window.location.href)
</script> </script>
<!-- 百度统计 -->
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?14e9f35ff8bc67fd4bcb5f07a6e6655a";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head> </head>
<body class="loading"> <body class="loading">

View File

@ -4,7 +4,7 @@
"github": "https://github.com/imsyy/home", "github": "https://github.com/imsyy/home",
"home": "https://imsyy.top", "home": "https://imsyy.top",
"private": true, "private": true,
"version": "4.0.0", "version": "4.0.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
public/images/icon/qq.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

26
socialLinks.json Normal file
View File

@ -0,0 +1,26 @@
[{
"name": "Github",
"icon": "/images/icon/github.png",
"tip": "去 Github 看看",
"url": "https://github.com/imsyy"
}, {
"name": "BiliBili",
"icon": "/images/icon/bilibili.png",
"tip": "(゜-゜)つロ 干杯 ~",
"url": "https://space.bilibili.com/98544142"
}, {
"name": "QQ",
"icon": "/images/icon/qq.png",
"tip": "有什么事吗",
"url": "https://wpa.qq.com/msgrd?v=3&uin=1539250352&site=qq&menu=yes"
}, {
"name": "Email",
"icon": "/images/icon/email.png",
"tip": "来封 Email ~",
"url": "mailto:one@imsyy.top"
}, {
"name": "Telegram",
"icon": "/images/icon/telegram.png",
"tip": "你懂的 ~",
"url": "https://twitter.com/iimmsyy"
}]

View File

@ -35,4 +35,14 @@ export const getAdcode = async (key) => {
export const getWeather = async (key, city) => { export const getWeather = async (key, city) => {
const res = await fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=${key}&city=${city}`); const res = await fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=${key}&city=${city}`);
return await res.json(); return await res.json();
}
/**
* 获取配置
*/
// 获取社交链接
export const getSocialLinks = async () => {
const res = await fetch("/socialLinks.json");
return await res.json();
} }

View File

@ -3,7 +3,7 @@
<div class="message"> <div class="message">
<!-- Logo --> <!-- Logo -->
<div class="logo"> <div class="logo">
<img class="logo-img" src="/images/icon/logo.png" alt="logo" /> <img class="logo-img" :src="siteLogo" alt="logo" />
<div class="name"> <div class="name">
<span class="bg">{{ siteUrl[0] }}</span> <span class="bg">{{ siteUrl[0] }}</span>
<span class="sm">.{{ siteUrl[1] }}</span> <span class="sm">.{{ siteUrl[1] }}</span>
@ -35,6 +35,8 @@ import { Error } from "@icon-park/vue-next";
import { mainStore } from "@/store"; import { mainStore } from "@/store";
const store = mainStore(); const store = mainStore();
// logo
let siteLogo = import.meta.env.VITE_SITE_LOGO;
// //
let siteUrl = import.meta.env.VITE_SITE_URL.split("."); let siteUrl = import.meta.env.VITE_SITE_URL.split(".");

View File

@ -3,58 +3,14 @@
<div class="social"> <div class="social">
<div class="link"> <div class="link">
<a <a
id="github" v-for="item in socialLinksData"
:href="socialLinks.github" :key="item.name"
:href="item.url"
target="_blank" target="_blank"
@mouseenter="changeTip" @mouseenter="socialTip = item.tip"
@mouseleave="leaveTip" @mouseleave="socialTip = '通过这里联系我吧'"
> >
<Icon size="24"> <img class="icon" :src="item.icon" height="24" />
<Github />
</Icon>
</a>
<a
id="qq"
:href="socialLinks.qq"
target="_blank"
@mouseenter="changeTip"
@mouseleave="leaveTip"
>
<Icon size="24">
<Qq />
</Icon>
</a>
<a
id="email"
:href="socialLinks.email"
@mouseenter="changeTip"
@mouseleave="leaveTip"
>
<Icon size="28">
<EmailRound />
</Icon>
</a>
<a
id="telegram"
:href="socialLinks.telegram"
target="_blank"
@mouseenter="changeTip"
@mouseleave="leaveTip"
>
<Icon size="24">
<Telegram />
</Icon>
</a>
<a
id="twitter"
:href="socialLinks.twitter"
target="_blank"
@mouseenter="changeTip"
@mouseleave="leaveTip"
>
<Icon size="24">
<Twitter />
</Icon>
</a> </a>
</div> </div>
<span class="tip">{{ socialTip }}</span> <span class="tip">{{ socialTip }}</span>
@ -62,61 +18,37 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive } from "vue"; import { ref, onMounted } from "vue";
import { Github, Qq, Telegram, Twitter } from "@vicons/fa"; import { getSocialLinks } from "@/api";
import { EmailRound } from "@vicons/material"; import { Error } from "@icon-park/vue-next";
import { Icon } from "@vicons/utils";
// //
let socialHover = ref(false); let socialLinksData = ref([]);
let socialTip = ref("通过这里联系我吧"); let socialTip = ref("通过这里联系我吧");
let socialTipData = {
github: "去 Github 看看", //
qq: "有什么事吗", const getSocialLinksData = () => {
email: "来封 Email", getSocialLinks()
telegram: "你懂的 ~", .then((res) => {
twitter: "你懂的 ~", socialLinksData.value = res;
console.log(socialLinksData.value);
})
.catch((err) => {
console.error(err);
ElMessage({
message: "社交链接获取失败",
grouping: true,
icon: h(Error, {
theme: "filled",
fill: "#efefef",
}),
});
});
}; };
// onMounted(() => {
const socialLinks = reactive({ getSocialLinksData();
github: "https://github.com/" + import.meta.env.VITE_SOCIAL_GITHUB,
qq:
"https://wpa.qq.com/msgrd?v=3&uin=" +
import.meta.env.VITE_SOCIAL_QQ +
"&site=qq&menu=yes",
email: "mailto:" + import.meta.env.VITE_SOCIAL_EMAIL,
telegram: "https://t.me/" + import.meta.env.VITE_SOCIAL_TELEGRAM,
twitter: "https://twitter.com/" + import.meta.env.VITE_SOCIAL_TWITTER,
}); });
//
const changeTip = (e) => {
let tipKey = e.target.id;
switch (tipKey) {
case "github":
socialTip.value = socialTipData.github;
return true;
case "qq":
socialTip.value = socialTipData.qq;
return true;
case "email":
socialTip.value = socialTipData.email;
return true;
case "telegram":
socialTip.value = socialTipData.telegram;
return true;
case "twitter":
socialTip.value = socialTipData.twitter;
return true;
default:
return true;
}
};
const leaveTip = () => {
socialTip.value = "通过这里联系我吧";
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -151,8 +83,12 @@ const leaveTip = () => {
justify-content: center; justify-content: center;
a { a {
display: inherit; display: inherit;
span { .icon {
margin: 0 12px; margin: 0 12px;
transition: all 0.3s;
&:active {
transform: scale(0.9);
}
} }
} }
} }

View File

@ -14,14 +14,4 @@ const pinia = createPinia();
pinia.use(piniaPluginPersistedstate); pinia.use(piniaPluginPersistedstate);
app.use(pinia); app.use(pinia);
app.mount('#app') app.mount('#app')
// if ('serviceWorker' in navigator) {
// navigator.serviceWorker.register('/sw.js')
// .then(() => {
// console.log('Service worker registered.');
// })
// .catch(err => {
// console.log('Failed to register service worker: ', err);
// });
// }