feat: 同步支持新版API

This commit is contained in:
imsyy
2024-04-10 17:52:54 +08:00
parent 77c9c0f8bc
commit bdfebd32b5
17 changed files with 1920 additions and 1691 deletions

View File

@@ -3,7 +3,7 @@
"description": "今日热榜", "description": "今日热榜",
"author": "imsyy", "author": "imsyy",
"github": "https://github.com/imsyy", "github": "https://github.com/imsyy",
"version": "1.0.0", "version": "1.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -12,24 +12,24 @@
}, },
"dependencies": { "dependencies": {
"@icon-park/vue-next": "^1.4.2", "@icon-park/vue-next": "^1.4.2",
"@jridgewell/sourcemap-codec": "^1.4.14", "@jridgewell/sourcemap-codec": "^1.4.15",
"axios": "^1.3.3", "axios": "^1.6.8",
"lunar-calendar": "^0.1.4", "lunar-calendar": "^0.1.4",
"pinia": "^2.0.28", "pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.1.0", "pinia-plugin-persistedstate": "^3.2.1",
"sass": "^1.56.1", "sass": "^1.74.1",
"scrollreveal": "^4.0.9", "scrollreveal": "^4.0.9",
"terser": "^5.16.5", "terser": "^5.30.3",
"vue": "^3.2.45", "vue": "^3.4.21",
"vue-router": "^4.1.6", "vue-router": "^4.3.0",
"vuedraggable": "^4.1.0" "vuedraggable": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue": "^4.6.2",
"naive-ui": "^2.34.3", "naive-ui": "^2.38.1",
"unplugin-auto-import": "^0.12.0", "unplugin-auto-import": "^0.12.2",
"unplugin-vue-components": "^0.22.11", "unplugin-vue-components": "^0.22.12",
"vite": "^4.0.0", "vite": "^4.5.3",
"vite-plugin-pwa": "^0.14.1" "vite-plugin-pwa": "^0.14.7"
} }
} }

3457
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

BIN
public/logo/acfun.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
public/logo/hellogithub.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/logo/honkai.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
public/logo/jianshu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
public/logo/starrail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
public/logo/zhihu-daily.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -7,10 +7,13 @@ import axios from "@/api/request";
* @param {object} params 请求参数 * @param {object} params 请求参数
* @returns * @returns
*/ */
export const getHotLists = (type, isNew, params) => { export const getHotLists = (type, isNew = false, params) => {
return axios({ return axios({
method: "GET", method: "GET",
url: `/${type}${isNew ? "/new" : "/"}`, url: `/${type}`,
params, params: {
cache: !isNew,
...params,
},
}); });
}; };

View File

