1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-06-11 04:39:35 +08:00

feat: 文章详情支持豆瓣插件

This commit is contained in:
小莫唐尼
2025-11-13 17:33:23 +08:00
parent b9ad94ddb5
commit a717beb0e7
7 changed files with 1631 additions and 1273 deletions
+7
View File
@@ -288,4 +288,11 @@ export default {
checkPluginAvailable: (name) => {
return HttpHandler.Get(`/apis/api.plugin.halo.run/v1alpha1/plugins/${name}/available`, {})
},
/**
* 获取豆瓣详情
* @param {String} url url
*/
getDoubanDetail: (url) => {
return HttpHandler.Get(`/apis/api.douban.moony.la/v1alpha1/doubanmovies/-/getDoubanDetail`, {url})
}
}
@@ -0,0 +1,224 @@
<template>
<view class="card" :class="[loading]">
<view v-if="loading !== 'success'" class="card-error" @click="fnGetData()">
{{ loadingText }}
</view>
<template v-else>
<view class="tag">豆瓣</view>
<view class="flex">
<view v-if="posterEmpty" class="poster round-2">无封面</view>
<image v-else class="poster round-2" :src="poster" mode="aspectFill" @error="onPosterError"></image>
<view class="box">
<view class="flex box-right" style="gap: 0 12rpx">
<text class="title">{{ detail.spec.name }}</text>
<tm-rate v-model="detail.spec.score / 2" color="orange" size="24" :margin="2" :num="5"></tm-rate>
<text class="text-size-s">{{ detail.spec.score }}</text>
</view>
<view class="content">{{ detail.spec.cardSubtitle }}</view>
<view class="flex flex-wrap" style="margin-left: -10rpx">
<tm-tags color="orange" :shadow="0" size="s" model="fill">{{ types[detail.spec.type] }}</tm-tags>
<tm-tags v-for="(gen, genIndex) in detail.spec.genres" :key="genIndex" color="light-blue" :shadow="0" size="s" model="fill">{{ gen }}</tm-tags>
</view>
</view>
</view>
<!-- 扩展内容 -->
<view class="btn-group">
<tm-button theme="bg-gradient-orange-accent" icon="icon-copy" :shadow="0" :dense="true" size="m" @click="copy('post')">原文地址</tm-button>
<tm-button theme="bg-gradient-light-blue-accent" icon="icon-copy" :shadow="0" :dense="true" size="m" @click="copy('douban')">豆瓣地址</tm-button>
<tm-button theme="bg-gradient-light-blue-accent" icon="icon-copy" :shadow="0" :dense="true" size="m" @click="copy('info')">资源信息</tm-button>
</view>
</template>
</view>
</template>
<script>
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmRate from '@/tm-vuetify/components/tm-rate/tm-rate.vue';
export default {
name: 'ArticleDouban',
components: {
tmButton,
tmTags,
tmRate
},
props: {
url: {
type: String,
default: ''
},
index: {
type: Number,
default: 0
},
article: {
type: Object,
default: () => ({})
}
},
data() {
return {
loading: 'loading',
loadingText: '加载中,请稍等...',
detail: null,
types: {
movie: '电影',
book: '图书',
music: '音乐',
game: '游戏',
drama: '舞台剧'
},
poster: '',
posterEmpty: false
};
},
created() {
this.fnGetData();
},
methods: {
onPosterError() {
if (!this.article.spec.cover) {
this.poster = '';
this.posterEmpty = true;
} else {
this.poster = this.$utils.checkImageUrl(this.article.spec.cover);
this.posterEmpty = false;
}
},
fnGetData() {
this.loadingText = '加载中,请稍等...';
this.loading = 'loading';
this.$httpApi.v2
.getDoubanDetail(this.url)
.then((res) => {
this.detail = res;
this.poster = res.spec.poster;
setTimeout(() => {
this.loading = 'success';
}, 200);
})
.catch((err) => {
console.error(err);
this.loading = 'error';
this.loadingText = '豆瓣内容加载失败,点击重试';
});
},
showToast(content) {
uni.showToast({
icon: 'none',
title: content,
mask: true
});
},
copy(type) {
if (type === 'post') {
const articleUrl = this.$baseApiUrl + (this.article?.status?.permalink ?? '');
this.$utils.copyText(articleUrl, '文章原文地址复制成功');
return;
}
if (type === 'douban') {
this.$utils.copyText(this.detail?.spec.link, '豆瓣资源地址复制成功');
return;
}
if(type==='info'){
const content = `名称:${this.detail?.spec.name}丨其他:${this.detail?.spec.cardSubtitle}丨标签:${this.detail?.spec.genres.join('/')}丨时间:${this.detail?.spec.pubdate}丨评分:${this.detail?.spec.score}分丨链接:${this.detail?.spec.link}`
this.$utils.copyText(content, '资源信息复制成功');
}
}
}
};
</script>
<style lang="scss" scoped>
.w-full {
width: 100%;
}
.wp-50 {
width: 50%;
}
.card {
position: relative;
display: flex;
flex-direction: column;
box-sizing: border-box;
padding: 24rpx;
border-radius: 12rpx;
background-color: #ffff;
overflow: hidden;
margin-bottom: 12rpx;
border: 1px solid #eee;
&.error {
padding: 0;
border-style: dashed;
border-color: #e88080;
color: #e88080;
background-color: rgba(232, 128, 128, 0.075);
}
&.loading {
padding: 0;
border-style: dashed;
border-color: rgba(3, 174, 252, 1);
color: rgba(3, 174, 252, 1);
background-color: rgba(3, 174, 252, 0.075);
}
}
.card-error {
padding: 50rpx 24rpx;
font-size: 24rpx;
border-radius: 12rpx;
text-align: center;
}
.poster {
width: 180rpx;
height: 220rpx;
flex-shrink: 0;
background-color: #eee;
display: flex;
align-items: center;
justify-content: center;
font-size: 24rpx;
}
.box {
box-sizing: border-box;
font-size: 26rpx;
padding-left: 24rpx;
}
.box-right {
display: flex;
align-items: center;
}
.title {
font-size: 32rpx;
font-weight: bold;
text-indent: 24rpx;
}
.content {
margin-top: 12rpx;
text-indent: 24rpx;
line-height: 36rpx;
color: rgba(0, 0, 0, 0.85);
}
.tag {
position: absolute;
right: 0;
top: 0;
font-size: 24rpx;
padding: 2rpx 12rpx;
background-color: #f5c618;
}
.btn-group {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 22rpx;
gap: 0 22rpx;
}
</style>
+3
View File
@@ -16,6 +16,9 @@ export const DefaultAppConfigs = {
pluginConfig: {
toolsPlugin: {},
linksSubmitPlugin: {},
doubanPlugin: {
position: 'top'
}
},
pageConfig: {
homeConfig: {
+2 -2
View File
@@ -2,8 +2,8 @@
"name" : "uni-halo",
"appid" : "__UNI__5748B6E",
"description" : "uni-halo博客:基于halo开源博客系统API开发的多端博客。",
"versionName" : "2.0.8",
"versionCode" : 208,
"versionName" : "2.0.9",
"versionCode" : 209,
"transformPx" : false,
/* 5+App */
"app-plus" : {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "uni-halo",
"version": "2.0.8",
"version": "2.0.9",
"description": "<p align=\"center\">\r <img alt=\"logo\" src=\"https://b.925i.cn/uni_halo/uni_halo_logo.png\" width=\"120\" height=\"120\" style=\"margin-bottom: 10px;\">\r </p>\r <h3 align=\"center\" style=\"margin: 30px 0 30px;font-weight: bold;font-size:40px;\">uni-halo</h3>\r <h3 align=\"center\">uni-halo 基于Halo一款现代化的开源博客/CMS系统API开发的可多端编译应用</h3>",
"repository": {
"type": "git",
+1 -1
View File
@@ -15,7 +15,7 @@
const _DEV_ = false
const _DEV_TO_TYPE_ = "page"
const _DEV_TO_PATH_ = "/pagesA/article-detail/article-detail?name=077efb85-3544-4307-b24c-537a9e53f116"
const _DEV_TO_PATH_ = "/pagesA/article-detail/article-detail?name=817fae88-f68a-4fb1-9e4f-dc1c84471252"
export default {
mixins: [pluginAvailableMixin],
File diff suppressed because it is too large Load Diff