mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-08 17:20:38 +08:00
add detail link
This commit is contained in:
16
src/api/nprogress.ts
Normal file
16
src/api/nprogress.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import NProgress from 'nprogress';
|
||||||
|
import 'nprogress/nprogress.css';
|
||||||
|
|
||||||
|
export function configureNProgress() {
|
||||||
|
NProgress.configure({
|
||||||
|
showSpinner: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function startNProgress() {
|
||||||
|
NProgress.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function doneNProgress() {
|
||||||
|
NProgress.done();
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import api from "@/api";
|
import api from "@/api";
|
||||||
|
import { doneNProgress, startNProgress } from "@/api/nprogress";
|
||||||
import { MediaInfo, Subscribe } from "@/api/types";
|
import { MediaInfo, Subscribe } from "@/api/types";
|
||||||
|
|
||||||
// 输入参数
|
// 输入参数
|
||||||
@@ -28,6 +29,7 @@ const getChipColor = (type: string) => {
|
|||||||
|
|
||||||
// 添加订阅
|
// 添加订阅
|
||||||
const addSubscribe = async () => {
|
const addSubscribe = async () => {
|
||||||
|
startNProgress();
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post("subscribe", {
|
const result: { [key: string]: any } = await api.post("subscribe", {
|
||||||
name: props.media?.title,
|
name: props.media?.title,
|
||||||
@@ -41,6 +43,7 @@ const addSubscribe = async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
doneNProgress();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 取消订阅
|
// 取消订阅
|
||||||
@@ -86,6 +89,24 @@ const handleSubscribe = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 拼装详情页链接
|
||||||
|
const getDetailLink = () => {
|
||||||
|
let link = "";
|
||||||
|
if (props.media?.douban_id) {
|
||||||
|
link = `https://movie.douban.com/subject/${props.media?.douban_id}/`;
|
||||||
|
} else if (props.media?.type === "电影") {
|
||||||
|
link = `https://www.themoviedb.org/movie/${props.media?.tmdb_id}`;
|
||||||
|
} else if (props.media?.type === "电视剧") {
|
||||||
|
link = `https://www.themoviedb.org/tv/${props.media?.tmdb_id}`;
|
||||||
|
}
|
||||||
|
return link;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开详情页
|
||||||
|
const openDetailWindow = () => {
|
||||||
|
window.open(getDetailLink(), "_blank");
|
||||||
|
};
|
||||||
|
|
||||||
// 装载时检查是否已订阅
|
// 装载时检查是否已订阅
|
||||||
onMounted(checkSubscribe);
|
onMounted(checkSubscribe);
|
||||||
</script>
|
</script>
|
||||||
@@ -139,6 +160,7 @@ onMounted(checkSubscribe);
|
|||||||
<VCardText
|
<VCardText
|
||||||
class="flex flex-col flex-wrap justify-end align-left text-white absolute bottom-0 cursor-pointer pa-2"
|
class="flex flex-col flex-wrap justify-end align-left text-white absolute bottom-0 cursor-pointer pa-2"
|
||||||
v-show="hover.isHovering"
|
v-show="hover.isHovering"
|
||||||
|
@click.stop="openDetailWindow"
|
||||||
>
|
>
|
||||||
<span class="font-bold">{{ props.media?.year }}</span>
|
<span class="font-bold">{{ props.media?.year }}</span>
|
||||||
<h1
|
<h1
|
||||||
@@ -154,7 +176,7 @@ onMounted(checkSubscribe);
|
|||||||
<IconBtn
|
<IconBtn
|
||||||
icon="mdi-heart"
|
icon="mdi-heart"
|
||||||
:color="isSubscribed ? 'error' : 'white'"
|
:color="isSubscribed ? 'error' : 'white'"
|
||||||
@click="handleSubscribe"
|
@click.stop="handleSubscribe"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable import/order */
|
/* eslint-disable import/order */
|
||||||
import '@/@iconify/icons-bundle'
|
import '@/@iconify/icons-bundle'
|
||||||
import App from '@/App.vue'
|
import App from '@/App.vue'
|
||||||
|
import { configureNProgress, doneNProgress, startNProgress } from '@/api/nprogress'
|
||||||
import vuetify from '@/plugins/vuetify'
|
import vuetify from '@/plugins/vuetify'
|
||||||
import { loadFonts } from '@/plugins/webfontloader'
|
import { loadFonts } from '@/plugins/webfontloader'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
@@ -8,13 +9,11 @@ import store from '@/store'
|
|||||||
import '@core/scss/template/index.scss'
|
import '@core/scss/template/index.scss'
|
||||||
import '@layouts/styles/index.scss'
|
import '@layouts/styles/index.scss'
|
||||||
import '@styles/styles.scss'
|
import '@styles/styles.scss'
|
||||||
import NProgress from 'nprogress'
|
|
||||||
import 'nprogress/nprogress.css'
|
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
loadFonts()
|
loadFonts()
|
||||||
|
|
||||||
// Nprogress
|
// Nprogress
|
||||||
NProgress.configure({ showSpinner: false })
|
configureNProgress()
|
||||||
|
|
||||||
// Create vue app
|
// Create vue app
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
@@ -37,11 +36,11 @@ router.beforeEach((to, from, next) => {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 否则,允许继续进行路由导航
|
// 否则,允许继续进行路由导航
|
||||||
NProgress.start()
|
startNProgress()
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
NProgress.done()
|
doneNProgress()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user