@@ -1,10 +1,11 @@
<template> <template>
<n-card <n-card
hoverable
class="hot-list"
:header-style="{ padding: '16px' }" :header-style="{ padding: '16px' }"
:content-style="{ padding: '0 16px' }" :content-style="{ padding: '0 16px' }"
:footer-style="{ padding: '16px' }" :footer-style="{ padding: '16px' }"
:id="`hot-list-${hotData.name}`"
class="hot-list"
hoverable
@click="toList" @click="toList"
> >
<template #header> <template #header>
@@ -17,8 +18,8 @@
/> />
<n-text class="name-text">{{ hotData.label }}</n-text> <n-text class="name-text">{{ hotData.label }}</n-text>
</div> </div>
<n-text v-if="hotListData?.subtitle" class="subtitle" :depth="2"> <n-text v-if="hotListData?.type" class="subtitle" :depth="2">
{{ hotListData.subtitle }} {{ hotListData.type }}
</n-text> </n-text>
<n-skeleton v-else width="60px" text round /> <n-skeleton v-else width="60px" text round />
</n-space> </n-space>
@@ -170,7 +171,7 @@ const getHotListsData = async (name, isNew = false) => {
try { try {
// hotListData.value = null; // hotListData.value = null;
loadingError.value = false; loadingError.value = false;
const item = store.newsArr.find((item) => item.name == name) const item = store.newsArr.find((item) => item.name == name);
const result = await getHotLists(item.name, isNew, item.params); const result = await getHotLists(item.name, isNew, item.params);
// console.log(result); // console.log(result);
if (result.code === 200) { if (result.code === 200) {
@@ -231,6 +232,23 @@ const toList = () => {
} }
}; };
// 判断列表是否显示
const checkListShow = () => {
const typeName = props.hotData.name;
const listId = "hot-list-" + typeName;
const listDom = document.getElementById(listId);
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
console.log(`👀 ${typeName} 可见,开始加载`);
getHotListsData(props.hotData.name);
observer.unobserve(entry.target);
}
});
});
observer.observe(listDom);
};
// 实时改变更新时间 // 实时改变更新时间
watch( watch(
() => store.timeData, () => store.timeData,
@@ -242,7 +260,7 @@ watch(
); );
onMounted(() => { onMounted(() => {
if (props.hotData.name) getHotListsData(props.hotData.name); checkListShow();
}); });
</script> </script>
@@ -251,17 +269,6 @@ onMounted(() => {
border-radius: 12px; border-radius: 12px;
transition: all 0.3s; transition: all 0.3s;
cursor: pointer; cursor: pointer;
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.3s ease-in-out;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
.title { .title {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -82,13 +82,13 @@ export const mainStore = defineStore("mainData", {
}, },
{ {
label: "腾讯新闻", label: "腾讯新闻",
name: "newsqq", name: "qq-news",
order: 12, order: 12,
show: true, show: true,
}, },
{ {
label: "豆瓣", label: "豆瓣电影",
name: "douban_new", name: "douban-movie",
order: 13, order: 13,
show: true, show: true,
}, },
@@ -98,21 +98,21 @@ export const mainStore = defineStore("mainData", {
order: 14, order: 14,
show: true, show: true,
}, },
{
label: "崩坏:星穹铁道",
name: "starrail",
order: 16,
show: true,
},
{ {
label: "LOL", label: "LOL",
name: "lol", name: "lol",
order: 15, order: 15,
show: true, show: true,
}, },
{
label: "快手",
name: "kuaishou",
order: 16,
show: true,
},
{ {
label: "网易新闻", label: "网易新闻",
name: "netease", name: "netease-news",
order: 17, order: 17,
show: true, show: true,
}, },
@@ -124,33 +124,31 @@ export const mainStore = defineStore("mainData", {
}, },
{ {
label: "豆瓣讨论小组", label: "豆瓣讨论小组",
name: "douban_group", name: "douban-group",
order: 19, order: 19,
show: true, show: true,
}, },
{
label: "网易云音乐",
name: "netease_music_toplist",
params: { type: 1 },
order: 20,
show: true,
},
{
label: "QQ音乐热歌榜",
name: "qq_music_toplist",
params: { type: 1 },
order: 21,
show: true,
},
{ {
label: "NGA", label: "NGA",
name: "ngabbs", name: "ngabbs",
order: 20,
show: true,
},
{
label: "HelloGitHub",
name: "hellogithub",
order: 21,
show: true,
},
{
label: "简书",
name: "jianshu",
order: 22, order: 22,
show: true, show: true,
}, },
{ {
label: "V2EX", label: "知乎日报",
name: "v2ex", name: "zhihu-daily",
order: 23, order: 23,
show: true, show: true,
}, },
@@ -163,7 +161,7 @@ export const mainStore = defineStore("mainData", {
// 时间数据 // 时间数据
timeData: null, timeData: null,
// 字体大小 // 字体大小
listFontSize: 14, listFontSize: 16,
}; };
}, },
getters: {}, getters: {},

View File

@@ -1,5 +1,4 @@
// 全局样式 // 全局样式
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
@@ -11,4 +10,15 @@ html,
body, body,
#app { #app {
height: 100%; height: 100%;
} }
// 动画
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.3s ease-in-out;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}

View File

@@ -53,7 +53,7 @@
<n-card class="set-item"> <n-card class="set-item">
<div class="top" style="flex-direction: column; align-items: flex-start"> <div class="top" style="flex-direction: column; align-items: flex-start">
<div class="name"> <div class="name">
<n-text class="text">歌词文本大小</n-text> <n-text class="text">列表文本大小</n-text>
<n-card <n-card
class="tip" class="tip"
:style="{ :style="{
@@ -74,8 +74,8 @@
:min="14" :min="14"
:step="0.01" :step="0.01"
:marks="{ :marks="{
14: '默认', 14: '小一点',
16: '大一点', 16: '默认',
20: '最大', 20: '最大',
}" }"
/> />