Răsfoiți Sursa

新增:文章版权说明;
新增:文章详情点击标签跳转查询标签下的文章列表;
优化:调整markdown文字大小

小莫唐尼 3 ani în urmă
părinte
comite
e46c5c2b6f

+ 2 - 0
api/index.js

@@ -16,6 +16,7 @@ import archive from './archive.js'
 import article from './article.js'
 import blogger from './blogger.js'
 import category from './category.js'
+import tag from './tag.js'
 import comment from './comment.js'
 import journal from './journal.js'
 import link from './link.js'
@@ -44,6 +45,7 @@ const ApiManager = {
 	...article,
 	...blogger,
 	...category,
+	...tag,
 	...comment,
 	...journal,
 	...link,

+ 24 - 0
api/tag.js

@@ -0,0 +1,24 @@
+/**
+ * 标签接口
+ * @see https://api.halo.run/content-api.html#tag/tag-controller
+ */
+
+import HttpHandler from '@/common/http/request.js'
+export default {
+	/**
+	 * 查询标签列表
+	 * @param {Object} params  查询参数 
+	 */
+	getTagList: (params) => {
+		return HttpHandler.Get('/api/content/tags', params)
+	},
+
+	/**
+	 * 查询标签下的文章
+	 * @param {String} slug  别名
+	 * @param {Object} params  查询参数 
+	 */
+	getTagPostsList: (slug, params) => {
+		return HttpHandler.Get(`/api/content/tags/${slug}/posts`, params)
+	},
+}

+ 7 - 7
common/markdown/markdown.config.js

@@ -44,47 +44,47 @@ export default {
 			color: var(--main);
 			line-height: 24px;
 			position: relative;
-			font-size:1.25em;
+			font-size:1.2em;
 			`,
 		h2: `
 			color: var(--main);
 			line-height: 24px;
 			position: relative;
 			margin: 22px 0 16px;
-			font-size: 1.2em;
+			font-size: 1.16em;
 		`,
 		h3: `
 		    color: var(--main);
 		    line-height: 24px;
 		    position: relative;
 			margin: 26px 0 18px;
-			font-size: 1.3em;
+			font-size: 1.14em;
 		`,
 		h4: `
 			color: var(--main);
 		    line-height: 24px;
 		    margin-bottom: 18px;
 		    position: relative;
-			font-size: 1.18em;
+			font-size: 1.2em;
 		`,
 		h5: `
 			color: var(--main);
 		    line-height: 24px;
 		    margin-bottom: 14px;
 		    position: relative;
-			font-size: 1em;
+			font-size: 16px;
 		`,
 		h6: `
 			color: #303133;
 			line-height: 24px;
 			margin-bottom: 14px;
 			position: relative;
-			font-size: 1em;
+			font-size: 14px;
 		`,
 		p: `
 		    line-height: 1.65;
 		    margin-bottom: 14px;
-			font-size: 15px;
+			font-size: 14px;
 		`,
 		'code': `  `,
 		strong: 'font-weight: 700;color: rgb(248, 57, 41);',

+ 5 - 1
components/comment-item/comment-item.vue

@@ -33,7 +33,7 @@
 				</view>
 			</view>
 			<view v-if="useActions" class="">
-				<tm-button size="s" text theme="blue" @click="$emit('on-comment', { type: 'user', comment: comment })">回复</tm-button>
+				<tm-button v-if="!disallowComment" size="s" text theme="blue" @click="$emit('on-comment', { type: 'user', comment: comment })">回复</tm-button>
 				<tm-button size="s" text theme="grey" @click="$emit('on-copy', comment.content)">复制</tm-button>
 			</view>
 		</view>
@@ -59,6 +59,10 @@ export default {
 			type: Array,
 			default: () => []
 		},
+		disallowComment: {
+			type: Boolean,
+			default: false
+		},
 		useActions: {
 			type: Boolean,
 			default: true

+ 22 - 6
components/comment-list/comment-list.vue

@@ -12,7 +12,6 @@
 				<!-- <text class="filter-item">全部</text> -->
 			</view>
 		</view>
-		<!-- <view v-if="disallowComment" class="disallow-comment"><tm-empty icon="icon-shiliangzhinengduixiang-" label="文章已开启禁止评论"></tm-empty></view> -->
 		<!-- 内容区域 -->
 		<view class="comment-list_content">
 			<view v-if="loading != 'success'" class="loading-wrap flex">
@@ -27,9 +26,22 @@
 				</view>
 			</view>
 			<block v-else>
+				<tm-alerts
+					v-if="disallowComment && dataList.length !== 0"
+					color="red"
+					text
+					:margin="[0, 0]"
+					:shadow="0"
+					label="Ծ‸Ծ博主已设置该文章禁止评论!"
+					:round="3"
+					close
+				></tm-alerts>
 				<view class="empty pt-50" v-if="dataList.length == 0">
-					<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无评论">
-						<tm-button theme="bg-gradient-light-blue-accent" size="m" v-if="!disallowComment" @click="fnToComment(null)">抢沙发</tm-button>
+					<tm-empty v-if="disallowComment" icon="icon-shiliangzhinengduixiang-" label="暂无评论">
+						<text class="text-red text-size-s">- 文章已开启禁止评论 -</text>
+					</tm-empty>
+					<tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无评论">
+						<tm-button theme="bg-gradient-light-blue-accent" size="m" @click="fnToComment(null)">抢沙发</tm-button>
 					</tm-empty>
 				</view>
 				<block v-else>
@@ -40,6 +52,7 @@
 							:isChild="false"
 							:comment="comment"
 							:postId="postId"
+							:disallowComment="disallowComment"
 							@on-copy="fnCopyContent"
 							@on-comment="fnToComment"
 							@on-todo="fnToDo"
@@ -54,6 +67,7 @@
 									:isChild="true"
 									:comment="childComment"
 									:postId="postId"
+									:disallowComment="disallowComment"
 									@on-copy="fnCopyContent"
 									@on-comment="fnToComment"
 									@on-todo="fnToDo"
@@ -74,9 +88,11 @@
 <script>
 import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
 import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
+import tmAlerts from '@/tm-vuetify/components/tm-alerts/tm-alerts.vue';
+
 export default {
 	name: 'comment-list',
-	components: { tmEmpty, tmButton },
+	components: { tmEmpty, tmButton, tmAlerts },
 	props: {
 		// 是否禁用评论
 		disallowComment: {
@@ -200,7 +216,7 @@ export default {
 		position: relative;
 		box-sizing: border-box;
 		padding-left: 24rpx;
-		font-size: 34rpx;
+		font-size: 30rpx;
 		font-weight: bold;
 
 		&:before {
@@ -209,7 +225,7 @@ export default {
 			left: 0rpx;
 			top: 8rpx;
 			width: 8rpx;
-			height: 30rpx;
+			height: 26rpx;
 			background-color: rgb(3, 174, 252);
 			border-radius: 6rpx;
 		}

+ 8 - 0
config/halo.config.template.js

@@ -41,6 +41,14 @@ export default {
 		description: '', // 介绍
 	},
 
+	// 版权信息(用于文章详情)
+	copyright: {
+		use: true, // 是否使用版权描述
+		author: '', // 版权归属说明
+		description: '', // 版权描述
+		violation: '', // 侵权处理说明
+	},
+
 	// 社交信息(将会在`/pagesA/contact/contact`页面中展示)
 	// 具体的某个参数值留空则不展示
 	social: {

+ 18 - 0
pages.json

@@ -215,6 +215,24 @@
 					"navigationBarTitleText": "设置",
 					"enablePullDownRefresh": false
 				}
+			}, {
+				"path": "tags/tags",
+				"style": {
+					"navigationBarTitleText": "",
+					"enablePullDownRefresh": false
+				}
+			}, {
+				"path": "tag-detail/tag-detail",
+				"style": {
+					"navigationBarTitleText": "标签详情",
+					"enablePullDownRefresh": true,
+					"app-plus": {
+						"pullToRefresh": {
+							"color": "#03a9f4",
+							"style": "circle"
+						}
+					}
+				}
 			}]
 		},
 		{

+ 1 - 1
pages/tabbar/links/links.vue

@@ -40,7 +40,7 @@
 								<!-- 色彩版本 -->
 								<view
 									v-if="!globalAppSettings.links.useSimple"
-									class="info flex pa-36"
+									class="info flex pt-24 pb-24 pl-12 pr-12"
 									:class="{ 'border-b-1': linkIndex != team.children.length - 1 || index == result.length - 1 }"
 									@click="fnOnLinkEvent(link)"
 								>

+ 73 - 17
pagesA/article-detail/article-detail.vue

@@ -11,14 +11,11 @@
 				<view class="title">{{ result.title }}</view>
 				<view class="detail">
 					<view class="author">
-						<text class="author-name">{{ author.nickname }}</text>
-						<text class="author-time">发布于:{{ { d: result.createTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }}</text>
+						<text class="author-name">博主:{{ author.nickname }}</text>
+						<text class="author-time">时间:{{ { d: result.createTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }}</text>
 					</view>
 
 					<view class="cover" v-if="result.thumbnail"><image class="cover-img" mode="aspectFill" :src="calcUrl(result.thumbnail)"></image></view>
-					<!-- <view class="mt-24">
-						<text class="category-tag" v-for="(item, index) in result.tags" :key="index">{{ item.name }}</text>
-					</view> -->
 					<view class="count" :class="{ 'no-thumbnail': !result.thumbnail }">
 						<view class="count-item">
 							<text class="value">{{ result.visits }}</text>
@@ -41,13 +38,21 @@
 			</view>
 			<!-- 分类 -->
 			<view class="category">
-				<view class="">
-					分类:
-					<text class="category-tag" v-for="(item, index) in result.categories" :key="index">{{ item.name }}</text>
+				<view class="category-type">
+					<text class="text-weight-b">分类:</text>
+					<text v-if="result.categories.length == 0" class="category-tag is-empty">未选择分类</text>
+					<block v-else>
+						<text class="category-tag" v-for="(item, index) in result.categories" :key="index" @click="fnToCate(item)">{{ item.name }}</text>
+					</block>
 				</view>
-				<view class="mt-18">
-					标签:
-					<text class="category-tag" v-for="(item, index) in result.tags" :key="index">{{ item.name }}</text>
+				<view class="mt-18 category-type">
+					<text class="text-weight-b">标签:</text>
+					<text v-if="result.tags.length == 0" class="category-tag is-empty">未选择标签</text>
+					<block v-else>
+						<text class="category-tag" :style="{ backgroundColor: item.color }" v-for="(item, index) in result.tags" :key="index" @click="fnToTag(item)">
+							{{ item.name }}
+						</text>
+					</block>
 				</view>
 			</view>
 			<!-- 广告区域 -->
@@ -88,10 +93,20 @@
 					<!-- #endif -->
 				</view>
 
-				<!-- 免责声明:todo -->
+				<!-- 版权声明 -->
+				<view v-if="copyright.use" class="copyright-wrap bg-white mt-24 pa-24 round-4">
+					<view class="copyright-title text-weight-b">版权信息</view>
+					<view class="copyright-content mt-12  grey-lighten-5 text-grey-darken-2 round-4 pt-12 pb-12 pl-24 pr-24 ">
+						<view v-if="copyright.author" class="copyright-text text-size-s ">版权归属:{{ copyright.author }}</view>
+						<view v-if="copyright.description" class="copyright-text text-size-s mt-12">版权说明:{{ copyright.description }}</view>
+						<view v-if="copyright.violation" class="copyright-text text-size-s mt-12 text-red">侵权处理:{{ copyright.violation }}</view>
+					</view>
+				</view>
 
 				<!-- 评论展示区域 -->
-				<view class="comment-wrap mt-24 pa-24 round-4"><commentList :postId="result.id" :post="result" @on-comment-detail="fnOnShowCommentDetail"></commentList></view>
+				<view class="comment-wrap bg-white mt-24 pa-24 round-4">
+					<commentList :disallowComment="result.disallowComment" :postId="result.id" :post="result" @on-comment-detail="fnOnShowCommentDetail"></commentList>
+				</view>
 			</view>
 
 			<!-- 返回顶部 -->
@@ -228,6 +243,9 @@ export default {
 		};
 	},
 	computed: {
+		copyright() {
+			return getApp().globalData.copyright;
+		},
 		calcUrl() {
 			return url => {
 				if (this.$utils.checkIsUrl(url)) {
@@ -304,6 +322,9 @@ export default {
 		},
 
 		fnToComment() {
+			if (this.result.disallowComment) {
+				return uni.$tm.toast('文章已开启禁止评论!');
+			}
 			this.$Router.push({
 				path: '/pagesA/comment/comment',
 				query: {
@@ -598,6 +619,16 @@ export default {
 				.catch(err => {
 					this.commentDetail.loading = 'error';
 				});
+		},
+		fnToCate(category) {
+			uni.navigateTo({
+				url: `/pagesA/category-detail/category-detail?slug=${category.slug}&name=${category.name}`
+			});
+		},
+		fnToTag(tag) {
+			uni.navigateTo({
+				url: `/pagesA/tag-detail/tag-detail?id=${tag.id}&slug=${tag.slug}&name=${tag.name}`
+			});
 		}
 	}
 };
@@ -646,7 +677,7 @@ export default {
 			&-name {
 			}
 			&-time {
-				margin-left: 12rpx;
+				margin-left: 36rpx;
 			}
 		}
 
@@ -711,12 +742,18 @@ export default {
 	box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.03);
 	// border: 2rpx solid #f8f8f8;
 	font-size: 28rpx;
+	&-type {
+		line-height: 55rpx;
+	}
 	&-tag {
 		background-color: #5bb8fa;
 		color: #fff;
 		padding: 6rpx 12rpx;
 		border-radius: 6rpx;
 		font-size: 24rpx;
+		&.is-empty {
+			background-color: #607d8b;
+		}
 	}
 }
 .category-tag + .category-tag {
@@ -725,11 +762,27 @@ export default {
 .content {
 	margin-top: 24rpx;
 }
-.ad-wrap {
+.evan-markdown,
+.ad-wrap,
+.copyright-wrap,
+.comment-wrap {
 	box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.03);
 }
-.comment-wrap {
-	background-color: #fff;
+.copyright-title {
+	position: relative;
+	box-sizing: border-box;
+	padding-left: 24rpx;
+	font-size: 30rpx;
+	&:before {
+		content: '';
+		position: absolute;
+		left: 0rpx;
+		top: 8rpx;
+		width: 8rpx;
+		height: 26rpx;
+		background-color: rgb(3, 174, 252);
+		border-radius: 6rpx;
+	}
 }
 .poup-head {
 	border-bottom: 2rpx solid #f5f5f5;
@@ -754,6 +807,9 @@ export default {
 	min-height: 60vh;
 	overflow: hidden;
 }
+.copyright-text {
+	line-height: 1.7;
+}
 .poster-loading {
 	width: 100%;
 	position: absolute;

+ 1 - 1
pagesA/category-detail/category-detail.vue

@@ -87,7 +87,7 @@ export default {
 			this.$httpApi
 				.getCategoryPostList(this.slug, this.queryParams)
 				.then(res => {
-					this.fnSetPageTitle(this.pageTitle + ` (共${res.data.total}篇)`);
+					this.fnSetPageTitle(`分类:${this.pageTitle} (共${res.data.total}篇)`);
 					this.result = res.data;
 					if (this.isLoadMore) {
 						this.dataList = this.dataList.concat(res.data.content);

+ 144 - 0
pagesA/tag-detail/tag-detail.vue

@@ -0,0 +1,144 @@
+<template>
+	<view class="app-page">
+		<view v-if="loading != 'success'" class="loading-wrap">
+			<tm-skeleton model="listAvatr"></tm-skeleton>
+			<tm-skeleton model="listAvatr"></tm-skeleton>
+			<tm-skeleton model="listAvatr"></tm-skeleton>
+			<tm-skeleton model="listAvatr"></tm-skeleton>
+		</view>
+		<block v-else>
+			<view class="empty" v-if="dataList.length == 0"><tm-empty icon="icon-shiliangzhinengduixiang-" label="该标签下暂无文章"></tm-empty></view>
+			<block v-else>
+				<block v-for="(article, index) in dataList" :key="article.createTime">
+					<!-- 文章卡片 -->
+					<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"><article-card :article="article" @on-click="fnToArticleDetail"></article-card></tm-translate>
+				</block>
+				<view class="load-text">{{ loadMoreText }}</view>
+			</block>
+
+			<tm-flotbutton @click="fnToTopPage" color="light-blue" size="m" icon="icon-angle-up"></tm-flotbutton>
+		</block>
+	</view>
+</template>
+
+<script>
+import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
+import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
+import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
+import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
+import ArticleCard from '@/components/article-card/article-card.vue';
+export default {
+	components: {
+		tmSkeleton,
+		tmTranslate,
+		tmFlotbutton,
+		tmEmpty,
+		ArticleCard
+	},
+	data() {
+		return {
+			loading: 'loading',
+			queryParams: {
+				size: 10,
+				page: 0
+			},
+			slug: '',
+			pageTitle: '加载中...',
+			result: null,
+			dataList: [],
+			isLoadMore: false,
+			loadMoreText: ''
+		};
+	},
+
+	onLoad(e) {
+		this.slug = e.slug;
+		this.pageTitle = e.name;
+		this.fnGetData();
+	},
+	onPullDownRefresh() {
+		this.isLoadMore = false;
+		this.queryParams.page = 0;
+		this.fnGetData();
+	},
+	onReachBottom(e) {
+		if (this.result.hasNext) {
+			this.queryParams.page += 1;
+			this.isLoadMore = true;
+			this.fnGetData();
+		} else {
+			uni.showToast({
+				icon: 'none',
+				title: '没有更多数据了'
+			});
+		}
+	},
+	methods: {
+		fnGetData() {
+			uni.showLoading({
+				mask: true,
+				title: '加载中...'
+			});
+			// 设置状态为加载中
+			if (!this.isLoadMore) {
+				this.loading = 'loading';
+			}
+			this.loadMoreText = '加载中...';
+			this.$httpApi
+				.getTagPostsList(this.slug, this.queryParams)
+				.then(res => {
+					this.fnSetPageTitle(`标签:${this.pageTitle} (共${res.data.total}篇)`);
+					this.result = res.data;
+					if (this.isLoadMore) {
+						this.dataList = this.dataList.concat(res.data.content);
+					} else {
+						this.dataList = res.data.content;
+					}
+					this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
+					setTimeout(() => {
+						this.loading = 'success';
+					}, 500);
+				})
+				.catch(err => {
+					console.error(err);
+					this.loading = 'error';
+					this.loadMoreText = '加载失败,请下拉刷新!';
+				})
+				.finally(() => {
+					setTimeout(() => {
+						uni.hideLoading();
+						uni.stopPullDownRefresh();
+					}, 500);
+				});
+		},
+		//跳转文章详情
+		fnToArticleDetail(article) {
+			uni.navigateTo({
+				url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
+				animationType: 'slide-in-right'
+			});
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+.app-page {
+	width: 100vw;
+	min-height: 100vh;
+	display: flex;
+	flex-direction: column;
+	padding: 24rpx 0;
+	background-color: #fafafd;
+}
+.loading-wrap {
+	padding: 0 24rpx;
+	min-height: 100vh;
+}
+.empty {
+	height: 60vh;
+	display: flex;
+	align-items: center;
+	justify-content: center;
+}
+</style>

+ 14 - 0
pagesA/tags/tags.vue

@@ -0,0 +1,14 @@
+<template>
+	<view>文章标签页面</view>
+</template>
+
+<script>
+export default {
+	data() {
+		return {};
+	},
+	methods: {}
+};
+</script>
+
+<style></style>