feat: 网站链接多页支持 #129 #20 #47

This commit is contained in:
imsyy 2023-06-12 11:39:06 +08:00
parent acc8f54ef9
commit 177b539e39
13 changed files with 155 additions and 77 deletions

6
.env
View File

@ -16,13 +16,13 @@ VITE_DESC_HELLO_OTHER = "Oops !"
VITE_DESC_TEXT_OTHER = "哎呀,这都被你发现了( 再点击一次可关闭 "
# 社交链接
## 请在 public 目录下的 socialLinks.json 文件中配置
## 请在 src/assets/socialLinks.json 文件中配置
# 网站链接
## 请在 src/components/Links/index.vue 文件中配置
## 请在 src/assets/siteLinks.json 文件中配置
# 天气 Key
## 请前往高德开放平台注册 Web服务 Key免费的
## 请前往高德开放平台注册 **Web服务** Key免费的
## 请各位大佬行行好,别再让我超量了
VITE_WEATHER_KEY = "6c13af6fc30868bee488faf2cc652ab4"

View File

@ -27,8 +27,6 @@
- [x] 音乐播放器
- [x] 移动端适配
* [ ] 播放器取消使用 Aplayer
### 部署
* **安装** [node.js](https://nodejs.org/zh-cn/) **环境**

View File

@ -19,6 +19,7 @@
"fetch-jsonp": "^1.2.3",
"pinia": "^2.0.23",
"pinia-plugin-persistedstate": "^3.0.0",
"swiper": "^9.3.2",
"terser": "^5.16.1",
"vue": "^3.2.37",
"vue3-aplayer": "^1.7.3"

View File

@ -55,10 +55,6 @@ const getWidth = () => {
onMounted(() => {
//
cursorInit();
//
helloInit();
//
checkDays();
//
window.addEventListener("load", () => {
console.log("加载完成");
@ -67,6 +63,10 @@ onMounted(() => {
//
const loadingBox = document.getElementById("loading-box");
loadingBox.classList.add("loaded");
//
helloInit();
//
checkDays();
});
//
@ -207,4 +207,4 @@ main {
filter: blur(10px);
}
}
</style>
</style>

View File

@ -67,13 +67,3 @@ export const getWeather = async (key, city) => {
);
return await res.json();
};
/**
* 获取配置
*/
// 获取社交链接
export const getSocialLinks = async () => {
const res = await fetch("/socialLinks.json");
return await res.json();
};

41
src/assets/siteLinks.json Normal file
View File

@ -0,0 +1,41 @@
[
[
{
"icon": "Blog",
"name": "博客",
"link": "https://blog.imsyy.top/"
},
{
"icon": "Cloud",
"name": "网盘",
"link": "https://pan.imsyy.top/"
},
{
"icon": "CompactDisc",
"name": "音乐",
"link": "https://music.imsyy.top/"
},
{
"icon": "Compass",
"name": "起始页",
"link": "https://nav.imsyy.top/"
},
{
"icon": "Book",
"name": "网址集",
"link": "https://web.imsyy.top/"
},
{
"icon": "Fire",
"name": "今日热榜",
"link": "https://hot.imsyy.top/"
}
],
[
{
"icon": "LaptopCode",
"name": "站点监测",
"link": "https://status.imsyy.top/"
}
]
]

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

Before

Width:  |  Height:  |  Size: 496 B

View File

@ -7,7 +7,7 @@
@click.stop
>
<!-- 打开音乐面板 -->
<Transition name="fade">
<Transition name="el-fade-in-linear">
<div
class="open-music"
v-show="openMusicShow && store.musicIsOk"

View File

@ -6,28 +6,46 @@
</Icon>
<span class="title">网站列表</span>
</div>
<el-row class="link-all" :gutter="20">
<el-col
:span="8"
v-for="(item, index) in linksData"
:key="item"
@click="jumpLink(item)"
>
<div
class="item cards"
:style="index < 3 ? 'margin-bottom: 20px' : null"
>
<Icon size="26">
<component :is="item.icon" />
</Icon>
<span class="name">{{ item.name }}</span>
</div>
</el-col>
</el-row>
<!-- 网站列表 -->
<Swiper
v-if="siteLinks[0]"
:modules="[Pagination, Mousewheel]"
:slides-per-view="1"
:space-between="40"
:pagination="{
el: '.swiper-pagination',
clickable: true,
bulletElement: 'div',
}"
:mousewheel="true"
>
<SwiperSlide v-for="site in siteLinks" :key="site">
<el-row class="link-all" :gutter="20">
<el-col
:span="8"
v-for="(item, index) in site"
:key="item"
@click="jumpLink(item)"
>
<div
class="item cards"
:style="index < 3 ? 'margin-bottom: 20px' : null"
>
<Icon size="26">
<component :is="siteIcon[item.icon]" />
</Icon>
<span class="name">{{ item.name }}</span>
</div>
</el-col>
</el-row>
</SwiperSlide>
<div class="swiper-pagination" />
</Swiper>
</div>
</template>
<script setup>
import { onMounted } from "vue";
import { Icon } from "@vicons/utils";
import {
Link,
@ -37,12 +55,29 @@ import {
Compass,
Book,
Fire,
LaptopCode,
} from "@vicons/fa";
import { mainStore } from "@/store";
import { Swiper, SwiperSlide } from "swiper/vue";
import { Pagination, Mousewheel } from "swiper";
import siteLinks from "@/assets/siteLinks.json";
import "swiper/scss";
import "swiper/scss/pagination";
const store = mainStore();
//
const siteIcon = {
Blog,
Cloud,
CompactDisc,
Compass,
Book,
Fire,
LaptopCode,
};
//
// 6
const linksData = [
{
icon: Blog,
@ -79,11 +114,15 @@ const linksData = [
//
const jumpLink = (data) => {
if (data.name === "音乐" && store.musicClick) {
if ($openList) $openList();
if (typeof $openList === "function") $openList();
} else {
window.open(data.link, "_blank");
}
};
onMounted(() => {
console.log(siteLinks);
});
</script>
<style lang="scss" scoped>
@ -101,6 +140,29 @@ const jumpLink = (data) => {
text-shadow: 0 0 5px #00000050;
}
}
.swiper {
left: -10px;
width: calc(100% + 20px);
padding: 5px 10px 0;
z-index: 0;
.swiper-slide {
height: 100%;
}
.swiper-pagination {
position: static;
margin-top: 4px;
:deep(.swiper-pagination-bullet) {
background-color: #fff;
width: 18px;
height: 4px;
border-radius: 4px;
transition: opacity 0.3s;
&:hover {
opacity: 1;
}
}
}
}
.link-all {
.item {
height: 100px;

View File

@ -3,7 +3,7 @@
<div class="social">
<div class="link">
<a
v-for="item in socialLinksData"
v-for="item in socialLinks"
:key="item.name"
:href="item.url"
target="_blank"
@ -18,37 +18,11 @@
</template>
<script setup>
import { ref, onMounted } from "vue";
import { getSocialLinks } from "@/api";
import { Error } from "@icon-park/vue-next";
import { ref } from "vue";
import socialLinks from "@/assets/socialLinks.json";
//
const socialLinksData = ref([]);
//
const socialTip = ref("通过这里联系我吧");
//
const getSocialLinksData = () => {
getSocialLinks()
.then((res) => {
socialLinksData.value = res;
console.log(socialLinksData.value);
})
.catch((err) => {
console.error(err);
ElMessage({
message: "社交链接获取失败",
grouping: true,
icon: h(Error, {
theme: "filled",
fill: "#efefef",
}),
});
});
};
onMounted(() => {
getSocialLinksData();
});
</script>
<style lang="scss" scoped>
@ -109,4 +83,4 @@ onMounted(() => {
}
}
}
</style>
</style>

View File

@ -33,10 +33,10 @@
<script setup>
import { ref } from "vue";
import { CloseOne, SettingTwo } from "@icon-park/vue-next";
import TimeCapsule from "@/components/TimeCapsule/index.vue";
import { mainStore } from "@/store";
const store = mainStore();
import TimeCapsule from "@/components/TimeCapsule/index.vue";
const store = mainStore();
const closeShow = ref(false);
</script>
@ -60,6 +60,7 @@ const closeShow = ref(false);
right: 14px;
width: 28px;
height: 28px;
transition: transform 0.3s, opacity 0.3s;
&:hover {
transform: scale(1.2);
@ -80,4 +81,4 @@ const closeShow = ref(false);
height: 100%;
}
}
</style>
</style>

View File

@ -3040,6 +3040,11 @@ sourcemap-codec@^1.4.8:
resolved "https://registry.npmmirror.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz"
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
ssr-window@^4.0.2:
version "4.0.2"
resolved "https://registry.npmmirror.com/ssr-window/-/ssr-window-4.0.2.tgz#dc6b3ee37be86ac0e3ddc60030f7b3bc9b8553be"
integrity sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ==
string.prototype.matchall@^4.0.6:
version "4.0.8"
resolved "https://registry.npmmirror.com/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz#3bf85722021816dcd1bf38bb714915887ca79fd3"
@ -3112,6 +3117,13 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
swiper@^9.3.2:
version "9.3.2"
resolved "https://registry.npmmirror.com/swiper/-/swiper-9.3.2.tgz#f29eddb17f231221c7727372637c44279174a4e1"
integrity sha512-Kj9Z4kXRmJR3YT/Wj+XLWj8P6IcRt+WG38uL8M3/Wny7+6sV0TlP9vnE1X+Co9c7VzNooojWGnFa+Wf/9+CUMA==
dependencies:
ssr-window "^4.0.2"
temp-dir@^2.0.0:
version "2.0.0"
resolved "https://registry.npmmirror.com/temp-dir/-/temp-dir-2.0.0.tgz#bde92b05bdfeb1516e804c9c00ad45177f31321e"
@ -3311,7 +3323,7 @@ uri-js@^4.2.2:
vite-plugin-html@^3.2.0:
version "3.2.0"
resolved "https://registry.npmmirror.com/vite-plugin-html/-/vite-plugin-html-3.2.0.tgz"
resolved "https://registry.npmmirror.com/vite-plugin-html/-/vite-plugin-html-3.2.0.tgz#0d4df9900642a321a139f1c25c05195ba9d0ec79"
integrity sha512-2VLCeDiHmV/BqqNn5h2V+4280KRgQzCFN47cst3WiNK848klESPQnzuC3okH5XHtgwHH/6s1Ho/YV6yIO0pgoQ==
dependencies:
"@rollup/pluginutils" "^4.2.0"