mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
Compare commits
23 Commits
4eae337a8e
...
88236e0f6f
| Author | SHA1 | Date | |
|---|---|---|---|
| 88236e0f6f | |||
| 2c19368437 | |||
| 9a5510546b | |||
| 7e6efd6525 | |||
| abae523a30 | |||
| bf077a3092 | |||
| b8887641e1 | |||
| 2177541de3 | |||
| 46711982c5 | |||
| ab7154713e | |||
| 2327cfa312 | |||
| 713646fc93 | |||
| 1cb300f07a | |||
| e5e3ad3d8b | |||
| 885646ec0c | |||
| ba74d094cd | |||
| 5e5ce93a33 | |||
| 3e8d705bb2 | |||
| 424ab538dc | |||
| 9c06766f81 | |||
| f76e8a43d4 | |||
| 8bb76fcd08 | |||
| b85c69b3ec |
@@ -1,5 +1,5 @@
|
|||||||
VITE_APP_TITLE = 'uni-halo'
|
VITE_APP_TITLE = 'uni-halo'
|
||||||
VITE_APP_PORT = 9520
|
VITE_APP_PORT = 5200
|
||||||
|
|
||||||
VITE_UNI_APPID = '__UNI__5748B6E'
|
VITE_UNI_APPID = '__UNI__5748B6E'
|
||||||
VITE_WX_APPID = 'wx1bb161867082c72f'
|
VITE_WX_APPID = 'wx1bb161867082c72f'
|
||||||
@@ -8,7 +8,7 @@ VITE_WX_APPID = 'wx1bb161867082c72f'
|
|||||||
# macOS 示例:
|
# macOS 示例:
|
||||||
# WECHAT_DEVTOOLS_CLI_PATH = '/Applications/wechatwebdevtools.app/Contents/MacOS/cli'
|
# WECHAT_DEVTOOLS_CLI_PATH = '/Applications/wechatwebdevtools.app/Contents/MacOS/cli'
|
||||||
# Windows 示例:
|
# Windows 示例:
|
||||||
# WECHAT_DEVTOOLS_CLI_PATH = 'C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat'
|
WECHAT_DEVTOOLS_CLI_PATH = 'D:\DevUtils\Tencent\微信web开发者工具\cli.bat'
|
||||||
|
|
||||||
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
|
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
|
||||||
# https://uniapp.dcloud.net.cn/collocation/manifest.html#h5-router
|
# https://uniapp.dcloud.net.cn/collocation/manifest.html#h5-router
|
||||||
@@ -21,13 +21,14 @@ VITE_APP_HALO_TOKEN = ''
|
|||||||
# 默认后台请求地址
|
# 默认后台请求地址
|
||||||
# 不同命令会按 mode 叠加读取 .env.development / .env.test / .env.production。
|
# 不同命令会按 mode 叠加读取 .env.development / .env.test / .env.production。
|
||||||
# 微信小程序如果没有配置下面的专用地址,也会回退使用这个值。
|
# 微信小程序如果没有配置下面的专用地址,也会回退使用这个值。
|
||||||
VITE_SERVER_BASEURL = 'http://localhost:8090'
|
# VITE_SERVER_BASEURL = 'http://localhost:8090'
|
||||||
|
VITE_SERVER_BASEURL = 'http://192.168.1.2:8090'
|
||||||
|
|
||||||
# 微信小程序专用后台请求地址,按微信开发者工具 envVersion 区分。
|
# 微信小程序专用后台请求地址,按微信开发者工具 envVersion 区分。
|
||||||
# 不配置时会回退使用 VITE_SERVER_BASEURL。
|
# 不配置时会回退使用 VITE_SERVER_BASEURL。
|
||||||
VITE_SERVER_BASEURL__WEIXIN_DEVELOP = ''
|
VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'http://192.168.1.2:8090'
|
||||||
VITE_SERVER_BASEURL__WEIXIN_TRIAL = ''
|
VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'http://192.168.1.2:8090'
|
||||||
VITE_SERVER_BASEURL__WEIXIN_RELEASE = ''
|
VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'http://192.168.1.2:8090'
|
||||||
|
|
||||||
# h5是否需要配置代理
|
# h5是否需要配置代理
|
||||||
VITE_APP_PROXY_ENABLE = false
|
VITE_APP_PROXY_ENABLE = false
|
||||||
|
|||||||
Vendored
+2
-1
@@ -9,4 +9,5 @@ VITE_SHOW_SOURCEMAP = false
|
|||||||
VITE_APP_HALO_TOKEN = ''
|
VITE_APP_HALO_TOKEN = ''
|
||||||
|
|
||||||
# development mode 后台请求地址
|
# development mode 后台请求地址
|
||||||
VITE_SERVER_BASEURL = 'http://localhost:8090'
|
# VITE_SERVER_BASEURL = 'http://localhost:8090'
|
||||||
|
VITE_SERVER_BASEURL = 'http://192.168.1.2:8090'
|
||||||
|
|||||||
+5
-2
@@ -2,10 +2,13 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { isPageTabbar } from './tabbar/store'
|
import { isPageTabbar } from './tabbar/store'
|
||||||
import { currRoute } from './utils'
|
import { currRoute } from './utils'
|
||||||
|
import { useSettingsPopup } from '@/hooks/useSettingsPopup'
|
||||||
import CustomTabbar from '@/tabbar/index.vue'
|
import CustomTabbar from '@/tabbar/index.vue'
|
||||||
|
|
||||||
const isCurrentPageTabbar = ref(true)
|
const isCurrentPageTabbar = ref(true)
|
||||||
const globalSettingsVisible = ref(false)
|
const globalSettingsVisible = ref(false)
|
||||||
|
|
||||||
|
const { settingsPopupVisible, openSettingsPopup } = useSettingsPopup()
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
const { path } = currRoute()
|
const { path } = currRoute()
|
||||||
if (path === '/') {
|
if (path === '/') {
|
||||||
@@ -21,10 +24,10 @@
|
|||||||
<view>
|
<view>
|
||||||
<uh-global-actions>
|
<uh-global-actions>
|
||||||
<uh-scrolltop-button :fixed="false" />
|
<uh-scrolltop-button :fixed="false" />
|
||||||
<uh-settings-button :fixed="false" @click="globalSettingsVisible = !globalSettingsVisible" />
|
<uh-settings-button :fixed="false" @action-click="openSettingsPopup()" />
|
||||||
</uh-global-actions>
|
</uh-global-actions>
|
||||||
|
|
||||||
<uh-settings-popup v-model="globalSettingsVisible" @close="globalSettingsVisible = false" />
|
<uh-settings-popup v-model="settingsPopupVisible" />
|
||||||
|
|
||||||
<KuRootView />
|
<KuRootView />
|
||||||
|
|
||||||
|
|||||||
+5
-6
@@ -1,5 +1,4 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
<script setup lang="ts">
|
|
||||||
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
import { getCurrentInstance, onMounted, onUnmounted } from 'vue'
|
import { getCurrentInstance, onMounted, onUnmounted } from 'vue'
|
||||||
import { navigateToInterceptor } from '@/router/interceptor'
|
import { navigateToInterceptor } from '@/router/interceptor'
|
||||||
@@ -14,7 +13,7 @@
|
|||||||
|
|
||||||
onLaunch((options) => {
|
onLaunch((options) => {
|
||||||
// 初始化获取配置
|
// 初始化获取配置
|
||||||
useAppConfigStore()
|
useAppConfigStore().refreshStatic()
|
||||||
|
|
||||||
console.log('App.vue onLaunch', options)
|
console.log('App.vue onLaunch', options)
|
||||||
})
|
})
|
||||||
@@ -50,8 +49,8 @@
|
|||||||
window.removeEventListener('pageshow', syncTabbarWhenPageVisible)
|
window.removeEventListener('pageshow', syncTabbarWhenPageVisible)
|
||||||
})
|
})
|
||||||
// #endif
|
// #endif
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
+24
-5
@@ -14,6 +14,7 @@ import type {
|
|||||||
IComment,
|
IComment,
|
||||||
ICommentListReq,
|
ICommentListReq,
|
||||||
ICommentListRes,
|
ICommentListRes,
|
||||||
|
ICommentReplyListRes,
|
||||||
ILink,
|
ILink,
|
||||||
ILinkGroup,
|
ILinkGroup,
|
||||||
ILinkListRes,
|
ILinkListRes,
|
||||||
@@ -44,8 +45,8 @@ const COMMENT_WIDGET_CAPTCHA_COOKIES = 'comment-widget-captcha';
|
|||||||
*/
|
*/
|
||||||
export function getPostList(params: IPostListReq) {
|
export function getPostList(params: IPostListReq) {
|
||||||
return http.Get<IResponse<IPostListRes>>('/apis/api.content.halo.run/v1alpha1/posts', {
|
return http.Get<IResponse<IPostListRes>>('/apis/api.content.halo.run/v1alpha1/posts', {
|
||||||
query: params,
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo, query: params }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ export function getPostByName(name: string) {
|
|||||||
'Wechat-Session-Id': getOpenid(),
|
'Wechat-Session-Id': getOpenid(),
|
||||||
'nologin-email': getNologinEmail()
|
'nologin-email': getNologinEmail()
|
||||||
},
|
},
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -67,6 +69,7 @@ export function getPostByName(name: string) {
|
|||||||
*/
|
*/
|
||||||
export function getPostListByKeyword(params: ISearchReq) {
|
export function getPostListByKeyword(params: ISearchReq) {
|
||||||
return http.Post<IResponse<ISearchRes>>('/apis/api.halo.run/v1alpha1/indices/-/search', params, {
|
return http.Post<IResponse<ISearchRes>>('/apis/api.halo.run/v1alpha1/indices/-/search', params, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -79,6 +82,7 @@ export function getPostListByKeyword(params: ISearchReq) {
|
|||||||
export function getCategoryList(params: ICategoryListReq) {
|
export function getCategoryList(params: ICategoryListReq) {
|
||||||
return http.Get<IResponse<ICategoryListRes>>('/apis/api.content.halo.run/v1alpha1/categories', {
|
return http.Get<IResponse<ICategoryListRes>>('/apis/api.content.halo.run/v1alpha1/categories', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -88,8 +92,8 @@ export function getCategoryList(params: ICategoryListReq) {
|
|||||||
*/
|
*/
|
||||||
export function getCategoryPostList(name: string, params: IPostListReq) {
|
export function getCategoryPostList(name: string, params: IPostListReq) {
|
||||||
return http.Get<IResponse<IPostListRes>>(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, {
|
return http.Get<IResponse<IPostListRes>>(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, {
|
||||||
params,
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo, query: params }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +103,7 @@ export function getCategoryPostList(name: string, params: IPostListReq) {
|
|||||||
export function getTagList(params: ICategoryListReq) {
|
export function getTagList(params: ICategoryListReq) {
|
||||||
return http.Get<IResponse<ITagListRes>>('/apis/api.content.halo.run/v1alpha1/tags', {
|
return http.Get<IResponse<ITagListRes>>('/apis/api.content.halo.run/v1alpha1/tags', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -109,6 +114,7 @@ export function getTagList(params: ICategoryListReq) {
|
|||||||
export function getPostByTagName(tagName: string, params: IPostListReq) {
|
export function getPostByTagName(tagName: string, params: IPostListReq) {
|
||||||
return http.Get<IResponse<IPostListRes>>(`/apis/api.content.halo.run/v1alpha1/tags/${tagName}/posts`, {
|
return http.Get<IResponse<IPostListRes>>(`/apis/api.content.halo.run/v1alpha1/tags/${tagName}/posts`, {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -130,7 +136,7 @@ export function getPostCommentList(params: ICommentListReq) {
|
|||||||
* 评论回复列表
|
* 评论回复列表
|
||||||
*/
|
*/
|
||||||
export function getPostCommentReplyList(commentName: string, params: ICommentListReq) {
|
export function getPostCommentReplyList(commentName: string, params: ICommentListReq) {
|
||||||
return http.Get<IResponse<ICommentListRes>>(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, {
|
return http.Get<IResponse<ICommentReplyListRes>>(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, {
|
||||||
params,
|
params,
|
||||||
cacheFor: 0,
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
@@ -152,6 +158,8 @@ export interface IAddCommentReq {
|
|||||||
};
|
};
|
||||||
/** 验证码,提交时转入 X-Captcha-Code 头 */
|
/** 验证码,提交时转入 X-Captcha-Code 头 */
|
||||||
captchaCode?: string;
|
captchaCode?: string;
|
||||||
|
/** 回复的回复:被引用回复(CommentReply)的 name */
|
||||||
|
quoteReply?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,6 +175,7 @@ export function addPostComment(data: IAddCommentReq) {
|
|||||||
if (cookie) headers.Cookie = cookie;
|
if (cookie) headers.Cookie = cookie;
|
||||||
return http.Post<IResponse<IComment>>('/apis/api.halo.run/v1alpha1/comments', rest, {
|
return http.Post<IResponse<IComment>>('/apis/api.halo.run/v1alpha1/comments', rest, {
|
||||||
headers,
|
headers,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -184,6 +193,7 @@ export function addPostCommentReply(commentName: string, data: IAddCommentReq) {
|
|||||||
if (cookie) headers.Cookie = cookie;
|
if (cookie) headers.Cookie = cookie;
|
||||||
return http.Post<IResponse<IComment>>(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, rest, {
|
return http.Post<IResponse<IComment>>(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, rest, {
|
||||||
headers,
|
headers,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -196,6 +206,7 @@ export function addPostCommentReply(commentName: string, data: IAddCommentReq) {
|
|||||||
export function getMomentList(params: IMomentListReq) {
|
export function getMomentList(params: IMomentListReq) {
|
||||||
return http.Get<IResponse<IMomentListRes>>('/apis/api.moment.halo.run/v1alpha1/moments', {
|
return http.Get<IResponse<IMomentListRes>>('/apis/api.moment.halo.run/v1alpha1/moments', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -205,6 +216,7 @@ export function getMomentList(params: IMomentListReq) {
|
|||||||
*/
|
*/
|
||||||
export function getMomentByName(name: string) {
|
export function getMomentByName(name: string) {
|
||||||
return http.Get<IResponse<IMoment>>(`/apis/api.moment.halo.run/v1alpha1/moments/${name}`, {
|
return http.Get<IResponse<IMoment>>(`/apis/api.moment.halo.run/v1alpha1/moments/${name}`, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -217,6 +229,7 @@ export function getMomentByName(name: string) {
|
|||||||
export function getPhotoGroupList(params: IPhotoGroupListReq) {
|
export function getPhotoGroupList(params: IPhotoGroupListReq) {
|
||||||
return http.Get<IResponse<IPhotoGroupListRes>>('/apis/api.photo.halo.run/v1alpha1/photogroups', {
|
return http.Get<IResponse<IPhotoGroupListRes>>('/apis/api.photo.halo.run/v1alpha1/photogroups', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -227,6 +240,7 @@ export function getPhotoGroupList(params: IPhotoGroupListReq) {
|
|||||||
export function getPhotoListByGroupName(params: IPhotoListReq) {
|
export function getPhotoListByGroupName(params: IPhotoListReq) {
|
||||||
return http.Get<IResponse<IPhotoListRes>>('/apis/api.photo.halo.run/v1alpha1/photos', {
|
return http.Get<IResponse<IPhotoListRes>>('/apis/api.photo.halo.run/v1alpha1/photos', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -239,6 +253,7 @@ export function getPhotoListByGroupName(params: IPhotoListReq) {
|
|||||||
export function getFriendLinkGroupList(params: ICategoryListReq) {
|
export function getFriendLinkGroupList(params: ICategoryListReq) {
|
||||||
return http.Get<IResponse<Array<ILinkGroup>>>('/apis/api.link.halo.run/v1alpha1/linkgroups', {
|
return http.Get<IResponse<Array<ILinkGroup>>>('/apis/api.link.halo.run/v1alpha1/linkgroups', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -249,6 +264,7 @@ export function getFriendLinkGroupList(params: ICategoryListReq) {
|
|||||||
export function getFriendLinkList(params: ICategoryListReq) {
|
export function getFriendLinkList(params: ICategoryListReq) {
|
||||||
return http.Get<IResponse<ILinkListRes>>('/apis/api.link.halo.run/v1alpha1/links', {
|
return http.Get<IResponse<ILinkListRes>>('/apis/api.link.halo.run/v1alpha1/links', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -260,6 +276,7 @@ export function getFriendLinkList(params: ICategoryListReq) {
|
|||||||
*/
|
*/
|
||||||
export function getBlogStatistics() {
|
export function getBlogStatistics() {
|
||||||
return http.Get<IResponse<IBlogStats>>('/apis/api.halo.run/v1alpha1/stats/-', {
|
return http.Get<IResponse<IBlogStats>>('/apis/api.halo.run/v1alpha1/stats/-', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -269,6 +286,7 @@ export function getBlogStatistics() {
|
|||||||
*/
|
*/
|
||||||
export function submitUpvote(data: IUpvoteReq) {
|
export function submitUpvote(data: IUpvoteReq) {
|
||||||
return http.Post<IResponse<unknown>>('/apis/api.halo.run/v1alpha1/trackers/upvote', data, {
|
return http.Post<IResponse<unknown>>('/apis/api.halo.run/v1alpha1/trackers/upvote', data, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -278,6 +296,7 @@ export function submitUpvote(data: IUpvoteReq) {
|
|||||||
*/
|
*/
|
||||||
export function postTrackersCounter(data: ITrackerCounterReq) {
|
export function postTrackersCounter(data: ITrackerCounterReq) {
|
||||||
return http.Post<IResponse<unknown>>('/apis/api.halo.run/v1alpha1/trackers/counter', data, {
|
return http.Post<IResponse<unknown>>('/apis/api.halo.run/v1alpha1/trackers/counter', data, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo }
|
meta: { requestFrom: RequestFrom.Halo }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-6
@@ -42,7 +42,7 @@ export interface IPostSpec {
|
|||||||
excerpt?: string
|
excerpt?: string
|
||||||
cover?: string
|
cover?: string
|
||||||
owner:IOwner
|
owner:IOwner
|
||||||
/** 发布时间(Halo 2.x 结构,旧项目直接使用) */
|
/** 发布时间(Halo 2.x 结构) */
|
||||||
publishTime?: string
|
publishTime?: string
|
||||||
deleted: boolean
|
deleted: boolean
|
||||||
publish: boolean
|
publish: boolean
|
||||||
@@ -97,7 +97,7 @@ export interface IPost {
|
|||||||
categories?: ICategory[]
|
categories?: ICategory[]
|
||||||
tags?: ITag[]
|
tags?: ITag[]
|
||||||
contributors?: IContributor[]
|
contributors?: IContributor[]
|
||||||
/** 旧项目使用的顶层统计(兼容 Halo 旧版结构) */
|
/** 顶层统计(兼容 Halo 旧版结构) */
|
||||||
stats?: {
|
stats?: {
|
||||||
visit?: number
|
visit?: number
|
||||||
upvote?: number
|
upvote?: number
|
||||||
@@ -123,7 +123,7 @@ export type IPostListRes = IListResult<IPost>
|
|||||||
/** 文章搜索请求参数(关键字) */
|
/** 文章搜索请求参数(关键字) */
|
||||||
export interface ISearchReq {
|
export interface ISearchReq {
|
||||||
keyword?: string
|
keyword?: string
|
||||||
/** 返回条数上限(旧版默认 50) */
|
/** 返回条数上限(默认 50) */
|
||||||
limit?: number
|
limit?: number
|
||||||
page?: number
|
page?: number
|
||||||
size?: number
|
size?: number
|
||||||
@@ -152,7 +152,7 @@ export interface ICategory {
|
|||||||
visiblePostCount?: number
|
visiblePostCount?: number
|
||||||
}
|
}
|
||||||
children?: ICategory[]
|
children?: ICategory[]
|
||||||
/** 文章数(旧项目首页直接读取/排序用) */
|
/** 文章数 */
|
||||||
postCount?: number
|
postCount?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +235,8 @@ export interface IComment {
|
|||||||
status?: {
|
status?: {
|
||||||
hasReply?: boolean
|
hasReply?: boolean
|
||||||
replyCount?: number
|
replyCount?: number
|
||||||
|
/** 可见回复数(公开接口按审核可见统计) */
|
||||||
|
visibleReplyCount?: number
|
||||||
visibleTime?: string
|
visibleTime?: string
|
||||||
}
|
}
|
||||||
replies?: IListResult<ICommentReply>
|
replies?: IListResult<ICommentReply>
|
||||||
@@ -264,12 +266,19 @@ export interface ICommentReply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 评论回复列表响应(分页) */
|
||||||
|
export type ICommentReplyListRes = IListResult<ICommentReply>
|
||||||
|
|
||||||
export interface ICommentListReq {
|
export interface ICommentListReq {
|
||||||
page?: number
|
page?: number
|
||||||
size?: number
|
size?: number
|
||||||
sort?: string[]
|
sort?: string[]
|
||||||
/** 主题名称(文章 name) */
|
/** 主题名称(文章 name) */
|
||||||
name?: string
|
name?: string
|
||||||
|
/** 是否携带该评论的部分回复(默认 false) */
|
||||||
|
withReplies?: boolean
|
||||||
|
/** 携带回复条数(仅 withReplies=true 时生效,默认 10) */
|
||||||
|
replySize?: number
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +364,7 @@ export interface IPhoto {
|
|||||||
displayName: string
|
displayName: string
|
||||||
description?: string
|
description?: string
|
||||||
url: string
|
url: string
|
||||||
/** 封面图(部分接口返回,兼容旧代码) */
|
/** 封面图(部分接口返回) */
|
||||||
cover?: string
|
cover?: string
|
||||||
priority?: number
|
priority?: number
|
||||||
takeTime?: string
|
takeTime?: string
|
||||||
@@ -447,7 +456,7 @@ export interface ITrackerCounterReq {
|
|||||||
title?: string
|
title?: string
|
||||||
referrer?: string
|
referrer?: string
|
||||||
language?: string
|
language?: string
|
||||||
/** 访问页面路径(旧项目埋点 url 字段) */
|
/** 访问页面路径(埋点 url 字段) */
|
||||||
url?: string
|
url?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+71
-23
@@ -18,10 +18,7 @@ export interface IImagesConfig {
|
|||||||
export interface IPluginConfig {
|
export interface IPluginConfig {
|
||||||
toolsPlugin?: { Authorization?: string } & Record<string, unknown>
|
toolsPlugin?: { Authorization?: string } & Record<string, unknown>
|
||||||
/**
|
/**
|
||||||
* 友链信息(插件端 spec.linkInfo 直接下发到本键,结构 = {submissionEnabled, miniInfo, siteInfo},字段名无映射;
|
* 友链信息(插件端 spec.linkInfo 直接下发到本键,结构 = {submissionEnabled, miniInfo, siteInfo},字段名无映射)
|
||||||
* linksSubmitPlugin 旧键已弃用不再下发;votePlugin/linksPlugin 已下线(2026-09-10,app 端改插件启用检测判定);
|
|
||||||
* 2026-09-11 起新增基本配置 submissionEnabled(公开提交申请开关,原 setting linkConfig);authorInfo 已下线,
|
|
||||||
* 作者信息改读 authorConfig.blogger)
|
|
||||||
*/
|
*/
|
||||||
linkInfo?: {
|
linkInfo?: {
|
||||||
/** 基本配置:是否开放公开提交申请(默认 true;false 时隐藏「提交申请」入口) */
|
/** 基本配置:是否开放公开提交申请(默认 true;false 时隐藏「提交申请」入口) */
|
||||||
@@ -34,7 +31,7 @@ export interface IPluginConfig {
|
|||||||
description?: string
|
description?: string
|
||||||
applyRemark?: string
|
applyRemark?: string
|
||||||
}
|
}
|
||||||
/** 站点信息(对齐 Halo 官方友链提交 API:displayName/url/logo/description/backlink/feedUrls,2026-09-11 起不再含 email) */
|
/** 站点信息(对齐 Halo 官方友链提交 API:displayName/url/logo/description/backlink/feedUrls) */
|
||||||
siteInfo?: {
|
siteInfo?: {
|
||||||
displayName?: string
|
displayName?: string
|
||||||
url?: string
|
url?: string
|
||||||
@@ -115,20 +112,26 @@ export interface IPageConfig {
|
|||||||
categoryConfig?: { type?: string }
|
categoryConfig?: { type?: string }
|
||||||
momentConfig?: { useTagRandomColor?: boolean }
|
momentConfig?: { useTagRandomColor?: boolean }
|
||||||
galleryConfig?: { pageTitle?: string }
|
galleryConfig?: { pageTitle?: string }
|
||||||
|
/** 恋爱日记页(插件端「通用配置 → 页面设置 → 恋爱日记」配置) */
|
||||||
|
loveDiaryConfig?: {
|
||||||
|
pageTitle?: string
|
||||||
|
/** 恋爱页背景图(留空客户端内置回退) */
|
||||||
|
bgImageUrl?: string
|
||||||
|
}
|
||||||
aboutConfig?: {
|
aboutConfig?: {
|
||||||
bgImageUrl?: string
|
bgImageUrl?: string
|
||||||
waveImageUrl?: string
|
waveImageUrl?: string
|
||||||
/** 页脚版权(2026-09-10 起插件端从应用设置迁入,显示于关于页页脚) */
|
/** 页脚版权(显示于关于页页脚) */
|
||||||
copyrightConfig?: {
|
copyrightConfig?: {
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
content?: string
|
content?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 免责声明页(2026-09-10 起插件端从应用设置迁入:不再有 enabled 开关,按内容非空展示) */
|
/** 免责声明页(按内容非空展示) */
|
||||||
disclaimers?: {
|
disclaimers?: {
|
||||||
content?: string
|
content?: string
|
||||||
}
|
}
|
||||||
/** 文章详情页配置(2026-09-10 起插件端从应用设置迁入:评论开关与版权文案) */
|
/** 文章详情页配置(评论开关与版权文案) */
|
||||||
postDetailConfig?: {
|
postDetailConfig?: {
|
||||||
showComment?: boolean
|
showComment?: boolean
|
||||||
copyrightEnabled?: boolean
|
copyrightEnabled?: boolean
|
||||||
@@ -184,14 +187,15 @@ export interface IAppConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 恋爱配置(2026-09-10 起插件端 loveEnabled 总开关下线,入口显隐由模块入口开关
|
* 恋爱配置(恋爱日记入口仅密码状态无开关;三模块入口自身即 app 端入口列表数据:
|
||||||
* (ourStory/lovePhoto/loveDaily.enabled)与 navList 统一管理,客户端按模块开关判定)
|
* title/subTitle/颜色(hex8)/iconBgColor/path/priority,按 priority 降序下发;
|
||||||
|
* app 端按模块 key 直接渲染入口列表,locked=passwordEnabled 且本地无有效 token)
|
||||||
*/
|
*/
|
||||||
loveConfig?: Record<string, unknown>
|
loveConfig?: ILoveConfigGroup
|
||||||
imagesConfig?: IImagesConfig
|
imagesConfig?: IImagesConfig
|
||||||
/**
|
/**
|
||||||
* 博主与社交(插件端 GeneralConfig.profile.blogger/social 重建;blogger 含
|
* 博主与社交(blogger 含
|
||||||
* nickname/avatar/email/description/website(官网地址 2026-09-10 新增))
|
* nickname/avatar/email/description/website)
|
||||||
*/
|
*/
|
||||||
authorConfig?: Record<string, unknown>
|
authorConfig?: Record<string, unknown>
|
||||||
appConfig?: Record<string, unknown>
|
appConfig?: Record<string, unknown>
|
||||||
@@ -219,7 +223,7 @@ export interface IAppConfig {
|
|||||||
avatarRadius?: boolean
|
avatarRadius?: boolean
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 维护模式(additive,2026-09-04 插件端 GeneralConfig.spec.maintenance 经 getConfigs
|
* 维护模式(additive,插件端 GeneralConfig.spec.maintenance 经 getConfigs
|
||||||
* 下发;仅 scheduled/active 时存在,键缺失=未维护或已到点自动结束)
|
* 下发;仅 scheduled/active 时存在,键缺失=未维护或已到点自动结束)
|
||||||
*/
|
*/
|
||||||
maintenance?: IPublicMaintenance
|
maintenance?: IPublicMaintenance
|
||||||
@@ -228,7 +232,7 @@ export interface IAppConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* getConfigs 顶层 maintenance 键(插件端输出;status 判定权威在服务端,客户端仅据此
|
* getConfigs 顶层 maintenance 键(插件端输出;status 判定权威在服务端,客户端仅据此
|
||||||
* 展示维护页与倒计时,设计见插件 .docs/maintenance-config-design.md)
|
* 展示维护页与倒计时)
|
||||||
*/
|
*/
|
||||||
export interface IPublicMaintenance {
|
export interface IPublicMaintenance {
|
||||||
/** scheduled 维护预告(倒计时至 startTime)/ active 维护中(倒计时至 endTime) */
|
/** scheduled 维护预告(倒计时至 startTime)/ active 维护中(倒计时至 endTime) */
|
||||||
@@ -428,7 +432,7 @@ export interface ICommentCaptcha {
|
|||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- 通知公告(plugin-uni-halo notice,2026-09-03 客户端接入) ---------- */
|
/* ---------- 通知公告(plugin-uni-halo notice) ---------- */
|
||||||
|
|
||||||
/** 公告公开列表项(脱敏,不含 content;内嵌类型信息 typeDisplayName/typeColor) */
|
/** 公告公开列表项(脱敏,不含 content;内嵌类型信息 typeDisplayName/typeColor) */
|
||||||
export interface INoticeListVo {
|
export interface INoticeListVo {
|
||||||
@@ -478,13 +482,57 @@ export interface INoticeDetail {
|
|||||||
|
|
||||||
/* ---------- 恋爱模块(plugin-uni-halo love) ---------- */
|
/* ---------- 恋爱模块(plugin-uni-halo love) ---------- */
|
||||||
|
|
||||||
export interface ILoveConfig {
|
/** 恋爱模块入口(三模块共用;loveDiary 仅使用密码相关字段) */
|
||||||
/** 纪念日 */
|
export interface ILoveModuleConfig {
|
||||||
anniversary?: string
|
/** 是否在恋爱页展示该模块入口(loveDiary 不使用:入口显隐由快捷导航/功能入口注册表控制) */
|
||||||
/** 恋人信息 */
|
enabled?: boolean
|
||||||
lovers?: {
|
/** 入口名称(app 端入口列表标题) */
|
||||||
name?: string
|
title?: string
|
||||||
avatar?: string
|
/** 入口副标题(app 端入口列表副标题) */
|
||||||
|
subTitle?: string
|
||||||
|
/** 标题颜色(hex8 #rrggbbaa) */
|
||||||
|
titleColor?: string
|
||||||
|
/** 副标题颜色(hex8 #rrggbbaa) */
|
||||||
|
subTitleColor?: string
|
||||||
|
/** 图标背景色(hex8 #rrggbbaa) */
|
||||||
|
iconBgColor?: string
|
||||||
|
/** 图标字体前缀(如 uhlove-icon,app 端渲染入口图标) */
|
||||||
|
iconPrefix?: string
|
||||||
|
/** 图标名(app 端渲染入口图标) */
|
||||||
|
icon?: string
|
||||||
|
/** app 端跳转路径 */
|
||||||
|
path?: string
|
||||||
|
/** 排序字段(越大越靠前,插件端按 priority 降序输出) */
|
||||||
|
priority?: number
|
||||||
|
/** 是否已设置密码(app 端据此显示锁定态:passwordEnabled && 本地无有效 token) */
|
||||||
|
passwordEnabled?: boolean
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
/** getConfigs loveConfig 组(恋爱日记仅密码状态;三模块入口即 app 端入口列表数据) */
|
||||||
|
export interface ILoveConfigGroup {
|
||||||
|
/** 恋爱日记入口(恋爱页本身,仅密码状态,无 enabled 开关) */
|
||||||
|
loveDiary?: Pick<ILoveModuleConfig, 'passwordEnabled'>
|
||||||
|
/** 恋爱故事模块入口 */
|
||||||
|
ourStory?: ILoveModuleConfig
|
||||||
|
/** 恋爱相册模块入口 */
|
||||||
|
lovePhoto?: ILoveModuleConfig
|
||||||
|
/** 恋爱清单模块入口 */
|
||||||
|
loveDaily?: ILoveModuleConfig
|
||||||
|
/** 恋爱信息(纪念日 + 恋人信息;经 getConfigs loveConfig.loveInfo 下发) */
|
||||||
|
loveInfo?: {
|
||||||
|
/** 纪念日标题(默认「这是我们一起走过的」) */
|
||||||
|
loveDateTitle?: string
|
||||||
|
/** 恋爱纪念日(yyyy-MM-dd),用于计算恋爱天数 */
|
||||||
|
loveDate?: string
|
||||||
|
/** 男生昵称 */
|
||||||
|
boyNickname?: string
|
||||||
|
/** 男生头像 */
|
||||||
|
boyAvatar?: string
|
||||||
|
/** 女生昵称 */
|
||||||
|
girlNickname?: string
|
||||||
|
/** 女生头像 */
|
||||||
|
girlAvatar?: string
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
|
|||||||
+39
-19
@@ -19,7 +19,6 @@ import type {
|
|||||||
ILoveAlbum,
|
ILoveAlbum,
|
||||||
ILoveAlbumListReq,
|
ILoveAlbumListReq,
|
||||||
ILoveAlbumListRes,
|
ILoveAlbumListRes,
|
||||||
ILoveConfig,
|
|
||||||
ILoveDailyItem,
|
ILoveDailyItem,
|
||||||
ILoveDailyItemListReq,
|
ILoveDailyItemListReq,
|
||||||
ILoveDailyItemListRes,
|
ILoveDailyItemListRes,
|
||||||
@@ -77,6 +76,7 @@ export function getAuditData() {
|
|||||||
*/
|
*/
|
||||||
export function getBanners() {
|
export function getBanners() {
|
||||||
return http.Get<IResponse<IBannerPublicItem[]>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/banners', {
|
return http.Get<IResponse<IBannerPublicItem[]>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/banners', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -86,6 +86,7 @@ export function getBanners() {
|
|||||||
*/
|
*/
|
||||||
export function getBannerDetail(name: string) {
|
export function getBannerDetail(name: string) {
|
||||||
return http.Get<IResponse<IBannerPublicDetail>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/banners/${name}`, {
|
return http.Get<IResponse<IBannerPublicDetail>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/banners/${name}`, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -95,6 +96,7 @@ export function getBannerDetail(name: string) {
|
|||||||
*/
|
*/
|
||||||
export function getHaloGlobalInfo() {
|
export function getHaloGlobalInfo() {
|
||||||
return http.Get<IResponse<IHaloGlobalConfig>>('/actuator/globalinfo', {
|
return http.Get<IResponse<IHaloGlobalConfig>>('/actuator/globalinfo', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -104,6 +106,7 @@ export function getHaloGlobalInfo() {
|
|||||||
*/
|
*/
|
||||||
export function getCommentWidgetConfig() {
|
export function getCommentWidgetConfig() {
|
||||||
return http.Get<IResponse<ICommentWidgetConfig>>('/apis/api.commentwidget.halo.run/v1alpha1/config', {
|
return http.Get<IResponse<ICommentWidgetConfig>>('/apis/api.commentwidget.halo.run/v1alpha1/config', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -114,6 +117,7 @@ export function getCommentWidgetConfig() {
|
|||||||
export function checkVersion(baseUrl: string) {
|
export function checkVersion(baseUrl: string) {
|
||||||
return http.Get<IResponse<IUpdateCheckRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/upgrade/checkVersion', {
|
return http.Get<IResponse<IUpdateCheckRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/upgrade/checkVersion', {
|
||||||
params: { baseUrl },
|
params: { baseUrl },
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -123,11 +127,12 @@ export function checkVersion(baseUrl: string) {
|
|||||||
*/
|
*/
|
||||||
export function getQRCodeInfo(key: string) {
|
export function getQRCodeInfo(key: string) {
|
||||||
return http.Get<IResponse<IQRCodeInfo>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/getQRCodeInfo/${key}`, {
|
return http.Get<IResponse<IQRCodeInfo>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/getQRCodeInfo/${key}`, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ==================== 防刷验证码(plugin-uni-halo,2026-09-03 客户端接入) ==================== */
|
/* ==================== 防刷验证码(plugin-uni-halo) ==================== */
|
||||||
|
|
||||||
/** 防刷验证码(服务端 captcha/generate 返回;受保护写接口 403 时响应体亦附带新验证码) */
|
/** 防刷验证码(服务端 captcha/generate 返回;受保护写接口 403 时响应体亦附带新验证码) */
|
||||||
export interface IPluginCaptcha {
|
export interface IPluginCaptcha {
|
||||||
@@ -147,6 +152,7 @@ export interface ICaptchaQuery {
|
|||||||
*/
|
*/
|
||||||
export function getPluginCaptcha() {
|
export function getPluginCaptcha() {
|
||||||
return http.Get<IResponse<IPluginCaptcha>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/captcha/generate', {
|
return http.Get<IResponse<IPluginCaptcha>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/captcha/generate', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -158,7 +164,7 @@ export function buildCaptchaQuery(captcha?: ICaptchaQuery | null): ICaptchaQuery
|
|||||||
return { captchaId: captcha.captchaId, captchaCode: captcha.captchaCode }
|
return { captchaId: captcha.captchaId, captchaCode: captcha.captchaCode }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ==================== 通知公告(plugin-uni-halo,2026-09-03 客户端接入) ==================== */
|
/* ==================== 通知公告(plugin-uni-halo) ==================== */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告分页列表(公开,仅已发布;脱敏不含 content,内嵌类型信息)。
|
* 公告分页列表(公开,仅已发布;脱敏不含 content,内嵌类型信息)。
|
||||||
@@ -167,6 +173,7 @@ export function buildCaptchaQuery(captcha?: ICaptchaQuery | null): ICaptchaQuery
|
|||||||
export function getNotices(params: { page?: number, size?: number }) {
|
export function getNotices(params: { page?: number, size?: number }) {
|
||||||
return http.Get<IResponse<INoticeListRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices', {
|
return http.Get<IResponse<INoticeListRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -176,6 +183,7 @@ export function getNotices(params: { page?: number, size?: number }) {
|
|||||||
*/
|
*/
|
||||||
export function getNoticeLatest() {
|
export function getNoticeLatest() {
|
||||||
return http.Get<IResponse<INoticeListVo | null>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices/latest', {
|
return http.Get<IResponse<INoticeListVo | null>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices/latest', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -185,22 +193,13 @@ export function getNoticeLatest() {
|
|||||||
*/
|
*/
|
||||||
export function getNoticeDetail(name: string) {
|
export function getNoticeDetail(name: string) {
|
||||||
return http.Get<IResponse<INoticeDetail>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices/${name}`, {
|
return http.Get<IResponse<INoticeDetail>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices/${name}`, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ==================== 恋爱模块 ==================== */
|
/* ==================== 恋爱模块 ==================== */
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取恋爱配置(纪念日 + 恋人信息)
|
|
||||||
*/
|
|
||||||
export function getLoveConfig() {
|
|
||||||
return http.Get<IResponse<ILoveConfig>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-config', {
|
|
||||||
cacheFor: 0,
|
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取恋爱相册列表(lovePhoto 模块设密码时需携带模块解锁 token)
|
* 获取恋爱相册列表(lovePhoto 模块设密码时需携带模块解锁 token)
|
||||||
*/
|
*/
|
||||||
@@ -208,7 +207,7 @@ export function getLoveAlbums(params: ILoveAlbumListReq) {
|
|||||||
const token = getLoveModuleToken('lovePhoto')
|
const token = getLoveModuleToken('lovePhoto')
|
||||||
return http.Get<IResponse<ILoveAlbumListRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-albums', {
|
return http.Get<IResponse<ILoveAlbumListRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-albums', {
|
||||||
params: { ...params, ...(token ? { token } : {}) },
|
params: { ...params, ...(token ? { token } : {}) },
|
||||||
cacheFor: 0,
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -220,7 +219,7 @@ export function getLoveAlbumByName(name: string, params: ILoveAlbumListReq) {
|
|||||||
const token = getLoveModuleToken('lovePhoto')
|
const token = getLoveModuleToken('lovePhoto')
|
||||||
return http.Get<IResponse<ILoveAlbum>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-albums/${name}`, {
|
return http.Get<IResponse<ILoveAlbum>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-albums/${name}`, {
|
||||||
params: { ...params, ...(token ? { token } : {}) },
|
params: { ...params, ...(token ? { token } : {}) },
|
||||||
cacheFor: 0,
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -237,15 +236,17 @@ export function unlockAlbum(name: string, password: string, captcha?: ICaptchaQu
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
params: { ...buildCaptchaQuery(captcha), ...(token ? { token } : {}) },
|
params: { ...buildCaptchaQuery(captcha), ...(token ? { token } : {}) },
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 恋爱模块入口解锁(模块密码,签发 30 分钟 token;模块:ourStory/lovePhoto/loveDaily)
|
* 恋爱模块入口解锁(入口密码,签发 30 分钟 token;module:loveDiary(恋爱日记入口)/
|
||||||
|
* ourStory/lovePhoto/loveDaily;插件端要求验证码,失败 403 返回新验证码)
|
||||||
*/
|
*/
|
||||||
export function unlockLoveModule(module: string, password: string) {
|
export function unlockLoveModule(module: string, password: string, captcha?: ICaptchaQuery | null) {
|
||||||
return http.Post<IResponse<{ token: string }>>(
|
return http.Post<IResponse<{ token: string }>>(
|
||||||
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-modules/unlock',
|
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-modules/unlock',
|
||||||
{
|
{
|
||||||
@@ -253,6 +254,8 @@ export function unlockLoveModule(module: string, password: string) {
|
|||||||
password,
|
password,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
params: buildCaptchaQuery(captcha),
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -267,7 +270,8 @@ export function getLoveDailyItems(params: ILoveDailyItemListReq) {
|
|||||||
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-daily-items',
|
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-daily-items',
|
||||||
{
|
{
|
||||||
params: { ...params, ...(token ? { token } : {}) },
|
params: { ...params, ...(token ? { token } : {}) },
|
||||||
cacheFor: 0,
|
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -280,6 +284,7 @@ export function getLoveStories(params: ILoveStoryListReq) {
|
|||||||
const token = getLoveModuleToken('ourStory')
|
const token = getLoveModuleToken('ourStory')
|
||||||
return http.Get<IResponse<ILoveStoryListRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-stories', {
|
return http.Get<IResponse<ILoveStoryListRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-stories', {
|
||||||
params: { ...params, ...(token ? { token } : {}) },
|
params: { ...params, ...(token ? { token } : {}) },
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -294,6 +299,7 @@ export function getMiniProgramLinkGroupedList() {
|
|||||||
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/mini-program-links',
|
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/mini-program-links',
|
||||||
{
|
{
|
||||||
params: { grouped: true },
|
params: { grouped: true },
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -306,6 +312,7 @@ export function getMiniProgramLinkTypes() {
|
|||||||
return http.Get<IResponse<IMiniProgramLinkGroupOption[]>>(
|
return http.Get<IResponse<IMiniProgramLinkGroupOption[]>>(
|
||||||
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/mini-program-links/types',
|
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/mini-program-links/types',
|
||||||
{
|
{
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -318,6 +325,7 @@ export function getMiniProgramLinkDetail(name: string) {
|
|||||||
return http.Get<IResponse<IMiniProgramLink>>(
|
return http.Get<IResponse<IMiniProgramLink>>(
|
||||||
`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/mini-program-links/${name}`,
|
`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/mini-program-links/${name}`,
|
||||||
{
|
{
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -335,6 +343,7 @@ export function submitMiniProgramLinkApplication(data: IMiniProgramLinkSubmissio
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
params: buildCaptchaQuery(captcha),
|
params: buildCaptchaQuery(captcha),
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -358,6 +367,7 @@ export function requestRestrictReadCheck(restrictType: RestrictReadType, code: s
|
|||||||
'Wechat-Session-Id': getOpenid(),
|
'Wechat-Session-Id': getOpenid(),
|
||||||
'nologin-email': getNologinEmail(),
|
'nologin-email': getNologinEmail(),
|
||||||
},
|
},
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -371,6 +381,7 @@ export function createVerificationCode() {
|
|||||||
'Authorization': getToolsAuthorization(),
|
'Authorization': getToolsAuthorization(),
|
||||||
'Wechat-Session-Id': getOpenid(),
|
'Wechat-Session-Id': getOpenid(),
|
||||||
},
|
},
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -385,6 +396,7 @@ export function createVerificationCode() {
|
|||||||
export function getVoteList(params: IVoteListReq) {
|
export function getVoteList(params: IVoteListReq) {
|
||||||
return http.Get<IResponse<IVoteListRes>>('/apis/api.vote.kunkunyu.com/v1alpha1/votes', {
|
return http.Get<IResponse<IVoteListRes>>('/apis/api.vote.kunkunyu.com/v1alpha1/votes', {
|
||||||
params,
|
params,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -394,6 +406,7 @@ export function getVoteList(params: IVoteListReq) {
|
|||||||
*/
|
*/
|
||||||
export function getVoteDetail(name: string) {
|
export function getVoteDetail(name: string) {
|
||||||
return http.Get<IResponse<IVoteDetail>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/detail`, {
|
return http.Get<IResponse<IVoteDetail>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/detail`, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -403,6 +416,7 @@ export function getVoteDetail(name: string) {
|
|||||||
*/
|
*/
|
||||||
export function getVoteUserList(name: string) {
|
export function getVoteUserList(name: string) {
|
||||||
return http.Get<IResponse<unknown[]>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/user-list`, {
|
return http.Get<IResponse<unknown[]>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/user-list`, {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -420,6 +434,7 @@ export function submitVote(name: string, data: IVoteSubmitReq, canAnonymously =
|
|||||||
}
|
}
|
||||||
return http.Post<IResponse<unknown>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/submit`, data, {
|
return http.Post<IResponse<unknown>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/submit`, data, {
|
||||||
headers,
|
headers,
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -432,6 +447,7 @@ export function submitVote(name: string, data: IVoteSubmitReq, canAnonymously =
|
|||||||
export function getDoubanDetail(url: string) {
|
export function getDoubanDetail(url: string) {
|
||||||
return http.Get<IResponse<IDoubanDetail>>('/apis/api.douban.moony.la/v1alpha1/doubanmovies/-/getDoubanDetail', {
|
return http.Get<IResponse<IDoubanDetail>>('/apis/api.douban.moony.la/v1alpha1/doubanmovies/-/getDoubanDetail', {
|
||||||
params: { url },
|
params: { url },
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -454,7 +470,8 @@ export function getCommentWidgetCaptcha() {
|
|||||||
export interface IDataStatistics {
|
export interface IDataStatistics {
|
||||||
tags: { name: string, count: number }[]
|
tags: { name: string, count: number }[]
|
||||||
categories: { name: string, total: number }[]
|
categories: { name: string, total: number }[]
|
||||||
articles: { date: string, count: number }[]
|
/** 发布趋势:articleTotal=当日文章数,momentTotal=当日瞬间数,total=二者之和 */
|
||||||
|
articles: { date: string, articleTotal: number, momentTotal: number, name: string, total: number }[]
|
||||||
comments: { username: string, count: number }[]
|
comments: { username: string, count: number }[]
|
||||||
top10Articles: { name: string, views: number }[]
|
top10Articles: { name: string, views: number }[]
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
@@ -466,6 +483,7 @@ export interface IDataStatistics {
|
|||||||
*/
|
*/
|
||||||
export function getChartData() {
|
export function getChartData() {
|
||||||
return http.Get<IResponse<IDataStatistics>>('/apis/api.data.statistics.xhhao.com/v1alpha1/chart/data', {
|
return http.Get<IResponse<IDataStatistics>>('/apis/api.data.statistics.xhhao.com/v1alpha1/chart/data', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -475,6 +493,7 @@ export function getChartData() {
|
|||||||
*/
|
*/
|
||||||
export function getGithubConfig() {
|
export function getGithubConfig() {
|
||||||
return http.Get<IResponse<unknown>>('/apis/api.data.statistics.xhhao.com/v1alpha1/github/config', {
|
return http.Get<IResponse<unknown>>('/apis/api.data.statistics.xhhao.com/v1alpha1/github/config', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -484,6 +503,7 @@ export function getGithubConfig() {
|
|||||||
*/
|
*/
|
||||||
export function getUptimeKumaStatus() {
|
export function getUptimeKumaStatus() {
|
||||||
return http.Get<IResponse<unknown>>('/apis/api.data.statistics.xhhao.com/v1alpha1/uptime/status', {
|
return http.Get<IResponse<unknown>>('/apis/api.data.statistics.xhhao.com/v1alpha1/uptime/status', {
|
||||||
|
cacheFor: 0,
|
||||||
meta: { requestFrom: RequestFrom.Halo },
|
meta: { requestFrom: RequestFrom.Halo },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
photos.value = []
|
photos.value = []
|
||||||
handleLoadPhotos()
|
handleLoadPhotos()
|
||||||
}
|
}
|
||||||
})
|
}, { immediate: true })
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
isShow.value = false
|
isShow.value = false
|
||||||
@@ -91,7 +91,6 @@
|
|||||||
<uh-glass-popup v-model="isShow" position="bottom" :z-index="100" custom-class="!border rounded-2xl"
|
<uh-glass-popup v-model="isShow" position="bottom" :z-index="100" custom-class="!border rounded-2xl"
|
||||||
safe-area-inset-bottom @close="handleClose">
|
safe-area-inset-bottom @close="handleClose">
|
||||||
<view class="box-border h-full w-full flex flex-col gap-y-3 p-4">
|
<view class="box-border h-full w-full flex flex-col gap-y-3 p-4">
|
||||||
<!-- 头部 -->
|
|
||||||
<view class="w-full flex shrink-0 items-center justify-between">
|
<view class="w-full flex shrink-0 items-center justify-between">
|
||||||
<view class="flex items-center gap-x-1 font-bold">
|
<view class="flex items-center gap-x-1 font-bold">
|
||||||
{{ albumName }}
|
{{ albumName }}
|
||||||
@@ -99,12 +98,12 @@
|
|||||||
<view
|
<view
|
||||||
class="uh-global-card-glass uh-shadow-xs h-6 w-6 flex items-center justify-center border rounded-lg"
|
class="uh-global-card-glass uh-shadow-xs h-6 w-6 flex items-center justify-center border rounded-lg"
|
||||||
@click="handleClose">
|
@click="handleClose">
|
||||||
<wd-icon name="close" size="32rpx" />
|
<wd-icon name="close" size="28rpx" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 照片列表 -->
|
<!-- 照片列表 -->
|
||||||
<scroll-view class="box-border max-h-[50vh] flex-1" scroll-y :show-scrollbar="false">
|
<scroll-view class="w-full box-border max-h-[50vh] flex-1" scroll-y :show-scrollbar="false">
|
||||||
<!-- 加载/错误/空占位(状态机) -->
|
<!-- 加载/错误/空占位(状态机) -->
|
||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :use-refresh-button="false"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :use-refresh-button="false"
|
||||||
:loading-status="loadingStatus" error-text="照片加载失败,请点击刷新重试" empty-text="这个相册暂时还没有照片~"
|
:loading-status="loadingStatus" error-text="照片加载失败,请点击刷新重试" empty-text="这个相册暂时还没有照片~"
|
||||||
@@ -122,8 +121,7 @@
|
|||||||
<view v-if="photo.description" class="mb-1 text-xs text-white leading-5">
|
<view v-if="photo.description" class="mb-1 text-xs text-white leading-5">
|
||||||
{{ photo.description }}
|
{{ photo.description }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="photo.takenDate || photo.location"
|
<view v-if="photo.takenDate || photo.location" class="flex flex-col gap-y-1">
|
||||||
class="flex flex-col gap-y-1">
|
|
||||||
<text v-if="photo.takenDate" class="text-xs text-white">
|
<text v-if="photo.takenDate" class="text-xs text-white">
|
||||||
<wd-icon name="time-line"></wd-icon> {{ photo.takenDate }}
|
<wd-icon name="time-line"></wd-icon> {{ photo.takenDate }}
|
||||||
</text>
|
</text>
|
||||||
@@ -139,11 +137,11 @@
|
|||||||
|
|
||||||
<!-- 底部关闭 -->
|
<!-- 底部关闭 -->
|
||||||
<view class="w-full shrink-0 flex items-center justify-center gap-x-2">
|
<view class="w-full shrink-0 flex items-center justify-center gap-x-2">
|
||||||
<uh-button custom-class="py-2 flex-1 uh-global-card-glass border rounded-xl bg-white/90"
|
<uh-button class="flex-1" custom-class="py-2 flex-1 uh-global-card-glass text-xs border rounded-xl bg-white/90"
|
||||||
@click="handleClose">
|
@click="handleClose">
|
||||||
关闭
|
关闭
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<uh-button custom-class="flex-1 py-2 uh-global-card-glass rounded-xl !bg-love/90 text-white border"
|
<uh-button class="flex-1" custom-class="flex-1 py-2 uh-global-card-glass text-xs rounded-xl !bg-love/90 text-white border"
|
||||||
@click="handleLoadPhotos">
|
@click="handleLoadPhotos">
|
||||||
刷新
|
刷新
|
||||||
</uh-button>
|
</uh-button>
|
||||||
|
|||||||
@@ -68,13 +68,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// immediate:组件 v-if 条件创建时 show 可能已为 true,需立即同步(如相册解锁弹窗)
|
||||||
watch(() => props.show, (val) => {
|
watch(() => props.show, (val) => {
|
||||||
isShow.value = val
|
isShow.value = val
|
||||||
if (val) {
|
if (val) {
|
||||||
password.value = ''
|
password.value = ''
|
||||||
resetCaptcha()
|
resetCaptcha()
|
||||||
|
// 插件端开启验证码时打开即拉取显示,避免首次提交 403 后才出现
|
||||||
|
handleRefreshCaptcha()
|
||||||
}
|
}
|
||||||
})
|
}, { immediate: true })
|
||||||
|
|
||||||
/** 弹窗开关同步(遮罩/关闭按钮/取消):关闭时复位输入并通知父组件 */
|
/** 弹窗开关同步(遮罩/关闭按钮/取消):关闭时复位输入并通知父组件 */
|
||||||
function handleOnPopupClose(val : boolean) {
|
function handleOnPopupClose(val : boolean) {
|
||||||
|
|||||||
@@ -38,11 +38,10 @@
|
|||||||
|
|
||||||
const isGrid = computed(() => props.variant === 'grid')
|
const isGrid = computed(() => props.variant === 'grid')
|
||||||
|
|
||||||
/** 单一事实源:每种布局的完整形态,模板不再有任何 order / 条件分支 */
|
|
||||||
const CARD_LAYOUTS = computed(()=> ({
|
const CARD_LAYOUTS = computed(()=> ({
|
||||||
image_top: {
|
image_top: {
|
||||||
container: `flex flex-col gap-y-2 ${isGrid.value ? '!p-0' : ''}`,
|
container: `flex flex-col gap-y-2 ${isGrid.value ? '!p-0' : ''}`,
|
||||||
cover: `${isGrid.value ? 'rounded-lb-0 rounded-rb-0' : ''}`,
|
cover: `mb-1 ${isGrid.value ? 'rounded-lb-0 rounded-rb-0' : ''}`,
|
||||||
contentWrapper: `box-border w-full ${isGrid.value ? 'p-2 pt-0' : ''}`,
|
contentWrapper: `box-border w-full ${isGrid.value ? 'p-2 pt-0' : ''}`,
|
||||||
footer: 'flex items-center',
|
footer: 'flex items-center',
|
||||||
authorGroup: 'flex-1 items-center justify-start gap-x-1',
|
authorGroup: 'flex-1 items-center justify-start gap-x-1',
|
||||||
@@ -69,7 +68,7 @@
|
|||||||
pinned: 'right-3 top-3',
|
pinned: 'right-3 top-3',
|
||||||
},
|
},
|
||||||
image_left: {
|
image_left: {
|
||||||
container: 'flex gap-x-3 !p-2',
|
container: 'flex gap-x-3 !p-3',
|
||||||
cover: 'shrink-0 !w-36 !h-24',
|
cover: 'shrink-0 !w-36 !h-24',
|
||||||
contentWrapper: 'w-0 flex-1 justify-between',
|
contentWrapper: 'w-0 flex-1 justify-between',
|
||||||
footer: 'flex items-center justify-between',
|
footer: 'flex items-center justify-between',
|
||||||
@@ -80,10 +79,10 @@
|
|||||||
time: '!hidden',
|
time: '!hidden',
|
||||||
tagCategory: '!hidden',
|
tagCategory: '!hidden',
|
||||||
visits: '',
|
visits: '',
|
||||||
pinned: 'left-3 top-3',
|
pinned: 'left-4 top-4',
|
||||||
},
|
},
|
||||||
image_right: {
|
image_right: {
|
||||||
container: 'flex gap-x-3 !p-2',
|
container: 'flex gap-x-3 !p-3',
|
||||||
cover: 'order-2 shrink-0 !w-36 !h-24',
|
cover: 'order-2 shrink-0 !w-36 !h-24',
|
||||||
contentWrapper: 'order-1 w-0 flex-1 justify-between',
|
contentWrapper: 'order-1 w-0 flex-1 justify-between',
|
||||||
footer: 'flex items-center justify-between',
|
footer: 'flex items-center justify-between',
|
||||||
@@ -94,7 +93,7 @@
|
|||||||
time: '!hidden',
|
time: '!hidden',
|
||||||
tagCategory: '!hidden',
|
tagCategory: '!hidden',
|
||||||
visits: '',
|
visits: '',
|
||||||
pinned: 'right-3 top-3',
|
pinned: 'right-4 top-4',
|
||||||
},
|
},
|
||||||
}) as Record<CardLayout, CardLayoutClasses>)
|
}) as Record<CardLayout, CardLayoutClasses>)
|
||||||
|
|
||||||
@@ -159,17 +158,16 @@
|
|||||||
</text>
|
</text>
|
||||||
<view class="relative overflow-hidden" :class="[isGrid ? 'w-full h-24 rounded-lg' : 'w-full h-36 rounded-lg', cardLayout.cover]">
|
<view class="relative overflow-hidden" :class="[isGrid ? 'w-full h-24 rounded-lg' : 'w-full h-36 rounded-lg', cardLayout.cover]">
|
||||||
<image class="w-full h-full block" :src="checkThumbnailUrl(article.spec.cover)" mode="aspectFill" lazy-load />
|
<image class="w-full h-full block" :src="checkThumbnailUrl(article.spec.cover)" mode="aspectFill" lazy-load />
|
||||||
<!-- <view v-if="isGrid" class="absolute left-0 bottom-0 w-full h-4 bg-gradient-to-b from-white/0 to-white" /> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="flex flex-col gap-y-2 text-sm" :class="cardLayout.contentWrapper">
|
<view class="flex flex-col gap-y-3 text-sm" :class="cardLayout.contentWrapper">
|
||||||
<view class="truncate font-bold">
|
<view class="truncate font-bold text-3xs">
|
||||||
{{ article.spec.title }}
|
{{ article.spec.title }}
|
||||||
</view>
|
</view>
|
||||||
<view :class="isGrid ? 'content line-clamp-1 text-gray-600' : 'content line-clamp-2 text-gray-600'">
|
<view class="text-xs" :class="isGrid ? 'line-clamp-1 text-gray-600' : 'line-clamp-2 text-gray-600'">
|
||||||
{{ article.status?.excerpt }}
|
{{ article.status?.excerpt }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="!isGrid" class="my-1 box-border flex flex-wrap gap-2" :class="cardLayout.tagCategory">
|
<view v-if="!isGrid" class="box-border flex flex-wrap gap-2" :class="cardLayout.tagCategory">
|
||||||
<template v-if="article.categories && article.categories.length !== 0">
|
<template v-if="article.categories && article.categories.length !== 0">
|
||||||
<text v-for="cate in article.categories" :key="cate.metadata.name"
|
<text v-for="cate in article.categories" :key="cate.metadata.name"
|
||||||
class="box-border uh-global-card-glass border uh-shadow-xs rounded-xl bg-secondary px-2 py-0.5 text-xs">
|
class="box-border uh-global-card-glass border uh-shadow-xs rounded-xl bg-secondary px-2 py-0.5 text-xs">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 文章迷你卡片(源自旧项目 components/article-min-card,新建复刻)
|
* 文章迷你卡片
|
||||||
* 用于分类页 list-post 视图的文章列表
|
* 用于分类页 list-post 视图的文章列表
|
||||||
*/
|
*/
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|||||||
@@ -334,7 +334,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 提交按钮(与旧项目一致:选择后才出现状态机) -->
|
<!-- 提交按钮(选择后才出现状态机) -->
|
||||||
<view v-if="submitForm.voteData.length !== 0" class="mt-3">
|
<view v-if="submitForm.voteData.length !== 0" class="mt-3">
|
||||||
<wd-button v-if="isVoted" disabled block>
|
<wd-button v-if="isVoted" disabled block>
|
||||||
您已参与投票
|
您已参与投票
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view v-if="votePluginAvailable && voteIds.length > 0" class="box-border px-3">
|
<view v-if="votePluginAvailable && voteIds.length > 0" class="box-border px-4 mb-4">
|
||||||
<view class="box-border uh-global-card-glass mb-3 rounded-xl p-3">
|
<view class="box-border uh-global-card-glass rounded-xl p-3">
|
||||||
<uh-section-title>
|
<uh-section-title>
|
||||||
相关投票
|
相关投票
|
||||||
<template #right>
|
<template #right>
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
customClass ?: string | Array<string>;
|
customClass ?: string | Array<string>;
|
||||||
}
|
}
|
||||||
@@ -8,11 +14,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<IProps>();
|
const props = defineProps<IProps>();
|
||||||
const emit = defineEmits<IEmits>();
|
const emits = defineEmits<IEmits>();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border bg-primary uh-shadow-xs text-black flex items-center justify-center text-sm px-4 py-1.5 rounded-lg" :class="props.customClass" @click="emit('click')">
|
<view
|
||||||
<slot></slot>
|
class="box-border bg-primary uh-shadow-xs text-black flex items-center justify-center text-sm px-4 py-1.5 rounded-lg"
|
||||||
|
:class="props.customClass" @click="emits('click')">
|
||||||
|
<slot />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
import { checkAvatarUrl } from '@/utils/url'
|
import { checkAvatarUrl } from '@/utils/url'
|
||||||
import { useSettingStore } from '@/store/setting'
|
import { useSettingStore } from '@/store/setting'
|
||||||
import type { IComment } from '@/api/types/halo'
|
import type { ICommentReply } from '@/api/types/halo'
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
comment : IComment
|
comment : ICommentReply
|
||||||
isChild ?: boolean
|
isChild ?: boolean
|
||||||
useActions ?: boolean
|
useActions ?: boolean
|
||||||
useSolid ?: boolean
|
useSolid ?: boolean
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
disallowComment ?: boolean
|
disallowComment ?: boolean
|
||||||
postName ?: string
|
postName ?: string
|
||||||
classItem ?: string[]
|
classItem ?: string[]
|
||||||
|
/** 回复引用名映射(quoteReply name -> 被引用人 displayName),命中时显示「回复 @xxx」 */
|
||||||
|
quoteReplyMap ?: Record<string, string>
|
||||||
}>(), {
|
}>(), {
|
||||||
isChild: false,
|
isChild: false,
|
||||||
useActions: true,
|
useActions: true,
|
||||||
@@ -23,11 +25,12 @@
|
|||||||
disallowComment: false,
|
disallowComment: false,
|
||||||
postName: '',
|
postName: '',
|
||||||
classItem: () => [],
|
classItem: () => [],
|
||||||
|
quoteReplyMap: () => ({}),
|
||||||
})
|
})
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e : 'on-comment', data : { type : string, comment : IComment }) : void
|
(e : 'on-comment', data : { type : string, comment : ICommentReply }) : void
|
||||||
(e : 'on-copy', raw : string) : void
|
(e : 'on-copy', raw : string) : void
|
||||||
(e : 'on-detail', comment : IComment) : void
|
(e : 'on-detail', comment : ICommentReply) : void
|
||||||
}>()
|
}>()
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
dayjs.locale('zh-cn')
|
dayjs.locale('zh-cn')
|
||||||
@@ -37,6 +40,35 @@
|
|||||||
|
|
||||||
const avatar = computed(() => checkAvatarUrl(props.comment.spec.owner.avatar))
|
const avatar = computed(() => checkAvatarUrl(props.comment.spec.owner.avatar))
|
||||||
|
|
||||||
|
/** 用户是否提供了头像(无头像时用昵称首字占位) */
|
||||||
|
const hasAvatar = computed(() => !!props.comment.spec.owner.avatar?.trim())
|
||||||
|
|
||||||
|
/** 昵称首字(头像占位) */
|
||||||
|
const avatarText = computed(() => {
|
||||||
|
const name = props.comment.spec.owner.displayName?.trim()
|
||||||
|
return name ? Array.from(name)[0] : '?'
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 头像加载失败标记(失败后回退首字占位) */
|
||||||
|
const avatarError = ref(false)
|
||||||
|
|
||||||
|
/** 是否渲染图片头像(有头像且未加载失败) */
|
||||||
|
const showImage = computed(() => hasAvatar.value && !avatarError.value)
|
||||||
|
|
||||||
|
/** 头像地址变化时重置加载失败标记(组件复用时) */
|
||||||
|
watch(() => props.comment.spec.owner.avatar, () => {
|
||||||
|
avatarError.value = false
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 引用回复标识(被引用人在父级已加载回复映射中可查到时显示) */
|
||||||
|
const quoteReplyText = computed(() => {
|
||||||
|
const quoteName = props.comment.spec.quoteReply
|
||||||
|
if (!quoteName)
|
||||||
|
return ''
|
||||||
|
const displayName = props.quoteReplyMap[quoteName]
|
||||||
|
return displayName ? `回复 @${displayName}` : ''
|
||||||
|
})
|
||||||
|
|
||||||
/** 评论时间 */
|
/** 评论时间 */
|
||||||
const createTimeText = computed(() => {
|
const createTimeText = computed(() => {
|
||||||
const time = props.comment.spec.creationTime
|
const time = props.comment.spec.creationTime
|
||||||
@@ -49,7 +81,8 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
function handleOnImageError() {
|
function handleOnImageError() {
|
||||||
// 头像加载失败时回退默认头像(由 checkAvatarUrl 兜底,此处保持简单)
|
// 头像加载失败时回退昵称首字占位
|
||||||
|
avatarError.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnCopy() {
|
function handleOnCopy() {
|
||||||
@@ -70,18 +103,23 @@
|
|||||||
'pl-10':props.isChild,
|
'pl-10':props.isChild,
|
||||||
}">
|
}">
|
||||||
<view class="flex shrink-0">
|
<view class="flex shrink-0">
|
||||||
<image class="box-border h-10 w-10 shrink-0 rounded-full border border-white uh-shadow-xs border-solid" :src="avatar" mode="aspectFill"
|
<image v-if="showImage"
|
||||||
@error="handleOnImageError" />
|
class="box-border h-10 w-10 shrink-0 rounded-full border border-white uh-shadow-xs border-solid" :src="avatar"
|
||||||
|
mode="aspectFill" @error="handleOnImageError" />
|
||||||
|
<view v-else class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[#bbe52a6b]">
|
||||||
|
<text class="text-sm font-bold text-gray-900">{{ avatarText }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-1 box-border pl-2">
|
<view class="flex-1 box-border pl-2">
|
||||||
<view class="text-sm text-gray-500">
|
<view class="text-sm text-gray-500">
|
||||||
<text class="text-grey text-xs">{{ comment.spec.owner.displayName }}</text>
|
<text class="text-grey text-xs">{{ comment.spec.owner.displayName }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-0.5 box-border text-sm text-gray-900 leading-5" @click="handleOnDetail"
|
<view v-if="quoteReplyText" class="mt-1 text-xs text-gray-400">{{ quoteReplyText }}</view>
|
||||||
|
<view class="mt-0.5 box-border text-sm text-gray-900 leading-5" @click="handleOnDetail"
|
||||||
v-html="comment.spec.raw" />
|
v-html="comment.spec.raw" />
|
||||||
<view class="mt-2 flex items-center gap-x-4">
|
<view class="mt-2 flex items-center gap-x-4">
|
||||||
<text class="text-gray-900 text-xs">{{ createTimeText }}</text>
|
<text class="text-gray-900 text-xs">{{ createTimeText }}</text>
|
||||||
<view v-if="useActions" class="actions flex gap-2 font-bold">
|
<view v-if="useActions" class="actions flex gap-2 font-medium">
|
||||||
<view v-if="!disallowComment" class="text-xs" @click="handleOnReply">
|
<view v-if="!disallowComment" class="text-xs" @click="handleOnReply">
|
||||||
回复
|
回复
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, onUnmounted, ref } from 'vue'
|
import { onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||||
import { getPostCommentList } from '@/api/halo'
|
import { getPostCommentList, getPostCommentReplyList } from '@/api/halo'
|
||||||
import { checkAvatarUrl } from '@/utils/url'
|
import type { IComment, ICommentListRes, ICommentReply } from '@/api/types/halo'
|
||||||
import type { IComment, ICommentListRes } from '@/api/types/halo'
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
disallowComment ?: boolean
|
disallowComment ?: boolean
|
||||||
@@ -16,7 +15,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e : 'on-comment', data : { isComment : boolean, postName : string, title : string }) : void
|
(e : 'on-comment', data : { isComment : boolean, postName : string, title : string, quoteReply ?: string }) : void
|
||||||
(e : 'on-comment-detail', data : { postName : string, comment : IComment }) : void
|
(e : 'on-comment-detail', data : { postName : string, comment : IComment }) : void
|
||||||
(e : 'on-loaded', list : IComment[]) : void
|
(e : 'on-loaded', list : IComment[]) : void
|
||||||
}>()
|
}>()
|
||||||
@@ -29,22 +28,35 @@
|
|||||||
name: props.postName,
|
name: props.postName,
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 50,
|
size: 50,
|
||||||
withReplies: true,
|
|
||||||
replySize: 10,
|
|
||||||
})
|
})
|
||||||
const result = ref<ICommentListRes | null>(null)
|
const result = ref<ICommentListRes | null>(null)
|
||||||
const dataList = ref<IComment[]>([])
|
const dataList = ref<IComment[]>([])
|
||||||
|
|
||||||
|
/** 回复按需加载每页条数(对齐官方 comment-widget replySize 默认 20) */
|
||||||
|
const REPLIES_PAGE_SIZE = 20
|
||||||
|
|
||||||
|
interface IRepliesState {
|
||||||
|
list : ICommentReply[]
|
||||||
|
total : number
|
||||||
|
page : number
|
||||||
|
hasNext : boolean
|
||||||
|
status : 'loading' | 'success' | 'error'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 已展开的评论 name 集合 */
|
||||||
|
const expanded = reactive(new Set<string>())
|
||||||
|
/** 各评论已加载回复(展开后缓存,收起再展开不重拉) */
|
||||||
|
const repliesMap = reactive(new Map<string, IRepliesState>())
|
||||||
|
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
loading.value = 'loading'
|
loading.value = 'loading'
|
||||||
try {
|
try {
|
||||||
const res = await getPostCommentList({ ...queryParams.value })
|
const res = await getPostCommentList({ ...queryParams.value })
|
||||||
result.value = res.data
|
result.value = res.data
|
||||||
dataList.value = res.data.items.map((item) => {
|
dataList.value = res.data.items
|
||||||
// todo:临时
|
// 列表刷新后清空展开缓存,保证回复区展示最新数据
|
||||||
item.spec.owner.avatar = checkAvatarUrl(item.spec.owner.avatar ?? 'https://api.dicebear.com/10.x/adventurer-neutral/svg')
|
expanded.clear()
|
||||||
return item
|
repliesMap.clear()
|
||||||
})
|
|
||||||
loading.value = 'success'
|
loading.value = 'success'
|
||||||
emit('on-loaded', dataList.value)
|
emit('on-loaded', dataList.value)
|
||||||
}
|
}
|
||||||
@@ -54,17 +66,97 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleToComment(data ?: { type : string, comment : IComment }) {
|
/** 回复数(优先可见数,兜底总回复数/内嵌 total) */
|
||||||
|
function getReplyCount(comment : IComment) : number {
|
||||||
|
return comment.status?.visibleReplyCount ?? comment.status?.replyCount ?? comment.replies?.total ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRepliesState(comment : IComment) : IRepliesState | undefined {
|
||||||
|
return repliesMap.get(comment.metadata.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 展开/收起某条评论的回复(首次展开时按需拉取) */
|
||||||
|
function toggleReplies(comment : IComment) {
|
||||||
|
const name = comment.metadata.name
|
||||||
|
if (expanded.has(name)) {
|
||||||
|
expanded.delete(name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
expanded.add(name)
|
||||||
|
if (!repliesMap.has(name)) {
|
||||||
|
loadReplies(comment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 首次展开:拉取第一页回复 */
|
||||||
|
async function loadReplies(comment : IComment) {
|
||||||
|
const name = comment.metadata.name
|
||||||
|
if (!repliesMap.has(name)) {
|
||||||
|
repliesMap.set(name, { list: [], total: 0, page: 0, hasNext: false, status: 'loading' })
|
||||||
|
}
|
||||||
|
const state = repliesMap.get(name)!
|
||||||
|
state.status = 'loading'
|
||||||
|
try {
|
||||||
|
const res = await getPostCommentReplyList(name, { page: 1, size: REPLIES_PAGE_SIZE })
|
||||||
|
const data = res.data
|
||||||
|
state.list = data.items
|
||||||
|
state.total = data.total
|
||||||
|
state.page = data.page
|
||||||
|
state.hasNext = data.hasNext
|
||||||
|
state.status = 'success'
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error('获取回复失败', err)
|
||||||
|
state.status = 'error'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载更多回复(追加下一页) */
|
||||||
|
async function loadMoreReplies(comment : IComment) {
|
||||||
|
const state = repliesMap.get(comment.metadata.name)
|
||||||
|
if (!state || state.status === 'loading')
|
||||||
|
return
|
||||||
|
state.status = 'loading'
|
||||||
|
try {
|
||||||
|
const res = await getPostCommentReplyList(comment.metadata.name, { page: state.page + 1, size: REPLIES_PAGE_SIZE })
|
||||||
|
const data = res.data
|
||||||
|
state.list = state.list.concat(data.items)
|
||||||
|
state.page = data.page
|
||||||
|
state.hasNext = data.hasNext
|
||||||
|
state.status = 'success'
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error('加载更多回复失败', err)
|
||||||
|
state.status = 'error'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 已加载回复的 name -> displayName 映射(供「回复 @xxx」引用标识查询) */
|
||||||
|
function buildQuoteReplyMap(comment : IComment) : Record<string, string> {
|
||||||
|
const state = repliesMap.get(comment.metadata.name)
|
||||||
|
if (!state)
|
||||||
|
return {}
|
||||||
|
const map : Record<string, string> = {}
|
||||||
|
state.list.forEach((reply) => {
|
||||||
|
map[reply.metadata.name] = reply.spec.owner.displayName
|
||||||
|
})
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 回复/新增评论(data 有值=回复某条评论;parentComment=所属一级评论,回复接口需要其 name) */
|
||||||
|
function handleToComment(data ?: { type : string, comment : ICommentReply }, parentComment ?: IComment) {
|
||||||
if (props.disallowComment) {
|
if (props.disallowComment) {
|
||||||
uni.showToast({ icon: 'none', title: '文章已禁止评论!' })
|
uni.showToast({ icon: 'none', title: '文章已禁止评论!' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (data) {
|
if (data && parentComment) {
|
||||||
// 回复某条评论
|
// 回复:postName 必须是一级评论(Comment)的 name;回复二级评论时带 quoteReply 引用其 name
|
||||||
|
const isQuote = data.comment.metadata.name !== parentComment.metadata.name
|
||||||
emit('on-comment', {
|
emit('on-comment', {
|
||||||
isComment: false,
|
isComment: false,
|
||||||
postName: data.comment.metadata.name,
|
postName: parentComment.metadata.name,
|
||||||
title: data.comment.spec.owner.displayName,
|
title: data.comment.spec.owner.displayName,
|
||||||
|
quoteReply: isQuote ? data.comment.metadata.name : undefined,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -120,10 +212,7 @@
|
|||||||
<uh-section-title>
|
<uh-section-title>
|
||||||
评论列表
|
评论列表
|
||||||
<template #right>
|
<template #right>
|
||||||
<view class="flex items-center gap-1.5 text-xs text-gray-500 font-normal" @click="handleGetData">
|
<text class="text-xs text-gray-500 font-normal" @click="handleGetData">刷新</text>
|
||||||
<wd-icon name="refresh" size="28rpx" />
|
|
||||||
<text class="">刷新</text>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
</uh-section-title>
|
</uh-section-title>
|
||||||
|
|
||||||
@@ -146,19 +235,14 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<view v-if="disallowComment && dataList.length !== 0"
|
<view v-if="dataList.length === 0" class="py-12">
|
||||||
class="rounded-xl bg-gray-50 px-3 py-2 text-xs text-red-400">
|
<view class="flex flex-col items-center">
|
||||||
Ծ‸Ծ 博主已设置该文章禁止评论!
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-if="dataList.length === 0" class="empty py-12">
|
|
||||||
<view class="empty-box flex flex-col items-center">
|
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-confused" size="100rpx" class="text-primary" />
|
<wd-icon class-prefix="uhemoji-icon" name="-confused" size="100rpx" class="text-primary" />
|
||||||
<text class="mt-2 text-sm text-gray-500">暂无评论</text>
|
<text class="mt-2 text-xs text-gray-500">暂无评论</text>
|
||||||
<view v-if="disallowComment" class="mt-2 text-xs text-red-400">
|
<view v-if="disallowComment" class="mt-2 text-xs text-red-400">
|
||||||
文章已开启禁止评论
|
文章已开启禁止评论
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="mt-2 bg-primary text-black text-sm px-4 py-1.5 rounded-lg"
|
<view v-else class="mt-2 bg-primary text-black text-xs px-4 py-1.5 rounded-lg"
|
||||||
@click="handleToComment()">
|
@click="handleToComment()">
|
||||||
抢沙发
|
抢沙发
|
||||||
</view>
|
</view>
|
||||||
@@ -166,20 +250,56 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<!-- 一级评论 -->
|
<!-- 一级评论 + 按需展开的回复区 -->
|
||||||
<template v-for="comment in dataList" :key="comment.metadata.name">
|
<template v-for="comment in dataList" :key="comment.metadata.name">
|
||||||
<uh-comment-item :use-content-bg="false" :is-child="false" :comment="comment"
|
<uh-comment-item :use-content-bg="false" :is-child="false" :comment="comment"
|
||||||
:post-name="postName" :disallow-comment="disallowComment" @on-copy="handleCopyContent"
|
:post-name="postName" :disallow-comment="disallowComment" @on-copy="handleCopyContent"
|
||||||
@on-comment="handleToComment" @on-detail="handleShowCommentDetail" />
|
@on-comment="(d) => handleToComment(d, comment)" @on-detail="handleShowCommentDetail" />
|
||||||
|
|
||||||
<!-- 二级评论 -->
|
<!-- 回复展开区(默认收起,抖音式) -->
|
||||||
<template v-if="comment.replies && comment.replies.items.length !== 0">
|
<view v-if="getReplyCount(comment) > 0">
|
||||||
<uh-comment-item v-for="childComment in comment.replies.items"
|
<!-- 未展开:仅显示回复数 -->
|
||||||
:key="childComment.metadata.name" :use-content-bg="false" :is-child="true"
|
<view v-if="!expanded.has(comment.metadata.name)"
|
||||||
:comment="childComment" :post-name="postName" :disallow-comment="disallowComment"
|
class="mt-2 ml-10 inline-flex items-center rounded-lg bg-gray-100 px-3 py-1 text-xs text-gray-500"
|
||||||
@on-copy="handleCopyContent" @on-comment="handleToComment"
|
@click="toggleReplies(comment)">
|
||||||
@on-detail="handleShowCommentDetail" />
|
共 {{ getReplyCount(comment) }} 条回复
|
||||||
</template>
|
</view>
|
||||||
|
|
||||||
|
<!-- 已展开:回复列表 -->
|
||||||
|
<block v-else>
|
||||||
|
<view v-if="getRepliesState(comment)?.status === 'error'"
|
||||||
|
class="mt-2 ml-10 text-xs text-red-400" @click="loadReplies(comment)">
|
||||||
|
回复加载失败,点击重试
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-else-if="getRepliesState(comment)?.status === 'loading' && getRepliesState(comment)?.list.length === 0"
|
||||||
|
class="mt-2 ml-10 text-xs text-gray-400">
|
||||||
|
回复加载中...
|
||||||
|
</view>
|
||||||
|
<template v-else>
|
||||||
|
<uh-comment-item v-for="childComment in getRepliesState(comment)?.list"
|
||||||
|
:key="childComment.metadata.name" :use-content-bg="false" :is-child="true"
|
||||||
|
:comment="childComment" :post-name="postName"
|
||||||
|
:disallow-comment="disallowComment"
|
||||||
|
:quote-reply-map="buildQuoteReplyMap(comment)" @on-copy="handleCopyContent"
|
||||||
|
@on-comment="(d) => handleToComment(d, comment)"
|
||||||
|
@on-detail="handleShowCommentDetail" />
|
||||||
|
|
||||||
|
<!-- 加载更多(响应 hasNext) -->
|
||||||
|
<view v-if="getRepliesState(comment)?.hasNext"
|
||||||
|
class="mt-2 flex items-center justify-center">
|
||||||
|
<text class="text-xs text-gray-400" @click="loadMoreReplies(comment)">
|
||||||
|
{{ getRepliesState(comment)?.status === 'loading' ? '加载中...' : '加载更多回复' }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 收起 -->
|
||||||
|
<view class="mt-2 ml-10 text-xs text-gray-400" @click="toggleReplies(comment)">
|
||||||
|
收起回复
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</block>
|
</block>
|
||||||
</block>
|
</block>
|
||||||
|
|||||||
@@ -12,10 +12,13 @@
|
|||||||
postName : string
|
postName : string
|
||||||
/** 评论目标 kind(文章 Post / 瞬间 Moment) */
|
/** 评论目标 kind(文章 Post / 瞬间 Moment) */
|
||||||
subjectKind ?: string
|
subjectKind ?: string
|
||||||
|
/** 回复的回复:被引用回复(CommentReply)的 name,提交时转 quoteReply */
|
||||||
|
quoteReply ?: string
|
||||||
}>(), {
|
}>(), {
|
||||||
isComment: false,
|
isComment: false,
|
||||||
title: '',
|
title: '',
|
||||||
subjectKind: 'Post',
|
subjectKind: 'Post',
|
||||||
|
quoteReply: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -173,8 +176,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleHandle() {
|
async function handleHandle() {
|
||||||
if (!validateForm())
|
if (!validateForm()) { return }
|
||||||
return
|
|
||||||
|
|
||||||
uni.showLoading({ title: '正在提交...' })
|
uni.showLoading({ title: '正在提交...' })
|
||||||
|
|
||||||
@@ -211,6 +213,7 @@
|
|||||||
email: form.value.email,
|
email: form.value.email,
|
||||||
website: form.value.authorUrl,
|
website: form.value.authorUrl,
|
||||||
},
|
},
|
||||||
|
quoteReply: props.quoteReply || undefined,
|
||||||
captchaCode: config.value?.security?.captcha?.anonymousCommentCaptcha ? form.value.captchaCode : undefined,
|
captchaCode: config.value?.security?.captcha?.anonymousCommentCaptcha ? form.value.captchaCode : undefined,
|
||||||
})
|
})
|
||||||
uni.showToast({ icon: 'none', title: '回复成功,可能需要审核!' })
|
uni.showToast({ icon: 'none', title: '回复成功,可能需要审核!' })
|
||||||
@@ -265,54 +268,55 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<uh-glass-popup v-model="isShow" position="bottom" custom-class="!border rounded-2xl"
|
<uh-glass-popup v-model="isShow" position="bottom" custom-class="!border rounded-2xl" :z-index="100"
|
||||||
:z-index="100" @close="handleOnChange(false)">
|
@close="handleOnChange(false)">
|
||||||
<view class="box-border p-4">
|
<view class="box-border p-4">
|
||||||
<view
|
<view
|
||||||
class="relative w-full flex items-center justify-around box-border px-12 text-md font-bold text-center">
|
class="relative w-full flex items-center justify-around box-border px-12 text-md font-bold text-center">
|
||||||
{{ calcTitle }}
|
<text>{{ calcTitle }} </text>
|
||||||
<view class="absolute right-0 top-1 w-6 h-6 uh-global-card-glass shadow-none border rounded-lg"
|
<view
|
||||||
|
class="absolute right-0 top-0 w-6 h-6 uh-global-card-glass shadow-none border rounded-lg flex items-center justify-center"
|
||||||
@click="handleClose">
|
@click="handleClose">
|
||||||
<wd-icon name="close" size="32rpx" class="text-gray-500"></wd-icon>
|
<wd-icon name="close" size="28rpx" class="text-gray-500"></wd-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view :scroll-y="true" class="form mt-6">
|
<scroll-view :scroll-y="true" class="form mt-6">
|
||||||
<view class="form-item mb-4 flex items-center">
|
<view class="form-item mb-4 flex items-center">
|
||||||
<textarea v-model="form.content"
|
<textarea v-model="form.content"
|
||||||
class="h-22 uh-global-card-glass shadow-none border box-border w-full rounded-xl p-5 text-sm"
|
class="h-22 uh-global-card-glass shadow-none border box-border w-full rounded-xl px-3 py-2 text-xs"
|
||||||
:placeholder="config.editor?.placeholder || '请输入内容,不超过200字符...'" :maxlength="200" />
|
:placeholder="config.editor?.placeholder || '请输入内容,不超过200字符...'" :maxlength="200" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="form-item mb-4 flex items-center">
|
<view class="form-item mb-4 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">我的昵称</text>
|
<text class="label w-16 shrink-0 text-xs text-gray-500">我的昵称</text>
|
||||||
<input v-model="form.author"
|
<input v-model="form.author"
|
||||||
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-5 text-sm"
|
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-3 text-xs"
|
||||||
placeholder="请输入您的昵称...">
|
placeholder="请输入您的昵称...">
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="form-item mb-4 flex items-center">
|
<view class="form-item mb-4 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">我的邮箱</text>
|
<text class="label w-16 shrink-0 text-sm text-gray-500">我的邮箱</text>
|
||||||
<input v-model="form.email"
|
<input v-model="form.email"
|
||||||
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-5 text-sm"
|
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-3 text-xs"
|
||||||
placeholder="请输入您的邮箱...">
|
placeholder="请输入您的邮箱...">
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="form-item mb-4 flex items-center">
|
<view class="form-item mb-4 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">我的网站</text>
|
<text class="label w-16 shrink-0 text-sm text-gray-500">我的网站</text>
|
||||||
<input v-model="form.authorUrl"
|
<input v-model="form.authorUrl"
|
||||||
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-5 text-sm"
|
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-3 text-xs"
|
||||||
placeholder="请输入您的网址...">
|
placeholder="[ 可选 ] 请输入您的网址...">
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 匿名评论验证码 -->
|
<!-- 匿名评论验证码 -->
|
||||||
<view v-if="config?.security?.captcha?.anonymousCommentCaptcha"
|
<view v-if="config?.security?.captcha?.anonymousCommentCaptcha"
|
||||||
class="form-item mb-4 flex items-center">
|
class="form-item mb-4 flex items-center">
|
||||||
<text class="w-[140rpx] shrink-0 text-sm text-[#666]">验证码</text>
|
<text class="w-16 shrink-0 text-sm text-gray-500">验证码</text>
|
||||||
<view class="flex flex-1 items-center gap-4">
|
<view class="flex flex-1 items-center gap-3">
|
||||||
<input v-model="form.captchaCode"
|
<input v-model="form.captchaCode"
|
||||||
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-5 text-sm"
|
class="uh-global-card-glass shadow-none border h-9 flex-1 rounded-xl px-3 text-xs"
|
||||||
placeholder="请输入验证码结果">
|
placeholder="请输入验证码">
|
||||||
<view class="h-10 w-29 flex shrink-0 items-center justify-center">
|
<view class="h-10 w-29 flex shrink-0 items-center justify-center">
|
||||||
<uh-button v-if="captchaData.status === 'loading'"
|
<uh-button v-if="captchaData.status === 'loading'"
|
||||||
class="w-full uh-global-card-glass shadow-none border py-2.5 !rounded-xl text-xs text-gray-900">获取中...</uh-button>
|
class="w-full uh-global-card-glass shadow-none border py-2.5 !rounded-xl text-xs text-gray-900">获取中...</uh-button>
|
||||||
@@ -326,7 +330,8 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="submit-btn my-6">
|
<view class="submit-btn my-6">
|
||||||
<uh-button custom-class="py-2 !rounded-xl uh-global-card-glass border" @click="handleHandle">
|
<uh-button custom-class="py-2.5 !rounded-xl text-xs uh-global-card-glass border"
|
||||||
|
@click="handleHandle">
|
||||||
提交
|
提交
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { checkUrl } from '@/utils/url'
|
import { checkUrl } from '@/utils/url'
|
||||||
import type { DataLoadingStatus } from '@/hooks/useDataLoading'
|
import type { DataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
loadingStatus ?: DataLoadingStatus
|
loadingStatus ?: DataLoadingStatus
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
loadingStatus: 'loading',
|
loadingStatus: 'loading',
|
||||||
size: 'large',
|
size: 'large',
|
||||||
minHeight: '80vh',
|
minHeight: '80vh',
|
||||||
loadingText: '稍等,正在加载中哦',
|
loadingText: '稍等,正在加载中哦~',
|
||||||
errorText: '哎呀,加载失败了呢~',
|
errorText: '哎呀,加载失败了呢~',
|
||||||
emptyText: '啊偶,暂时没有数据呢~',
|
emptyText: '啊偶,暂时没有数据呢~',
|
||||||
loadingSubText: '',
|
loadingSubText: '',
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
<!-- 文案区 -->
|
<!-- 文案区 -->
|
||||||
<view class="relative z-2 flex flex-col items-center">
|
<view class="relative z-2 flex flex-col items-center">
|
||||||
<view class="flex items-center justify-center text-sm font-bold" :class="statusScene.mainTextClass">
|
<view class="flex items-center justify-center text-2xs font-medium" :class="statusScene.mainTextClass">
|
||||||
<text>{{ statusScene.mainText }}</text>
|
<text>{{ statusScene.mainText }}</text>
|
||||||
<view v-if="isLoading" class="ml-1 flex items-end gap-1">
|
<view v-if="isLoading" class="ml-1 flex items-end gap-1">
|
||||||
<view v-for="n in 3" :key="n" class="typing-dot bg-primary"
|
<view v-for="n in 3" :key="n" class="typing-dot bg-primary"
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
{{ statusScene.subText }}
|
{{ statusScene.subText }}
|
||||||
</text>
|
</text>
|
||||||
<view v-if="props.useRefreshButton" class="mt-4">
|
<view v-if="props.useRefreshButton" class="mt-4">
|
||||||
<uh-button :custom-class="'uh-global-card-glass uh-shadow-xs border' + sizeClasses.button"
|
<uh-button :custom-class="'uh-global-card-glass text-xs py-2 uh-shadow-xs border' + sizeClasses.button"
|
||||||
@click="emit('refresh')">
|
@click="emit('refresh')">
|
||||||
刷新试试
|
刷新试试
|
||||||
</uh-button>
|
</uh-button>
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { LoadMoreStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
interface IProps {
|
||||||
|
text : string
|
||||||
|
status : LoadMoreStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<IProps>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="w-full py-4 flex items-center justify-center gap-x-2 text-xs text-gray-400">
|
||||||
|
<wd-loading v-if="props.status==='loading'" size="32rpx" color="#D7F94C"></wd-loading> {{ props.text }}
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
@@ -1,118 +1,118 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
/** 单列选项(wd-picker PickerOption 的宽松形态,label/value 与 wot 一致) */
|
defineOptions({
|
||||||
interface IPickerOption {
|
options: {
|
||||||
label?: string | number
|
styleIsolation: 'apply-shared'
|
||||||
value?: string | number
|
}
|
||||||
disabled?: boolean
|
})
|
||||||
children?: IPickerOption[]
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IProps {
|
interface IPickerOption {
|
||||||
/** v-model:visible 是否显示 */
|
label ?: string | number
|
||||||
visible: boolean
|
value ?: string | number
|
||||||
/** 弹层标题 */
|
disabled ?: boolean
|
||||||
title?: string
|
children ?: IPickerOption[]
|
||||||
/** 选择器数据(单列/多列;与 wd-picker columns 一致) */
|
[key : string] : unknown
|
||||||
columns?: Array<IPickerOption | IPickerOption[]>
|
}
|
||||||
/** 选中项(单列如 ['value']) */
|
|
||||||
modelValue?: (string | number)[]
|
|
||||||
/** 确认/取消按钮文案 */
|
|
||||||
confirmButtonText?: string
|
|
||||||
cancelButtonText?: string
|
|
||||||
/** 自定义层级 */
|
|
||||||
zIndex?: number
|
|
||||||
/** 点击遮罩是否关闭 */
|
|
||||||
closeOnClickModal?: boolean
|
|
||||||
/** 底部安全距离适配 */
|
|
||||||
safeAreaInsetBottom?: boolean
|
|
||||||
/** 追加到选择器根元素的自定义类 */
|
|
||||||
customClass?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IEmits {
|
interface IProps {
|
||||||
(e: 'update:visible', value: boolean): void
|
visible : boolean
|
||||||
(e: 'update:modelValue', value: (string | number)[]): void
|
/** 弹层标题 */
|
||||||
(e: 'confirm', payload: { value: (string | number)[] }): void
|
title ?: string
|
||||||
(e: 'open'): void
|
/** 选择器数据(单列/多列;与 wd-picker columns 一致) */
|
||||||
(e: 'cancel'): void
|
columns ?: Array<IPickerOption | IPickerOption[]>
|
||||||
}
|
/** 选中项(单列如 ['value']) */
|
||||||
|
modelValue ?: (string | number)[]
|
||||||
|
/** 确认/取消按钮文案 */
|
||||||
|
confirmButtonText ?: string
|
||||||
|
cancelButtonText ?: string
|
||||||
|
/** 自定义层级 */
|
||||||
|
zIndex ?: number
|
||||||
|
/** 点击遮罩是否关闭 */
|
||||||
|
closeOnClickModal ?: boolean
|
||||||
|
/** 底部安全距离适配 */
|
||||||
|
safeAreaInsetBottom ?: boolean
|
||||||
|
/** 追加到选择器根元素的自定义类 */
|
||||||
|
customClass ?: string
|
||||||
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<IProps>(), {
|
interface IEmits {
|
||||||
title: '',
|
(e : 'update:visible', value : boolean) : void
|
||||||
columns: () => [],
|
(e : 'update:modelValue', value : (string | number)[]) : void
|
||||||
modelValue: () => [],
|
(e : 'confirm', payload : { value : (string | number)[] }) : void
|
||||||
confirmButtonText: '确定',
|
(e : 'open') : void
|
||||||
cancelButtonText: '取消',
|
(e : 'cancel') : void
|
||||||
zIndex: 15,
|
}
|
||||||
closeOnClickModal: true,
|
|
||||||
safeAreaInsetBottom: true,
|
|
||||||
customClass: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits<IEmits>()
|
const props = withDefaults(defineProps<IProps>(), {
|
||||||
|
title: '',
|
||||||
|
columns: () => [],
|
||||||
|
modelValue: () => [],
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
zIndex: 15,
|
||||||
|
closeOnClickModal: true,
|
||||||
|
safeAreaInsetBottom: true,
|
||||||
|
customClass: '',
|
||||||
|
})
|
||||||
|
|
||||||
const pickerClass = computed(() => `uh-picker ${props.customClass}`.trim())
|
const emit = defineEmits<IEmits>()
|
||||||
|
|
||||||
/* ---------------- wd-picker 事件转发(在 script 处理,模板只做绑定) ---------------- */
|
const pickerClass = computed(() => `uh-picker ${props.customClass}`.trim())
|
||||||
function handleUpdateVisible(value: boolean) {
|
|
||||||
emit('update:visible', value)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleUpdateModelValue(value: (string | number)[]) {
|
/* ---------------- wd-picker 事件转发(在 script 处理,模板只做绑定) ---------------- */
|
||||||
emit('update:modelValue', value)
|
function handleUpdateVisible(value : boolean) {
|
||||||
}
|
emit('update:visible', value)
|
||||||
|
}
|
||||||
|
|
||||||
function handleConfirm(payload: { value: (string | number)[] }) {
|
function handleUpdateModelValue(value : (string | number)[]) {
|
||||||
emit('confirm', payload)
|
emit('update:modelValue', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOpen() {
|
function handleConfirm(payload : { value : (string | number)[] }) {
|
||||||
emit('open')
|
emit('confirm', payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCancel() {
|
function handleOpen() {
|
||||||
emit('cancel')
|
emit('open')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleCancel() {
|
||||||
|
emit('cancel')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<wd-picker
|
<wd-picker :visible="visible" :title="title" :columns="columns" :model-value="modelValue"
|
||||||
:visible="visible" :title="title" :columns="columns" :model-value="modelValue"
|
:confirm-button-text="confirmButtonText" :cancel-button-text="cancelButtonText" :z-index="zIndex"
|
||||||
:confirm-button-text="confirmButtonText" :cancel-button-text="cancelButtonText" :z-index="zIndex"
|
:close-on-click-modal="closeOnClickModal" :safe-area-inset-bottom="safeAreaInsetBottom"
|
||||||
:close-on-click-modal="closeOnClickModal" :safe-area-inset-bottom="safeAreaInsetBottom"
|
:custom-class="pickerClass" @update:visible="handleUpdateVisible" @update:model-value="handleUpdateModelValue"
|
||||||
:custom-class="pickerClass" @update:visible="handleUpdateVisible" @update:model-value="handleUpdateModelValue"
|
@confirm="handleConfirm" @open="handleOpen" @cancel="handleCancel">
|
||||||
@confirm="handleConfirm" @open="handleOpen" @cancel="handleCancel"
|
<slot />
|
||||||
>
|
</wd-picker>
|
||||||
<slot />
|
|
||||||
</wd-picker>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
/* 弹层面板玻璃质感(与 uh-glass-popup 同款;wd-picker 内层 popup 挂 .wd-picker__popup) */
|
:deep(.wd-picker__popup .wd-popup) {
|
||||||
:deep(.wd-picker__popup .wd-popup) {
|
box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
background-color: rgb(255 255 255 / 85%);
|
||||||
background-color: rgb(255 255 255 / 85%);
|
border: 4rpx solid rgb(255 255 255 / 90%);
|
||||||
border: 4rpx solid rgb(255 255 255 / 90%);
|
box-shadow:
|
||||||
box-shadow:
|
inset 0 1rpx 0 rgb(255 255 255 / 75%),
|
||||||
inset 0 1rpx 0 rgb(255 255 255 / 75%),
|
0 8rpx 32rpx rgb(90 105 200 / 14%);
|
||||||
0 8rpx 32rpx rgb(90 105 200 / 14%);
|
backdrop-filter: blur(24rpx) saturate(160%);
|
||||||
backdrop-filter: blur(24rpx) saturate(160%);
|
-webkit-backdrop-filter: blur(24rpx) saturate(160%);
|
||||||
-webkit-backdrop-filter: blur(24rpx) saturate(160%);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* 低端 WebView 不支持 backdrop-filter 的兜底:提高不透明度保证可读性 */
|
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
||||||
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
:deep(.wd-picker__popup .wd-popup) {
|
||||||
:deep(.wd-picker__popup .wd-popup) {
|
background-color: rgb(255 255 255 / 88%);
|
||||||
background-color: rgb(255 255 255 / 88%);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.wd-popup--bottom) {
|
:deep(.wd-popup--bottom) {
|
||||||
left: 24rpx;
|
left: 24rpx;
|
||||||
bottom: 24rpx;
|
bottom: 24rpx;
|
||||||
right: 24rpx;
|
right: 24rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,9 +1,30 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
defineOptions({
|
||||||
* 玻璃质感弹窗:对 wd-popup 的二层封装。
|
options: {
|
||||||
* wd-popup 无背景/边框配置能力(index.scss 仅暴露 --wot-popup-bg 纯色变量),
|
styleIsolation: 'apply-shared',
|
||||||
* 故通过 custom-class 落到面板根元素后,用 :deep 覆盖为 uh-global-card-glass 同款效果。
|
},
|
||||||
*/
|
})
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<IProps>(), {
|
||||||
|
position: 'center',
|
||||||
|
zIndex: 10,
|
||||||
|
closable: false,
|
||||||
|
modal: true,
|
||||||
|
closeOnClickModal: true,
|
||||||
|
safeAreaInsetBottom: false,
|
||||||
|
radius: '',
|
||||||
|
round: false,
|
||||||
|
lazyRender: true,
|
||||||
|
hideWhenClose: true,
|
||||||
|
customStyle: '',
|
||||||
|
customClass: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<IEmits>()
|
||||||
|
|
||||||
|
/** 动画时长(ms),与 wd-popup 默认一致 */
|
||||||
|
const DURATION = 300
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
/** v-model:是否显示 */
|
/** v-model:是否显示 */
|
||||||
modelValue : boolean
|
modelValue : boolean
|
||||||
@@ -19,15 +40,18 @@
|
|||||||
closeOnClickModal ?: boolean
|
closeOnClickModal ?: boolean
|
||||||
/** 底部安全距离适配(iphone X 类机型) */
|
/** 底部安全距离适配(iphone X 类机型) */
|
||||||
safeAreaInsetBottom ?: boolean
|
safeAreaInsetBottom ?: boolean
|
||||||
/** 面板圆角(内联生效,优先级最高);传 wot 自带 round 时圆角由位置自动适配 */
|
/** 面板圆角(内联生效,优先级最高);与 round 二选一 */
|
||||||
radius ?: string
|
radius ?: string
|
||||||
/** 是否开启 wot 位置自适应圆角(bottom→上圆角 / center→四圆角等),与 radius 二选一 */
|
/** 位置自适应圆角(bottom→上圆角 / center→四圆角等),与 radius 二选一 */
|
||||||
round ?: boolean
|
round ?: boolean
|
||||||
|
/** 弹层内容懒渲染,首次显示时才渲染 */
|
||||||
lazyRender ?: boolean
|
lazyRender ?: boolean
|
||||||
hideWhenClose?: boolean
|
/** 关闭动画结束后是否隐藏面板(display:none);false 时保留渲染(内部状态不丢) */
|
||||||
|
hideWhenClose ?: boolean
|
||||||
/** 追加到面板的内联样式,如宽度:width:640rpx; */
|
/** 追加到面板的内联样式,如宽度:width:640rpx; */
|
||||||
customStyle ?: string
|
customStyle ?: string
|
||||||
customClass? :string
|
/** 追加到面板的类名(如 UnoCSS 原子类) */
|
||||||
|
customClass ?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IEmits {
|
interface IEmits {
|
||||||
@@ -37,76 +61,362 @@
|
|||||||
(e : 'click-modal') : void
|
(e : 'click-modal') : void
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<IProps>(), {
|
/* ---------------- 动画状态机 ---------------- */
|
||||||
position: 'center',
|
/** 首次显示后才渲染(lazyRender) */
|
||||||
zIndex: 10,
|
const inited = ref(false)
|
||||||
closable: false,
|
/** 是否渲染显示(关闭动画结束后 hideWhenClose 时置 false) */
|
||||||
modal: true,
|
const display = ref(false)
|
||||||
closeOnClickModal: true,
|
/** 动画阶段: enter / enter-to / leave / leave-to / '' */
|
||||||
safeAreaInsetBottom: false,
|
const phase = ref('')
|
||||||
radius: '',
|
|
||||||
round: false,
|
/** 动画名称(按位置):center 组合 zoom-in + fade */
|
||||||
lazyRender: true,
|
const transitionName = computed(() => {
|
||||||
hideWhenClose: true,
|
switch (props.position) {
|
||||||
customStyle: '',
|
case 'center':
|
||||||
customClass:''
|
return ['zoom-in', 'fade']
|
||||||
|
case 'left':
|
||||||
|
return 'slide-left'
|
||||||
|
case 'right':
|
||||||
|
return 'slide-right'
|
||||||
|
case 'top':
|
||||||
|
return 'slide-down'
|
||||||
|
default:
|
||||||
|
return 'slide-up'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<IEmits>()
|
const isShow = computed(() => !props.lazyRender || inited.value)
|
||||||
|
|
||||||
|
const panelClasses = computed(() => {
|
||||||
|
const names = Array.isArray(transitionName.value) ? transitionName.value : [transitionName.value]
|
||||||
|
let cls = `uh-glass-popup-panel uh-glass-popup-panel--${props.position} ${props.customClass}`
|
||||||
|
if (props.round) { cls += ' is-round' }
|
||||||
|
if (phase.value) {
|
||||||
|
const act = phase.value.startsWith('enter') ? 'enter-active' : 'leave-active'
|
||||||
|
for (const name of names) {
|
||||||
|
cls += ` uh-glass-popup-anim--${name}-${phase.value} uh-glass-popup-anim--${name}-${act}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cls
|
||||||
|
})
|
||||||
|
|
||||||
|
const maskClasses = computed(() => {
|
||||||
|
if (!phase.value) { return 'uh-glass-popup__mask' }
|
||||||
|
const act = phase.value.startsWith('enter') ? 'enter-active' : 'leave-active'
|
||||||
|
return `uh-glass-popup__mask uh-glass-popup-anim--fade-${phase.value} uh-glass-popup-anim--fade-${act}`
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 底部安全距离 */
|
||||||
|
const safeBottom = ref(0)
|
||||||
|
|
||||||
const panelStyle = computed(() => {
|
const panelStyle = computed(() => {
|
||||||
return props.customStyle
|
let style = `z-index:${props.zIndex};`
|
||||||
|
// hideWhenClose 且关闭动画结束:display:none 释放层级
|
||||||
|
if (!display.value && props.hideWhenClose) { style += 'display:none;' }
|
||||||
|
// 静止隐藏态(未开过或关闭后动画结束):透明 + 不拦截点击
|
||||||
|
if (!props.modelValue && !phase.value) { style += 'opacity:0;' }
|
||||||
|
if (!props.modelValue) { style += 'pointer-events:none;' }
|
||||||
|
if (safeBottom.value) { style += `padding-bottom:${safeBottom.value}px;` }
|
||||||
|
if (props.radius) { style += `border-radius:${props.radius};` }
|
||||||
|
return style + props.customStyle
|
||||||
})
|
})
|
||||||
|
|
||||||
const panelClass = computed(() =>{
|
const maskStyle = computed(() => {
|
||||||
return `uh-glass-popup-panel ${props.customClass}`
|
let style = `z-index:${props.zIndex};`
|
||||||
|
// 遮罩跟随面板的显隐
|
||||||
|
if (!display.value && props.hideWhenClose) { style += 'display:none;' }
|
||||||
|
if (!props.modelValue && !phase.value) { style += 'opacity:0;' }
|
||||||
|
// 关闭后透明且不拦截点击(hideWhenClose=false 保留渲染时仍需可穿透)
|
||||||
|
if (!props.modelValue) { style += 'pointer-events:none;' }
|
||||||
|
return style
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function sleep(ms : number) {
|
||||||
|
return new Promise<void>(resolve => setTimeout(resolve, ms))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 状态机是否在运行(防重入) */
|
||||||
|
let running = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动画状态机:以 modelValue 为目标循环推进,
|
||||||
|
* 运行期间若目标变化(快速开关)则重新评估,直到状态稳定
|
||||||
|
*/
|
||||||
|
async function runTransition() {
|
||||||
|
if (running) { return }
|
||||||
|
running = true
|
||||||
|
try {
|
||||||
|
// 首次打开才渲染内容(lazyRender)
|
||||||
|
if (props.modelValue) {
|
||||||
|
inited.value = true
|
||||||
|
display.value = true
|
||||||
|
}
|
||||||
|
// 循环推进直到与 modelValue 一致
|
||||||
|
while (true) {
|
||||||
|
const target = props.modelValue
|
||||||
|
if (target) {
|
||||||
|
phase.value = 'enter'
|
||||||
|
await sleep(50)
|
||||||
|
if (props.modelValue !== target) { continue }
|
||||||
|
phase.value = 'enter-to'
|
||||||
|
emit('open')
|
||||||
|
await sleep(DURATION)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!display.value) {
|
||||||
|
// 从未渲染,无需动画
|
||||||
|
break
|
||||||
|
}
|
||||||
|
phase.value = 'leave'
|
||||||
|
await sleep(50)
|
||||||
|
if (props.modelValue !== target) { continue }
|
||||||
|
phase.value = 'leave-to'
|
||||||
|
await sleep(DURATION + 50)
|
||||||
|
if (props.modelValue !== target) { continue }
|
||||||
|
if (props.hideWhenClose) { display.value = false }
|
||||||
|
}
|
||||||
|
if (props.modelValue === target) {
|
||||||
|
// 状态稳定
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
running = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
() => {
|
||||||
|
runTransition()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
/* ---------------- 遮罩与安全区 ---------------- */
|
||||||
|
function handleClickModal() {
|
||||||
|
emit('click-modal')
|
||||||
|
if (props.closeOnClickModal)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('close')
|
||||||
|
emit('update:modelValue', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
if (props.safeAreaInsetBottom) {
|
||||||
|
const { safeArea, screenHeight, safeAreaInsets } = uni.getWindowInfo()
|
||||||
|
|
||||||
|
if (safeArea) {
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
safeBottom.value = screenHeight - (safeArea.bottom || 0)
|
||||||
|
// #endif
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
safeBottom.value = safeAreaInsets ? safeAreaInsets.bottom : 0
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
safeBottom.value = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// 初始即为打开状态:直接播放进入动画
|
||||||
|
if (props.modelValue) { runTransition() }
|
||||||
|
})
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
// 锁定 body 滚动,防止弹层打开时页面穿透滚动
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(val) => {
|
||||||
|
document.body.style.overflow = val ? 'hidden' : ''
|
||||||
|
},
|
||||||
|
)
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
// 卸载时若弹层仍打开,恢复 body 滚动,避免滚动锁残留
|
||||||
|
document.body.style.overflow = ''
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<wd-popup
|
<view v-if="isShow">
|
||||||
:model-value="modelValue"
|
<!-- 遮罩层 -->
|
||||||
:position="position"
|
<view v-if="modal" class="uh-glass-popup__mask" :class="maskClasses" :style="maskStyle"
|
||||||
:z-index="zIndex"
|
@click="handleClickModal" @touchmove.stop.prevent />
|
||||||
:closable="closable"
|
<!-- 面板层 -->
|
||||||
:modal="modal"
|
<view :class="panelClasses" :style="panelStyle">
|
||||||
:close-on-click-modal="closeOnClickModal"
|
<slot />
|
||||||
:hide-when-close="hideWhenClose"
|
<view v-if="closable" class="uh-glass-popup__close" @click="close">
|
||||||
:safe-area-inset-bottom="safeAreaInsetBottom"
|
<text class="uh-glass-popup__close-icon">×</text>
|
||||||
:round="round"
|
</view>
|
||||||
:custom-style="panelStyle"
|
</view>
|
||||||
:custom-class="panelClass"
|
</view>
|
||||||
:lazy-render="lazyRender"
|
|
||||||
@update:model-value="(value: boolean) => emit('update:modelValue', value)"
|
|
||||||
@close="emit('close')"
|
|
||||||
@enter="emit('open')"
|
|
||||||
@click-modal="emit('click-modal')"
|
|
||||||
>
|
|
||||||
<slot></slot>
|
|
||||||
</wd-popup>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
/* 面板根元素(.wd-popup)同挂 custom-class,双类选择器提高优先级,覆盖 wot 默认纯白底 */
|
.uh-glass-popup__mask {
|
||||||
:deep(.wd-popup.uh-glass-popup-panel) {
|
position: fixed;
|
||||||
box-sizing: border-box;
|
left: 0;
|
||||||
background-color: rgb(255 255 255 / 85%);
|
top: 0;
|
||||||
border: 4rpx solid rgb(255 255 255 / 90%);
|
right: 0;
|
||||||
box-shadow: inset 0 1rpx 0 rgb(255 255 255 / 75%), 0 8rpx 32rpx rgb(90 105 200 / 14%);
|
bottom: 0;
|
||||||
backdrop-filter: blur(24rpx) saturate(160%);
|
background-color: rgb(0 0 0 / 55%);
|
||||||
-webkit-backdrop-filter: blur(24rpx) saturate(160%);
|
transition-timing-function: ease;
|
||||||
|
transition-duration: 300ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 低端 WebView 不支持 backdrop-filter 的兜底:提高不透明度保证可读性 */
|
.uh-glass-popup-panel {
|
||||||
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
box-sizing: border-box;
|
||||||
:deep(.wd-popup.uh-glass-popup-panel) {
|
position: fixed;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
background-color: rgb(255 255 255 / 85%);
|
||||||
|
border: 4rpx solid rgb(255 255 255 / 90%);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1rpx 0 rgb(255 255 255 / 75%),
|
||||||
|
0 8rpx 32rpx rgb(90 105 200 / 14%);
|
||||||
|
backdrop-filter: blur(24rpx) saturate(160%);
|
||||||
|
-webkit-backdrop-filter: blur(24rpx) saturate(160%);
|
||||||
|
transition-timing-function: ease;
|
||||||
|
transition-duration: 300ms;
|
||||||
|
|
||||||
|
/* 低端 WebView 不支持 backdrop-filter 的兜底:提高不透明度保证可读性 */
|
||||||
|
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
||||||
background-color: rgb(255 255 255 / 88%);
|
background-color: rgb(255 255 255 / 88%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.wd-popup--bottom){
|
/* 位置 */
|
||||||
left:24rpx;
|
.uh-glass-popup-panel--center {
|
||||||
bottom:24rpx;
|
left: 50%;
|
||||||
right:24rpx;
|
top: 50%;
|
||||||
|
transform: translate3d(-50%, -50%, 0);
|
||||||
|
transform-origin: 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--top {
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--bottom {
|
||||||
|
left: 24rpx;
|
||||||
|
bottom: 24rpx;
|
||||||
|
right: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--left {
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--right {
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 位置自适应圆角(round) */
|
||||||
|
.uh-glass-popup-panel--bottom.is-round {
|
||||||
|
border-radius: 16rpx 16rpx 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--top.is-round {
|
||||||
|
border-radius: 0 0 16rpx 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--left.is-round {
|
||||||
|
border-radius: 0 16rpx 16rpx 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--right.is-round {
|
||||||
|
border-radius: 16rpx 0 0 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-panel--center.is-round {
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 动画帧(enter 与 leave-to) */
|
||||||
|
.uh-glass-popup-anim--slide-up-enter,
|
||||||
|
.uh-glass-popup-anim--slide-up-leave-to {
|
||||||
|
transform: translate3d(0, 100%, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-anim--slide-down-enter,
|
||||||
|
.uh-glass-popup-anim--slide-down-leave-to {
|
||||||
|
transform: translate3d(0, -100%, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-anim--slide-left-enter,
|
||||||
|
.uh-glass-popup-anim--slide-left-leave-to {
|
||||||
|
transform: translate3d(-100%, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-anim--slide-right-enter,
|
||||||
|
.uh-glass-popup-anim--slide-right-leave-to {
|
||||||
|
transform: translate3d(100%, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-anim--zoom-in-enter,
|
||||||
|
.uh-glass-popup-anim--zoom-in-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-anim--fade-enter,
|
||||||
|
.uh-glass-popup-anim--fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 动画激活态(transition-property) */
|
||||||
|
.uh-glass-popup-anim--slide-up-enter-active,
|
||||||
|
.uh-glass-popup-anim--slide-up-leave-active,
|
||||||
|
.uh-glass-popup-anim--slide-down-enter-active,
|
||||||
|
.uh-glass-popup-anim--slide-down-leave-active,
|
||||||
|
.uh-glass-popup-anim--slide-left-enter-active,
|
||||||
|
.uh-glass-popup-anim--slide-left-leave-active,
|
||||||
|
.uh-glass-popup-anim--slide-right-enter-active,
|
||||||
|
.uh-glass-popup-anim--slide-right-leave-active {
|
||||||
|
transition-property: transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup-anim--zoom-in-enter-active,
|
||||||
|
.uh-glass-popup-anim--zoom-in-leave-active,
|
||||||
|
.uh-glass-popup-anim--fade-enter-active,
|
||||||
|
.uh-glass-popup-anim--fade-leave-active {
|
||||||
|
transition-property: opacity, transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* center 缩放需叠加居中位移 */
|
||||||
|
.uh-glass-popup-panel--center.uh-glass-popup-anim--zoom-in-enter,
|
||||||
|
.uh-glass-popup-panel--center.uh-glass-popup-anim--zoom-in-leave-to {
|
||||||
|
transform: scale(0.8) translate3d(-50%, -50%, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 右上角关闭按钮 */
|
||||||
|
.uh-glass-popup__close {
|
||||||
|
position: absolute;
|
||||||
|
top: 32rpx;
|
||||||
|
right: 32rpx;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-glass-popup__close-icon {
|
||||||
|
font-size: 48rpx;
|
||||||
|
line-height: 1;
|
||||||
|
color: rgb(0 0 0 / 45%);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
/** v-model:是否显示 */
|
||||||
|
modelValue : boolean
|
||||||
|
/** 弹出位置 */
|
||||||
|
position ?: 'center' | 'top' | 'right' | 'bottom' | 'left'
|
||||||
|
/** 层级 */
|
||||||
|
zIndex ?: number
|
||||||
|
/** 是否显示右上角关闭图标 */
|
||||||
|
closable ?: boolean
|
||||||
|
/** 是否显示遮罩 */
|
||||||
|
modal ?: boolean
|
||||||
|
/** 点击遮罩是否关闭 */
|
||||||
|
closeOnClickModal ?: boolean
|
||||||
|
/** 底部安全距离适配(iphone X 类机型) */
|
||||||
|
safeAreaInsetBottom ?: boolean
|
||||||
|
/** 面板圆角(内联生效,优先级最高);传 wot 自带 round 时圆角由位置自动适配 */
|
||||||
|
radius ?: string
|
||||||
|
/** 是否开启 wot 位置自适应圆角(bottom→上圆角 / center→四圆角等),与 radius 二选一 */
|
||||||
|
round ?: boolean
|
||||||
|
lazyRender ?: boolean
|
||||||
|
hideWhenClose?: boolean
|
||||||
|
/** 追加到面板的内联样式,如宽度:width:640rpx; */
|
||||||
|
customStyle ?: string
|
||||||
|
customClass? :string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IEmits {
|
||||||
|
(e : 'update:modelValue', value : boolean) : void
|
||||||
|
(e : 'close') : void
|
||||||
|
(e : 'open') : void
|
||||||
|
(e : 'click-modal') : void
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<IProps>(), {
|
||||||
|
position: 'center',
|
||||||
|
zIndex: 10,
|
||||||
|
closable: false,
|
||||||
|
modal: true,
|
||||||
|
closeOnClickModal: true,
|
||||||
|
safeAreaInsetBottom: false,
|
||||||
|
radius: '',
|
||||||
|
round: false,
|
||||||
|
lazyRender: true,
|
||||||
|
hideWhenClose: true,
|
||||||
|
customStyle: '',
|
||||||
|
customClass:''
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<IEmits>()
|
||||||
|
|
||||||
|
const panelStyle = computed(() => {
|
||||||
|
return props.customStyle
|
||||||
|
})
|
||||||
|
|
||||||
|
const panelClass = computed(() =>{
|
||||||
|
return `uh-glass-popup-panel ${props.customClass}`
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-popup
|
||||||
|
:model-value="modelValue"
|
||||||
|
:position="position"
|
||||||
|
:z-index="zIndex"
|
||||||
|
:closable="closable"
|
||||||
|
:modal="modal"
|
||||||
|
:close-on-click-modal="closeOnClickModal"
|
||||||
|
:hide-when-close="hideWhenClose"
|
||||||
|
:safe-area-inset-bottom="safeAreaInsetBottom"
|
||||||
|
:round="round"
|
||||||
|
:custom-style="panelStyle"
|
||||||
|
:custom-class="panelClass"
|
||||||
|
:lazy-render="lazyRender"
|
||||||
|
@update:model-value="(value: boolean) => emit('update:modelValue', value)"
|
||||||
|
@close="emit('close')"
|
||||||
|
@enter="emit('open')"
|
||||||
|
@click-modal="emit('click-modal')"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</wd-popup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
:deep(.wd-popup.uh-glass-popup-panel) {
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: rgb(255 255 255 / 85%);
|
||||||
|
border: 4rpx solid rgb(255 255 255 / 90%);
|
||||||
|
box-shadow: inset 0 1rpx 0 rgb(255 255 255 / 75%), 0 8rpx 32rpx rgb(90 105 200 / 14%);
|
||||||
|
backdrop-filter: blur(24rpx) saturate(160%);
|
||||||
|
-webkit-backdrop-filter: blur(24rpx) saturate(160%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 低端 WebView 不支持 backdrop-filter 的兜底:提高不透明度保证可读性 */
|
||||||
|
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
||||||
|
:deep(.wd-popup.uh-glass-popup-panel) {
|
||||||
|
background-color: rgb(255 255 255 / 88%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.wd-popup--bottom){
|
||||||
|
left:24rpx;
|
||||||
|
bottom:24rpx;
|
||||||
|
right:24rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="fixed right-3 bottom-22 z-50 flex flex-col gap-y-3 pb-safe">
|
<view class="fixed right-3 bottom-18 z-50 flex flex-col gap-y-3 pb-safe">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 贡献热度图(源自旧项目 components/heatmap,新建复刻,精简版)
|
* 贡献热度图
|
||||||
* 按日期统计文章发布数量,以年度格子图展示
|
* 按日期统计文章发布数量,以年度格子图展示
|
||||||
*/
|
*/
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
@@ -21,7 +21,8 @@ const weeks = ['一', '二', '三', '四', '五', '六', '日']
|
|||||||
const currentYear = ref(new Date().getFullYear())
|
const currentYear = ref(new Date().getFullYear())
|
||||||
const currentMonth = ref(new Date().getMonth() + 1)
|
const currentMonth = ref(new Date().getMonth() + 1)
|
||||||
|
|
||||||
const intensityColors = ['#ebedf0', '#dbeafe', '#93c5fd', '#3b82f6', '#1e40af']
|
/** 颜色分级(主题色系黄绿渐变,由浅到深) */
|
||||||
|
const intensityColors = ['#ebedf0', '#f4fad8', '#e9f79f', '#d7ee52', '#b9e424']
|
||||||
|
|
||||||
const yearOptions = computed(() => {
|
const yearOptions = computed(() => {
|
||||||
const years = new Set<number>()
|
const years = new Set<number>()
|
||||||
@@ -58,9 +59,16 @@ const daysInYear = computed(() => {
|
|||||||
: 366
|
: 366
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 单元格:日粒度,isEmpty=前置空位(非本年日期) */
|
||||||
|
interface IHeatmapCell {
|
||||||
|
date: string
|
||||||
|
count: number
|
||||||
|
isEmpty: boolean
|
||||||
|
}
|
||||||
|
|
||||||
/** 单元格列表:前置空位 + 全年每日 */
|
/** 单元格列表:前置空位 + 全年每日 */
|
||||||
const displayCells = computed(() => {
|
const displayCells = computed<IHeatmapCell[]>(() => {
|
||||||
const cells: { date: string, count: number, isEmpty: boolean }[] = []
|
const cells: IHeatmapCell[] = []
|
||||||
for (let i = 0; i < firstDayOffset.value; i++) {
|
for (let i = 0; i < firstDayOffset.value; i++) {
|
||||||
cells.push({ date: '', count: 0, isEmpty: true })
|
cells.push({ date: '', count: 0, isEmpty: true })
|
||||||
}
|
}
|
||||||
@@ -71,6 +79,31 @@ const displayCells = computed(() => {
|
|||||||
return cells
|
return cells
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 按周分组为列(每列 7 天,周一~周日;跨年补足空位),列不换行,横向滚动 */
|
||||||
|
const weekColumns = computed<IHeatmapCell[][]>(() => {
|
||||||
|
const cells = displayCells.value
|
||||||
|
const columns: IHeatmapCell[][] = []
|
||||||
|
for (let i = 0; i < cells.length; i += 7) {
|
||||||
|
columns.push(cells.slice(i, i + 7))
|
||||||
|
}
|
||||||
|
return columns
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 每列顶部月份标签:取该列第一个非空日期所属月份,与上一列同月则空占位(保证列高一致) */
|
||||||
|
const columnMonths = computed<string[]>(() => {
|
||||||
|
let lastMonth = -1
|
||||||
|
return weekColumns.value.map((column) => {
|
||||||
|
const firstReal = column.find(cell => !cell.isEmpty)
|
||||||
|
if (!firstReal)
|
||||||
|
return ''
|
||||||
|
const month = dayjs(firstReal.date).month()
|
||||||
|
if (month === lastMonth)
|
||||||
|
return ''
|
||||||
|
lastMonth = month
|
||||||
|
return `${month + 1}月`
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
/** 颜色分级 */
|
/** 颜色分级 */
|
||||||
function getDayColor(day: { count: number, isEmpty: boolean }): string {
|
function getDayColor(day: { count: number, isEmpty: boolean }): string {
|
||||||
if (day.isEmpty)
|
if (day.isEmpty)
|
||||||
@@ -86,10 +119,14 @@ function getDayColor(day: { count: number, isEmpty: boolean }): string {
|
|||||||
return intensityColors[4]
|
return intensityColors[4]
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDayTip(day: { date: string, count: number, isEmpty: boolean }): string {
|
/** 点击格子:toast 展示该日日期与发布篇数 */
|
||||||
|
function handleDayClick(day: IHeatmapCell) {
|
||||||
if (day.isEmpty)
|
if (day.isEmpty)
|
||||||
return ''
|
return
|
||||||
return `${day.date}:${day.count} 篇`
|
uni.showToast({
|
||||||
|
title: `${dayjs(day.date).format('YYYY年MM月DD日')} 发布 ${day.count} 篇`,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 累计总数 */
|
/** 累计总数 */
|
||||||
@@ -98,15 +135,6 @@ const totalCount = computed(() => props.chartData.reduce((sum, item) => sum + it
|
|||||||
/** 本年总数 */
|
/** 本年总数 */
|
||||||
const currentYearCount = computed(() => Object.values(yearDataMap.value).reduce((sum, n) => sum + n, 0))
|
const currentYearCount = computed(() => Object.values(yearDataMap.value).reduce((sum, n) => sum + n, 0))
|
||||||
|
|
||||||
/** 月份标签(按 5 周跨度取整月位置,简化:每两月一个标签) */
|
|
||||||
const monthLabels = computed(() => {
|
|
||||||
const labels: { index: number, name: string }[] = []
|
|
||||||
for (let m = 0; m < 12; m++) {
|
|
||||||
labels.push({ index: m * 5, name: `${m + 1}月` })
|
|
||||||
}
|
|
||||||
return labels
|
|
||||||
})
|
|
||||||
|
|
||||||
function changeYear(value: number) {
|
function changeYear(value: number) {
|
||||||
currentYear.value = value
|
currentYear.value = value
|
||||||
}
|
}
|
||||||
@@ -132,27 +160,27 @@ function changeYear(value: number) {
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="heatmap-container flex gap-2">
|
<view class="heatmap-container flex gap-2">
|
||||||
<view class="weeks flex flex-col gap-1 pt-8">
|
<!-- 周标签列(固定,不随横向滚动) -->
|
||||||
<view v-for="(week, index) in weeks" :key="index" class="week-label h-5 text-[16rpx] text-[#999] leading-5">
|
<view class="weeks flex shrink-0 flex-col gap-1">
|
||||||
|
<view class="h-6 shrink-0" />
|
||||||
|
<view v-for="(week, index) in weeks" :key="index" class="week-label h-6 text-[16rpx] text-[#999] leading-6">
|
||||||
{{ week }}
|
{{ week }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="heatmap-content flex-1 overflow-x-auto">
|
<!-- 主体:每列顶部带月份标签,整列横向排列(不换行),整体横向滚动 -->
|
||||||
<view class="months mb-1 flex">
|
<scroll-view scroll-x :show-scrollbar="false" class="heatmap-content flex-1">
|
||||||
<view v-for="month in monthLabels" :key="month.index" class="month-label w-[100rpx] shrink-0 text-[16rpx] text-[#999]">
|
<view class="inline-flex flex-col">
|
||||||
{{ month.name }}
|
<view class="flex gap-1">
|
||||||
|
<view v-for="(column, ci) in weekColumns" :key="ci" class="flex shrink-0 flex-col">
|
||||||
|
<view class="month-label h-6 w-6 whitespace-nowrap text-center text-[16rpx] text-[#999] leading-6">
|
||||||
|
{{ columnMonths[ci] }}
|
||||||
|
</view>
|
||||||
|
<view v-for="(day, di) in column" :key="di" class="day-cell mt-1 box-border h-6 w-6 rounded"
|
||||||
|
:style="{ backgroundColor: getDayColor(day) }" @click="handleDayClick(day)" />
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="days-container h-[220rpx] flex flex-wrap gap-1">
|
</scroll-view>
|
||||||
<view
|
|
||||||
v-for="(day, index) in displayCells"
|
|
||||||
:key="index"
|
|
||||||
class="day-cell box-border h-6 w-6 rounded"
|
|
||||||
:style="{ backgroundColor: getDayColor(day) }"
|
|
||||||
@click="getDayTip(day)"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="footer mt-6 flex items-center justify-between">
|
<view class="footer mt-6 flex items-center justify-between">
|
||||||
@@ -181,8 +209,8 @@ function changeYear(value: number) {
|
|||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: #fff;
|
color: #303133;
|
||||||
background-color: #03a9f4;
|
background-color: #b9e424;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,8 +101,8 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view v-if="bannerList.length > 0" class="relative w-full mb-6 box-border ">
|
<view v-if="bannerList.length > 0" class="relative w-full mb-6 box-border ">
|
||||||
<view class="box-border relative w-full h-52 overflow-hidden">
|
<view class="box-border relative w-full h-56 overflow-hidden">
|
||||||
<swiper class="w-full h-52" :circular="true" :indicator-dots="false" :autoplay="true" :interval="3000"
|
<swiper class="w-full h-56" :circular="true" :indicator-dots="false" :autoplay="true" :interval="3000"
|
||||||
:duration="1000" @change="handleBannerChange">
|
:duration="1000" @change="handleBannerChange">
|
||||||
<swiper-item v-for="(item, index) in bannerList" :key="index" class="relative">
|
<swiper-item v-for="(item, index) in bannerList" :key="index" class="relative">
|
||||||
<image :src="item.image || item.src" class="h-full w-full" mode="aspectFill"
|
<image :src="item.image || item.src" class="h-full w-full" mode="aspectFill"
|
||||||
@@ -111,22 +111,31 @@
|
|||||||
</swiper>
|
</swiper>
|
||||||
<view v-if="currentBanner"
|
<view v-if="currentBanner"
|
||||||
class="pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-y-2 bg-white/5 backdrop-blur-[2rpx]">
|
class="pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-y-2 bg-white/5 backdrop-blur-[2rpx]">
|
||||||
<text class="text-sm text-gray-900 font-bold bg-secondary px-3 py-0.5 rounded-xl">
|
<view class="box-border mt-3 flex items-center justify-center bg-secondary px-3 py-1 rounded-xl">
|
||||||
{{ currentBanner.title }}
|
<text class="text-2xs text-gray-900 font-semibold">
|
||||||
</text>
|
{{ currentBanner.title }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
<text
|
<text
|
||||||
class="text-xs text-white text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">{{ currentBanner.date }}</text>
|
class="text-xs text-white text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">{{ currentBanner.date }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="absolute bottom-0 left-0 right-0 h-12 w-full bg-gradient-to-b from-white/0 to-page" />
|
<view class="absolute bottom-0 left-0 right-0 h-12 w-full bg-gradient-to-b from-white/0 to-page" />
|
||||||
<view class="absolute left-0 right-0 z-10 flex items-center justify-center -translate-y-6">
|
<view class="absolute left-0 right-0 z-10 flex items-center justify-center uh-translate-y-n6">
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass border w-4/5 rounded-full px-4 py-2 text-sm text-gray-600 flex items-center justify-center gap-x-2"
|
class="uh-global-card-glass border w-4/5 rounded-full px-4 py-2.5 text-gray-600 flex items-center justify-center gap-x-2"
|
||||||
@click="handleToSearch()">
|
@click="handleToSearch()">
|
||||||
<wd-icon name="search-line" size="32rpx"></wd-icon>
|
<wd-icon name="search-line" size="32rpx"></wd-icon>
|
||||||
<text>哈喽,想看些什么 <text class="bg-secondary rounded-xl px-1">{ 内容 }</text> 呢~</text>
|
<text class="text-2xs">哈喽,想看些什么 <text class="bg-secondary rounded-xl px-1">{ 内容 }</text> 呢~</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
/* 向上偏移定位 */
|
||||||
|
.uh-translate-y-n6 {
|
||||||
|
transform: translateY(-1.5rem);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -75,32 +75,32 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view v-if="isEnableCategoryModule" class="mb-6">
|
<view v-if="isEnableCategoryModule" class="box-border mb-6 px-3">
|
||||||
<uh-section-title class="mb-4 px-3 box-border">
|
<uh-section-title>
|
||||||
精选分类
|
精选分类
|
||||||
<template #right>
|
<template #right>
|
||||||
<view class="uh-global-card-glass uh-shadow-xs border flex items-center justify-center rounded-md p-1 text-gray-400"
|
<view class="uh-global-card-glass uh-shadow-xs border flex items-center justify-center rounded-md p-1 text-gray-400"
|
||||||
@click="handleToCategoryPage">
|
@click="handleToCategoryPage">
|
||||||
<wd-icon name="arrow-right" size="28rpx" />
|
<wd-icon name="arrow-right" size="14px" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</uh-section-title>
|
</uh-section-title>
|
||||||
|
|
||||||
<view v-if="loading!=='success'" class="box-border px-3">
|
<view v-if="loading!=='success'" class="mt-4 box-border">
|
||||||
<view class="uh-global-card-glass shadow-none rounded-xl">
|
<view class="uh-global-card-glass shadow-none rounded-xl">
|
||||||
<uh-data-loading :loading-status="loading" min-height="28vh" size="small" :use-refresh-button="true"
|
<uh-data-loading :loading-status="loading" min-height="28vh" size="small" :use-refresh-button="true"
|
||||||
@refresh="handleGetCategoryList()" />
|
@refresh="handleGetCategoryList()" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-else class="w-full grid grid-cols-2 grid-rows-auto h-42 box-border px-3 gap-2">
|
<view v-else class="mt-4 w-full grid grid-cols-2 grid-rows-auto h-42 box-border gap-2">
|
||||||
<view v-for="(category,index) in categoryList" :key="category.metadata.name"
|
<view v-for="(category,index) in categoryList" :key="category.metadata.name"
|
||||||
class="uh-global-card-glass relative w-full h-full overflow-hidden rounded-xl text-center text-white"
|
class="uh-global-card-glass relative w-full h-full overflow-hidden rounded-xl text-center text-white"
|
||||||
:class="{'grid-row-span-2':index===0 }" @click="handleToCategoryBy(category)">
|
:class="{'grid-row-span-2':index===0 }" @click="handleToCategoryBy(category)">
|
||||||
<image :src="category.spec.cover" class="w-full h-full" mode="aspectFill" lazy-load />
|
<image :src="category.spec.cover" class="w-full h-full" mode="aspectFill" lazy-load />
|
||||||
<view class="absolute bottom-0 left-0 h-[140rpx] w-full bg-gradient-to-b from-black/0 to-black/30" />
|
<view class="absolute bottom-0 left-0 h-16 w-full bg-gradient-to-b from-black/0 to-black/30" />
|
||||||
<view class="absolute left-2 bottom-2 flex z-2 flex-col text-left">
|
<view class="absolute left-2 bottom-2 flex z-2 flex-col text-left">
|
||||||
<text class="text-sm font-bold">
|
<text class="text-xs font-semibold">
|
||||||
{{ category.spec.displayName }}
|
{{ category.spec.displayName }}
|
||||||
</text>
|
</text>
|
||||||
<text class="mt-1 text-xs text-gray-200">共 {{ category.postCount ?? 0 }} 篇</text>
|
<text class="mt-1 text-xs text-gray-200">共 {{ category.postCount ?? 0 }} 篇</text>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
|
import { useLoveModuleUnlock } from '@/hooks/useLoveModuleUnlock'
|
||||||
|
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
@@ -8,126 +9,53 @@
|
|||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
const calcIsShowQuickNavigationEnabled = computed(() => haloConfigs.value.pageConfig?.homeConfig?.useQuickNavigation)
|
const calcIsShowQuickNavigationEnabled = computed(() => haloConfigs.value.pageConfig?.homeConfig?.useQuickNavigation)
|
||||||
|
|
||||||
/** 快捷导航项(字段命名与插件端 quickNavigation 一致:key/title/subTitle/color/bgColor/iconPrefix/icon/path/visible,无 borderColor) */
|
|
||||||
interface QuickNavItem {
|
|
||||||
key : string
|
|
||||||
title ?: string
|
|
||||||
/** 副标题(对标 about 页 rightText,如「全部文章」;2026-09-10 插件端新增可空字段) */
|
|
||||||
subTitle ?: string
|
|
||||||
color ?: string
|
|
||||||
bgColor ?: string
|
|
||||||
iconPrefix ?: string
|
|
||||||
icon ?: string
|
|
||||||
path ?: string
|
|
||||||
visible ?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
// 是否使用本地的快捷导航数据(本地的可以任意修改图标、路径,插件端的无法修改图标)
|
|
||||||
const useLocalNav = false
|
|
||||||
/** 内置默认项(未配置时回退;字段命名与插件端一致,可作配置缺失字段的兜底) */
|
|
||||||
const DEFAULT_NAV_LIST : QuickNavItem[] = [
|
|
||||||
{
|
|
||||||
key: 'archives',
|
|
||||||
title: '文章归档',
|
|
||||||
subTitle: '全部文章',
|
|
||||||
color: '#03A9F4',
|
|
||||||
bgColor: 'rgba(3, 169, 244, 0.14)',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-mask',
|
|
||||||
path: '/pages-blog/archives/archives',
|
|
||||||
visible: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'vote',
|
|
||||||
title: '投票中心',
|
|
||||||
color: '#00BCD4',
|
|
||||||
bgColor: 'rgba(0, 188, 212, 0.14)',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-confused',
|
|
||||||
path: '/pages-blog/votes/votes',
|
|
||||||
visible: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'disclaimers',
|
|
||||||
title: '友情链接',
|
|
||||||
color: '#009688',
|
|
||||||
bgColor: 'rgba(0, 150, 136, 0.14)',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-wink',
|
|
||||||
path: '/pages-blog/friend-links/friend-links',
|
|
||||||
visible: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'love',
|
|
||||||
title: '恋爱日记',
|
|
||||||
color: '#FF4C67',
|
|
||||||
bgColor: 'rgba(255, 76, 103, 0.14)',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-in-love',
|
|
||||||
path: '/pages-blog/love/love',
|
|
||||||
visible: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'contact-blogger',
|
|
||||||
title: '联系博主',
|
|
||||||
color: '#FF9800',
|
|
||||||
bgColor: 'rgba(255, 152, 0, 0.14)',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-cool',
|
|
||||||
path: '/pages-blog/contact/contact',
|
|
||||||
visible: true,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
/** 快捷导航列表:优先读插件端配置(零映射,visible 过滤);未配置/为空回退内置默认(保留原显隐推导) */
|
|
||||||
const navList = computed(() => {
|
const navList = computed(() => {
|
||||||
const configured = haloConfigs.value.pageConfig?.homeConfig?.quickNavigation
|
const configured = haloConfigs.value.pageConfig?.homeConfig?.quickNavigation
|
||||||
let list : QuickNavItem[]
|
return configured.filter(item => item.visible !== false)
|
||||||
if (!useLocalNav && configured && configured.length) {
|
|
||||||
// 配置模式:以配置项为准,缺失字段(icon/iconPrefix/color/path 等)按 key 从默认项兜底
|
|
||||||
list = configured.map(item => {
|
|
||||||
const fallback = DEFAULT_NAV_LIST.find(d => d.key === item.key) || DEFAULT_NAV_LIST[0]
|
|
||||||
return { ...fallback, ...item }
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
list = DEFAULT_NAV_LIST;
|
|
||||||
}
|
|
||||||
return list.filter(item => item.visible !== false)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* 恋爱模块解锁拦截(目前仅恋爱日记设密码,命中锁定则先解锁再跳转;样式不变) */
|
||||||
|
const {
|
||||||
|
unlockModalVisible,
|
||||||
|
unlockTip,
|
||||||
|
handleUnlockRequest,
|
||||||
|
handleUnlockSuccess,
|
||||||
|
interceptNavigateByPath,
|
||||||
|
} = useLoveModuleUnlock()
|
||||||
|
|
||||||
function handleClickNav(item : { path ?: string }) {
|
function handleClickNav(item : { path ?: string }) {
|
||||||
if (!item.path)
|
if (!item.path) { return }
|
||||||
return
|
// 命中恋爱模块且锁定 → 弹解锁弹窗,解锁成功后由 hook 自动跳转
|
||||||
|
if (interceptNavigateByPath(item.path)) { return }
|
||||||
uni.navigateTo({ url: item.path })
|
uni.navigateTo({ url: item.path })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view v-if="calcIsShowQuickNavigationEnabled && navList.length"
|
<view v-if="calcIsShowQuickNavigationEnabled && navList.length"
|
||||||
class="box-border overflow-hidden rounded-xl p-3 px-4 mb-3">
|
class="box-border overflow-hidden rounded-xl p-3 mb-3">
|
||||||
<uh-section-title class="mb-4">
|
<uh-section-title> 快捷导航 </uh-section-title>
|
||||||
快捷导航
|
<view class="mt-4 grid grid-cols-5 gap-4">
|
||||||
</uh-section-title>
|
|
||||||
<view class="grid grid-cols-5 gap-4">
|
|
||||||
<view v-for="item in navList" :key="item.key" class="flex flex-col items-center gap-2"
|
<view v-for="item in navList" :key="item.key" class="flex flex-col items-center gap-2"
|
||||||
@click="handleClickNav(item)">
|
@click="handleClickNav(item)">
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass uh-shadow-xs h-13 w-13 flex items-center justify-center rounded-2xl border transition-transform active:scale-90"
|
class="uh-global-card-glass uh-shadow-xs h-13 w-13 flex items-center justify-center rounded-2xl border"
|
||||||
:style="{
|
:style="{
|
||||||
backgroundColor: item.bgColor
|
backgroundColor: item.bgColor
|
||||||
}">
|
}">
|
||||||
<wd-icon :class-prefix="item.iconPrefix" :name="item.icon" size="64rpx" />
|
<wd-icon :class-prefix="item.iconPrefix" :name="item.icon" size="64rpx" />
|
||||||
</view>
|
</view>
|
||||||
<view class="flex flex-col items-center gap-0.5">
|
<view class="flex flex-col items-center gap-0.5">
|
||||||
<text class="max-w-16 truncate text-xs text-gray-900">
|
<text class="max-w-16 truncate text-xs text-gray-900" :style="{color:item.color}">
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</text>
|
</text>
|
||||||
<text v-if="item.subTitle" class="max-w-16 truncate text-[10rpx] text-gray-400">
|
|
||||||
{{ item.subTitle }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 恋爱模块解锁弹窗(解锁成功自动跳转) -->
|
||||||
|
<uh-unlock-popup v-model:show="unlockModalVisible" title="请解锁" captcha-enabled
|
||||||
|
:tip="unlockTip" placeholder="请输入密码" confirm-text="进入" :request="handleUnlockRequest"
|
||||||
|
@success="handleUnlockSuccess" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,41 +1,45 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
defineOptions({
|
||||||
* 友链底部悬浮操作栏(通用组件)
|
options: {
|
||||||
* 参考瞬间详情页底部悬浮按钮设计;通过 :actions 控制显示的按钮,事件回调 emit('apply') / emit('info')
|
styleIsolation: 'apply-shared'
|
||||||
* 站点 tab / 小程序 tab 分别引入(如 :actions="['apply','info']" @apply=... @info=...)
|
}
|
||||||
*/
|
})
|
||||||
withDefaults(defineProps<{
|
|
||||||
/** 需要显示的按钮:apply=提交申请,info=友链信息;包含即显示 */
|
|
||||||
actions?: string[]
|
|
||||||
}>(), {
|
|
||||||
actions: () => ['apply', 'info'],
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const props = withDefaults(defineProps<{
|
||||||
(e: 'apply'): void
|
/** 需要显示的按钮:apply=提交申请,info=友链信息;包含即显示 */
|
||||||
(e: 'info'): void
|
actions ?: string[]
|
||||||
}>()
|
}>(), {
|
||||||
|
actions: () => ['apply', 'info'],
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e : 'apply') : void
|
||||||
|
(e : 'info') : void
|
||||||
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="fixed bottom-8 left-1/2 z-10 flex items-center justify-center pb-safe -translate-x-1/2">
|
<view class="fixed bottom-0 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
|
||||||
<view class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
<view
|
||||||
<view
|
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
||||||
v-if="actions.includes('apply')"
|
<view v-if="actions.includes('apply')"
|
||||||
class="uh-global-card-glass box-border h-9 flex flex-1 items-center justify-center gap-x-1 border rounded-full px-8 shadow-none"
|
class="uh-global-card-glass box-border py-2 flex flex-1 items-center justify-center gap-x-1 border rounded-full px-8 shadow-none"
|
||||||
@click="emit('apply')"
|
@click="emit('apply')">
|
||||||
>
|
<wd-icon name="edit" size="32rpx" />
|
||||||
<wd-icon name="edit" size="36rpx" />
|
<text class="shrink-0 text-xs text-gray-900 font-semibold">提交申请</text>
|
||||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">提交申请</text>
|
</view>
|
||||||
</view>
|
<view v-if="actions.includes('info')"
|
||||||
<view
|
class="uh-global-card-glass box-border py-2 flex flex-1 items-center justify-center gap-x-1 border rounded-full px-8 shadow-none"
|
||||||
v-if="actions.includes('info')"
|
@click="emit('info')">
|
||||||
class="uh-global-card-glass box-border h-9 flex flex-1 items-center justify-center gap-x-1 border rounded-full px-8 shadow-none"
|
<wd-icon name="info" size="32rpx" />
|
||||||
@click="emit('info')"
|
<text class="shrink-0 text-xs text-gray-900 font-semibold">友链信息</text>
|
||||||
>
|
</view>
|
||||||
<wd-icon name="info" size="36rpx" />
|
</view>
|
||||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">友链信息</text>
|
</view>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.uh-translate-x-center {
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,6 +3,12 @@
|
|||||||
import { getPluginCaptcha, submitMiniProgramLinkApplication } from '@/api/uni-halo'
|
import { getPluginCaptcha, submitMiniProgramLinkApplication } from '@/api/uni-halo'
|
||||||
import type { ICaptchaQuery, IPluginCaptcha } from '@/api/uni-halo'
|
import type { ICaptchaQuery, IPluginCaptcha } from '@/api/uni-halo'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
show ?: boolean
|
show ?: boolean
|
||||||
}>(), {
|
}>(), {
|
||||||
|
|||||||
@@ -1,213 +1,195 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
import { computed, ref, watch } from 'vue'
|
||||||
* 小程序友链信息弹窗
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
* 展示本站小程序申请提交的信息,字段结构与小程序提交申请弹窗(uh-links-mini-apply)一致:
|
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
||||||
* 小程序名称/太阳码/跳转地址/作者昵称/作者头像/作者网站/描述/申请说明/邮箱
|
|
||||||
* 数据源:插件端 getConfigs.pluginConfig.linkInfo(字段名与插件端一致,无映射;
|
|
||||||
* displayName/miniProgramCode/link/description/applyRemark/authorName/avatar/website;
|
|
||||||
* email 不在插件端维护,读不到时弹窗该栏自动隐藏)
|
|
||||||
*/
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
|
||||||
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
defineOptions({
|
||||||
show?: boolean
|
options: {
|
||||||
}>(), {
|
styleIsolation: 'apply-shared'
|
||||||
show: false,
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const props = withDefaults(defineProps<{
|
||||||
(e: 'on-close'): void
|
show ?: boolean
|
||||||
}>()
|
}>(), {
|
||||||
|
show: false,
|
||||||
|
})
|
||||||
|
|
||||||
const isShow = ref(false)
|
const emit = defineEmits<{
|
||||||
const appConfigStore = useAppConfigStore()
|
(e : 'on-close') : void
|
||||||
|
}>()
|
||||||
|
|
||||||
/** 小程序申请信息(字段与 uh-links-mini-apply 表单一致;小程序信息读 linkInfo.miniInfo;
|
const isShow = ref(false)
|
||||||
* 作者信息 2026-09-10 起改读应用设置-博主资料 authorConfig.blogger(linkInfo.authorInfo 已下线),字段名无映射) */
|
const appConfigStore = useAppConfigStore()
|
||||||
const miniInfo = computed(() => {
|
|
||||||
const miniCfg = (appConfigStore.configs.pluginConfig?.linkInfo?.miniInfo || {}) as Record<string, unknown>
|
|
||||||
const blogger = (appConfigStore.configs.authorConfig?.blogger || {}) as Record<string, unknown>
|
|
||||||
const str = (cfg: Record<string, unknown>, key: string, fallback = '') => String(cfg[key] || fallback || '')
|
|
||||||
return {
|
|
||||||
displayName: str(miniCfg, 'displayName'),
|
|
||||||
miniProgramCode: str(miniCfg, 'miniProgramCode'),
|
|
||||||
link: str(miniCfg, 'link'),
|
|
||||||
// 作者信息:博主资料 nickname/avatar/website(官网地址 2026-09-10 新增)
|
|
||||||
authorName: str(blogger, 'nickname'),
|
|
||||||
avatar: str(blogger, 'avatar'),
|
|
||||||
website: str(blogger, 'website'),
|
|
||||||
description: str(miniCfg, 'description'),
|
|
||||||
applyRemark: str(miniCfg, 'applyRemark'),
|
|
||||||
email: str(miniCfg, 'email'),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const hasInfo = computed(() => !!(miniInfo.value.displayName || miniInfo.value.miniProgramCode))
|
/** 小程序申请信息(字段与 uh-links-mini-apply 表单一致;小程序信息读 linkInfo.miniInfo;
|
||||||
|
* 作者信息读应用设置-博主资料 authorConfig.blogger,字段名无映射) */
|
||||||
|
const miniInfo = computed(() => {
|
||||||
|
const miniCfg = (appConfigStore.configs.pluginConfig?.linkInfo?.miniInfo || {}) as Record<string, unknown>
|
||||||
|
const blogger = (appConfigStore.configs.authorConfig?.blogger || {}) as Record<string, unknown>
|
||||||
|
const str = (cfg : Record<string, unknown>, key : string, fallback = '') => String(cfg[key] || fallback || '')
|
||||||
|
return {
|
||||||
|
displayName: str(miniCfg, 'displayName'),
|
||||||
|
miniProgramCode: str(miniCfg, 'miniProgramCode'),
|
||||||
|
link: str(miniCfg, 'link'),
|
||||||
|
// 作者信息:博主资料 nickname/avatar/website
|
||||||
|
authorName: str(blogger, 'nickname'),
|
||||||
|
avatar: str(blogger, 'avatar'),
|
||||||
|
website: str(blogger, 'website'),
|
||||||
|
description: str(miniCfg, 'description'),
|
||||||
|
applyRemark: str(miniCfg, 'applyRemark'),
|
||||||
|
email: str(miniCfg, 'email'),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/** 复制跳转地址 */
|
const hasInfo = computed(() => !!(miniInfo.value.displayName || miniInfo.value.miniProgramCode))
|
||||||
function handleCopyLink() {
|
|
||||||
if (!miniInfo.value.link) {
|
|
||||||
uni.showToast({ icon: 'none', title: '暂未填写跳转地址' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uni.setClipboardData({
|
|
||||||
data: miniInfo.value.link,
|
|
||||||
showToast: false,
|
|
||||||
success: () => {
|
|
||||||
uni.showToast({ icon: 'none', title: '地址复制成功!' })
|
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
uni.showToast({ icon: 'none', title: '复制失败!' })
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 复制小程序申请信息(拼接文案) */
|
/** 复制跳转地址 */
|
||||||
function handleCopyInfo() {
|
function handleCopyLink() {
|
||||||
const info = miniInfo.value
|
if (!miniInfo.value.link) {
|
||||||
const text = [
|
uni.showToast({ icon: 'none', title: '暂未填写跳转地址' })
|
||||||
info.displayName ? `小程序名称:${info.displayName}` : '',
|
return
|
||||||
info.link ? `小程序地址:${info.link}` : '',
|
}
|
||||||
info.authorName ? `作者昵称:${info.authorName}` : '',
|
uni.setClipboardData({
|
||||||
info.website ? `作者网站:${info.website}` : '',
|
data: miniInfo.value.link,
|
||||||
info.description ? `小程序描述:${info.description}` : '',
|
showToast: false,
|
||||||
info.applyRemark ? `申请说明:${info.applyRemark}` : '',
|
success: () => {
|
||||||
info.email ? `通知邮箱:${info.email}` : '',
|
uni.showToast({ icon: 'none', title: '地址复制成功!' })
|
||||||
].filter(Boolean).join('\n')
|
},
|
||||||
uni.setClipboardData({
|
fail: () => {
|
||||||
data: text,
|
uni.showToast({ icon: 'none', title: '复制失败!' })
|
||||||
showToast: false,
|
},
|
||||||
success: () => {
|
})
|
||||||
uni.showToast({ icon: 'none', title: '复制成功!' })
|
}
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
uni.showToast({ icon: 'none', title: '复制失败!' })
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 预览太阳码 */
|
/** 复制小程序申请信息(拼接文案) */
|
||||||
function handlePreviewCode() {
|
function handleCopyInfo() {
|
||||||
if (!miniInfo.value.miniProgramCode)
|
const info = miniInfo.value
|
||||||
return
|
const text = [
|
||||||
uni.previewImage({
|
info.displayName ? `小程序名称:${info.displayName}` : '',
|
||||||
urls: [checkImageUrl(miniInfo.value.miniProgramCode)],
|
info.link ? `小程序地址:${info.link}` : '',
|
||||||
current: checkImageUrl(miniInfo.value.miniProgramCode),
|
info.authorName ? `作者昵称:${info.authorName}` : '',
|
||||||
})
|
info.website ? `作者网站:${info.website}` : '',
|
||||||
}
|
info.description ? `小程序描述:${info.description}` : '',
|
||||||
|
info.applyRemark ? `申请说明:${info.applyRemark}` : '',
|
||||||
|
info.email ? `通知邮箱:${info.email}` : '',
|
||||||
|
].filter(Boolean).join('\n')
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: text,
|
||||||
|
showToast: false,
|
||||||
|
success: () => {
|
||||||
|
uni.showToast({ icon: 'none', title: '复制成功!' })
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.showToast({ icon: 'none', title: '复制失败!' })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function handleClose() {
|
/** 预览太阳码 */
|
||||||
isShow.value = false
|
function handlePreviewCode() {
|
||||||
emit('on-close')
|
if (!miniInfo.value.miniProgramCode)
|
||||||
}
|
return
|
||||||
|
uni.previewImage({
|
||||||
|
urls: [checkImageUrl(miniInfo.value.miniProgramCode)],
|
||||||
|
current: checkImageUrl(miniInfo.value.miniProgramCode),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => props.show, (val) => {
|
function handleClose() {
|
||||||
isShow.value = val
|
isShow.value = false
|
||||||
})
|
emit('on-close')
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.show, (val) => {
|
||||||
|
isShow.value = val
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<uh-glass-popup
|
<uh-glass-popup v-model="isShow" :z-index="100" position="bottom" custom-class="!border rounded-xl"
|
||||||
v-model="isShow" :z-index="100" position="bottom"
|
@close="handleClose">
|
||||||
custom-class="!border rounded-xl" @close="handleClose"
|
<view class="relative box-border w-full flex items-center justify-around px-4 pt-4">
|
||||||
>
|
<view class="w-full flex flex-col gap-y-1">
|
||||||
<view class="relative box-border w-full flex items-center justify-around px-4 pt-4">
|
<text class="text-md font-bold">小程序友链信息</text>
|
||||||
<view class="w-full flex flex-col gap-y-1">
|
<text class="text-xs text-gray-500">本站小程序申请提交的信息,欢迎互换</text>
|
||||||
<text class="text-md font-bold">小程序友链信息</text>
|
</view>
|
||||||
<text class="text-xs text-gray-500">本站小程序申请提交的信息,欢迎互换</text>
|
<view class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
|
||||||
</view>
|
@click="handleClose">
|
||||||
<view
|
<wd-icon name="close" size="32rpx" class="text-gray-500" />
|
||||||
class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
|
</view>
|
||||||
@click="handleClose"
|
</view>
|
||||||
>
|
|
||||||
<wd-icon name="close" size="32rpx" class="text-gray-500" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<scroll-view :scroll-y="true" :show-scrollbar="false" class="box-border max-h-[60vh] p-4">
|
<scroll-view :scroll-y="true" :show-scrollbar="false" class="box-border max-h-[60vh] p-4">
|
||||||
<!-- 未配置信息占位 -->
|
<!-- 未配置信息占位 -->
|
||||||
<view v-if="!hasInfo" class="py-10 text-center text-xs text-gray-400">
|
<view v-if="!hasInfo" class="py-10 text-center text-xs text-gray-400">
|
||||||
暂未配置小程序申请信息
|
暂未配置小程序申请信息
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<!-- 太阳码大图(点击预览) -->
|
<!-- 太阳码大图(点击预览) -->
|
||||||
<view v-if="miniInfo.miniProgramCode" class="code-area flex flex-col items-center">
|
<view v-if="miniInfo.miniProgramCode" class="code-area flex flex-col items-center">
|
||||||
<image
|
<image class="code-img h-32 w-32 rounded-xl" :src="checkImageUrl(miniInfo.miniProgramCode)"
|
||||||
class="code-img h-32 w-32 rounded-xl"
|
mode="aspectFill" @click="handlePreviewCode" />
|
||||||
:src="checkImageUrl(miniInfo.miniProgramCode)" mode="aspectFill"
|
<view class="code-tip mt-3 flex items-center text-xs text-gray-400">
|
||||||
@click="handlePreviewCode"
|
<wd-icon name="picture" size="14px" color="#a8a294" />
|
||||||
/>
|
<text class="ml-1">点击预览太阳码</text>
|
||||||
<view class="code-tip mt-3 flex items-center text-xs text-gray-400">
|
</view>
|
||||||
<wd-icon name="picture" size="14px" color="#a8a294" />
|
</view>
|
||||||
<text class="ml-1">点击预览太阳码</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 名称 -->
|
<!-- 名称 -->
|
||||||
<view v-if="miniInfo.displayName" class="mini-head mt-5 flex items-center">
|
<view v-if="miniInfo.displayName" class="mini-head mt-5 flex items-center">
|
||||||
<text class="mini-name text-[34rpx] text-gray-900 font-bold">{{ miniInfo.displayName }}</text>
|
<text class="mini-name text-[34rpx] text-gray-900 font-bold">{{ miniInfo.displayName }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 描述 -->
|
<!-- 描述 -->
|
||||||
<view v-if="miniInfo.description" class="mini-desc mt-4 text-[28rpx] text-gray-600 leading-[1.6]">
|
<view v-if="miniInfo.description" class="mini-desc mt-4 text-[28rpx] text-gray-600 leading-[1.6]">
|
||||||
{{ miniInfo.description }}
|
{{ miniInfo.description }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 作者信息 -->
|
<!-- 作者信息 -->
|
||||||
<view
|
<view v-if="miniInfo.authorName || miniInfo.avatar || miniInfo.website"
|
||||||
v-if="miniInfo.authorName || miniInfo.avatar || miniInfo.website"
|
class="mini-author-info mt-5 flex items-center rounded-xl bg-[#f6f3ee] p-4">
|
||||||
class="mini-author-info mt-5 flex items-center rounded-xl bg-[#f6f3ee] p-4"
|
<image v-if="miniInfo.avatar" class="author-avatar h-[72rpx] w-[72rpx] shrink-0 rounded-full"
|
||||||
>
|
:src="checkAvatarUrl(miniInfo.avatar)" mode="aspectFill" />
|
||||||
<image
|
<view class="author-detail ml-4 flex flex-1 flex-col">
|
||||||
v-if="miniInfo.avatar" class="author-avatar h-[72rpx] w-[72rpx] shrink-0 rounded-full"
|
<text v-if="miniInfo.authorName" class="author-name text-[28rpx] text-gray-900 font-medium">
|
||||||
:src="checkAvatarUrl(miniInfo.avatar)" mode="aspectFill"
|
{{ miniInfo.authorName }}
|
||||||
/>
|
</text>
|
||||||
<view class="author-detail ml-4 flex flex-1 flex-col">
|
<text v-if="miniInfo.website"
|
||||||
<text
|
class="author-website mt-1 overflow-hidden truncate whitespace-nowrap text-xs text-gray-400">
|
||||||
v-if="miniInfo.authorName"
|
网站:{{ miniInfo.website }}
|
||||||
class="author-name text-[28rpx] text-gray-900 font-medium"
|
</text>
|
||||||
>
|
</view>
|
||||||
{{ miniInfo.authorName }}
|
</view>
|
||||||
</text>
|
|
||||||
<text
|
|
||||||
v-if="miniInfo.website"
|
|
||||||
class="author-website mt-1 overflow-hidden truncate whitespace-nowrap text-xs text-gray-400"
|
|
||||||
>
|
|
||||||
网站:{{ miniInfo.website }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 跳转地址 -->
|
<!-- 跳转地址 -->
|
||||||
<view v-if="miniInfo.link" class="mini-link mt-5 flex items-center justify-between rounded-xl bg-secondary p-4">
|
<view v-if="miniInfo.link"
|
||||||
<view class="link-text flex-1 overflow-hidden truncate whitespace-nowrap text-[26rpx] text-[#4d7c0f]">
|
class="mini-link mt-5 flex items-center justify-between rounded-xl bg-secondary p-4">
|
||||||
{{ miniInfo.link }}
|
<view
|
||||||
</view>
|
class="link-text flex-1 overflow-hidden truncate whitespace-nowrap text-[26rpx] text-[#4d7c0f]">
|
||||||
<text class="ml-3 shrink-0 text-[26rpx] text-[#4d7c0f] font-bold" @click="handleCopyLink">复制</text>
|
{{ miniInfo.link }}
|
||||||
</view>
|
</view>
|
||||||
|
<text class="ml-3 shrink-0 text-[26rpx] text-[#4d7c0f] font-bold" @click="handleCopyLink">复制</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 申请说明 / 邮箱 -->
|
<!-- 申请说明 / 邮箱 -->
|
||||||
<view
|
<view v-if="miniInfo.applyRemark || miniInfo.email"
|
||||||
v-if="miniInfo.applyRemark || miniInfo.email"
|
class="mini-extra mt-5 flex flex-col gap-2 rounded-xl bg-[#f6f3ee] p-4 text-xs text-gray-500">
|
||||||
class="mini-extra mt-5 flex flex-col gap-2 rounded-xl bg-[#f6f3ee] p-4 text-xs text-gray-500"
|
<view v-if="miniInfo.applyRemark">
|
||||||
>
|
<text class="text-gray-400">申请说明:</text>{{ miniInfo.applyRemark }}
|
||||||
<view v-if="miniInfo.applyRemark">
|
</view>
|
||||||
<text class="text-gray-400">申请说明:</text>{{ miniInfo.applyRemark }}
|
<view v-if="miniInfo.email">
|
||||||
</view>
|
<text class="text-gray-400">通知邮箱:</text>{{ miniInfo.email }}
|
||||||
<view v-if="miniInfo.email">
|
</view>
|
||||||
<text class="text-gray-400">通知邮箱:</text>{{ miniInfo.email }}
|
</view>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="my-6">
|
<view class="my-6">
|
||||||
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyInfo">
|
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyInfo">
|
||||||
复制小程序申请信息
|
复制小程序申请信息
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</uh-glass-popup>
|
</uh-glass-popup>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,204 +1,186 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
import { ref, watch } from 'vue'
|
||||||
* 友链申请表单弹窗(站点版,源自旧页面 pages-blog/submit-link)
|
|
||||||
* 参考小程序申请弹窗 uh-links-mini-apply 的封装方式(uh-glass-popup bottom + 表单 + 提交)
|
|
||||||
* 提交后等待站长审核,通过后展示在「站点」列表中
|
|
||||||
*/
|
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
defineOptions({
|
||||||
show?: boolean
|
options: {
|
||||||
}>(), {
|
styleIsolation: 'apply-shared'
|
||||||
show: false,
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const props = withDefaults(defineProps<{
|
||||||
(e: 'on-close', data: { isSubmit: boolean, refresh: boolean }): void
|
show ?: boolean
|
||||||
}>()
|
}>(), {
|
||||||
|
show: false,
|
||||||
|
})
|
||||||
|
|
||||||
const isShow = ref(false)
|
const emit = defineEmits<{
|
||||||
|
(e : 'on-close', data : { isSubmit : boolean, refresh : boolean }) : void
|
||||||
|
}>()
|
||||||
|
|
||||||
interface IApplyForm {
|
const isShow = ref(false)
|
||||||
name: string
|
|
||||||
url: string
|
|
||||||
logo: string
|
|
||||||
linkPageUrl: string
|
|
||||||
email: string
|
|
||||||
rssUrl: string
|
|
||||||
description: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const form = ref<IApplyForm>({
|
interface IApplyForm {
|
||||||
name: '',
|
name : string
|
||||||
url: '',
|
url : string
|
||||||
logo: '',
|
logo : string
|
||||||
linkPageUrl: '',
|
linkPageUrl : string
|
||||||
email: '',
|
email : string
|
||||||
rssUrl: '',
|
rssUrl : string
|
||||||
description: '',
|
description : string
|
||||||
})
|
}
|
||||||
|
|
||||||
const submitting = ref(false)
|
const form = ref<IApplyForm>({
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
logo: '',
|
||||||
|
linkPageUrl: '',
|
||||||
|
email: '',
|
||||||
|
rssUrl: '',
|
||||||
|
description: '',
|
||||||
|
})
|
||||||
|
|
||||||
function handleResetForm() {
|
const submitting = ref(false)
|
||||||
form.value = {
|
|
||||||
name: '',
|
|
||||||
url: '',
|
|
||||||
logo: '',
|
|
||||||
linkPageUrl: '',
|
|
||||||
email: '',
|
|
||||||
rssUrl: '',
|
|
||||||
description: '',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkIsUrl(url: string): boolean {
|
function handleResetForm() {
|
||||||
return /^https?:\/\//i.test(url)
|
form.value = {
|
||||||
}
|
name: '',
|
||||||
|
url: '',
|
||||||
|
logo: '',
|
||||||
|
linkPageUrl: '',
|
||||||
|
email: '',
|
||||||
|
rssUrl: '',
|
||||||
|
description: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkIsEmail(email: string): boolean {
|
function checkIsUrl(url : string) : boolean {
|
||||||
return /^[\w.-]+@[\w-]+(?:\.[\w-]+)+$/.test(email)
|
return /^https?:\/\//i.test(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 提交校验 */
|
function checkIsEmail(email : string) : boolean {
|
||||||
function validateForm(): boolean {
|
return /^[\w.-]+@[\w-]+(?:\.[\w-]+)+$/.test(email)
|
||||||
if (!form.value.name.trim()) {
|
}
|
||||||
uni.showToast({ icon: 'none', title: '请输入网站名称!' })
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (!checkIsUrl(form.value.url)) {
|
|
||||||
uni.showToast({ icon: 'none', title: '请输入正确的网站地址!' })
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (form.value.logo.trim() && !checkIsUrl(form.value.logo.trim())) {
|
|
||||||
uni.showToast({ icon: 'none', title: '请输入正确的Logo地址!' })
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (form.value.email.trim() && !checkIsEmail(form.value.email.trim())) {
|
|
||||||
uni.showToast({ icon: 'none', title: '请输入正确的邮箱地址!' })
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 提交申请 */
|
/** 提交校验 */
|
||||||
async function handleSubmit() {
|
function validateForm() : boolean {
|
||||||
if (!validateForm())
|
if (!form.value.name.trim()) {
|
||||||
return
|
uni.showToast({ icon: 'none', title: '请输入网站名称!' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!checkIsUrl(form.value.url)) {
|
||||||
|
uni.showToast({ icon: 'none', title: '请输入正确的网站地址!' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (form.value.logo.trim() && !checkIsUrl(form.value.logo.trim())) {
|
||||||
|
uni.showToast({ icon: 'none', title: '请输入正确的Logo地址!' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (form.value.email.trim() && !checkIsEmail(form.value.email.trim())) {
|
||||||
|
uni.showToast({ icon: 'none', title: '请输入正确的邮箱地址!' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// linksSubmitPlugin 已弃用(2026-09-08),第三方友链自助提交暂未开放;
|
/** 提交申请 */
|
||||||
// 后续可对接 Halo 官方 plugin-links link-applications 接口
|
async function handleSubmit() {
|
||||||
uni.showToast({ icon: 'none', title: '友链申请功能暂未开放,请联系站长' })
|
if (!validateForm())
|
||||||
}
|
return
|
||||||
|
|
||||||
function handleOnChange(isOpen: boolean) {
|
// 第三方友链自助提交暂未开放
|
||||||
isShow.value = isOpen
|
uni.showToast({ icon: 'none', title: '友链申请功能暂未开放,请联系站长' })
|
||||||
if (!isOpen)
|
}
|
||||||
emit('on-close', { isSubmit: false, refresh: false })
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClose(refresh = false) {
|
function handleOnChange(isOpen : boolean) {
|
||||||
isShow.value = false
|
isShow.value = isOpen
|
||||||
emit('on-close', { isSubmit: true, refresh })
|
if (!isOpen)
|
||||||
}
|
emit('on-close', { isSubmit: false, refresh: false })
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => props.show, (val) => {
|
function handleClose(refresh = false) {
|
||||||
if (!val)
|
isShow.value = false
|
||||||
return
|
emit('on-close', { isSubmit: true, refresh })
|
||||||
isShow.value = true
|
}
|
||||||
handleResetForm()
|
|
||||||
})
|
watch(() => props.show, (val) => {
|
||||||
|
if (!val)
|
||||||
|
return
|
||||||
|
isShow.value = true
|
||||||
|
handleResetForm()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<uh-glass-popup
|
<uh-glass-popup v-model="isShow" :z-index="100" position="bottom" custom-class="!border rounded-xl"
|
||||||
v-model="isShow" :z-index="100" position="bottom"
|
@close="handleClose(false)">
|
||||||
custom-class="!border rounded-xl" @close="handleClose(false)"
|
<view class="relative mb-4 box-border w-full flex items-center justify-around px-4 pt-4">
|
||||||
>
|
<view class="w-full flex flex-col gap-y-1">
|
||||||
<view class="relative mb-4 box-border w-full flex items-center justify-around px-4 pt-4">
|
<text class="text-md font-bold">申请友链</text>
|
||||||
<view class="w-full flex flex-col gap-y-1">
|
<text class="text-xs text-gray-500">提交后等待站长审核,通过后展示在「站点」列表中</text>
|
||||||
<text class="text-md font-bold">申请友链</text>
|
</view>
|
||||||
<text class="text-xs text-gray-500">提交后等待站长审核,通过后展示在「站点」列表中</text>
|
<view class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
|
||||||
</view>
|
@click="handleClose(false)">
|
||||||
<view
|
<wd-icon name="close" size="32rpx" class="text-gray-500" />
|
||||||
class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
|
</view>
|
||||||
@click="handleClose(false)"
|
</view>
|
||||||
>
|
<scroll-view :scroll-y="true" :show-scrollbar="false" class="box-border max-h-[60vh] p-4 pt-0">
|
||||||
<wd-icon name="close" size="32rpx" class="text-gray-500" />
|
<view class="mb-5 flex items-center">
|
||||||
</view>
|
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">名称 *</text>
|
||||||
</view>
|
<input v-model="form.name"
|
||||||
<scroll-view :scroll-y="true" :show-scrollbar="false" class="box-border max-h-[60vh] p-4 pt-0">
|
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
||||||
<view class="mb-5 flex items-center">
|
placeholder="请输入网站名称">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">名称 *</text>
|
</view>
|
||||||
<input
|
|
||||||
v-model="form.name"
|
|
||||||
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
|
||||||
placeholder="请输入网站名称"
|
|
||||||
>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-5 flex items-center">
|
<view class="mb-5 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">网址 *</text>
|
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">网址 *</text>
|
||||||
<input
|
<input v-model="form.url"
|
||||||
v-model="form.url"
|
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
||||||
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
placeholder="请输入网站地址">
|
||||||
placeholder="请输入网站地址"
|
</view>
|
||||||
>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-5 flex items-center">
|
<view class="mb-5 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">Logo</text>
|
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">Logo</text>
|
||||||
<input
|
<input v-model="form.logo"
|
||||||
v-model="form.logo"
|
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
||||||
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
placeholder="请输入网站Logo(选填)">
|
||||||
placeholder="请输入网站Logo(选填)"
|
</view>
|
||||||
>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-5 flex items-center">
|
<view class="mb-5 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">邮箱</text>
|
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">邮箱</text>
|
||||||
<input
|
<input v-model="form.email"
|
||||||
v-model="form.email"
|
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
||||||
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
placeholder="请输入邮箱(选填)">
|
||||||
placeholder="请输入邮箱(选填)"
|
</view>
|
||||||
>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-5 flex items-center">
|
<view class="mb-5 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">友链页面</text>
|
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">友链页面</text>
|
||||||
<input
|
<input v-model="form.linkPageUrl"
|
||||||
v-model="form.linkPageUrl"
|
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
||||||
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
placeholder="贵站友情链接页面地址(选填)">
|
||||||
placeholder="贵站友情链接页面地址(选填)"
|
</view>
|
||||||
>
|
<view class="mb-2 pl-[140rpx] text-xs text-gray-400 -mt-3">
|
||||||
</view>
|
(即包含本站链接的页面)
|
||||||
<view class="mb-2 pl-[140rpx] text-xs text-gray-400 -mt-3">
|
</view>
|
||||||
(即包含本站链接的页面)
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-5 flex items-center">
|
<view class="mb-5 flex items-center">
|
||||||
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">RSS地址</text>
|
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">RSS地址</text>
|
||||||
<input
|
<input v-model="form.rssUrl"
|
||||||
v-model="form.rssUrl"
|
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
||||||
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
|
placeholder="用于抓取文章(选填)">
|
||||||
placeholder="用于抓取文章(选填)"
|
</view>
|
||||||
>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-5">
|
<view class="mb-5">
|
||||||
<text class="label mb-2 block text-sm text-[#666]">网站描述</text>
|
<text class="label mb-2 block text-sm text-[#666]">网站描述</text>
|
||||||
<textarea
|
<textarea v-model="form.description"
|
||||||
v-model="form.description"
|
class="uh-global-card-glass box-border h-24 w-full flex-1 border rounded-xl p-3 text-sm shadow-none"
|
||||||
class="uh-global-card-glass box-border h-24 w-full flex-1 border rounded-xl p-3 text-sm shadow-none"
|
placeholder="请输入网站描述,不超过30字符(选填)" :maxlength="30" />
|
||||||
placeholder="请输入网站描述,不超过30字符(选填)" :maxlength="30"
|
</view>
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="my-6">
|
<view class="my-6">
|
||||||
<uh-button custom-class="py-2 !rounded-xl" :loading="submitting" @click="handleSubmit">
|
<uh-button custom-class="py-2 !rounded-xl" :loading="submitting" @click="handleSubmit">
|
||||||
提交申请
|
提交申请
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</uh-glass-popup>
|
</uh-glass-popup>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,123 +1,115 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
import { computed, ref, watch } from 'vue'
|
||||||
* 站点友链信息弹窗(源自旧页面 pages-blog/submit-link 的博客详情弹窗,重设计为底部玻璃弹窗)
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
* 展示本站友链交换信息(博客名片 + 复制交换信息 + 站点缩略图)
|
import { checkAvatarUrl } from '@/utils/url'
|
||||||
* 数据源为插件端 linkInfo.siteInfo 配置(字段对齐 Halo 官方友链提交 API:displayName/url/logo/description/email/backlink/feedUrls)
|
|
||||||
*/
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
|
||||||
import { checkAvatarUrl } from '@/utils/url'
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
defineOptions({
|
||||||
show?: boolean
|
options: {
|
||||||
}>(), {
|
styleIsolation: 'apply-shared'
|
||||||
show: false,
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const props = withDefaults(defineProps<{
|
||||||
(e: 'on-close'): void
|
show ?: boolean
|
||||||
}>()
|
}>(), {
|
||||||
|
show: false,
|
||||||
|
})
|
||||||
|
|
||||||
const isShow = ref(false)
|
const emit = defineEmits<{
|
||||||
const appConfigStore = useAppConfigStore()
|
(e : 'on-close') : void
|
||||||
|
}>()
|
||||||
|
|
||||||
const blogDetail = computed(() => (appConfigStore.configs.pluginConfig?.linkInfo?.siteInfo as {
|
const isShow = ref(false)
|
||||||
displayName?: string
|
const appConfigStore = useAppConfigStore()
|
||||||
url?: string
|
|
||||||
logo?: string
|
|
||||||
description?: string
|
|
||||||
backlink?: string
|
|
||||||
feedUrls?: string[]
|
|
||||||
} | undefined) || {})
|
|
||||||
|
|
||||||
/** 友链交换信息文案(复制用) */
|
const blogDetail = computed(() => (appConfigStore.configs.pluginConfig?.linkInfo?.siteInfo as {
|
||||||
const calcBlogContent = computed(() => `
|
displayName ?: string
|
||||||
博客名称:${blogDetail.value.displayName || ''}
|
url ?: string
|
||||||
博客地址:${blogDetail.value.url || ''}
|
logo ?: string
|
||||||
博客logo:${checkAvatarUrl(blogDetail.value.logo)}
|
description ?: string
|
||||||
博客简介:${blogDetail.value.description || ''}
|
backlink ?: string
|
||||||
`)
|
feedUrls ?: string[]
|
||||||
|
} | undefined) || {})
|
||||||
|
|
||||||
function calcSiteThumbnail(val?: string): string {
|
/** 友链交换信息文案(复制用) */
|
||||||
if (!val)
|
const calcBlogContent = computed(() => `
|
||||||
return ''
|
博客名称:${blogDetail.value.displayName || ''}
|
||||||
const _val = val.endsWith('/') ? val : `${val}/`
|
博客地址:${blogDetail.value.url || ''}
|
||||||
return `https://image.thum.io/get/width/1000/crop/800/${_val}`
|
博客logo:${checkAvatarUrl(blogDetail.value.logo)}
|
||||||
}
|
博客简介:${blogDetail.value.description || ''}
|
||||||
|
`)
|
||||||
|
|
||||||
function handleCopyLink() {
|
function calcSiteThumbnail(val ?: string) : string {
|
||||||
uni.setClipboardData({
|
if (!val) { return '' }
|
||||||
data: calcBlogContent.value,
|
const _val = val.endsWith('/') ? val : `${val}/`
|
||||||
showToast: false,
|
return `https://image.thum.io/get/width/1000/crop/800/${_val}`
|
||||||
success: () => {
|
}
|
||||||
uni.showToast({ icon: 'none', title: '复制成功!' })
|
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
uni.showToast({ icon: 'none', title: '复制失败!' })
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClose() {
|
function handleCopyLink() {
|
||||||
isShow.value = false
|
uni.setClipboardData({
|
||||||
emit('on-close')
|
data: calcBlogContent.value,
|
||||||
}
|
showToast: false,
|
||||||
|
success: () => {
|
||||||
|
uni.showToast({ icon: 'none', title: '复制成功!' })
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.showToast({ icon: 'none', title: '复制失败!' })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => props.show, (val) => {
|
function handleClose() {
|
||||||
isShow.value = val
|
isShow.value = false
|
||||||
})
|
emit('on-close')
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.show, (val) => {
|
||||||
|
isShow.value = val
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<uh-glass-popup
|
<uh-glass-popup v-model="isShow" :z-index="100" position="bottom" custom-class="!border rounded-xl"
|
||||||
v-model="isShow" :z-index="100" position="bottom"
|
@close="handleClose">
|
||||||
custom-class="!border rounded-xl" @close="handleClose"
|
<view class="relative box-border w-full flex items-center justify-around px-4 pt-4">
|
||||||
>
|
<view class="w-full flex flex-col gap-y-1">
|
||||||
<view class="relative box-border w-full flex items-center justify-around px-4 pt-4">
|
<text class="text-md font-bold">友链信息</text>
|
||||||
<view class="w-full flex flex-col gap-y-1">
|
<text class="text-xs text-gray-500">本站友链交换信息,欢迎申请互换友链</text>
|
||||||
<text class="text-md font-bold">友链信息</text>
|
</view>
|
||||||
<text class="text-xs text-gray-500">本站友链交换信息,欢迎申请互换友链</text>
|
<view class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
|
||||||
</view>
|
@click="handleClose">
|
||||||
<view
|
<wd-icon name="close" size="32rpx" class="text-gray-500" />
|
||||||
class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
|
</view>
|
||||||
@click="handleClose"
|
</view>
|
||||||
>
|
<scroll-view :scroll-y="true" :show-scrollbar="false" class="box-border max-h-[60vh] p-4">
|
||||||
<wd-icon name="close" size="32rpx" class="text-gray-500" />
|
<!-- 博客名片 -->
|
||||||
</view>
|
<view class="flex items-center">
|
||||||
</view>
|
<image class="uh-global-card-glass h-20 w-20 shrink-0 rounded-2xl"
|
||||||
<scroll-view :scroll-y="true" :show-scrollbar="false" class="box-border max-h-[60vh] p-4">
|
:src="checkAvatarUrl(blogDetail.logo)" mode="aspectFill" />
|
||||||
<!-- 博客名片 -->
|
<view class="ml-4 flex flex-1 flex-col justify-center gap-y-1">
|
||||||
<view class="flex items-center">
|
<text class="text-md text-gray-900 font-bold">
|
||||||
<image
|
{{ blogDetail.displayName || '未命名博客' }}
|
||||||
class="uh-global-card-glass h-20 w-20 shrink-0 rounded-2xl"
|
</text>
|
||||||
:src="checkAvatarUrl(blogDetail.logo)" mode="aspectFill"
|
<text class="text-xs text-gray-500">
|
||||||
/>
|
{{ blogDetail.description || '这个博主很懒,没写简介~' }}
|
||||||
<view class="ml-4 flex flex-1 flex-col justify-center gap-y-1">
|
</text>
|
||||||
<text class="text-md text-gray-900 font-bold">
|
</view>
|
||||||
{{ blogDetail.displayName || '未命名博客' }}
|
</view>
|
||||||
</text>
|
|
||||||
<text class="text-xs text-gray-500">
|
|
||||||
{{ blogDetail.description || '这个博主很懒,没写简介~' }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 交换信息文案 -->
|
<!-- 交换信息文案 -->
|
||||||
<view class="mt-4 whitespace-pre-wrap text-xs text-gray-600 leading-5">
|
<view class="mt-4 whitespace-pre-wrap text-xs text-gray-600 leading-5">
|
||||||
<text>{{ calcBlogContent }}</text>
|
<text>{{ calcBlogContent }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 站点缩略图 -->
|
<!-- 站点缩略图 -->
|
||||||
<image
|
<image v-if="blogDetail.url" class="mt-4 h-[320rpx] w-full rounded-xl"
|
||||||
v-if="blogDetail.url" class="mt-4 h-[320rpx] w-full rounded-xl"
|
:src="calcSiteThumbnail(blogDetail.url)" mode="aspectFill" />
|
||||||
:src="calcSiteThumbnail(blogDetail.url)" mode="aspectFill"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<view class="my-6">
|
<view class="my-6">
|
||||||
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyLink">
|
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyLink">
|
||||||
复制友链交换信息
|
复制友链交换信息
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</uh-glass-popup>
|
</uh-glass-popup>
|
||||||
</template>
|
</template>
|
||||||
@@ -2,6 +2,12 @@
|
|||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { markdownConfig } from '@/config/markdown'
|
import { markdownConfig } from '@/config/markdown'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
modelValue ?: boolean
|
modelValue ?: boolean
|
||||||
content ?: string
|
content ?: string
|
||||||
@@ -30,18 +36,18 @@
|
|||||||
<uh-glass-popup v-model="show" position="bottom" :z-index="100" :safe-area-inset-bottom="true"
|
<uh-glass-popup v-model="show" position="bottom" :z-index="100" :safe-area-inset-bottom="true"
|
||||||
custom-class="rounded-xl">
|
custom-class="rounded-xl">
|
||||||
<view class="box-border px-4 py-4 text-center">
|
<view class="box-border px-4 py-4 text-center">
|
||||||
<text class="text-md text-gray-900 font-bold">
|
<text class="text-sm text-gray-900 font-bold">
|
||||||
维护详情
|
维护详情
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<scroll-view scroll-y :show-scrollbar="false"
|
<scroll-view scroll-y :show-scrollbar="false"
|
||||||
class="box-border max-h-[60vh] px-4 text-sm text-gray-900 leading-5">
|
class="box-border max-h-[60vh] px-4 text-2xs text-gray-900 leading-5">
|
||||||
<mp-html :content="content" lazy-load :domain="markdownConfig.domain" scroll-table selectable
|
<mp-html :content="content" lazy-load :domain="markdownConfig.domain" scroll-table selectable
|
||||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||||
copy-by-long-press />
|
copy-by-long-press />
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<view class="w-full box-border flex items-center p-3">
|
<view class="w-full box-border flex items-center p-3">
|
||||||
<uh-button custom-class="flex-1 shadow-none bg-white text-primary" @click="close()">关闭</uh-button>
|
<uh-button class="w-full flex-1" custom-class="w-full flex-1 shadow-none bg-white text-primary" @click="close()">关闭</uh-button>
|
||||||
</view>
|
</view>
|
||||||
</uh-glass-popup>
|
</uh-glass-popup>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,39 +1,42 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onPageScroll } from '@dcloudio/uni-app'
|
import { computed, ref } from 'vue'
|
||||||
import { ref, computed, useSlots, onMounted } from 'vue'
|
|
||||||
import { tabbarList } from '@/tabbar/config'
|
import { tabbarList } from '@/tabbar/config'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
useBack : boolean;
|
useBack : boolean
|
||||||
useTitle : boolean;
|
useTitle : boolean
|
||||||
defaultTitle ?: string;
|
defaultTitle ?: string
|
||||||
titleColor ?: string;
|
titleColor ?: string
|
||||||
scrollTitle ?: string;
|
scrollTitle ?: string
|
||||||
needPlaceholder ?: boolean;
|
needPlaceholder ?: boolean
|
||||||
backClass ?: string;
|
backClass ?: string
|
||||||
backStyle ?: string;
|
backStyle ?: string
|
||||||
|
scrollY ?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<IProps>(), {
|
const props = withDefaults(defineProps<IProps>(), {
|
||||||
useBack: true,
|
useBack: true,
|
||||||
useTitle: true,
|
useTitle: true,
|
||||||
needPlaceholder: true,
|
needPlaceholder: true,
|
||||||
backClass: 'text-gray-900'
|
backClass: 'text-gray-900',
|
||||||
})
|
})
|
||||||
|
|
||||||
const slots = useSlots()
|
const maxAlpha = ref(0.75)
|
||||||
|
|
||||||
const scrollY = ref(0)
|
|
||||||
const maxAlpha = ref(0.65)
|
|
||||||
|
|
||||||
const customStyle = computed(() => {
|
const customStyle = computed(() => {
|
||||||
const alpha = Math.min(scrollY.value / 360, maxAlpha.value)
|
const alpha = Math.min(props.scrollY / 360, maxAlpha.value)
|
||||||
return {
|
return {
|
||||||
|
backdropFilter: 'blur(2rpx)',
|
||||||
backgroundColor: `rgba(255, 255, 255, ${alpha})`,
|
backgroundColor: `rgba(255, 255, 255, ${alpha})`,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const scrollThreshold = computed(() => {
|
const scrollThreshold = computed(() => {
|
||||||
return scrollY.value / 360 <= 0.5;
|
return props.scrollY / 360 <= 0.5
|
||||||
})
|
})
|
||||||
|
|
||||||
const customCalss = computed(() => {
|
const customCalss = computed(() => {
|
||||||
@@ -44,7 +47,7 @@
|
|||||||
else {
|
else {
|
||||||
_class.push('text-gray-900')
|
_class.push('text-gray-900')
|
||||||
}
|
}
|
||||||
return _class;
|
return _class
|
||||||
})
|
})
|
||||||
|
|
||||||
const titleColorClass = computed(() => {
|
const titleColorClass = computed(() => {
|
||||||
@@ -53,12 +56,12 @@
|
|||||||
|
|
||||||
const visibleTitle = computed(() => {
|
const visibleTitle = computed(() => {
|
||||||
if (!props.scrollTitle) {
|
if (!props.scrollTitle) {
|
||||||
return props.defaultTitle;
|
return props.defaultTitle
|
||||||
}
|
}
|
||||||
if (scrollThreshold.value) {
|
if (scrollThreshold.value) {
|
||||||
return props.defaultTitle;
|
return props.defaultTitle
|
||||||
}
|
}
|
||||||
return props.scrollTitle;
|
return props.scrollTitle
|
||||||
})
|
})
|
||||||
|
|
||||||
// 如果是从分享进来的,我们需要处理为返回 home页面
|
// 如果是从分享进来的,我们需要处理为返回 home页面
|
||||||
@@ -69,52 +72,45 @@
|
|||||||
homePage,
|
homePage,
|
||||||
'pages/maintenance/maintenance',
|
'pages/maintenance/maintenance',
|
||||||
...tabbarList.map((item : any) => item.pagePath),
|
...tabbarList.map((item : any) => item.pagePath),
|
||||||
] as string[];
|
] as string[]
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
const currentPage = getCurrentPages()[0]
|
const currentPage = getCurrentPages()[0]
|
||||||
if (!allEntryPages.value.some(pagePath => pagePath == currentPage.route)) {
|
if (!allEntryPages.value.some(pagePath => pagePath == currentPage.route)) {
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: `/${homePage}`
|
url: `/${homePage}`,
|
||||||
})
|
})
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
uni.navigateBack({ delta: 1 })
|
uni.navigateBack({ delta: 1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
onPageScroll((e : any) => {
|
|
||||||
scrollY.value = e.scrollTop
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="w-full box-border">
|
<view class="fixed left-0 top-0 z-100 box-border w-full pt-safe" :class="customCalss" :style="[customStyle]">
|
||||||
<view class="box-border pt-safe w-full fixed left-0 top-0 z-100" :class="customCalss" :style="[customStyle]">
|
<view class="box-border h-[46px] w-full flex items-center gap-x-4 px-3">
|
||||||
<view class="w-full h-[46px] flex items-center gap-x-4 box-border px-3 backdrop-blur-[2rpx]">
|
<!-- 左边 -->
|
||||||
<!-- 左边 -->
|
<view class="min-w-18 shrink-0" @click="handleBack()">
|
||||||
<view class="shrink-0 min-w-18" @click="handleBack()">
|
<view v-if="props.useBack"
|
||||||
<view v-if="props.useBack"
|
class="uh-global-card-glass uh-shadow-xs h-8 flex items-center gap-x-2 border rounded-full px-3 text-sm"
|
||||||
class="uh-global-card-glass uh-shadow-xs h-8 px-3 rounded-full border flex items-center gap-x-2 text-sm"
|
:class="props.backClass" :style="[props.backStyle]">
|
||||||
:class="props.backClass" :style="[props.backStyle]">
|
<wd-icon name="arrow-left" size="30rpx" />
|
||||||
<wd-icon name="arrow-left" size="34rpx"></wd-icon>
|
<view class="h-4 w-[1px] bg-white/60" />
|
||||||
<view class="w-[1px] h-4 bg-white/60" />
|
<text class="text-[26rpx] font-bold">返回</text>
|
||||||
<text class="text-sm font-bold">返回</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<!-- 中间 -->
|
|
||||||
<view class="flex-1 truncate text-center font-bold transition-colors duration-300"
|
|
||||||
:class="titleColorClass">
|
|
||||||
<slot> {{visibleTitle}} </slot>
|
|
||||||
</view>
|
|
||||||
<!-- 右边 -->
|
|
||||||
<view class="shrink-0 min-w-18">
|
|
||||||
<slot name="right"></slot>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<!-- 中间 -->
|
||||||
<view v-if="props.needPlaceholder" class="box-border w-full pt-safe">
|
<view class="flex-1 truncate text-center font-bold transition-colors duration-300" :class="titleColorClass">
|
||||||
<view class="w-full h-[46px]"></view>
|
<slot> {{ visibleTitle }} </slot>
|
||||||
|
</view>
|
||||||
|
<!-- 右边 -->
|
||||||
|
<view class="min-w-18 shrink-0">
|
||||||
|
<slot name="right" />
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-if="props.needPlaceholder" class="box-border w-full pt-safe">
|
||||||
|
<view class="h-[46px] w-full" />
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -78,21 +78,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<uh-glass-popup v-model="isShow" position="center" :z-index="9999" custom-class="rounded-xl" @close="handleClose">
|
<uh-glass-popup v-model="isShow" position="center" :z-index="9999" custom-class="rounded-xl" @close="handleClose">
|
||||||
<view v-if="notice" class="box-border w-[80vw] p-4">
|
<view v-if="notice" class="box-border w-[80vw] p-4">
|
||||||
<!-- 头部:标题 + 关闭 -->
|
|
||||||
<view class="flex items-center justify-between">
|
<view class="flex items-center justify-between">
|
||||||
<view class="flex items-center gap-2">
|
<view class="flex items-center gap-2">
|
||||||
<wd-icon class-prefix="uhemoji2-icon" name="-happy-" size="36rpx" />
|
<wd-icon class-prefix="uhemoji2-icon" name="-happy-" size="36rpx" />
|
||||||
<text class="text-md font-bold text-gray-900">
|
<text class="text-md font-semibold text-gray-900">
|
||||||
最新公告
|
最新公告
|
||||||
</text>
|
</text>
|
||||||
<view v-if="notice.typeDisplayName" class="rounded px-1.5 py-0.5 text-xs" :style="{
|
<view v-if="notice.typeDisplayName" class="rounded px-1.5 py-0.5 text-xs text-primary bg-gray-100"
|
||||||
color: notice.typeColor || '#f83856',
|
:style="{
|
||||||
backgroundColor: notice.typeColor ? `${notice.typeColor}1a` : '#fdeef1',
|
color: notice.typeColor,
|
||||||
|
backgroundColor: notice.typeColor ? `${notice.typeColor}1a` : '',
|
||||||
}">
|
}">
|
||||||
{{ notice.typeDisplayName }}
|
{{ notice.typeDisplayName }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="uh-global-card-glass !bg-white/5 border flex h-6 w-6 rounded-lg items-center justify-center text-gray-500" @click="handleClose">
|
<view
|
||||||
|
class="uh-global-card-glass !bg-white/5 border flex h-6 w-6 rounded-lg items-center justify-center text-gray-500"
|
||||||
|
@click="handleClose">
|
||||||
<wd-icon name="close" size="16px" />
|
<wd-icon name="close" size="16px" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -101,13 +103,13 @@
|
|||||||
<view class="mt-4">
|
<view class="mt-4">
|
||||||
<image v-if="notice.cover" :src="checkImageUrl(notice.cover)" class="w-full h-34 rounded-lg mb-2">
|
<image v-if="notice.cover" :src="checkImageUrl(notice.cover)" class="w-full h-34 rounded-lg mb-2">
|
||||||
</image>
|
</image>
|
||||||
<view class="text-md font-bold leading-snug text-gray-900">
|
<view class="text-sm font-bold leading-snug text-gray-900">
|
||||||
{{ notice.title }}
|
{{ notice.title }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="notice.summary" class="mt-3 text-sm leading-relaxed text-gray-500">
|
<view v-if="notice.summary" class="mt-3 text-xs leading-relaxed text-gray-900">
|
||||||
{{ notice.summary }}
|
{{ notice.summary }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="notice.publishTime" class="mt-3 text-xs text-gray-400">
|
<view v-if="notice.publishTime" class="mt-3 text-xs text-gray-600">
|
||||||
日期:{{ formatDate(notice.publishTime) }}
|
日期:{{ formatDate(notice.publishTime) }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -117,7 +119,7 @@
|
|||||||
<view class="text-xs text-gray-600 " @click="handleDismissForever">
|
<view class="text-xs text-gray-600 " @click="handleDismissForever">
|
||||||
今日不再提醒
|
今日不再提醒
|
||||||
</view>
|
</view>
|
||||||
<uh-button custom-class="font-semibold text-xs" @click="handleViewAll">
|
<uh-button custom-class="text-xs" @click="handleViewAll">
|
||||||
查看全文 →
|
查看全文 →
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
|
|
||||||
|
const {configs} = storeToRefs(useAppConfigStore())
|
||||||
|
const copyrightConfig = computed(() => configs.value?.pageConfig?.aboutConfig?.copyrightConfig)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view v-if="copyrightConfig?.enabled" class="box-border mt-6 px-6 text-center text-xs text-gray-400">
|
||||||
|
<text>{{copyrightConfig.content }}</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
@@ -31,24 +31,24 @@
|
|||||||
class="max-w-3/5 mx-auto my-auto box-border flex flex-col items-center justify-center gap-6 text-sm"
|
class="max-w-3/5 mx-auto my-auto box-border flex flex-col items-center justify-center gap-6 text-sm"
|
||||||
:class="props.customClass">
|
:class="props.customClass">
|
||||||
|
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-cry" size="160rpx"></wd-icon>
|
<wd-icon class-prefix="uhemoji-icon" name="-cry" size="140rpx"></wd-icon>
|
||||||
|
|
||||||
<view class="box-border text-lg text-gray-900 font-bold">
|
<view class="box-border text-sm text-gray-900 font-bold">
|
||||||
{{ pluginInfo.name }}
|
{{ pluginInfo.name }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="errorText" class=" text-yellow-500 text-sm">
|
<view v-if="errorText" class="text-yellow-500 text-2xs">
|
||||||
{{ errorText }}
|
{{ errorText }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="w-full flex flex-col gap-y-4">
|
<view class="w-full flex flex-col gap-y-4">
|
||||||
<uh-button custom-class="!rounded-full py-2 !uh-shadow-xs" @click="handleRefresh()">
|
<uh-button custom-class="!rounded-full text-xs py-2 !uh-shadow-xs" @click="handleRefresh()">
|
||||||
{{props.checking?'正在刷新':'刷新试试'}}
|
{{props.checking?'正在刷新':'刷新试试'}}
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
<!-- #ifdef MP-WEIXIN -->
|
||||||
<!-- 微信端客服会话只能由原生 button 的 open-type="contact" 唤起,故此处不用 uh-button(view 实现) -->
|
<!-- 微信端客服会话只能由原生 button 的 open-type="contact" 唤起,故此处不用 uh-button(view 实现) -->
|
||||||
<button
|
<button
|
||||||
class="uh-contact-btn bg-white py-2 px-4 !rounded-full text-black text-sm leading-none flex items-center justify-center"
|
class="uh-contact-btn w-full bg-white py-2.5 px-4 !rounded-full text-black text-xs leading-none flex items-center justify-center"
|
||||||
open-type="contact" hover-class="none">提交反馈</button>
|
open-type="contact" hover-class="none">提交反馈</button>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 受限阅读骨架屏(源自旧项目 components/restrict-read-skeleton,新建复刻)
|
* 受限阅读骨架屏
|
||||||
* 受限内容遮挡 + 提示文字 + 验证按钮
|
* 受限内容遮挡 + 提示文字 + 验证按钮
|
||||||
*/
|
*/
|
||||||
withDefaults(defineProps<{
|
withDefaults(defineProps<{
|
||||||
@@ -74,7 +74,7 @@ function onTouchEnd() {
|
|||||||
<slot />
|
<slot />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="showButton" class="button-container absolute left-1/2 top-1/2 z-2 flex flex-col items-center -translate-x-1/2 -translate-y-1/2">
|
<view v-if="showButton" class="button-container absolute left-1/2 top-1/2 z-2 flex flex-col items-center uh-translate-center">
|
||||||
<text
|
<text
|
||||||
v-if="tipText"
|
v-if="tipText"
|
||||||
class="tip-text mb-5 text-center leading-[1.4]"
|
class="tip-text mb-5 text-center leading-[1.4]"
|
||||||
@@ -154,4 +154,9 @@ function onTouchEnd() {
|
|||||||
background-position: 0 50%;
|
background-position: 0 50%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 完全居中定位 */
|
||||||
|
.uh-translate-center {
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSlots } from 'vue'
|
|
||||||
const slots = useSlots();
|
|
||||||
const hasRightSlot = computed(() => !!slots.right?.())
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="w-full flex items-center justify-between">
|
<view class="w-full flex items-center justify-between">
|
||||||
<view class="shrink-0 relative">
|
<view class="relative shrink-0">
|
||||||
<text class="font-bold relative z-2">
|
<text class="relative z-2 text-2xs font-semibold">
|
||||||
<slot></slot>
|
<slot />
|
||||||
</text>
|
</text>
|
||||||
<view class="absolute z-1 -right-1 -bottom-0.5 rounded-xl bg-secondary h-4 w-4/5"></view>
|
<view class="absolute z-1 h-4 w-4/5 rounded-xl bg-secondary -bottom-0.5 -right-1" />
|
||||||
</view>
|
</view>
|
||||||
<view v-if="hasRightSlot" class="flex-1 flex items-center justify-end">
|
<view class="flex flex-1 items-center justify-end">
|
||||||
<slot name="right"></slot>
|
<slot name="right" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
fixed ?: boolean;
|
fixed ?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emits = defineEmits<{
|
||||||
|
(e : 'action-click') : void
|
||||||
|
}>()
|
||||||
|
|
||||||
const props = withDefaults(defineProps<IProps>(), {
|
const props = withDefaults(defineProps<IProps>(), {
|
||||||
customClass: '',
|
customClass: '',
|
||||||
fixed: true,
|
fixed: true,
|
||||||
@@ -17,10 +21,15 @@
|
|||||||
const visible = computed(() => {
|
const visible = computed(() => {
|
||||||
return whiteList.includes(currentPage.route)
|
return whiteList.includes(currentPage.route)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function handleClick() {
|
||||||
|
emits('action-click')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view v-if="visible" :class="[props.fixed?'fixed bottom-22 right-3 z-50 pb-safe':'',props.containerClass]">
|
<view v-if="visible" :class="[props.fixed?'fixed bottom-22 right-3 z-50 pb-safe':'',props.containerClass]"
|
||||||
|
@click="handleClick">
|
||||||
<view class="uh-global-card-glass border h-11 w-11 flex items-center justify-center rounded-full text-primary"
|
<view class="uh-global-card-glass border h-11 w-11 flex items-center justify-center rounded-full text-primary"
|
||||||
:class="props.customClass">
|
:class="props.customClass">
|
||||||
<wd-icon name="settings" size="42rpx" />
|
<wd-icon name="settings" size="42rpx" />
|
||||||
|
|||||||
@@ -2,9 +2,23 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useSettingStore } from '@/store/setting'
|
import { useSettingStore } from '@/store/setting'
|
||||||
import { usePreferenceRows } from '@/hooks/usePreferenceRows'
|
import { usePreferenceRows } from '@/hooks/usePreferenceRows'
|
||||||
import { useSettingsPopup } from '@/hooks/useSettingsPopup'
|
import { isWechat } from '@/utils/platform'
|
||||||
|
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
/** v-model:是否显示 */
|
||||||
|
modelValue : boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<IProps>()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
SETTING_TABS,
|
SETTING_TABS,
|
||||||
layoutGroups,
|
layoutGroups,
|
||||||
@@ -17,13 +31,21 @@
|
|||||||
isCardTypeOptionDisabled,
|
isCardTypeOptionDisabled,
|
||||||
} = usePreferenceRows()
|
} = usePreferenceRows()
|
||||||
|
|
||||||
const { settingsPopupVisible } = useSettingsPopup()
|
interface IEmits {
|
||||||
|
(e : 'update:modelValue', value : boolean) : void,
|
||||||
|
}
|
||||||
|
|
||||||
const emits = defineEmits(['close', 'open'])
|
const emits = defineEmits<IEmits>()
|
||||||
|
|
||||||
|
/** v-model 代理:将 uh-glass-popup 的 modelValue 转发给父组件,避免直接写 readonly props */
|
||||||
|
const popupVisible = computed({
|
||||||
|
get : () => props.modelValue,
|
||||||
|
set : (value : boolean) => emits('update:modelValue', value),
|
||||||
|
})
|
||||||
|
|
||||||
const activeTab = ref<'layout' | 'feature'>('layout')
|
const activeTab = ref<'layout' | 'feature'>('layout')
|
||||||
|
|
||||||
// 进行过滤,只保留当前页面的布局和功能
|
// 进行过滤,只保留当前页面的布局和功能
|
||||||
const pages = getCurrentPages()
|
const pages = getCurrentPages()
|
||||||
const currentPage = pages[pages.length - 1]
|
const currentPage = pages[pages.length - 1]
|
||||||
const filterLayoutGroups = computed(() => {
|
const filterLayoutGroups = computed(() => {
|
||||||
@@ -59,23 +81,20 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClose() {
|
function handleClose() {
|
||||||
emits('close')
|
emits('update:modelValue', false)
|
||||||
}
|
|
||||||
function onOpen() {
|
|
||||||
emits('open')
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<uh-glass-popup v-model="settingsPopupVisible" position="bottom" custom-class="rounded-xl !border"
|
<uh-glass-popup v-model="popupVisible" position="bottom" custom-class="rounded-xl !border"
|
||||||
safe-area-inset-bottom :z-index="110" hide-when-close @close="onClose" @open="onOpen">
|
safe-area-inset-bottom :z-index="110" hide-when-close>
|
||||||
<view class="box-border px-3 pt-3">
|
<view class="box-border px-3 pt-3">
|
||||||
<view class="mb-3 flex items-center justify-between">
|
<view class="mb-3 flex items-center justify-between">
|
||||||
<text class="text-md font-bold">偏好设置</text>
|
<text class="text-md font-bold">偏好设置</text>
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass shadow-none !bg-white/5 border flex h-6 w-6 items-center justify-center rounded-lg text-gray-500"
|
class="uh-global-card-glass shadow-none !bg-white/5 border flex h-6 w-6 items-center justify-center rounded-lg text-gray-500"
|
||||||
@click="onClose()">
|
@click="handleClose()">
|
||||||
<wd-icon name="close" size="16px" />
|
<wd-icon name="close" size="16px" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -123,8 +142,7 @@
|
|||||||
:class="[
|
:class="[
|
||||||
currentValueOf(row.path) === opt.value ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500',
|
currentValueOf(row.path) === opt.value ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500',
|
||||||
isCardTypeOptionDisabled(row.path, opt.value) ? 'opacity-40' : ''
|
isCardTypeOptionDisabled(row.path, opt.value) ? 'opacity-40' : ''
|
||||||
]"
|
]" @click="isCardTypeOptionDisabled(row.path, opt.value) ? null : handleInlineChoose(row.path, opt.value)">
|
||||||
@click="isCardTypeOptionDisabled(row.path, opt.value) ? null : handleInlineChoose(row.path, opt.value)">
|
|
||||||
{{ opt.label }}
|
{{ opt.label }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -148,9 +166,11 @@
|
|||||||
<view v-if="row.kind === 'bool'" class="box-border p-3"
|
<view v-if="row.kind === 'bool'" class="box-border p-3"
|
||||||
:class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''">
|
:class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''">
|
||||||
<view class="flex items-center justify-between">
|
<view class="flex items-center justify-between">
|
||||||
<text class="row-label text-sm text-gray-900 font-bold">{{ row.label }}</text>
|
<text
|
||||||
|
class="row-label text-sm text-gray-900 font-bold">{{ row.label }}</text>
|
||||||
<view class="flex items-center gap-2">
|
<view class="flex items-center gap-2">
|
||||||
<text v-if="row.following" class="row-sub text-2xs text-gray-400">默认</text>
|
<text v-if="row.following"
|
||||||
|
class="row-sub text-2xs text-gray-400">默认</text>
|
||||||
<view v-else
|
<view v-else
|
||||||
class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">
|
class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">
|
||||||
已自定义
|
已自定义
|
||||||
@@ -215,12 +235,13 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<!-- 底部操作栏 -->
|
<!-- 底部操作栏 -->
|
||||||
<view class="box-border w-full pb-4 pt-3 flex items-center gap-x-2">
|
<view class="box-border w-full pt-3 flex items-center gap-x-2" :class="[isWechat?'':'pb-3']">
|
||||||
<uh-button custom-class="flex-1 uh-global-card-glass bg-white/90 border py-2 !rounded-xl"
|
<uh-button class="flex-1" custom-class="flex-1 uh-global-card-glass bg-white/90 border py-2 !rounded-xl"
|
||||||
@click="onClose()">
|
@click="handleClose()">
|
||||||
关闭
|
关闭
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<uh-button custom-class="flex-1 uh-global-card-glass border py-2 !rounded-xl" @click="handleResetAll">
|
<uh-button class="flex-1" custom-class="flex-1 uh-global-card-glass border py-2 !rounded-xl"
|
||||||
|
@click="handleResetAll">
|
||||||
恢复默认
|
恢复默认
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
}
|
}
|
||||||
const props = withDefaults(defineProps<IProps>(), {
|
const props = withDefaults(defineProps<IProps>(), {
|
||||||
customClass: '',
|
customClass: '',
|
||||||
lineClass: '!h-2/5 -rotate-5',
|
lineClass: '!h-2/5 uh-rotate-n5',
|
||||||
textClass: 'font-bold'
|
textClass: 'font-bold'
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -20,3 +20,9 @@
|
|||||||
</text>
|
</text>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
/* 下划线轻微旋转 */
|
||||||
|
.uh-rotate-n5 {
|
||||||
|
transform: rotate(-5deg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { getPluginCaptcha } from '@/api/uni-halo'
|
||||||
|
import type { ICaptchaQuery, IPluginCaptcha } from '@/api/uni-halo'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
styleIsolation: 'apply-shared'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
show : boolean
|
||||||
|
/** 弹窗标题(如"解锁相册"/"请输入访问密码") */
|
||||||
|
title ?: string
|
||||||
|
/** 提示文案(如"此相册已加密,请输入密码查看") */
|
||||||
|
tip ?: string
|
||||||
|
/** 密码输入占位符 */
|
||||||
|
placeholder ?: string
|
||||||
|
/** 确认按钮文案 */
|
||||||
|
confirmText ?: string
|
||||||
|
/** 是否可关闭(强制解锁场景传 false:隐藏关闭按钮/取消按钮,点遮罩不关) */
|
||||||
|
closeable ?: boolean
|
||||||
|
/** 是否启用防刷验证码(受保护写接口 403 附新码时展示) */
|
||||||
|
captchaEnabled ?: boolean
|
||||||
|
/** 解锁请求函数(父组件注入具体接口;返回含 token 的对象表示成功) */
|
||||||
|
request ?: (password : string, captcha ?: ICaptchaQuery | null) => Promise<{ token ?: string, [key : string] : unknown } | null | undefined>
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<IProps>(), {
|
||||||
|
title: '解锁',
|
||||||
|
tip: '',
|
||||||
|
placeholder: '请输入密码',
|
||||||
|
confirmText: '解锁',
|
||||||
|
closeable: true,
|
||||||
|
captchaEnabled: false,
|
||||||
|
request: undefined,
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e : 'update:show', show : boolean) : void
|
||||||
|
(e : 'success', data : { token ?: string, [key : string] : unknown }) : void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const isShow = ref(false)
|
||||||
|
const password = ref('')
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
// 防刷验证码(服务端 403 附新码 / 主动刷新;captchaEnabled 时启用)
|
||||||
|
const captchaImage = ref('')
|
||||||
|
const captchaId = ref('')
|
||||||
|
const captchaCode = ref('')
|
||||||
|
const captchaLoading = ref(false)
|
||||||
|
|
||||||
|
const captchaSrc = computed(() => {
|
||||||
|
if (!captchaImage.value)
|
||||||
|
return ''
|
||||||
|
return captchaImage.value.startsWith('data:')
|
||||||
|
? captchaImage.value
|
||||||
|
: `data:image/png;base64,${captchaImage.value}`
|
||||||
|
})
|
||||||
|
|
||||||
|
function resetCaptcha() {
|
||||||
|
captchaImage.value = ''
|
||||||
|
captchaId.value = ''
|
||||||
|
captchaCode.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 用服务端返回的验证码(403 响应体附新码)填充展示 */
|
||||||
|
function applyCaptcha(captcha : IPluginCaptcha) {
|
||||||
|
captchaImage.value = captcha.imageBase64
|
||||||
|
captchaId.value = captcha.id
|
||||||
|
captchaCode.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 点击验证码图刷新 */
|
||||||
|
async function handleRefreshCaptcha() {
|
||||||
|
if (captchaLoading.value) { return }
|
||||||
|
captchaLoading.value = true
|
||||||
|
try {
|
||||||
|
const res = await getPluginCaptcha()
|
||||||
|
if (res.data) { applyCaptcha(res.data) }
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error('获取验证码失败', e)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
captchaLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// immediate:组件 v-if 条件创建时 show 可能已为 true,需立即同步(如相册解锁弹窗)
|
||||||
|
watch(() => props.show, (val) => {
|
||||||
|
isShow.value = val
|
||||||
|
if (val) {
|
||||||
|
password.value = ''
|
||||||
|
resetCaptcha()
|
||||||
|
// 插件端开启验证码时打开即拉取显示,避免首次提交 403 后才出现
|
||||||
|
if (props.captchaEnabled) {
|
||||||
|
handleRefreshCaptcha()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
|
/** 弹窗开关同步(遮罩/关闭按钮/取消):关闭时复位输入并通知父组件 */
|
||||||
|
function handleOnPopupClose(val : boolean) {
|
||||||
|
isShow.value = val
|
||||||
|
if (!val) {
|
||||||
|
password.value = ''
|
||||||
|
resetCaptcha()
|
||||||
|
}
|
||||||
|
emit('update:show', val)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleOnCancel() {
|
||||||
|
handleOnPopupClose(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleOnConfirm() {
|
||||||
|
if (loading.value)
|
||||||
|
return
|
||||||
|
if (!password.value.trim()) {
|
||||||
|
uni.showToast({ title: '请输入密码', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!props.request) {
|
||||||
|
uni.showToast({ title: '未配置解锁请求', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const captchaQuery : ICaptchaQuery | undefined = props.captchaEnabled && captchaImage.value
|
||||||
|
? { captchaId: captchaId.value, captchaCode: captchaCode.value }
|
||||||
|
: undefined
|
||||||
|
const res = await props.request(password.value, captchaQuery)
|
||||||
|
if (res && res.token) {
|
||||||
|
password.value = ''
|
||||||
|
resetCaptcha()
|
||||||
|
isShow.value = false
|
||||||
|
emit('update:show', false)
|
||||||
|
emit('success', res)
|
||||||
|
uni.showToast({ title: '解锁成功', icon: 'success' })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uni.showToast({ title: '解锁失败,请重试', icon: 'none' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error('解锁失败', e)
|
||||||
|
const err = e as { code ?: number, data ?: { message ?: string, captcha ?: IPluginCaptcha } }
|
||||||
|
if (err.code === 403 && err.data?.captcha) {
|
||||||
|
// 需要/校验失败:服务端附新验证码(一次性,旧码已作废),展示并要求重试
|
||||||
|
applyCaptcha(err.data.captcha)
|
||||||
|
uni.showToast({ title: '请完成验证码后重新解锁', icon: 'none' })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 密码错误等业务失败:清空密码并复位验证码(一次性,需重新获取)
|
||||||
|
password.value = ''
|
||||||
|
resetCaptcha()
|
||||||
|
uni.showToast({ title: '密码错误,请重试', icon: 'none' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<uh-glass-popup :model-value="isShow" position="bottom" :z-index="100" custom-class="!border rounded-2xl"
|
||||||
|
:close-on-click-modal="closeable" safe-area-inset-bottom @update:model-value="handleOnPopupClose">
|
||||||
|
<view class="box-border p-4 w-full">
|
||||||
|
<view class="w-full flex items-center justify-between">
|
||||||
|
<view class="font-bold flex items-center gap-x-1 text-love">
|
||||||
|
<wd-icon name="lock" size="42rpx"></wd-icon> {{ title }}
|
||||||
|
</view>
|
||||||
|
<view v-if="closeable"
|
||||||
|
class="w-6 h-6 uh-global-card-glass border uh-shadow-xs flex items-center justify-center rounded-lg"
|
||||||
|
@click="handleOnCancel">
|
||||||
|
<wd-icon name="close" size="28rpx"></wd-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="mt-6 flex flex-col items-center">
|
||||||
|
<view class="tip-text text-xs text-gray-600">
|
||||||
|
{{ tip }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<input v-model="password" :password="true" :placeholder="placeholder"
|
||||||
|
class="box-border mt-6 h-9 px-3 rounded-xl text-xs uh-global-card-glass uh-shadow-xs border" />
|
||||||
|
|
||||||
|
<view v-if="captchaEnabled && captchaSrc" class="mt-5 flex items-center justify-center gap-4">
|
||||||
|
<input v-model="captchaCode" placeholder="验证码"
|
||||||
|
class="box-border flex-1 h-9 px-3 rounded-xl text-xs uh-global-card-glass uh-shadow-xs border" />
|
||||||
|
<image :src="captchaSrc" class="shrink-0 h-9 w-24 rounded-xl" mode="widthFix"
|
||||||
|
@click="handleRefreshCaptcha" />
|
||||||
|
</view>
|
||||||
|
<view v-if="captchaEnabled && captchaSrc" class="mt-4 text-center text-xs text-gray-500">
|
||||||
|
点击图片刷新验证码
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 操作按钮:取消 + 解锁(强制解锁场景隐藏取消) -->
|
||||||
|
<view class="w-full mt-6 box-border flex items-center justify-center gap-4">
|
||||||
|
<uh-button v-if="closeable" class="flex-1"
|
||||||
|
custom-class="py-2 flex-1 uh-global-card-glass text-xs border rounded-xl bg-white/90"
|
||||||
|
@click="handleOnCancel">
|
||||||
|
取消
|
||||||
|
</uh-button>
|
||||||
|
<uh-button class="flex-1"
|
||||||
|
custom-class="py-2 flex-1 uh-global-card-glass rounded-xl text-xs !bg-love/90 text-white border"
|
||||||
|
@click="handleOnConfirm">
|
||||||
|
{{ loading ? '解锁中...' : confirmText }}
|
||||||
|
</uh-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</uh-glass-popup>
|
||||||
|
</template>
|
||||||
@@ -1,95 +1,91 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
||||||
|
|
||||||
interface IVoteCardOption {
|
interface IVoteCardOption {
|
||||||
id?: string
|
id ?: string
|
||||||
title?: string
|
title ?: string
|
||||||
checked?: boolean
|
checked ?: boolean
|
||||||
_uh_percent?: number
|
_uh_percent ?: number
|
||||||
[key: string]: unknown
|
[key : string] : unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IVoteCardData {
|
interface IVoteCardData {
|
||||||
metadata?: { name?: string, [key: string]: unknown }
|
metadata ?: { name ?: string, [key : string] : unknown }
|
||||||
spec?: {
|
spec ?: {
|
||||||
title?: string
|
title ?: string
|
||||||
remark?: string
|
remark ?: string
|
||||||
type?: string
|
type ?: string
|
||||||
timeLimit?: string
|
timeLimit ?: string
|
||||||
startDate?: string
|
startDate ?: string
|
||||||
endDate?: string
|
endDate ?: string
|
||||||
isVoted?: boolean
|
isVoted ?: boolean
|
||||||
_uh_type?: string
|
_uh_type ?: string
|
||||||
_uh_state?: { state: string, color: string, bgColor: string }
|
_uh_state ?: { state : string, color : string, bgColor : string }
|
||||||
options?: IVoteCardOption[]
|
options ?: IVoteCardOption[]
|
||||||
[key: string]: unknown
|
[key : string] : unknown
|
||||||
}
|
}
|
||||||
stats?: { voteCount?: number, voteDataList?: { id?: string, voteCount?: number }[] }
|
stats ?: { voteCount ?: number, voteDataList ?: { id ?: string, voteCount ?: number }[] }
|
||||||
[key: string]: unknown
|
[key : string] : unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
vote: IVoteCardData
|
vote : IVoteCardData
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
/** 跳转投票详情 */
|
/** 跳转投票详情 */
|
||||||
function handleToDetail() {
|
function handleToDetail() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
|
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化时间 */
|
/** 格式化时间 */
|
||||||
function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
|
function formatTime(date ?: string, fmt = 'yyyy-MM-dd HH:mm') : string {
|
||||||
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="uh-global-card-glass box-border w-full rounded-2xl p-4" @click="handleToDetail">
|
<view class="uh-global-card-glass box-border w-full rounded-2xl p-4" @click="handleToDetail">
|
||||||
<!-- 头部:类型/状态/已投票 -->
|
<!-- 头部:类型/状态/已投票 -->
|
||||||
<view class="flex items-center justify-between">
|
<view class="flex items-center justify-between">
|
||||||
<view class="flex flex-wrap items-center gap-1">
|
<view class="flex flex-wrap items-center gap-1">
|
||||||
<text
|
<text v-if="vote.spec?._uh_type"
|
||||||
v-if="vote.spec?._uh_type"
|
class="rounded-md bg-secondary px-1.5 py-0.5 text-xs text-[#4d7c0f]">
|
||||||
class="rounded-md bg-secondary px-1.5 py-0.5 text-[22rpx] text-[#4d7c0f]"
|
{{ vote.spec._uh_type }}
|
||||||
>
|
</text>
|
||||||
{{ vote.spec._uh_type }}
|
<text v-if="vote.spec?._uh_state" class="rounded-md px-1.5 py-0.5 text-xs"
|
||||||
</text>
|
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]">
|
||||||
<text
|
{{ vote.spec._uh_state.state }}
|
||||||
v-if="vote.spec?._uh_state"
|
</text>
|
||||||
class="rounded-md px-1.5 py-0.5 text-[22rpx]"
|
<text v-if="vote.spec?.isVoted"
|
||||||
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]"
|
class="rounded-md bg-primary/15 px-1.5 py-0.5 text-xs text-primary">
|
||||||
>
|
已投票
|
||||||
{{ vote.spec._uh_state.state }}
|
</text>
|
||||||
</text>
|
</view>
|
||||||
<text v-if="vote.spec?.isVoted" class="rounded-md bg-primary/15 px-1.5 py-0.5 text-[22rpx] text-primary">
|
<wd-icon name="arrow-right" size="32rpx" class="text-primary" />
|
||||||
已投票
|
</view>
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<wd-icon name="arrow-right" size="32rpx" class="text-primary" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 标题 + 备注 -->
|
<!-- 标题 + 备注 -->
|
||||||
<view class="vote-title mt-2 text-[30rpx] font-bold text-gray-900">
|
<view class="vote-title mt-2 text-sm font-bold text-gray-900">
|
||||||
{{ vote.spec?.title }}
|
{{ vote.spec?.title }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400">
|
<view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400">
|
||||||
{{ vote.spec.remark }}
|
{{ vote.spec.remark }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 底部:时间 + 参与人数 -->
|
<!-- 底部:时间 + 参与人数 -->
|
||||||
<view class="vote-card-foot mt-3 flex items-center justify-between border-t border-black/5 pt-2">
|
<view class="vote-card-foot mt-3 flex items-center justify-between border-t border-black/5 pt-2">
|
||||||
<text v-if="vote.spec?.timeLimit === 'permanent'" class="text-[22rpx] text-gray-400">
|
<text v-if="vote.spec?.timeLimit === 'permanent'" class="text-xs text-gray-400">
|
||||||
结束:永久有效
|
结束:永久有效
|
||||||
</text>
|
</text>
|
||||||
<text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-[22rpx] text-gray-400">
|
<text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-xs text-gray-400">
|
||||||
开始:{{ formatTime(vote.spec?.startDate) }}
|
开始:{{ formatTime(vote.spec?.startDate) }}
|
||||||
</text>
|
</text>
|
||||||
<text v-else class="text-[22rpx] text-gray-400">
|
<text v-else class="text-xs text-gray-400">
|
||||||
结束:{{ formatTime(vote.spec?.endDate) }}
|
结束:{{ formatTime(vote.spec?.endDate) }}
|
||||||
</text>
|
</text>
|
||||||
<text class="text-[22rpx] text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text>
|
<text class="text-xs text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -20,6 +20,7 @@ export const DefaultAppConfigs: IAppConfig = {
|
|||||||
momentConfig: {
|
momentConfig: {
|
||||||
useTagRandomColor: true,
|
useTagRandomColor: true,
|
||||||
},
|
},
|
||||||
|
loveDiaryConfig: {},
|
||||||
},
|
},
|
||||||
auditConfig: {
|
auditConfig: {
|
||||||
auditModeEnabled: false,
|
auditModeEnabled: false,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Halo 全局配置默认值(源自旧项目 config/halo.config.js)
|
* Halo 全局配置默认值
|
||||||
* 与 src/api/uni-halo.ts 的 getHaloGlobalInfo(/actuator/globalinfo)配合,deepMerge 使用
|
* 与 src/api/uni-halo.ts 的 getHaloGlobalInfo(/actuator/globalinfo)配合,deepMerge 使用
|
||||||
*/
|
*/
|
||||||
import type { IHaloGlobalConfig } from '@/api/types/uni-halo'
|
import type { IHaloGlobalConfig } from '@/api/types/uni-halo'
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export const markdownConfig = {
|
|||||||
margin-bottom: 18px;
|
margin-bottom: 18px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: var(--routine);
|
|
||||||
background: #f2f6fc;
|
background: #f2f6fc;
|
||||||
border: 1px solid #dcdcdc;
|
border: 1px solid #dcdcdc;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义导航顶部位置
|
||||||
|
*/
|
||||||
|
export function useCustomNavbarPlaceholder(customNavbarHeight?: number) {
|
||||||
|
const height = ref(0);
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
const winInfo = uni.getWindowInfo();
|
||||||
|
const safeAreaTop = winInfo.safeArea.top;
|
||||||
|
|
||||||
|
height.value += safeAreaTop;
|
||||||
|
// #ifdef H5
|
||||||
|
height.value += 10;
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
height.value += customNavbarHeight ?? 46;
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(init);
|
||||||
|
|
||||||
|
return { height };
|
||||||
|
}
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
|
||||||
import { describe, expect, it, vi } from 'vitest'
|
|
||||||
import { defineComponent, h } from 'vue'
|
|
||||||
import { useDataLoading } from './useDataLoading'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在 Vue 应用上下文中运行 composable。
|
|
||||||
* composable 的 ref/computed 只能在 setup() 内使用,
|
|
||||||
* withSetup 通过挂载一个临时组件来提供这个上下文。
|
|
||||||
*/
|
|
||||||
function withSetup<T>(composableFn: () => T): T {
|
|
||||||
let result!: T
|
|
||||||
const Comp = defineComponent({
|
|
||||||
setup() {
|
|
||||||
result = composableFn()
|
|
||||||
return () => h('div')
|
|
||||||
},
|
|
||||||
})
|
|
||||||
const wrapper = mount(Comp)
|
|
||||||
wrapper.unmount()
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('useDataLoading', () => {
|
|
||||||
it('初始状态:status=loading, data=undefined', () => {
|
|
||||||
const fetcher = vi.fn().mockResolvedValue('data')
|
|
||||||
const { status, data } = withSetup(() => useDataLoading(fetcher))
|
|
||||||
|
|
||||||
expect(status.value).toBe('loading')
|
|
||||||
expect(data.value).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('run 成功:status 从 loading 流转到 success,data 更新为返回值并触发 onSuccess', async () => {
|
|
||||||
const fetcher = vi.fn().mockResolvedValue('result')
|
|
||||||
const onSuccess = vi.fn()
|
|
||||||
const { status, data, run } = withSetup(() => useDataLoading(fetcher, { onSuccess }))
|
|
||||||
|
|
||||||
const promise = run()
|
|
||||||
expect(status.value).toBe('loading')
|
|
||||||
|
|
||||||
await promise
|
|
||||||
expect(status.value).toBe('success')
|
|
||||||
expect(data.value).toBe('result')
|
|
||||||
expect(onSuccess).toHaveBeenCalledWith('result')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('run 返回空数组:status 流转到 empty', async () => {
|
|
||||||
const fetcher = vi.fn().mockResolvedValue([])
|
|
||||||
const { status, run } = withSetup(() => useDataLoading(fetcher))
|
|
||||||
|
|
||||||
await run()
|
|
||||||
expect(status.value).toBe('empty')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('isEmpty 自定义判空:返回 true 时 status 为 empty', async () => {
|
|
||||||
const fetcher = vi.fn(async (): Promise<{ total: number, items: number[] }> => ({ total: 0, items: [1] }))
|
|
||||||
const { status, run } = withSetup(() => useDataLoading(fetcher, { isEmpty: data => data.total === 0 }))
|
|
||||||
|
|
||||||
await run()
|
|
||||||
expect(status.value).toBe('empty')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('run 失败:不向外抛出异常,status 流转到 error 并触发 onError', async () => {
|
|
||||||
const err = new Error('network error')
|
|
||||||
const onError = vi.fn()
|
|
||||||
const fetcher = vi.fn().mockRejectedValue(err)
|
|
||||||
const { status, data, run } = withSetup(() => useDataLoading(fetcher, { onError }))
|
|
||||||
|
|
||||||
await expect(run()).resolves.toBeUndefined()
|
|
||||||
|
|
||||||
expect(status.value).toBe('error')
|
|
||||||
expect(data.value).toBeUndefined()
|
|
||||||
expect(onError).toHaveBeenCalledWith(err)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('带参数 run:参数透传给 fetcher', async () => {
|
|
||||||
const fetcher = vi.fn(async (name: string) => `hi ${name}`)
|
|
||||||
const { data, run } = withSetup(() => useDataLoading(fetcher))
|
|
||||||
|
|
||||||
await run('world')
|
|
||||||
expect(fetcher).toHaveBeenCalledWith('world')
|
|
||||||
expect(data.value).toBe('hi world')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
+38
-47
@@ -1,22 +1,20 @@
|
|||||||
import type { Ref } from 'vue'
|
import { ref } from 'vue';
|
||||||
import { ref } from 'vue'
|
import type { Ref } from 'vue';
|
||||||
|
import type { DataLoadingStatus } from './useDataLoadingStatus';
|
||||||
/** 数据加载四态(取值与旧 DataLoadingStatusEnum 一致,二者可互相兼容) */
|
|
||||||
export type DataLoadingStatus = 'loading' | 'error' | 'empty' | 'success'
|
|
||||||
|
|
||||||
export interface IUseDataLoadingOptions<T> {
|
export interface IUseDataLoadingOptions<T> {
|
||||||
/** 自定义判空;默认:数组看长度、对象看键数、空值视为空 */
|
/** 自定义判空;默认:数组看长度、对象看键数、空值视为空 */
|
||||||
isEmpty?: (data: T) => boolean
|
isEmpty?: (data: T) => boolean;
|
||||||
/** 成功回调(数据就绪) */
|
/** 成功回调(数据就绪) */
|
||||||
onSuccess?: (data: T) => void
|
onSuccess?: (data: T) => void;
|
||||||
/** 失败回调(run 已捕获异常,不会向外抛出) */
|
/** 失败回调(run 已捕获异常,不会向外抛出) */
|
||||||
onError?: (err: unknown) => void
|
onError?: (err: unknown) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUseDataLoadingReturn<T, P extends unknown[]> {
|
export interface IUseDataLoadingReturn<T, P extends unknown[]> {
|
||||||
data: Ref<T | undefined>
|
data: Ref<T | undefined>;
|
||||||
status: Ref<DataLoadingStatus>
|
status: Ref<DataLoadingStatus>;
|
||||||
run: (...args: P) => Promise<T | undefined>
|
run: (...args: P) => Promise<T | undefined>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,41 +27,34 @@ export interface IUseDataLoadingReturn<T, P extends unknown[]> {
|
|||||||
* onLoad(() => run())
|
* onLoad(() => run())
|
||||||
* onPullDownRefresh(async () => { await run(); uni.stopPullDownRefresh() })
|
* onPullDownRefresh(async () => { await run(); uni.stopPullDownRefresh() })
|
||||||
*/
|
*/
|
||||||
export function useDataLoading<T, P extends unknown[] = []>(
|
export function useDataLoading<T, P extends unknown[] = []>(fetcher: (...args: P) => Promise<T>, options: IUseDataLoadingOptions<T> = {}): IUseDataLoadingReturn<T, P> {
|
||||||
fetcher: (...args: P) => Promise<T>,
|
const { isEmpty, onSuccess, onError } = options;
|
||||||
options: IUseDataLoadingOptions<T> = {},
|
|
||||||
): IUseDataLoadingReturn<T, P> {
|
|
||||||
const { isEmpty, onSuccess, onError } = options
|
|
||||||
|
|
||||||
const data = ref<T | undefined>(undefined) as Ref<T | undefined>
|
const data = ref<T | undefined>(undefined) as Ref<T | undefined>;
|
||||||
const status = ref<DataLoadingStatus>('loading')
|
const status = ref<DataLoadingStatus>('loading');
|
||||||
|
|
||||||
function calcEmpty(value: T): boolean {
|
function calcEmpty(value: T): boolean {
|
||||||
if (isEmpty)
|
if (isEmpty) return isEmpty(value);
|
||||||
return isEmpty(value)
|
if (Array.isArray(value)) return value.length === 0;
|
||||||
if (Array.isArray(value))
|
if (value !== null && typeof value === 'object') return Object.keys(value).length === 0;
|
||||||
return value.length === 0
|
return value === undefined || value === null || value === '';
|
||||||
if (value !== null && typeof value === 'object')
|
}
|
||||||
return Object.keys(value).length === 0
|
|
||||||
return value === undefined || value === null || value === ''
|
|
||||||
}
|
|
||||||
|
|
||||||
async function run(...args: P): Promise<T | undefined> {
|
async function run(...args: P): Promise<T | undefined> {
|
||||||
status.value = 'loading'
|
status.value = 'loading';
|
||||||
try {
|
try {
|
||||||
const res = await fetcher(...args)
|
const res = await fetcher(...args);
|
||||||
data.value = res
|
data.value = res;
|
||||||
status.value = calcEmpty(res) ? 'empty' : 'success'
|
status.value = calcEmpty(res) ? 'empty' : 'success';
|
||||||
onSuccess?.(res)
|
onSuccess?.(res);
|
||||||
return res
|
return res;
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
console.error('[useDataLoading] 请求失败', err);
|
||||||
console.error('[useDataLoading] 请求失败', err)
|
status.value = 'error';
|
||||||
status.value = 'error'
|
onError?.(err);
|
||||||
onError?.(err)
|
return undefined;
|
||||||
return undefined
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return { data, status, run }
|
return { data, status, run };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,86 @@
|
|||||||
import type { DataLoadingStatus } from './useDataLoading'
|
|
||||||
|
|
||||||
export const DataLoadingStatusEnum = {
|
export const DataLoadingStatusEnum = {
|
||||||
Loading: 'loading',
|
Loading: 'loading',
|
||||||
Error: 'error',
|
Error: 'error',
|
||||||
Empty: 'empty',
|
Empty: 'empty',
|
||||||
Success: 'success',
|
Success: 'success',
|
||||||
NoNetwork: 'noNetwork',
|
NoNetwork: 'noNetwork'
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export function useDataLoadingStatus(status?: DataLoadingStatus) {
|
export type DataLoadingStatus = (typeof DataLoadingStatusEnum)[keyof typeof DataLoadingStatusEnum];
|
||||||
const loadingStatus = ref<DataLoadingStatus>(status ?? DataLoadingStatusEnum.Loading)
|
|
||||||
|
|
||||||
function resetLoadingStatus() {
|
const LoadMoreStatusText = {
|
||||||
loadingStatus.value = DataLoadingStatusEnum.Loading
|
loadMore: '哎嘿,往下还有数据哦~',
|
||||||
}
|
loading: '稍等,正在加载中哦~',
|
||||||
|
noMore: '呜呜,没有更多数据了~',
|
||||||
|
error: '呜呜,加载失败了哦~',
|
||||||
|
noNetwork: '呜呜,网络好像有点问题哦~'
|
||||||
|
} as const;
|
||||||
|
|
||||||
function updateLoadingStatus(newStatus: DataLoadingStatus) {
|
export type LoadMoreStatus = keyof typeof LoadMoreStatusText;
|
||||||
loadingStatus.value = newStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
export interface LoadMoreStatusState {
|
||||||
loadingStatus,
|
active: boolean;
|
||||||
resetLoadingStatus,
|
hasNext: boolean;
|
||||||
updateLoadingStatus,
|
status: LoadMoreStatus;
|
||||||
}
|
text: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoadMoreStatusOption {
|
||||||
|
active?: boolean;
|
||||||
|
status?: LoadMoreStatus;
|
||||||
|
text?: string;
|
||||||
|
hasNext?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDataLoadingStatus(defaultStatus?: DataLoadingStatus) {
|
||||||
|
const loadingStatus = ref<DataLoadingStatus>(defaultStatus ?? DataLoadingStatusEnum.Loading);
|
||||||
|
|
||||||
|
const _loadMoreStatus = ref<LoadMoreStatusState>({
|
||||||
|
active: false,
|
||||||
|
hasNext: false,
|
||||||
|
status: 'loadMore',
|
||||||
|
text: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadMoreStatus = computed(() => {
|
||||||
|
const result = {
|
||||||
|
..._loadMoreStatus.value
|
||||||
|
};
|
||||||
|
if (!_loadMoreStatus.value.text) {
|
||||||
|
result.text = LoadMoreStatusText[_loadMoreStatus.value.status];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
|
function resetLoadMoreStatus() {
|
||||||
|
_loadMoreStatus.value.active = false;
|
||||||
|
_loadMoreStatus.value.hasNext = false;
|
||||||
|
_loadMoreStatus.value.status = 'loadMore';
|
||||||
|
_loadMoreStatus.value.text = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetLoadingStatus() {
|
||||||
|
loadingStatus.value = DataLoadingStatusEnum.Loading;
|
||||||
|
resetLoadMoreStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLoadingStatus(status: DataLoadingStatus) {
|
||||||
|
loadingStatus.value = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLoadMoreStatus(status: LoadMoreStatusOption) {
|
||||||
|
_loadMoreStatus.value.active = status.active ?? false;
|
||||||
|
_loadMoreStatus.value.status = status.status ?? 'loadMore';
|
||||||
|
_loadMoreStatus.value.hasNext = status.hasNext ?? false;
|
||||||
|
_loadMoreStatus.value.text = status.text ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
loadingStatus,
|
||||||
|
loadMoreStatus,
|
||||||
|
resetLoadingStatus,
|
||||||
|
resetLoadMoreStatus,
|
||||||
|
updateLoadingStatus,
|
||||||
|
updateLoadMoreStatus
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/**
|
||||||
|
* 恋爱模块解锁流程(供 love 页 / 首页快捷导航 / 我的页 / 三模块页共用):
|
||||||
|
* - path → moduleKey 判定(插件端下发 path 前缀匹配,兼容带 query)
|
||||||
|
* - 锁定判定(passwordEnabled && 本地无有效 token)
|
||||||
|
* - 解锁弹窗状态 + 解锁请求 + 成功回调(存 token,可配置跳转)
|
||||||
|
*/
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { unlockLoveModule, type ICaptchaQuery } from '@/api/uni-halo'
|
||||||
|
import { getLoveModuleToken, setLoveModuleToken, type LoveModuleKey } from '@/utils/loveModuleToken'
|
||||||
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
|
import type { ILoveModuleConfig } from '@/api/types/uni-halo'
|
||||||
|
|
||||||
|
/** 恋爱模块 path 前缀 → moduleKey(与插件端下发 path 约定一致) */
|
||||||
|
const LOVE_MODULE_PATH_MAP: Array<{ key: LoveModuleKey; pathPrefix: string }> = [
|
||||||
|
{ key: 'loveDiary', pathPrefix: '/pages-blog/love/love' },
|
||||||
|
{ key: 'ourStory', pathPrefix: '/pages-blog/love/stories' },
|
||||||
|
{ key: 'lovePhoto', pathPrefix: '/pages-blog/love/album' },
|
||||||
|
{ key: 'loveDaily', pathPrefix: '/pages-blog/love/list' },
|
||||||
|
]
|
||||||
|
|
||||||
|
/** 由跳转 path 反查恋爱模块 key(非恋爱模块路径返回 undefined) */
|
||||||
|
export function getLoveModuleKeyByPath(path: string): LoveModuleKey | undefined {
|
||||||
|
return LOVE_MODULE_PATH_MAP.find(item => path.startsWith(item.pathPrefix))?.key
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useLoveModuleUnlock(options?: {
|
||||||
|
/** 解锁成功(已存 token)后的回调,如刷新配置/恢复数据加载 */
|
||||||
|
onUnlocked?: (moduleKey: LoveModuleKey) => void
|
||||||
|
}) {
|
||||||
|
const appConfigStore = useAppConfigStore()
|
||||||
|
const loveConfig = computed(() => appConfigStore.configs.loveConfig)
|
||||||
|
|
||||||
|
/* ---------------- 弹窗状态 ---------------- */
|
||||||
|
const unlockModalVisible = ref(false)
|
||||||
|
/** 待解锁模块 */
|
||||||
|
const pendingModule = ref<LoveModuleKey>('loveDiary')
|
||||||
|
/** 解锁成功后跳转路径(空则不跳转) */
|
||||||
|
const pendingPath = ref('')
|
||||||
|
|
||||||
|
const unlockTip = computed(() => {
|
||||||
|
const moduleCfg = getModuleConfig(pendingModule.value)
|
||||||
|
const tip = moduleCfg?.title || ''
|
||||||
|
return `${tip}已设置访问密码,输入后进入`
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 恋爱模块配置读取(入口与三模块共用字段;loveDiary 仅密码状态) */
|
||||||
|
function getModuleConfig(moduleKey: LoveModuleKey): ILoveModuleConfig | undefined {
|
||||||
|
return (loveConfig.value as unknown as Record<string, ILoveModuleConfig | undefined>)[moduleKey]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 模块是否锁定:设了密码且本地无有效 token */
|
||||||
|
function isModuleLocked(moduleKey: LoveModuleKey): boolean {
|
||||||
|
return !!getModuleConfig(moduleKey)?.passwordEnabled && !getLoveModuleToken(moduleKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开解锁弹窗(path 用于解锁成功后跳转,空则不跳) */
|
||||||
|
function openUnlock(moduleKey: LoveModuleKey, path = '') {
|
||||||
|
pendingModule.value = moduleKey
|
||||||
|
pendingPath.value = path
|
||||||
|
unlockModalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 通用解锁请求:unlock 签发 token(插件端要求验证码,403 附新码由弹窗展示重试) */
|
||||||
|
async function handleUnlockRequest(password: string, captcha?: ICaptchaQuery | null) {
|
||||||
|
const res = await unlockLoveModule(pendingModule.value, password, captcha)
|
||||||
|
return res.data as { token?: string, [key: string]: unknown } | null | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解锁成功:存 token → 回调 → 按配置跳转 */
|
||||||
|
function handleUnlockSuccess(data: { token?: string }) {
|
||||||
|
if (!data.token) {
|
||||||
|
uni.showToast({ icon: 'none', title: '解锁失败,请重试' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setLoveModuleToken(pendingModule.value, data.token)
|
||||||
|
options?.onUnlocked?.(pendingModule.value)
|
||||||
|
if (pendingPath.value) {
|
||||||
|
uni.navigateTo({ url: pendingPath.value })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 跳转拦截:命中恋爱模块且锁定 → 弹窗并返回 true(调用方不再跳转) */
|
||||||
|
function interceptNavigateByPath(path: string): boolean {
|
||||||
|
const moduleKey = getLoveModuleKeyByPath(path)
|
||||||
|
if (moduleKey && isModuleLocked(moduleKey)) {
|
||||||
|
openUnlock(moduleKey, path)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
unlockModalVisible,
|
||||||
|
pendingModule,
|
||||||
|
unlockTip,
|
||||||
|
isModuleLocked,
|
||||||
|
openUnlock,
|
||||||
|
handleUnlockRequest,
|
||||||
|
handleUnlockSuccess,
|
||||||
|
interceptNavigateByPath,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
export function usePageScroll(defaultScrollValue: number = 0) {
|
||||||
|
const scrollY = ref(defaultScrollValue);
|
||||||
|
|
||||||
|
function updatePageScrollValue(scrollValue: number) {
|
||||||
|
scrollY.value = scrollValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { scrollY, updatePageScrollValue };
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* 插件清单与可用性 hook
|
* 插件清单与可用性 hook
|
||||||
* 源自旧项目 utils/plugin.js(TS 化)与 utils/plugin.ts,整体迁移至 hooks 目录。
|
|
||||||
* 提供:
|
* 提供:
|
||||||
* - 依赖插件 ID 常量(NeedPluginIds)与插件清单(NeedPlugins)
|
* - 依赖插件 ID 常量(NeedPluginIds)与插件清单(NeedPlugins)
|
||||||
* - 底层可用性检查(checkNeedPluginAvailable)
|
* - 底层可用性检查(checkNeedPluginAvailable)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ export function useSettingsPopup() {
|
|||||||
|
|
||||||
function closeSettingsPopup() {
|
function closeSettingsPopup() {
|
||||||
settingsPopupVisible.value = false;
|
settingsPopupVisible.value = false;
|
||||||
console.log('Settings popup closed', settingsPopupVisible.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { settingsPopupVisible, openSettingsPopup, closeSettingsPopup };
|
return { settingsPopupVisible, openSettingsPopup, closeSettingsPopup };
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ const httpInterceptor = {
|
|||||||
|
|
||||||
// 非 alova 请求,正常执行
|
// 非 alova 请求,正常执行
|
||||||
// 接口请求支持通过 query 参数配置 queryString
|
// 接口请求支持通过 query 参数配置 queryString
|
||||||
|
console.log('==========options',options)
|
||||||
|
|
||||||
|
if (options?.meta?.query) {
|
||||||
if (options.query) {
|
// const queryStr = qs.stringify(options?.meta?.query, {
|
||||||
// const queryStr = qs.stringify(options.query, {
|
|
||||||
// allowDots: true,
|
// allowDots: true,
|
||||||
// encodeValuesOnly: true,
|
// encodeValuesOnly: true,
|
||||||
// skipNulls: true,
|
// skipNulls: true,
|
||||||
@@ -28,7 +28,7 @@ const httpInterceptor = {
|
|||||||
// arrayFormat: 'repeat'
|
// arrayFormat: 'repeat'
|
||||||
// })
|
// })
|
||||||
|
|
||||||
const queryStr = stringifyQuery(options.query)
|
const queryStr = stringifyQuery(options?.meta?.query)
|
||||||
if (options.url.includes('?')) {
|
if (options.url.includes('?')) {
|
||||||
options.url += `&${queryStr}`;
|
options.url += `&${queryStr}`;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
export type CustomRequestOptions = UniApp.RequestOptions & {
|
export type CustomRequestOptions = UniApp.RequestOptions & {
|
||||||
query?: Record<string, any>
|
query?: Record<string, any>
|
||||||
|
// 对标 alova 参数
|
||||||
|
meta?: Record<string, any>
|
||||||
/** 出错时是否隐藏错误提示 */
|
/** 出错时是否隐藏错误提示 */
|
||||||
hideErrorToast?: boolean
|
hideErrorToast?: boolean
|
||||||
} & IUniUploadFileOptions // 添加uni.uploadFile参数类型
|
} & IUniUploadFileOptions // 添加uni.uploadFile参数类型
|
||||||
|
|||||||
+1
-3
@@ -3,9 +3,7 @@
|
|||||||
"tabbar.category": "Category",
|
"tabbar.category": "Category",
|
||||||
"tabbar.gallery": "Gallery",
|
"tabbar.gallery": "Gallery",
|
||||||
"tabbar.moments": "Moments",
|
"tabbar.moments": "Moments",
|
||||||
"tabbar.about": "About",
|
"tabbar.mine": "About",
|
||||||
"tabbar.me": "Me",
|
|
||||||
"tabbar.i18n": "I18n",
|
|
||||||
"page.home.title": "Home",
|
"page.home.title": "Home",
|
||||||
"page.category.title": "Category",
|
"page.category.title": "Category",
|
||||||
"page.gallery.title": "Gallery",
|
"page.gallery.title": "Gallery",
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
"tabbar.category": "分类",
|
"tabbar.category": "分类",
|
||||||
"tabbar.gallery": "图库",
|
"tabbar.gallery": "图库",
|
||||||
"tabbar.moments": "瞬间",
|
"tabbar.moments": "瞬间",
|
||||||
"tabbar.about": "关于",
|
"tabbar.mine": "关于",
|
||||||
"tabbar.me": "我的",
|
|
||||||
"tabbar.i18n": "多语言",
|
|
||||||
"page.home.title": "首页",
|
"page.home.title": "首页",
|
||||||
"page.category.title": "分类",
|
"page.category.title": "分类",
|
||||||
"page.gallery.title": "图库",
|
"page.gallery.title": "图库",
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { checkUrl } from '@/utils/url'
|
import { checkUrl } from '@/utils/url'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
@@ -10,19 +11,18 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
const appInfo = computed(() => {
|
const appInfo = computed(() => {
|
||||||
const _appInfo = (appConfigStore.configs?.appConfig?.appInfo as any)
|
|
||||||
return {
|
return {
|
||||||
name: _appInfo.name ?? 'UniHalo',
|
name: 'UniHalo',
|
||||||
logo: checkUrl(_appInfo?.logo ?? 'https://uni-halo.925i.cn/logo.png')
|
logo: checkUrl('/plugins/plugin-uni-halo/assets/static/logo.png')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const links = [
|
const links = [
|
||||||
{ title: '开源组织', value: '巷子工坊', copy: 'https://www.ialley.cn', tip: '巷子工坊官网已复制成功!', tileColor: '#5c6bc0', tileLetter: '组' },
|
{ title: '小莫唐尼', value: 'https://www.xiaoxiaomo.cn', copy: 'https://www.xiaoxiaomo.cn', tip: '作者主页地址已复制', tileColor: '#26a69a', tileLetter: '作' },
|
||||||
{ title: '开源作者', value: '小莫唐尼', copy: 'https://www.xiaoxiaomo.cn', tip: '作者主页地址已复制', tileColor: '#26a69a', tileLetter: '作' },
|
|
||||||
{ title: '作者博客', value: 'https://blog.xiaoxiaomo.cn', copy: 'https://blog.xiaoxiaomo.cn', tip: '作者博客地址已复制', tileColor: '#7e57c2', tileLetter: '博' },
|
{ title: '作者博客', value: 'https://blog.xiaoxiaomo.cn', copy: 'https://blog.xiaoxiaomo.cn', tip: '作者博客地址已复制', tileColor: '#7e57c2', tileLetter: '博' },
|
||||||
{ title: '文档地址', value: 'https://uni-halo.925i.cn', copy: 'https://uni-halo.925i.cn', tip: '项目码云仓库已复制', tileColor: '#039be5', tileLetter: '文' },
|
{ title: '文档地址', value: 'https://uni-halo.925i.cn', copy: 'https://uni-halo.925i.cn', tip: '项目码云仓库已复制', tileColor: '#039be5', tileLetter: '文' },
|
||||||
{ title: '码云仓库', value: 'https://gitee.com/ialley-workshop-open/uni-halo', copy: 'https://gitee.com/ialley-workshop-open/uni-halo', tip: '码云仓库地址已复制', tileColor: '#c71d23', tileLetter: '码' },
|
{ title: '码云仓库', value: 'https://gitee.com/ialley-workshop-open/uni-halo', copy: 'https://gitee.com/ialley-workshop-open/uni-halo', tip: '码云仓库地址已复制', tileColor: '#c71d23', tileLetter: '码' },
|
||||||
@@ -39,6 +39,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
uni.setNavigationBarTitle({ title: '关于项目' })
|
uni.setNavigationBarTitle({ title: '关于项目' })
|
||||||
})
|
})
|
||||||
@@ -47,20 +51,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen flex flex-col overflow-hidden bg-page px-4 pb-8 pt-2">
|
<view class="box-border min-h-screen w-screen flex flex-col overflow-hidden bg-page px-4 pb-8 pt-2">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="关于项目" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="关于项目" title-color="text-gray-900" />
|
||||||
|
|
||||||
|
<view class="fixed -right-8 top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] uh-blur-xl" />
|
||||||
|
<view class="fixed -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] uh-blur-xl" />
|
||||||
|
|
||||||
<view class="relative">
|
<view class="relative">
|
||||||
<view class="absolute h-[220rpx] w-[220rpx] rounded-full bg-[rgba(185,228,36,0.32)] -right-8 -top-8" />
|
|
||||||
<view
|
|
||||||
class="absolute top-[150rpx] h-[180rpx] w-[180rpx] rounded-full bg-[rgba(215,249,76,0.45)] -left-10" />
|
|
||||||
<view class="uh-global-card-glass relative flex flex-col items-center rounded-2xl px-6 pb-7 pt-10">
|
<view class="uh-global-card-glass relative flex flex-col items-center rounded-2xl px-6 pb-7 pt-10">
|
||||||
<image class="h-[140rpx] w-[140rpx] rounded-3xl shadow-lg" :src="appInfo.logo" mode="aspectFill" />
|
<image class="uh-global-card-glass uh-shadow-xs border h-18 w-18 rounded-2xl" :src="appInfo.logo"
|
||||||
<view class="mt-4 text-xl text-gray-900 font-bold">
|
mode="aspectFill" />
|
||||||
|
<view class="mt-4 text-xl text- font-bold">
|
||||||
{{appInfo.name}}
|
{{appInfo.name}}
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-3 flex items-center gap-2">
|
<view class="mt-3 flex items-center gap-2">
|
||||||
<text class="rounded-full bg-secondary px-3 py-1 text-[20rpx] text-[#4d7c0f]">AGPL-3.0 开源协议</text>
|
<text class="rounded-full bg-secondary px-3 py-1 text-[20rpx] text-gray-900">AGPL-3.0 开源协议</text>
|
||||||
<text class="rounded-full bg-[#f6f3ee] px-3 py-1 text-[20rpx] text-gray-500">UniApp × Halo</text>
|
<text class="rounded-full bg-gray-100 px-3 py-1 text-[20rpx] text-gray-900">UniApp × Halo</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-4 text-center text-xs text-gray-500 leading-relaxed">
|
<view class="mt-4 text-center text-xs text-gray-500 leading-relaxed">
|
||||||
基于 uni-app 打造的 Halo 博客跨端客户端
|
基于 uni-app 打造的 Halo 博客跨端客户端
|
||||||
@@ -68,32 +73,33 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 相关链接 -->
|
<uh-section-title class="mb-3 mt-6"> 相关链接 </uh-section-title>
|
||||||
<uh-section-title class="mb-3 mt-6">
|
|
||||||
相关链接
|
<view class="box-border uh-global-card-glass flex flex-col gap-y-6 rounded-2xl py-4">
|
||||||
</uh-section-title>
|
<view v-for="(link) in links" :key="link.title" class="flex items-center gap-3 px-4"
|
||||||
<view class="link-list uh-global-card-glass overflow-hidden rounded-2xl">
|
|
||||||
<view v-for="(link, index) in links" :key="link.title" class="link-item flex items-center gap-3 px-4 py-4"
|
|
||||||
:class="index < links.length - 1 ? 'border-b border-black/5' : ''"
|
|
||||||
@click="copyText(link.copy, link.tip)">
|
@click="copyText(link.copy, link.tip)">
|
||||||
<view
|
<view
|
||||||
class="tile h-[76rpx] w-[76rpx] flex shrink-0 items-center justify-center rounded-xl border border-black/5"
|
class="uh-global-card-glass uh-shadow-xs border h-9 w-9 flex shrink-0 items-center justify-center rounded-xl"
|
||||||
:style="{ backgroundColor: `${link.tileColor}1A` }">
|
:style="{ backgroundColor: `${link.tileColor}1A` }">
|
||||||
<text class="text-[30rpx] font-bold" :style="{ color: link.tileColor }">{{ link.tileLetter }}</text>
|
<text class="text-sm font-bold" :style="{ color: link.tileColor }">{{ link.tileLetter }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="min-w-0 flex flex-1 flex-col">
|
<view class="min-w-0 flex flex-1 flex-col justify-center">
|
||||||
<text class="text-[28rpx] text-gray-900 font-bold">{{ link.title }}</text>
|
<text class="text-2xs text-gray-900 font-bold">{{ link.title }}</text>
|
||||||
<view class="mt-1 overflow-hidden text-ellipsis whitespace-nowrap text-[24rpx] text-gray-400">
|
<view class="truncate text-xs text-gray-400">
|
||||||
{{ link.value }}
|
{{ link.value }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<wd-icon name="copy" size="28rpx" color="#c8c2b4" class="shrink-0" />
|
<wd-icon name="copy" size="28rpx" class="shrink-0 text-gray-500" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 版权 -->
|
<uh-page-copyright />
|
||||||
<view class="copyright mt-auto pt-8 text-center text-[22rpx] text-gray-400">
|
|
||||||
<view>「 2022 uni-halo 丨 开源项目丨巷子工坊@小莫唐尼 」</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.uh-blur-xl {
|
||||||
|
filter: blur(20rpx);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,302 +1,306 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getPostList } from '@/api/halo'
|
import { getPostList } from '@/api/halo'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { useSettingStore } from '@/store/setting'
|
import { useSettingStore } from '@/store/setting'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { sleep } from '@/utils/common'
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import type { IPost } from '@/api/types/halo'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { sleep } from '@/utils/common'
|
||||||
|
import type { IPost } from '@/api/types/halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '归档',
|
navigationBarTitleText: '归档',
|
||||||
enablePullDownRefresh: true,
|
enablePullDownRefresh: true,
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const appConfigStore = useAppConfigStore()
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
|
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
/** 归档页列表布局(偏好设置驱动:single=单列 / double=双列) */
|
/** 归档页列表布局(偏好设置驱动:single=单列 / double=双列) */
|
||||||
const archivesListLayout = computed(() => settingStore.settings.archivesListLayout)
|
const archivesListLayout = computed(() => settingStore.settings.archivesListLayout)
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const activeTabIndex = ref(0)
|
const activeTabIndex = ref(0)
|
||||||
const queryParams = ref({ size: 10, page: 1 })
|
const queryParams = ref({ size: 10, page: 1 })
|
||||||
const result = ref<{ hasNext: boolean }>({ hasNext: false })
|
const cacheDataList = ref<IPost[]>([])
|
||||||
const cacheDataList = ref<IPost[]>([])
|
const dataList = ref<{
|
||||||
const dataList = ref<{
|
sort : number
|
||||||
sort: number
|
key : string
|
||||||
key: string
|
year : string
|
||||||
year: string
|
month : string
|
||||||
month: string
|
posts : IPost[]
|
||||||
posts: IPost[]
|
}[]>([])
|
||||||
}[]>([])
|
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref('加载中...')
|
|
||||||
|
|
||||||
const postLabelYearKey = 'content.halo.run/archive-year'
|
const postLabelYearKey = 'content.halo.run/archive-year'
|
||||||
const postLabelMonthKey = 'content.halo.run/archive-month'
|
const postLabelMonthKey = 'content.halo.run/archive-month'
|
||||||
|
|
||||||
/* ---------------- 数据处理 ---------------- */
|
/* ---------------- 数据处理 ---------------- */
|
||||||
/** 按 tab 分组文章 */
|
/** 按 tab 分组文章 */
|
||||||
function handleGetPosts(list: IPost[]): Record<string, IPost[]> {
|
function handleGetPosts(list : IPost[]) : Record<string, IPost[]> {
|
||||||
const posts: Record<string, IPost[]> = {}
|
const posts : Record<string, IPost[]> = {}
|
||||||
list.forEach((item) => {
|
list.forEach((item) => {
|
||||||
const labels = item.metadata.labels || {}
|
const labels = item.metadata.labels || {}
|
||||||
let postItemKey = ''
|
let postItemKey = ''
|
||||||
if (activeTabIndex.value === 0) {
|
if (activeTabIndex.value === 0) {
|
||||||
postItemKey = `${labels[postLabelYearKey]}-${labels[postLabelMonthKey]}`
|
postItemKey = `${labels[postLabelYearKey]}-${labels[postLabelMonthKey]}`
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
postItemKey = `${labels[postLabelYearKey]}`
|
postItemKey = `${labels[postLabelYearKey]}`
|
||||||
}
|
}
|
||||||
if (posts[postItemKey]) {
|
if (posts[postItemKey]) {
|
||||||
posts[postItemKey].push(item)
|
posts[postItemKey].push(item)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
posts[postItemKey] = [item]
|
posts[postItemKey] = [item]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return posts
|
return posts
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 处理成显示数据(分组 + 排序) */
|
/** 处理成显示数据(分组 + 排序) */
|
||||||
function handleGetShowDataList(posts: Record<string, IPost[]>): typeof dataList.value {
|
function handleGetShowDataList(posts : Record<string, IPost[]>) : typeof dataList.value {
|
||||||
const listResult: typeof dataList.value = []
|
const listResult : typeof dataList.value = []
|
||||||
Object.keys(posts).forEach((key) => {
|
Object.keys(posts).forEach((key) => {
|
||||||
const postData = {
|
const postData = {
|
||||||
sort: 0,
|
sort: 0,
|
||||||
key,
|
key,
|
||||||
year: key,
|
year: key,
|
||||||
month: '',
|
month: '',
|
||||||
posts: posts[key],
|
posts: posts[key],
|
||||||
}
|
}
|
||||||
if (activeTabIndex.value === 0) {
|
if (activeTabIndex.value === 0) {
|
||||||
const splitDate = key.split('-')
|
const splitDate = key.split('-')
|
||||||
postData.year = splitDate[0]
|
postData.year = splitDate[0]
|
||||||
postData.month = splitDate[1]
|
postData.month = splitDate[1]
|
||||||
postData.sort = Number(key.replace('-', ''))
|
postData.sort = Number(key.replace('-', ''))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
postData.sort = Number(key)
|
postData.sort = Number(key)
|
||||||
}
|
}
|
||||||
listResult.push(postData)
|
listResult.push(postData)
|
||||||
})
|
})
|
||||||
listResult.sort((a, b) => Number(b.sort) - Number(a.sort))
|
listResult.sort((a, b) => Number(b.sort) - Number(a.sort))
|
||||||
return listResult
|
return listResult
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 去重缓存列表 */
|
/** 去重缓存列表 */
|
||||||
function handleUniqueCacheDatalist(list: IPost[]): IPost[] {
|
function handleUniqueCacheDatalist(list : IPost[]) : IPost[] {
|
||||||
const seen = new Set<string>()
|
const seen = new Set<string>()
|
||||||
return list.filter((item) => {
|
return list.filter((item) => {
|
||||||
return seen.has(item.metadata.name) ? false : (seen.add(item.metadata.name), true)
|
return seen.has(item.metadata.name) ? false : (seen.add(item.metadata.name), true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
// 审核模式:真实文章按 audit-data posts 过滤(数组顺序即展示顺序)
|
// 审核模式:真实文章按 audit-data posts 过滤(数组顺序即展示顺序),一次拉取不分页
|
||||||
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
resetLoadMoreStatus()
|
||||||
try {
|
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
||||||
const res = await getPostList({ page: 1, size: 99999, sort: ['spec.publishTime,desc'] })
|
try {
|
||||||
const filtered = res.data.items.filter(item => auditPostNames.includes(item.metadata.name))
|
const res = await getPostList({ page: 1, size: 99999, sort: ['spec.publishTime,desc'] })
|
||||||
const orderMap = new Map(auditPostNames.map((name, index) => [name, index]))
|
const filtered = res.data.items.filter(item => auditPostNames.includes(item.metadata.name))
|
||||||
filtered.sort((a, b) => (orderMap.get(a.metadata.name) ?? 999) - (orderMap.get(b.metadata.name) ?? 999))
|
const orderMap = new Map(auditPostNames.map((name, index) => [name, index]))
|
||||||
const posts = handleGetPosts(filtered)
|
filtered.sort((a, b) => (orderMap.get(a.metadata.name) ?? 999) - (orderMap.get(b.metadata.name) ?? 999))
|
||||||
dataList.value = handleGetShowDataList(posts)
|
const posts = handleGetPosts(filtered)
|
||||||
cacheDataList.value = filtered
|
dataList.value = handleGetShowDataList(posts)
|
||||||
updateLoadingStatus(
|
cacheDataList.value = filtered
|
||||||
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
updateLoadingStatus(
|
||||||
)
|
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
loadMoreText.value = '呜呜,没有更多数据啦~'
|
)
|
||||||
uni.stopPullDownRefresh()
|
updateLoadMoreStatus({
|
||||||
}
|
active: false,
|
||||||
catch (err) {
|
status: 'noMore',
|
||||||
console.error(err)
|
hasNext: false,
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
})
|
||||||
loadMoreText.value = '加载失败,请下拉刷新!'
|
uni.stopPullDownRefresh()
|
||||||
}
|
}
|
||||||
return
|
catch (err) {
|
||||||
}
|
console.error(err)
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (isLoadMore.value) {
|
if (!loadMoreStatus.value.active) {
|
||||||
uni.showLoading({ title: '加载中...' })
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
|
||||||
}
|
|
||||||
loadMoreText.value = '加载中...'
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// getPostList 返回 IResponse<IPostListRes>,数据在 .data 下
|
// getPostList 返回 IResponse<IPostListRes>,数据在 .data 下
|
||||||
const res = await getPostList({ ...queryParams.value })
|
const res = await getPostList({ ...queryParams.value })
|
||||||
result.value = { hasNext: res.data.hasNext }
|
const posts = handleGetPosts(res.data.items)
|
||||||
const posts = handleGetPosts(res.data.items)
|
const showDataList = handleGetShowDataList(posts)
|
||||||
const showDataList = handleGetShowDataList(posts)
|
|
||||||
|
|
||||||
if (isLoadMore.value) {
|
if (loadMoreStatus.value.active) {
|
||||||
cacheDataList.value = handleUniqueCacheDatalist([...cacheDataList.value, ...res.data.items])
|
cacheDataList.value = handleUniqueCacheDatalist([...cacheDataList.value, ...res.data.items])
|
||||||
// 合并增量数据
|
// 合并增量数据
|
||||||
showDataList.forEach((item) => {
|
showDataList.forEach((item) => {
|
||||||
const find = dataList.value.find(x => x.key === item.key)
|
const find = dataList.value.find(x => x.key === item.key)
|
||||||
if (find) {
|
if (find) {
|
||||||
item.posts.forEach((post) => {
|
item.posts.forEach((post) => {
|
||||||
if (!find.posts.some(x => x.metadata.name === post.metadata.name)) {
|
if (!find.posts.some(x => x.metadata.name === post.metadata.name)) {
|
||||||
find.posts.push(post)
|
find.posts.push(post)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
showDataList.forEach((post) => {
|
showDataList.forEach((post) => {
|
||||||
if (!dataList.value.some(x => x.key === post.key)) {
|
if (!dataList.value.some(x => x.key === post.key)) {
|
||||||
dataList.value.push(post)
|
dataList.value.push(post)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
dataList.value.sort((a, b) => Number(b.sort) - Number(a.sort))
|
dataList.value.sort((a, b) => Number(b.sort) - Number(a.sort))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dataList.value = showDataList
|
dataList.value = showDataList
|
||||||
cacheDataList.value = res.data.items
|
cacheDataList.value = res.data.items
|
||||||
}
|
}
|
||||||
await sleep(500)
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(
|
await sleep(500)
|
||||||
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
updateLoadingStatus(
|
||||||
)
|
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
loadMoreText.value = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'
|
)
|
||||||
}
|
}
|
||||||
catch (err) {
|
updateLoadMoreStatus({
|
||||||
console.error(err)
|
active: false,
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
loadMoreText.value = '加载失败,请下拉刷新!'
|
hasNext: res.data.hasNext,
|
||||||
}
|
})
|
||||||
finally {
|
}
|
||||||
uni.stopPullDownRefresh()
|
catch (err) {
|
||||||
}
|
console.error(err)
|
||||||
}
|
if (loadMoreStatus.value.active) {
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uni.stopPullDownRefresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 顶部 tab 定义(同收藏页胶囊 chip) */
|
/** 顶部 tab 定义(同收藏页胶囊 chip) */
|
||||||
const archiveTabs = [
|
const archiveTabs = [
|
||||||
{ key: 'month', label: '按月份查看' },
|
{ key: 'month', label: '按月份查看' },
|
||||||
{ key: 'year', label: '按年份查看' },
|
{ key: 'year', label: '按年份查看' },
|
||||||
]
|
]
|
||||||
|
|
||||||
function handleOnTabChange(e: { index: number }) {
|
function handleOnTabChange(e : { index : number }) {
|
||||||
activeTabIndex.value = e.index
|
activeTabIndex.value = e.index
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
dataList.value = handleGetShowDataList(handleGetPosts(cacheDataList.value))
|
dataList.value = handleGetShowDataList(handleGetPosts(cacheDataList.value))
|
||||||
uni.pageScrollTo({ scrollTop: 0, duration: 500 })
|
uni.pageScrollTo({ scrollTop: 0, duration: 500 })
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleToTopPage(duration = 500) {
|
function handleToTopPage(duration = 500) {
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
duration,
|
duration,
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('回顶失败', err)
|
console.error('回顶失败', err)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
handleGetData()
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
handleGetData()
|
||||||
isLoadMore.value = false
|
|
||||||
queryParams.value.page = 1
|
|
||||||
handleGetData()
|
|
||||||
})
|
|
||||||
|
|
||||||
onReachBottom(() => {
|
onPullDownRefresh(() => {
|
||||||
if (calcAuditModeEnabled.value) {
|
resetLoadMoreStatus()
|
||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
queryParams.value.page = 1
|
||||||
return
|
handleGetData()
|
||||||
}
|
})
|
||||||
if (result.value.hasNext) {
|
|
||||||
queryParams.value.page += 1
|
onReachBottom(() => {
|
||||||
isLoadMore.value = true
|
if (calcAuditModeEnabled.value) {
|
||||||
handleGetData()
|
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
||||||
}
|
return
|
||||||
else {
|
}
|
||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
// 正在加载时阻止重复请求
|
||||||
}
|
if (loadMoreStatus.value.active) {
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
// 有更多数据时继续加载
|
||||||
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="min-h-screen w-screen flex flex-col bg-page">
|
<view class="min-h-screen w-screen flex flex-col bg-page">
|
||||||
<!-- 自定义导航 -->
|
<uh-navbar :scroll-y="scrollY" default-title="内容归档" title-color="text-gray-900" />
|
||||||
<uh-navbar default-title="内容归档" title-color="text-gray-900" />
|
|
||||||
|
|
||||||
<!-- 顶部-->
|
<wd-sticky :offset-top="offsetTop">
|
||||||
<wd-sticky>
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
<scroll-view scroll-x class="w-full whitespace-nowrap">
|
<view v-for="(tab, index) in archiveTabs" :key="tab.key"
|
||||||
<view class="box-border flex gap-2 px-3 pb-1 pt-3">
|
class="uh-global-card-glass shadow-none mb-2 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
<view
|
:class="{ 'bg-primary text-gray-900 font-semibold': activeTabIndex === index }"
|
||||||
v-for="(tab, index) in archiveTabs" :key="tab.key"
|
@click="handleOnTabChange({ index })">
|
||||||
class="uh-global-card-glass uh-shadow-xs inline-block border rounded-2xl px-5 py-1.5 text-sm"
|
{{ tab.label }}
|
||||||
:class="activeTabIndex === index ? 'bg-primary font-bold' : 'text-gray-500'"
|
</view>
|
||||||
@click="handleOnTabChange({ index })"
|
</scroll-view>
|
||||||
>
|
</wd-sticky>
|
||||||
{{ tab.label }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</wd-sticky>
|
|
||||||
|
|
||||||
<uh-data-loading v-if="loadingStatus !== 'success'"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
:loading-status="loadingStatus"
|
empty-text="暂无归档的内容" @refresh="handleGetData" />
|
||||||
:empty-text="calcAuditModeEnabled ? '暂无归档的内容' : '暂无归档的文章'"
|
|
||||||
@refresh="handleGetData"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
<!-- 内容区域 -->
|
||||||
|
<template v-else>
|
||||||
|
<view class="px-3 pt-3">
|
||||||
|
<view v-for="item in dataList" :key="item.key" class="flex">
|
||||||
|
<view class="flex-1 pb-4">
|
||||||
|
<view class="mb-3 flex items-center gap-1">
|
||||||
|
<text class="text-md text-gray-900 font-bold">{{ item.year }}年</text>
|
||||||
|
<text v-if="activeTabIndex === 0"
|
||||||
|
class="text-md text-gray-900 font-bold">{{ item.month }}月</text>
|
||||||
|
<text class="ml-2 rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">共
|
||||||
|
{{ item.posts.length }} 篇{{ calcAuditModeEnabled ? '内容' : '文章' }}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 内容区域 -->
|
<view v-if="item.posts.length !== 0"
|
||||||
<block v-else>
|
:class="archivesListLayout === 'double' ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-y-4'">
|
||||||
<!-- 时间线 -->
|
<uh-article-card v-for="post in item.posts" :key="post.metadata.name" from="archives"
|
||||||
<view class="timeline px-4 pt-3">
|
:variant="archivesListLayout === 'double' ? 'grid' : 'list'" :article="post"
|
||||||
<view v-for="(item, index) in dataList" :key="item.key" class="timeline-item flex">
|
:audit-mode="calcAuditModeEnabled" />
|
||||||
<!-- <view class="timeline-left w-[96rpx] flex shrink-0 flex-col items-center">
|
</view>
|
||||||
<view class="timeline-dot mt-2 h-4 w-4 rounded-full bg-secondary shadow-[0_0_0_8rpx_rgba(215,249,76,0.3)]" />
|
<uh-data-loading v-else :loading-status="DataLoadingStatusEnum.Empty" empty-text="该分类下暂无文章"
|
||||||
<view v-if="index !== dataList.length - 1" class="timeline-line mt-2 w-[2rpx] flex-1 bg-black/5" />
|
@refresh="handleGetData" />
|
||||||
</view> -->
|
</view>
|
||||||
<!-- <view class="timeline-content min-w-0 flex-1 pb-10 pl-5"> -->
|
</view>
|
||||||
<view class="flex-1 pb-10">
|
</view>
|
||||||
<view class="mb-3 flex items-center gap-2">
|
|
||||||
<text class="text-md text-gray-900 font-bold">{{ item.year }}年</text>
|
|
||||||
<text v-if="activeTabIndex === 0" class="text-md text-gray-900 font-bold">{{ item.month }}月</text>
|
|
||||||
<text class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-500 leading-none">共 {{ item.posts.length }} 篇{{ calcAuditModeEnabled ? '内容' : '文章' }}</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-if="item.posts.length !== 0"
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
:class="archivesListLayout === 'double' ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-y-4'">
|
</template>
|
||||||
<uh-article-card
|
</view>
|
||||||
v-for="post in item.posts"
|
|
||||||
:key="post.metadata.name"
|
|
||||||
from="archives"
|
|
||||||
:variant="archivesListLayout === 'double' ? 'grid' : 'list'"
|
|
||||||
:article="post"
|
|
||||||
:audit-mode="calcAuditModeEnabled"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
<view v-else class="post-empty py-6 text-[26rpx] text-gray-400">
|
|
||||||
该日期下暂无归档文章!
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="load-text pb-6 text-center text-[24rpx] text-gray-400">
|
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</block>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||||
import { getPostByName, getPostCommentReplyList, postTrackersCounter } from '@/api/halo'
|
import { getPostByName, getPostCommentReplyList, postTrackersCounter } from '@/api/halo'
|
||||||
import { useUpvote } from '@/hooks/useUpvote'
|
import { useUpvote } from '@/hooks/useUpvote'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { createVerificationCode, requestRestrictReadCheck } from '@/api/uni-halo'
|
import { createVerificationCode, requestRestrictReadCheck } from '@/api/uni-halo'
|
||||||
import { formatTime } from '@/utils/formatTime'
|
import { formatTime } from '@/utils/formatTime'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const favoritesStore = useFavoritesStore()
|
const favoritesStore = useFavoritesStore()
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
@@ -56,6 +58,7 @@
|
|||||||
isComment: false,
|
isComment: false,
|
||||||
postName: '',
|
postName: '',
|
||||||
title: '',
|
title: '',
|
||||||
|
quoteReply: '',
|
||||||
})
|
})
|
||||||
const commentDetail = ref({
|
const commentDetail = ref({
|
||||||
show: false,
|
show: false,
|
||||||
@@ -76,6 +79,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const globalAppSettings = computed(() => settingStore.settings)
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
const calcIsShowComment = computed(() => !!postDetailConfig.value?.showComment)
|
const calcIsShowComment = computed(() => !!postDetailConfig.value?.showComment)
|
||||||
const doubanPluginConfig = computed(() => (haloConfigs.value.pluginConfig?.doubanPlugin as { position ?: string } | undefined) || {})
|
const doubanPluginConfig = computed(() => (haloConfigs.value.pluginConfig?.doubanPlugin as { position ?: string } | undefined) || {})
|
||||||
@@ -192,7 +196,7 @@
|
|||||||
const { hasUpvoted, handleDoLikes } = useUpvote('posts', () => result.value?.metadata.name)
|
const { hasUpvoted, handleDoLikes } = useUpvote('posts', () => result.value?.metadata.name)
|
||||||
|
|
||||||
function handleDoLikesClick() {
|
function handleDoLikesClick() {
|
||||||
handleDoLikes((name) => {
|
handleDoLikes(() => {
|
||||||
if (result.value?.stats) {
|
if (result.value?.stats) {
|
||||||
result.value.stats.upvote = (result.value.stats.upvote || 0) + 1
|
result.value.stats.upvote = (result.value.stats.upvote || 0) + 1
|
||||||
}
|
}
|
||||||
@@ -297,8 +301,6 @@
|
|||||||
|
|
||||||
/* ---------------- 评论 ---------------- */
|
/* ---------------- 评论 ---------------- */
|
||||||
function handleToComment() {
|
function handleToComment() {
|
||||||
console.log('calcIsShowComment.value', calcIsShowComment.value)
|
|
||||||
console.log('result.value', result.value)
|
|
||||||
if (!result.value) {
|
if (!result.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -314,15 +316,17 @@
|
|||||||
isComment: true,
|
isComment: true,
|
||||||
postName: result.value.metadata.name,
|
postName: result.value.metadata.name,
|
||||||
title: '新增评论',
|
title: '新增评论',
|
||||||
|
quoteReply: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnComment(data : { isComment : boolean, postName : string, title : string }) {
|
function handleOnComment(data : { isComment : boolean, postName : string, title : string, quoteReply ?: string }) {
|
||||||
commentModal.value = {
|
commentModal.value = {
|
||||||
show: true,
|
show: true,
|
||||||
isComment: data.isComment,
|
isComment: data.isComment,
|
||||||
postName: data.postName,
|
postName: data.postName,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
|
quoteReply: data.quoteReply ?? '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +412,7 @@
|
|||||||
|
|
||||||
/* ---------------- 格式化 ---------------- */
|
/* ---------------- 格式化 ---------------- */
|
||||||
function formatPublishTime(time ?: string) : string {
|
function formatPublishTime(time ?: string) : string {
|
||||||
// 与旧项目一致:yyyy年MM月dd日 星期w
|
// yyyy年MM月dd日 星期w
|
||||||
return time ? formatTime({ d: time, f: 'yyyy年MM月dd日 星期w' }) : ''
|
return time ? formatTime({ d: time, f: 'yyyy年MM月dd日 星期w' }) : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,6 +423,10 @@
|
|||||||
handleGetData()
|
handleGetData()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onPullDownRefresh(() => {
|
||||||
handleGetData()
|
handleGetData()
|
||||||
})
|
})
|
||||||
@@ -440,24 +448,18 @@
|
|||||||
imageUrl: cover,
|
imageUrl: cover,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const globalAppSettings = computed(() => settingStore.settings)
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
console.log('获取当前所有的页面')
|
|
||||||
console.log(getCurrentPages())
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-safe">
|
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-safe">
|
||||||
<!-- 顶部导航 -->
|
<!-- 顶部导航 -->
|
||||||
<uh-navbar default-title="内容详情" :need-placeholder="false" :scroll-title="result?.spec?.title" />
|
<uh-navbar :scroll-y="scrollY" default-title="内容详情" :need-placeholder="false"
|
||||||
|
:scroll-title="result?.spec?.title" />
|
||||||
|
|
||||||
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus"
|
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus"
|
||||||
@refresh="handleGetData()" />
|
@refresh="handleGetData()" />
|
||||||
|
|
||||||
<view v-else class="box-border pt-72">
|
<view v-else class="box-border pt-72 pb-4">
|
||||||
<!-- 顶部背景封面区域 -->
|
<!-- 顶部背景封面区域 -->
|
||||||
<view class="fixed left-0 top-0 h-72 w-full">
|
<view class="fixed left-0 top-0 h-72 w-full">
|
||||||
<image v-if="result?.spec.cover" :src="result.spec.cover" class="h-full w-full" mode="aspectFill" />
|
<image v-if="result?.spec.cover" :src="result.spec.cover" class="h-full w-full" mode="aspectFill" />
|
||||||
@@ -465,16 +467,16 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass box-border overflow-hidden border rounded-lt-3xl rounded-rt-3xl border-b-none -translate-y-12"
|
class="uh-global-card-glass box-border overflow-hidden border rounded-lt-3xl rounded-rt-3xl border-b-none uh-content-lift"
|
||||||
:style="{
|
:style="{
|
||||||
boxShadow: '0 -16rpx 12rpx rgba(0, 0, 0, 0.035)',
|
boxShadow: '0 -16rpx 12rpx rgba(0, 0, 0, 0.035)',
|
||||||
}">
|
}">
|
||||||
<!-- 顶部信息 -->
|
<!-- 顶部信息 -->
|
||||||
<view class="box-border flex flex-col gap-3 p-3 pb-2">
|
<view class="box-border flex flex-col gap-3 p-4 pb-2">
|
||||||
<view class="flex items-center gap-x-2">
|
<view class="flex items-center gap-x-2">
|
||||||
<image :src="result.owner.avatar" class="uh-global-card-glass block h-6 w-6 rounded-full"
|
<image :src="result.owner.avatar" class="uh-global-card-glass block h-6 w-6 rounded-full"
|
||||||
mode="aspectFill" />
|
mode="aspectFill" />
|
||||||
<text class="text-sm font-semibold">{{ result?.owner?.displayName }}</text>
|
<text class="text-sm text-gray-900">{{ result?.owner?.displayName }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="font-semibold">
|
<view class="font-semibold">
|
||||||
{{ result?.spec.title }}
|
{{ result?.spec.title }}
|
||||||
@@ -492,7 +494,7 @@
|
|||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="uh-global-card-glass uh-shadow-xs box-border flex flex-col gap-2 rounded-xl p-3">
|
<view class="uh-global-card-glass uh-shadow-xs box-border flex flex-col gap-3 rounded-xl p-4">
|
||||||
<view v-if="originalURL" class="flex flex-1 items-center gap-x-2 text-gray-500">
|
<view v-if="originalURL" class="flex flex-1 items-center gap-x-2 text-gray-500">
|
||||||
<text class="text-xs">原文</text>
|
<text class="text-xs">原文</text>
|
||||||
<text class="text-xs text-gray-900" @click.stop="handleToOriginal(originalURL)">
|
<text class="text-xs text-gray-900" @click.stop="handleToOriginal(originalURL)">
|
||||||
@@ -525,7 +527,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 内容区域 -->
|
<!-- 内容区域 -->
|
||||||
<view class="box-border flex flex-col gap-y-3 p-3 text-gray-900 text-sm">
|
<view class="box-border flex flex-col gap-y-4 p-4 pt-2 text-gray-900 text-3xs">
|
||||||
<!-- 受限阅读 -->
|
<!-- 受限阅读 -->
|
||||||
<template v-if="checkPostRestrictRead(result!)">
|
<template v-if="checkPostRestrictRead(result!)">
|
||||||
<view v-if="showContentArr.length === 0">
|
<view v-if="showContentArr.length === 0">
|
||||||
@@ -560,19 +562,19 @@
|
|||||||
<!-- 相关投票(容器内置插件检查/展开收起,无数据或插件未激活自动不渲染) -->
|
<!-- 相关投票(容器内置插件检查/展开收起,无数据或插件未激活自动不渲染) -->
|
||||||
<uh-article-vote :vote-ids="result?._voteIds || []" />
|
<uh-article-vote :vote-ids="result?._voteIds || []" />
|
||||||
|
|
||||||
<view class="box-border px-1">
|
<view class="box-border px-4">
|
||||||
<!-- 版权声明 -->
|
<!-- 版权声明 -->
|
||||||
<view v-if="postDetailConfig?.copyrightEnabled" class="box-border px-2 mb-3">
|
<view v-if="postDetailConfig?.copyrightEnabled" class="box-border mb-4">
|
||||||
<view class="uh-global-card-glass uh-shadow-xs rounded-xl p-3">
|
<view class="uh-global-card-glass uh-shadow-xs rounded-xl p-3">
|
||||||
<uh-section-title>版权声明</uh-section-title>
|
<uh-section-title>版权声明</uh-section-title>
|
||||||
<view class="mt-3 flex flex-col gap-y-2 text-gray-600">
|
<view class="mt-3 flex flex-col gap-y-2 text-gray-600 text-xs">
|
||||||
<view v-if="postDetailConfig.copyrightAuthor" class="text-sm leading-5">
|
<view v-if="postDetailConfig.copyrightAuthor" class="leading-5">
|
||||||
版权归属:{{ postDetailConfig.copyrightAuthor }}
|
版权归属:{{ postDetailConfig.copyrightAuthor }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="postDetailConfig.copyrightDesc" class="text-sm leading-5">
|
<view v-if="postDetailConfig.copyrightDesc" class="leading-5">
|
||||||
版权说明:{{ postDetailConfig.copyrightDesc }}
|
版权说明:{{ postDetailConfig.copyrightDesc }}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="postDetailConfig.copyrightViolation" class="text-sm text-red-400 leading-5">
|
<view v-if="postDetailConfig.copyrightViolation" class="text-red-400 leading-5">
|
||||||
侵权处理:{{ postDetailConfig.copyrightViolation }}
|
侵权处理:{{ postDetailConfig.copyrightViolation }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -580,37 +582,39 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 评论区域 -->
|
<!-- 评论区域 -->
|
||||||
<view class="box-border px-2">
|
<view class="box-border">
|
||||||
<uh-comment-list v-if="calcIsShowComment && result" :disallow-comment="!result.spec.allowComment"
|
<uh-comment-list v-if="calcIsShowComment && result"
|
||||||
:post-name="result.metadata.name" :post="result" @on-comment="handleOnComment"
|
:disallow-comment="!result.spec.allowComment" :post-name="result.metadata.name"
|
||||||
@on-comment-detail="handleOnShowCommentDetail" @on-loaded="handleCommentLoaded" />
|
:post="result" @on-comment="handleOnComment" @on-comment-detail="handleOnShowCommentDetail"
|
||||||
|
@on-loaded="handleCommentLoaded" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 悬浮操作 -->
|
<!-- 悬浮操作 -->
|
||||||
<view class="fixed bottom-8 left-1/2 z-10 flex items-center justify-center pb-safe -translate-x-1/2">
|
<view class="fixed bottom-0 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
|
||||||
<!-- #7BE200 -->
|
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||||
:class="{ active: hasUpvoted() }" @click="handleDoLikesClick">
|
:class="[hasUpvoted()?'text-primary':'text-gray-900']" @click="handleDoLikesClick">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="36rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="36rpx" />
|
||||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">点赞</text>
|
<text class="shrink-0 text-xs font-semibold">点赞</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="calcIsShowComment"
|
<view v-if="calcIsShowComment"
|
||||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||||
@click="handleToComment()">
|
@click="handleToComment()">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="36rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="36rpx" />
|
||||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">评论</text>
|
<text class="shrink-0 text-xs text-gray-900 font-semibold">评论</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||||
@click="handleTogglePostFavorite">
|
@click="handleTogglePostFavorite">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
|
||||||
<text class="shrink-0 text-sm text-gray-900 font-semibold"
|
<text class="shrink-0 text-xs font-semibold"
|
||||||
:style="hasFavorited() ? { color: '#ffb300' } : ''">{{ hasFavorited() ? '已收藏' : '收藏' }}</text>
|
:class="[hasFavorited()?'text-primary':'text-gray-900']">
|
||||||
|
{{ hasFavorited() ? '已收藏' : '收藏' }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -636,6 +640,19 @@
|
|||||||
|
|
||||||
<!-- 评论弹窗 -->
|
<!-- 评论弹窗 -->
|
||||||
<uh-comment-modal v-if="commentModal.show" :show="commentModal.show" :is-comment="commentModal.isComment"
|
<uh-comment-modal v-if="commentModal.show" :show="commentModal.show" :is-comment="commentModal.isComment"
|
||||||
:title="commentModal.title" :post-name="commentModal.postName" @on-close="handleOnCommentModalClose" />
|
:title="commentModal.title" :post-name="commentModal.postName" :quote-reply="commentModal.quoteReply"
|
||||||
|
@on-close="handleOnCommentModalClose" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
/* 内容区域上移 */
|
||||||
|
.uh-content-lift {
|
||||||
|
transform: translateY(-3rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 水平居中定位 */
|
||||||
|
.uh-translate-x-center {
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,232 +1,248 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getCategoryList, getPostList } from '@/api/halo'
|
import { getCategoryList, getCategoryPostList, getPostList } from '@/api/halo'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { useSettingStore } from '@/store/setting'
|
import { useSettingStore } from '@/store/setting'
|
||||||
import { checkAvatarUrl } from '@/utils/url'
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { t } from '@/locale'
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { checkAvatarUrl } from '@/utils/url'
|
||||||
import { sleep } from '@/utils/common'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
import type { ICategory, IPost } from '@/api/types/halo'
|
import { sleep } from '@/utils/common'
|
||||||
|
import type { ICategory, IPost } from '@/api/types/halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '文章列表',
|
navigationBarTitleText: '文章列表',
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
enablePullDownRefresh: true,
|
enablePullDownRefresh: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const appConfigStore = useAppConfigStore()
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
|
const appConfigStore = useAppConfigStore()
|
||||||
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
|
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
/** 文章列表页列表布局(偏好设置驱动:single=单列 / double=双列) */
|
/** 文章列表页列表布局(偏好设置驱动:single=单列 / double=双列) */
|
||||||
const articlesListLayout = computed(() => settingStore.settings.articlesListLayout)
|
const articlesListLayout = computed(() => settingStore.settings.articlesListLayout)
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const articleList = ref<IPost[]>([])
|
const articleList = ref<IPost[]>([])
|
||||||
const queryParams = ref({ size: 10, page: 1 })
|
const queryParams = ref({ size: 10, page: 1 })
|
||||||
const hasNext = ref(false)
|
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref(t('common.loading'))
|
|
||||||
|
|
||||||
interface IFilterOption {
|
interface IFilterOption {
|
||||||
label: string
|
label : string
|
||||||
value: string
|
value : string
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoryList = ref<ICategory[]>([])
|
const categoryList = ref<ICategory[]>([])
|
||||||
|
|
||||||
const sortMap: Record<string, string[]> = {
|
const sortMap : Record<string, string[]> = {
|
||||||
default: ['spec.pinned,desc', 'spec.publishTime,desc'],
|
default: ['spec.pinned,desc', 'spec.publishTime,desc'],
|
||||||
latest: ['spec.publishTime,desc'],
|
latest: ['spec.publishTime,desc'],
|
||||||
oldest: ['spec.publishTime,asc'],
|
oldest: ['spec.publishTime,asc'],
|
||||||
pinned: ['spec.pinned,desc'],
|
pinned: ['spec.pinned,desc'],
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoryOptions = computed<IFilterOption[]>(() => [
|
const categoryOptions = computed<IFilterOption[]>(() => [
|
||||||
{ label: '全部', value: '' },
|
{ label: '全部', value: '' },
|
||||||
...categoryList.value.map(c => ({ label: c.spec.displayName, value: c.metadata.name })),
|
...categoryList.value.map(c => ({ label: c.spec.displayName, value: c.metadata.name })),
|
||||||
])
|
])
|
||||||
|
|
||||||
const sortOptions: IFilterOption[] = [
|
const sortOptions : IFilterOption[] = [
|
||||||
{ label: '默认排序', value: 'default' },
|
{ label: '默认排序', value: 'default' },
|
||||||
{ label: '最新', value: 'latest' },
|
{ label: '最新', value: 'latest' },
|
||||||
{ label: '最旧', value: 'oldest' },
|
{ label: '最旧', value: 'oldest' },
|
||||||
{ label: '置顶', value: 'pinned' },
|
{ label: '置顶', value: 'pinned' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const filterValues = ref<Record<string, string>>({ category: '', sort: 'default' })
|
const filterValues = ref<Record<string, string>>({ category: '', sort: 'default' })
|
||||||
|
|
||||||
/** 切换分类/排序:重置分页并重新查询 */
|
/** 切换分类/排序:重置分页并重新查询 */
|
||||||
function handleSelectFilter(key: 'category' | 'sort', value: string) {
|
function handleSelectFilter(key : 'category' | 'sort', value : string) {
|
||||||
if (filterValues.value[key] === value)
|
if (filterValues.value[key] === value) { return }
|
||||||
return
|
filterValues.value[key] = value
|
||||||
filterValues.value[key] = value
|
resetLoadMoreStatus()
|
||||||
isLoadMore.value = false
|
articleList.value = []
|
||||||
articleList.value = []
|
queryParams.value.page = 1
|
||||||
queryParams.value.page = 1
|
handleGetArticleList()
|
||||||
handleGetArticleList()
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** 拉取分类列表(用于筛选选项) */
|
/** 拉取分类列表(用于筛选选项) */
|
||||||
async function handleGetCategoryList() {
|
async function handleGetCategoryList() {
|
||||||
try {
|
try {
|
||||||
const res = await getCategoryList({ page: 1, size: 0, tree: true })
|
const res = await getCategoryList({ page: 1, size: 0, tree: true })
|
||||||
categoryList.value = res.data.items || []
|
categoryList.value = res.data.items || []
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error('获取分类列表失败', err)
|
console.error('获取分类列表失败', err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetArticleList() {
|
async function handleGetArticleList() {
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
// 审核模式
|
||||||
try {
|
resetLoadMoreStatus()
|
||||||
const res = await getPostList({ page: 1, size: 0, sort: ['spec.publishTime,desc'] })
|
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
||||||
const filtered = res.data.items.filter(item => auditPostNames.includes(item.metadata.name))
|
try {
|
||||||
articleList.value = filtered.map((item) => {
|
const res = await getPostList({ page: 1, size: 0, sort: ['spec.publishTime,desc'] })
|
||||||
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
const filtered = res.data.items.filter(item => auditPostNames.includes(item.metadata.name))
|
||||||
return item
|
articleList.value = filtered.map((item) => {
|
||||||
})
|
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
||||||
await sleep(600)
|
return item
|
||||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
})
|
||||||
loadMoreText.value = t('common.noMore')
|
await sleep(600)
|
||||||
}
|
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
catch (err) {
|
updateLoadMoreStatus({
|
||||||
console.error('获取审核文章失败', err)
|
active: false,
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
status: 'noMore',
|
||||||
loadMoreText.value = t('common.loadFailed')
|
hasNext: false,
|
||||||
}
|
})
|
||||||
finally {
|
}
|
||||||
uni.stopPullDownRefresh()
|
catch (err) {
|
||||||
}
|
console.error('获取审核文章失败', err)
|
||||||
return
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
}
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uni.stopPullDownRefresh()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!isLoadMore.value) {
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
loadMoreText.value = t('common.loading')
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const params = {
|
const category = filterValues.value.category || ''
|
||||||
...queryParams.value,
|
const params = {
|
||||||
category: filterValues.value.category || undefined,
|
...queryParams.value,
|
||||||
sort: sortMap[filterValues.value.sort] || sortMap.default,
|
sort: sortMap[filterValues.value.sort] || sortMap.default,
|
||||||
}
|
}
|
||||||
const res = await getPostList(params)
|
// 注意:/posts 公开接口不支持 category 过滤参数,分类筛选需走分类下文章接口
|
||||||
hasNext.value = res.data.hasNext
|
const res = category
|
||||||
articleList.value = (isLoadMore.value
|
? await getCategoryPostList(category, params)
|
||||||
? articleList.value.concat(res.data.items)
|
: await getPostList(params)
|
||||||
: res.data.items).map((item) => {
|
articleList.value = (loadMoreStatus.value.active
|
||||||
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
? articleList.value.concat(res.data.items)
|
||||||
return item
|
: res.data.items).map((item) => {
|
||||||
})
|
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
||||||
await sleep(600)
|
return item
|
||||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
})
|
||||||
loadMoreText.value = res.data.hasNext ? t('common.loadMore') : t('common.noMore')
|
if (!loadMoreStatus.value.active) {
|
||||||
}
|
await sleep(600)
|
||||||
catch (err) {
|
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
}
|
||||||
loadMoreText.value = t('common.loadFailed')
|
updateLoadMoreStatus({
|
||||||
console.error('获取文章失败', err)
|
active: false,
|
||||||
}
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
finally {
|
hasNext: res.data.hasNext,
|
||||||
uni.stopPullDownRefresh()
|
})
|
||||||
}
|
}
|
||||||
}
|
catch (err) {
|
||||||
|
console.error('获取文章失败', err)
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uni.stopPullDownRefresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onLoad(() => {
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
handleGetCategoryList()
|
updatePageScrollValue(option.scrollTop)
|
||||||
handleGetArticleList()
|
})
|
||||||
})
|
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onLoad(() => {
|
||||||
if (calcAuditModeEnabled.value) {
|
handleGetCategoryList()
|
||||||
uni.stopPullDownRefresh()
|
handleGetArticleList()
|
||||||
return
|
})
|
||||||
}
|
|
||||||
isLoadMore.value = false
|
|
||||||
queryParams.value.page = 1
|
|
||||||
articleList.value = []
|
|
||||||
handleGetArticleList()
|
|
||||||
})
|
|
||||||
|
|
||||||
onReachBottom(() => {
|
onPullDownRefresh(() => {
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
uni.stopPullDownRefresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (hasNext.value) {
|
resetLoadMoreStatus()
|
||||||
queryParams.value.page += 1
|
queryParams.value.page = 1
|
||||||
isLoadMore.value = true
|
articleList.value = []
|
||||||
handleGetArticleList()
|
handleGetArticleList()
|
||||||
}
|
})
|
||||||
else {
|
|
||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
onReachBottom(() => {
|
||||||
}
|
if (calcAuditModeEnabled.value) {
|
||||||
})
|
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 正在加载时阻止重复请求
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 有更多数据时继续加载
|
||||||
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetArticleList()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="min-h-screen w-screen flex flex-col bg-page">
|
<view class="min-h-screen w-screen flex flex-col bg-page">
|
||||||
<uh-navbar default-title="文章列表" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="文章列表" title-color="text-gray-900" />
|
||||||
|
|
||||||
<wd-sticky v-if="categoryOptions.length > 1" class="w-full">
|
<wd-sticky v-if="categoryOptions.length > 1" class="w-screen overflow-hidden" :offset-top="offsetTop">
|
||||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap pt-2">
|
<view class="w-screen overflow-hidden">
|
||||||
<view
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap pb-1.5">
|
||||||
v-for="cate in categoryOptions" :key="cate.value"
|
<view v-for="cate in categoryOptions" :key="cate.value"
|
||||||
class="uh-global-card-glass uh-shadow-xs mb-1 ml-3 inline-flex border rounded-2xl px-4 py-1 text-sm"
|
class="uh-global-card-glass shadow-none ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
:class="{ 'bg-primary text-gray-900 font-bold': filterValues.category === cate.value }"
|
:class="{ 'bg-primary text-gray-900 font-semibold': filterValues.category === cate.value }"
|
||||||
@click="handleSelectFilter('category', cate.value)"
|
@click="handleSelectFilter('category', cate.value)">
|
||||||
>
|
{{ cate.label }}
|
||||||
{{ cate.label }}
|
</view>
|
||||||
</view>
|
</scroll-view>
|
||||||
</scroll-view>
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
</wd-sticky>
|
<view class="box-border flex gap-2 px-3 pb-1.5">
|
||||||
|
<view v-for="opt in sortOptions" :key="opt.value"
|
||||||
|
class="uh-global-card-glass shadow-none inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
|
:class="{ 'bg-primary text-gray-900 font-semibold': filterValues.sort === opt.value, 'text-gray-500': filterValues.sort !== opt.value }"
|
||||||
|
@click="handleSelectFilter('sort', opt.value)">
|
||||||
|
{{ opt.label }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</wd-sticky>
|
||||||
|
|
||||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
<view class="box-border flex gap-2 px-3 py-2">
|
empty-text="啊偶,还没有任何内容哦~" min-height="75vh" @refresh="handleGetArticleList" />
|
||||||
<view
|
|
||||||
v-for="opt in sortOptions" :key="opt.value"
|
|
||||||
class="uh-global-card-glass uh-shadow-xs inline-flex border rounded-full px-3 py-1 text-xs"
|
|
||||||
:class="{ 'bg-secondary text-gray-900 font-bold': filterValues.sort === opt.value }"
|
|
||||||
@click="handleSelectFilter('sort', opt.value)"
|
|
||||||
>
|
|
||||||
{{ opt.label }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
|
|
||||||
<uh-data-loading
|
<view v-else class="box-border flex flex-col gap-4 p-3">
|
||||||
v-if="loadingStatus !== DataLoadingStatusEnum.Success"
|
<view :class="articlesListLayout === 'double' ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-3'">
|
||||||
:loading-status="loadingStatus"
|
<uh-article-card v-for="(article, index) in articleList" :key="article.metadata.name || index"
|
||||||
empty-text="啊偶,还没有任何内容哦~"
|
from="articles" :variant="articlesListLayout === 'double' ? 'grid' : 'list'" :article="article"
|
||||||
min-height="75vh"
|
:audit-mode="calcAuditModeEnabled" />
|
||||||
@refresh="handleGetArticleList"
|
</view>
|
||||||
/>
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
|
</view>
|
||||||
<view v-else class="box-border flex flex-col gap-4 p-3">
|
</view>
|
||||||
<view :class="articlesListLayout === 'double' ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-3'">
|
|
||||||
<uh-article-card
|
|
||||||
v-for="(article, index) in articleList"
|
|
||||||
:key="article.metadata.name || index"
|
|
||||||
from="articles"
|
|
||||||
:variant="articlesListLayout === 'double' ? 'grid' : 'list'"
|
|
||||||
:article="article"
|
|
||||||
:audit-mode="calcAuditModeEnabled"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
<view class="box-border py-5 text-center text-xs text-gray-400">
|
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
@@ -2,184 +2,160 @@
|
|||||||
/**
|
/**
|
||||||
* 轮播详情页(自定义 Banner 条目点击后进入)
|
* 轮播详情页(自定义 Banner 条目点击后进入)
|
||||||
* 通过公开详情接口(getBannerDetail)拉取 content 富文本与外链,类文章详情页
|
* 通过公开详情接口(getBannerDetail)拉取 content 富文本与外链,类文章详情页
|
||||||
* 外链平台差异(条件编译):非 APP-PLUS(小程序/H5)提供复制+显示链接,APP-PLUS 提供访问按钮(web-view)
|
* 外链平台差异(条件编译):非 APP-PLUS(小程序/H5)提供复制链接,APP-PLUS 提供访问按钮(web-view)
|
||||||
*/
|
*/
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { getBannerDetail } from '@/api/uni-halo'
|
import { getBannerDetail } from '@/api/uni-halo'
|
||||||
import { checkAvatarUrl, checkThumbnailUrl } from '@/utils/url'
|
import { checkAvatarUrl, checkThumbnailUrl } from '@/utils/url'
|
||||||
import { formatTime } from '@/utils/formatTime'
|
import { formatTime } from '@/utils/formatTime'
|
||||||
import { copyToClipboard } from '@/utils/restrictRead'
|
import { copyToClipboard } from '@/utils/restrictRead'
|
||||||
|
import { sleep } from '@/utils/common'
|
||||||
|
import { markdownConfig } from '@/config/markdown'
|
||||||
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import type { IBannerPublicDetail } from '@/api/types/uni-halo'
|
import type { IBannerPublicDetail } from '@/api/types/uni-halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '轮播详情',
|
navigationBarTitleText: '轮播详情',
|
||||||
},
|
navigationStyle: 'custom',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const loading = ref<'loading' | 'success' | 'error'>('loading')
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
|
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||||
|
const name = ref('')
|
||||||
const detail = ref<IBannerPublicDetail | null>(null)
|
const detail = ref<IBannerPublicDetail | null>(null)
|
||||||
const linkCopied = ref(false)
|
const linkCopied = ref(false)
|
||||||
|
|
||||||
async function handleGetData(name: string) {
|
/** 封面图:无封面时回退默认缩略图 */
|
||||||
loading.value = 'loading'
|
|
||||||
try {
|
|
||||||
const res = await getBannerDetail(name)
|
|
||||||
detail.value = res.data || null
|
|
||||||
if (detail.value?.title) {
|
|
||||||
uni.setNavigationBarTitle({ title: detail.value.title })
|
|
||||||
}
|
|
||||||
loading.value = 'success'
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error('获取轮播详情失败', err)
|
|
||||||
loading.value = 'error'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRetry() {
|
|
||||||
const name = detail.value?.name || ''
|
|
||||||
if (name) {
|
|
||||||
handleGetData(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoad((options) => {
|
|
||||||
const name = options?.name
|
|
||||||
if (name) {
|
|
||||||
handleGetData(name)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
loading.value = 'error'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const coverUrl = computed(() => checkThumbnailUrl(detail.value?.cover, true))
|
const coverUrl = computed(() => checkThumbnailUrl(detail.value?.cover, true))
|
||||||
|
|
||||||
const authorName = computed(() => detail.value?.authorName || '')
|
const authorName = computed(() => detail.value?.authorName || '')
|
||||||
|
|
||||||
const authorAvatar = computed(() =>
|
const authorAvatar = computed(() =>
|
||||||
detail.value?.authorAvatar ? checkAvatarUrl(detail.value.authorAvatar) : '',
|
detail.value?.authorAvatar ? checkAvatarUrl(detail.value.authorAvatar) : '',
|
||||||
)
|
)
|
||||||
|
|
||||||
const dateText = computed(() => {
|
const dateText = computed(() => {
|
||||||
if (!detail.value?.date) {
|
if (!detail.value?.date) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
const d = new Date(detail.value.date)
|
const d = new Date(detail.value.date)
|
||||||
if (Number.isNaN(d.getTime())) {
|
if (Number.isNaN(d.getTime())) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
return formatTime({ d: detail.value.date, f: 'yyyy-MM-dd' })
|
return formatTime({ d: detail.value.date, f: 'yyyy-MM-dd' })
|
||||||
|
})
|
||||||
|
|
||||||
|
const content = computed(() => detail.value?.content || '')
|
||||||
|
|
||||||
|
/** 外链存在即展示底部操作(复制/访问) */
|
||||||
|
const hasLink = computed(() => !!detail.value?.link)
|
||||||
|
|
||||||
|
/** 加载轮播详情(状态机;404/无数据 → 空态,其余错误 → error 态,可重试) */
|
||||||
|
async function loadDetail() {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
|
if (!name.value) {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Empty)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await getBannerDetail(name.value)
|
||||||
|
detail.value = res.data || null
|
||||||
|
await sleep(600)
|
||||||
|
updateLoadingStatus(detail.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error('轮播详情加载失败', err)
|
||||||
|
const code = (err as { code ?: number }).code
|
||||||
|
updateLoadingStatus(code === 404 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onPageScroll((option: Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
name.value = options?.name || ''
|
||||||
|
loadDetail()
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 非 APP-PLUS:复制链接 */
|
/** 非 APP-PLUS:复制链接 */
|
||||||
function handleCopyLink() {
|
function handleCopyLink() {
|
||||||
if (!detail.value?.link) {
|
if (!detail.value?.link) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
copyToClipboard(detail.value.link, '链接已复制')
|
copyToClipboard(detail.value.link, '链接已复制')
|
||||||
linkCopied.value = true
|
linkCopied.value = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
linkCopied.value = false
|
linkCopied.value = false
|
||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** APP-PLUS:打开内置 web-view 访问外链 */
|
/** APP-PLUS:打开内置 web-view 访问外链 */
|
||||||
function handleOpenLink() {
|
function handleOpenLink() {
|
||||||
if (!detail.value?.link) {
|
if (!detail.value?.link) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages-blog/website/website?data=${JSON.stringify({
|
url: `/pages-blog/website/website?data=${JSON.stringify({
|
||||||
title: detail.value.title || '查看链接',
|
title: detail.value.title || '查看链接',
|
||||||
url: encodeURIComponent(detail.value.link),
|
url: encodeURIComponent(detail.value.link),
|
||||||
})}`,
|
})}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="app-page">
|
<view class="box-border min-h-screen w-screen bg-page pb-safe">
|
||||||
<!-- 加载/错误占位 -->
|
<!-- 自定义导航 -->
|
||||||
<view v-if="loading !== 'success'">
|
<uh-navbar :scroll-y="scrollY" default-title="轮播详情" title-color="text-gray-900" :scroll-title="detail?.title" />
|
||||||
<uh-data-loading :loading-status="loading" @refresh="handleRetry" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 详情内容 -->
|
<!-- 加载/错误/空态(状态机) -->
|
||||||
<view v-else-if="detail" class="pb-8">
|
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="75vh"
|
||||||
<!-- 封面图 -->
|
error-text="轮播详情加载失败" empty-text="轮播图不存在或已下线" empty-sub-text="" @refresh="loadDetail" />
|
||||||
<image v-if="coverUrl" :src="coverUrl" class="h-[420rpx] w-full" mode="aspectFill" />
|
|
||||||
|
|
||||||
<view class="px-4">
|
<!-- 正文 -->
|
||||||
<!-- 标题 -->
|
<view v-else-if="detail" class="box-border p-4">
|
||||||
<view class="mt-6 text-[34rpx] text-[#303133] font-bold leading-snug">
|
<image v-if="coverUrl" class="mb-5 h-[320rpx] w-full rounded-xl" :src="coverUrl" mode="aspectFill" />
|
||||||
{{ detail.title }}
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 作者/日期信息 -->
|
<view class="text-[36rpx] font-bold leading-snug text-gray-900">
|
||||||
<view v-if="authorName || dateText" class="mt-3 flex items-center gap-2">
|
{{ detail.title }}
|
||||||
<image
|
</view>
|
||||||
v-if="authorAvatar"
|
|
||||||
:src="authorAvatar"
|
|
||||||
class="h-[44rpx] w-[44rpx] rounded-full"
|
|
||||||
mode="aspectFill"
|
|
||||||
/>
|
|
||||||
<text class="text-[24rpx] text-[#909399]">{{ authorName }}</text>
|
|
||||||
<text v-if="dateText" class="text-[22rpx] text-[#c0c4cc]">{{ dateText }}</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 富文本内容 -->
|
<!-- 作者/日期信息 -->
|
||||||
<view v-if="detail.content" class="mt-6 border-t border-[#f0f0f0] pt-6">
|
<view v-if="authorName || dateText" class="mt-3 flex items-center gap-2">
|
||||||
<mp-html :content="detail.content" />
|
<image v-if="authorAvatar" :src="authorAvatar" class="h-[44rpx] w-[44rpx] rounded-full"
|
||||||
</view>
|
mode="aspectFill" />
|
||||||
|
<text class="text-[24rpx] text-gray-500">{{ authorName }}</text>
|
||||||
|
<text v-if="dateText" class="text-[22rpx] text-gray-500">{{ dateText }}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 外链(平台差异,条件编译) -->
|
<!-- 富文本内容 -->
|
||||||
<view v-if="detail.link" class="link-card mt-8 rounded-xl bg-[#f7f7f9] p-4">
|
<view v-if="content" class="box-border w-full mt-2 pt-4 pb-6">
|
||||||
<view class="mb-3 text-[24rpx] text-[#909399]">
|
<mp-html :content="content" lazy-load :domain="markdownConfig.domain ?? ''" scroll-table selectable
|
||||||
相关链接
|
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||||
</view>
|
:show-line-number="false" copy-by-long-press />
|
||||||
<text class="link-text block break-all text-[26rpx] text-[#606266] leading-relaxed">
|
</view>
|
||||||
{{ detail.link }}
|
|
||||||
</text>
|
<!-- 外链(平台差异,条件编译):非 APP 复制 / APP 访问 -->
|
||||||
<!-- #ifndef APP-PLUS -->
|
<view v-if="hasLink" class="fixed left-0 right-0 bottom-0 pb-safe px-4 box-border">
|
||||||
<!-- 非 App 端(小程序/H5):复制 + 提示已复制 -->
|
<view class="w-full h-full uh-global-card-glass border rounded-full mb-4">
|
||||||
<view
|
<!-- #ifndef APP-PLUS -->
|
||||||
class="link-btn mt-3 inline-flex items-center rounded-lg px-6 py-2 text-[24rpx] text-white"
|
<uh-button custom-class="w-full !rounded-full py-2.5 font-medium" @click="handleCopyLink">
|
||||||
:class="linkCopied ? 'link-btn-copied' : ''"
|
{{ linkCopied ? '已复制' : '复制链接' }}
|
||||||
@click="handleCopyLink"
|
</uh-button>
|
||||||
>
|
<!-- #endif -->
|
||||||
{{ linkCopied ? '已复制' : '复制链接' }}
|
<!-- #ifdef APP-PLUS -->
|
||||||
</view>
|
<uh-button custom-class="w-full !rounded-full py-2.5 font-medium" @click="handleOpenLink">
|
||||||
<!-- #endif -->
|
访问链接
|
||||||
<!-- #ifdef APP-PLUS -->
|
</uh-button>
|
||||||
<!-- App 端:访问按钮(内置 web-view) -->
|
<!-- #endif -->
|
||||||
<view class="link-btn mt-3 inline-flex items-center rounded-lg px-6 py-2 text-[24rpx] text-white" @click="handleOpenLink">
|
</view>
|
||||||
访问链接
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- #endif -->
|
</view>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.app-page {
|
|
||||||
min-height: 100vh;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.link-text {
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.link-btn {
|
|
||||||
background: #2563eb;
|
|
||||||
|
|
||||||
&.link-btn-copied {
|
|
||||||
background: #10b981;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||||
import { getCategoryPostList } from '@/api/halo'
|
import { getCategoryPostList } from '@/api/halo'
|
||||||
|
import { sleep } from '@/utils/common'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import type { IPost, IPostListReq } from '@/api/types/halo'
|
import type { IPost, IPostListReq } from '@/api/types/halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
@@ -13,15 +15,13 @@ definePage({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const queryParams = ref({ size: 10, page: 0 })
|
const queryParams = ref({ size: 10, page: 0 })
|
||||||
const name = ref('')
|
const name = ref('')
|
||||||
const pageTitle = ref('加载中...')
|
const pageTitle = ref('加载中...')
|
||||||
const navbarTitle = ref('分类详情')
|
const navbarTitle = ref('分类详情')
|
||||||
const hasNext = ref(false)
|
|
||||||
const dataList = ref<IPost[]>([])
|
const dataList = ref<IPost[]>([])
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref('')
|
|
||||||
|
|
||||||
/* ---------------- 排序切换(sort 参数由接口透传,见 IPostListReq.sort) ---------------- */
|
/* ---------------- 排序切换(sort 参数由接口透传,见 IPostListReq.sort) ---------------- */
|
||||||
const sortOptions: { key: string; label: string; sort?: string[] }[] = [
|
const sortOptions: { key: string; label: string; sort?: string[] }[] = [
|
||||||
@@ -36,16 +36,15 @@ function handleSortChange(key: string) {
|
|||||||
if (activeSort.value === key)
|
if (activeSort.value === key)
|
||||||
return
|
return
|
||||||
activeSort.value = key
|
activeSort.value = key
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
queryParams.value.page = 0
|
queryParams.value.page = 0
|
||||||
handleGetData()
|
handleGetData()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
if (!isLoadMore.value) {
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
loadMoreText.value = '加载中...'
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const reqParams: Record<string, unknown> = { ...queryParams.value }
|
const reqParams: Record<string, unknown> = { ...queryParams.value }
|
||||||
@@ -58,26 +57,35 @@ async function handleGetData() {
|
|||||||
}
|
}
|
||||||
const res = await getCategoryPostList(name.value, reqParams as IPostListReq)
|
const res = await getCategoryPostList(name.value, reqParams as IPostListReq)
|
||||||
navbarTitle.value = `${pageTitle.value} (共${res.data.total}篇)`
|
navbarTitle.value = `${pageTitle.value} (共${res.data.total}篇)`
|
||||||
hasNext.value = res.data.hasNext
|
dataList.value = loadMoreStatus.value.active
|
||||||
dataList.value = isLoadMore.value
|
|
||||||
? dataList.value.concat(res.data.items)
|
? dataList.value.concat(res.data.items)
|
||||||
: res.data.items
|
: res.data.items
|
||||||
loadMoreText.value = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'
|
if (!loadMoreStatus.value.active) {
|
||||||
setTimeout(() => {
|
await sleep(600)
|
||||||
updateLoadingStatus(
|
updateLoadingStatus(
|
||||||
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
)
|
)
|
||||||
}, 500)
|
}
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
if (loadMoreStatus.value.active) {
|
||||||
loadMoreText.value = '加载失败,请下拉刷新!'
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setTimeout(() => {
|
uni.stopPullDownRefresh()
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
}, 500)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +96,10 @@ function handleToArticleDetail(article: IPost) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageScroll((option: Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
name.value = options?.name || ''
|
name.value = options?.name || ''
|
||||||
pageTitle.value = options?.title || '分类详情'
|
pageTitle.value = options?.title || '分类详情'
|
||||||
@@ -96,19 +108,24 @@ onLoad((options) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onPullDownRefresh(() => {
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
queryParams.value.page = 0
|
queryParams.value.page = 0
|
||||||
handleGetData()
|
handleGetData()
|
||||||
})
|
})
|
||||||
|
|
||||||
onReachBottom(() => {
|
onReachBottom(() => {
|
||||||
if (hasNext.value) {
|
// 正在加载时阻止重复请求
|
||||||
queryParams.value.page += 1
|
if (loadMoreStatus.value.active) {
|
||||||
isLoadMore.value = true
|
return
|
||||||
handleGetData()
|
|
||||||
}
|
}
|
||||||
else {
|
// 有更多数据时继续加载
|
||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -126,7 +143,7 @@ onShareTimeline(() => ({
|
|||||||
<template>
|
<template>
|
||||||
<view class="app-page min-h-screen w-screen flex flex-col" style="background-color: #fafafd;">
|
<view class="app-page min-h-screen w-screen flex flex-col" style="background-color: #fafafd;">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar :default-title="navbarTitle" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" :default-title="navbarTitle" title-color="text-gray-900" />
|
||||||
|
|
||||||
<!-- 排序切换:默认 / 按置顶 / 按最新 / 按最旧 -->
|
<!-- 排序切换:默认 / 按置顶 / 按最新 / 按最旧 -->
|
||||||
<view class="box-border flex items-center gap-2 px-3 py-2">
|
<view class="box-border flex items-center gap-2 px-3 py-2">
|
||||||
@@ -158,9 +175,7 @@ onShareTimeline(() => ({
|
|||||||
:article="article"
|
:article="article"
|
||||||
@on-click="handleToArticleDetail"
|
@on-click="handleToArticleDetail"
|
||||||
/>
|
/>
|
||||||
<view class="load-text py-5 text-center text-[24rpx] text-[#999]">
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
|
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
|
||||||
|
import { onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { checkAvatarUrl } from '@/utils/url'
|
import { checkAvatarUrl } from '@/utils/url'
|
||||||
import { formatTime } from '@/utils/formatTime'
|
import { formatTime } from '@/utils/formatTime'
|
||||||
import { markdownConfig } from '@/config/markdown'
|
import { markdownConfig } from '@/config/markdown'
|
||||||
@@ -14,16 +16,15 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
interface ISoical {
|
interface ISoical {
|
||||||
key ?: string
|
|
||||||
name : string
|
name : string
|
||||||
content : string
|
content : string
|
||||||
icon ?: string,
|
color : string
|
||||||
color : string,
|
bgColor : string
|
||||||
bgColor : string,
|
priority ?: number
|
||||||
priority ?: number,
|
visible ?: boolean
|
||||||
visible ?: boolean,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
|
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
|
||||||
|
|
||||||
@@ -45,11 +46,11 @@
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return [...configured]
|
return [...configured]
|
||||||
.filter(item => item.visible !== false)
|
.filter(item => item.visible && item.content.trim())
|
||||||
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
|
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && !!item.content))
|
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && item.content.trim()))
|
||||||
|
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
@@ -67,7 +68,6 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 实时时间(收信日期,formatTime 工具每秒刷新) ---------------- */
|
|
||||||
const nowText = ref('')
|
const nowText = ref('')
|
||||||
let clock : ReturnType<typeof setInterval> | null = null
|
let clock : ReturnType<typeof setInterval> | null = null
|
||||||
function refreshNowText() {
|
function refreshNowText() {
|
||||||
@@ -80,23 +80,27 @@
|
|||||||
clearInterval(clock)
|
clearInterval(clock)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
|
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="联系博主" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="联系博主" title-color="text-gray-900" />
|
||||||
|
|
||||||
<view class="fixed -right-8 top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] blur-xl" />
|
<view class="fixed top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] uh-blur-xl -right-8" />
|
||||||
<view class="fixed -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl" />
|
<view class="fixed top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] uh-blur-xl -left-10" />
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="box-border relative flex items-center justify-between uh-global-card-glass uh-shadow-xs rounded-xl p-4">
|
class="uh-global-card-glass uh-shadow-xs relative box-border flex items-center justify-between rounded-xl p-4">
|
||||||
<view class="flex-1 relative flex flex-col rounded-2xl">
|
<view class="relative flex flex-1 flex-col rounded-2xl">
|
||||||
<view class="flex items-center gap-x-2 text-xs text-primary">
|
<view class="flex items-center gap-x-2 text-xs text-primary">
|
||||||
TO <text class="text-sm">·</text> 收
|
TO <text class="text-sm">·</text> 收
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-2 text-md text-gray-900 tracking-wider">
|
<view class="text-md mt-2 text-gray-900 tracking-wider">
|
||||||
素未谋面的朋友
|
素未谋面的朋友
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-2 text-xs text-black/60">
|
<view class="mt-2 text-xs text-black/60">
|
||||||
@@ -107,13 +111,13 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="shrink-0 uh-global-card-glass uh-shadow-xs border relative rotate-3 box-border w-22 overflow-hidden flex flex-col gap-y-1 items-center justify-center p-2">
|
class="uh-global-card-glass uh-shadow-xs uh-rotate-3 relative box-border w-22 flex shrink-0 flex-col items-center justify-center gap-y-1 overflow-hidden border p-2">
|
||||||
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
|
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
|
||||||
<text class="text-xs font-normal truncate">{{ bloggerInfo.nickname }}</text>
|
<text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="mt-4 flex flex-col gap-y-6 box-border uh-global-card-glass uh-shadow-xs rounded-xl px-4 py-3">
|
<view class="uh-global-card-glass uh-shadow-xs mt-4 box-border flex flex-col gap-y-6 rounded-xl px-4 py-3">
|
||||||
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh"
|
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh"
|
||||||
empty-text="暂无联系方式" empty-sub-text="" />
|
empty-text="暂无联系方式" empty-sub-text="" />
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -121,28 +125,38 @@
|
|||||||
<view class="text-md text-gray-900">
|
<view class="text-md text-gray-900">
|
||||||
展信安:
|
展信安:
|
||||||
</view>
|
</view>
|
||||||
<mp-html v-if="bloggerInfo.intro" lazy-load :domain="markdownConfig.domain ?? ''"
|
<view v-if="bloggerInfo.intro" class="text-sm text-gray-900">
|
||||||
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
|
||||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
||||||
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
|
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||||
:show-language-name="true" copy-by-long-press />
|
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
|
||||||
<view class="mt-2 w-full flex items-end flex-col gap-y-3">
|
:show-language-name="true" copy-by-long-press />
|
||||||
<text class="text-md font-semibold text-gray-900">{{ bloggerInfo.nickname }}</text>
|
</view>
|
||||||
|
<view v-else class="py-4 text-sm text-gray-600">
|
||||||
|
祝你早安,午安,晚安。每天都有好心情,生活愉快!
|
||||||
|
</view>
|
||||||
|
<view class="mt-2 w-full flex flex-col items-end gap-y-3">
|
||||||
|
<text class="text-md text-gray-900 font-semibold">{{ bloggerInfo.nickname }}</text>
|
||||||
<text class="text-xs text-black/60">{{ nowText }}</text>
|
<text class="text-xs text-black/60">{{ nowText }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="box-border pt-4 w-full flex flex-col gap-y-2 border-t border-t-dashed border-gray-200">
|
<view class="box-border w-full flex flex-col gap-y-2 border-t border-gray-200 border-t-dashed pt-4">
|
||||||
|
<view class="text-md mb-2 text-gray-900">
|
||||||
|
若有意,可依此觅:
|
||||||
|
</view>
|
||||||
<view v-for="item in socialList" :key="item.name" class="flex items-center gap-3"
|
<view v-for="item in socialList" :key="item.name" class="flex items-center gap-3"
|
||||||
@click="handleOnClick(item)">
|
@click="handleOnClick(item)">
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass uh-shadow-xs border h-10 w-10 flex shrink-0 items-center justify-center rounded-xl"
|
class="uh-global-card-glass uh-shadow-xs h-11 w-11 flex shrink-0 items-center justify-center border rounded-xl"
|
||||||
:style="{ backgroundColor: item.bgColor ,color:item.color }">
|
:style="{ backgroundColor: item.bgColor, color: item.color }">
|
||||||
<text class="text-sm text-gray-500 font-bold"> {{ item.icon }} </text>
|
<text class="text-sm font-bold" :style="{ color: item.color }">
|
||||||
|
{{ item.name ? item.name.charAt(0) : '' }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="min-w-0 flex flex-1 flex-col">
|
<view class="min-w-0 flex flex-1 flex-col">
|
||||||
<text class="text-xs text-gray-500">{{ item.name }}</text>
|
<text class="text-xs text-gray-500">{{ item.name }}</text>
|
||||||
<view class="mt-1 break-all text-sm text-gray-900 leading-snug">
|
<view class="mt-1 break-all text-xs text-gray-900">
|
||||||
{{ item.content }}
|
{{ item.content }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -153,3 +167,13 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.uh-rotate-3 {
|
||||||
|
transform: rotate(3deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-blur-xl {
|
||||||
|
filter: blur(20rpx);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { onPullDownRefresh } from '@dcloudio/uni-app'
|
import { onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'
|
||||||
import { getChartData } from '@/api/uni-halo'
|
import { getChartData } from '@/api/uni-halo'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||||
import type { IDataStatistics } from '@/api/uni-halo'
|
import type { IDataStatistics } from '@/api/uni-halo'
|
||||||
import { sleep } from '@/utils/common'
|
import { sleep } from '@/utils/common'
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
/** 依赖插件(plugin-data-statistics,参考 gallery 对象传参模式) */
|
/** 依赖插件(plugin-data-statistics,参考 gallery 对象传参模式) */
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const { pluginId, checking, tips, available: uniHaloPluginAvailable, check: checkPluginAvailable } = usePluginAvailable({
|
const { pluginId, checking, tips, available: uniHaloPluginAvailable, check: checkPluginAvailable } = usePluginAvailable({
|
||||||
pluginId: NeedPluginIds.PluginDataStatistics,
|
pluginId: NeedPluginIds.PluginDataStatistics,
|
||||||
tips: '阿偶,检测到当前插件没有安装或者启用,无法使用功能哦,请联系管理员',
|
tips: '阿偶,检测到当前插件没有安装或者启用,无法使用功能哦,请联系管理员',
|
||||||
@@ -39,13 +41,20 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
/* ---------------- 图表配置 ---------------- */
|
/* ---------------- 图表配置 ---------------- */
|
||||||
const chartColors = ['#3B82F6', '#10B981', '#F59E0B', '#EF4444', '#8B5CF6', '#EC4899', '#14B8A6', '#F97316', '#ea7ccc', '#0EA5E9']
|
/** 主题色(与 style/index.scss 的 --wot-color-theme 保持一致) */
|
||||||
|
const themeColor = '#b9e424'
|
||||||
|
/** 图表系列色板:以主题色为基调配色,黄→绿→青相邻色系,避免杂乱 */
|
||||||
|
const chartColors = [themeColor, '#8bc34a', '#4caf50', '#26a69a', '#ffd54f', '#d4e157', '#66bb6a', '#9ccc65', '#00bcd4', '#ffb300']
|
||||||
|
|
||||||
/** 标签统计(环形图) */
|
/** 标签统计(环形图) */
|
||||||
const tagChart = ref({
|
const tagChart = ref({
|
||||||
isExpand: true,
|
isExpand: true,
|
||||||
type: 'ring',
|
type: 'ring',
|
||||||
data: { series: [{ data: [] as { name : string, value : number }[] }] },
|
data: { series: [{ data: [] as { name : string, value : number }[] }] },
|
||||||
|
/** 环形图中间标题(默认会被 uCharts 填充"收益率",需显式覆盖) */
|
||||||
|
title: { name: '', fontSize: 13, color: '#909399' },
|
||||||
|
/** 环形图中间数值 */
|
||||||
|
subtitle: { name: '', fontSize: 24, color: themeColor },
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 分类统计(柱状图) */
|
/** 分类统计(柱状图) */
|
||||||
@@ -77,8 +86,11 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
/* ---------------- 数据处理 ---------------- */
|
/* ---------------- 数据处理 ---------------- */
|
||||||
|
/** 环形图最大展示标签数(标签过多时扇区过密,占比难读) */
|
||||||
|
const TAG_CHART_TOP_N = 8
|
||||||
|
|
||||||
function handleTagChart() {
|
function handleTagChart() {
|
||||||
const data = [...statistics.value.tags].sort((a, b) => b.count - a.count)
|
const data = [...statistics.value.tags].sort((a, b) => b.count - a.count).slice(0, TAG_CHART_TOP_N)
|
||||||
tagChart.value.data = {
|
tagChart.value.data = {
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
@@ -86,6 +98,10 @@
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
// 中间文案:文章总数(articles 按日 articleTotal 求和,避免多标签文章重复计数)
|
||||||
|
const total = statistics.value.articles.reduce((sum, item) => sum + item.articleTotal, 0)
|
||||||
|
tagChart.value.title = { name: '文章总数', fontSize: 13, color: '#909399' }
|
||||||
|
tagChart.value.subtitle = { name: `${total} 篇`, fontSize: 24, color: themeColor }
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCategoriesChart() {
|
function handleCategoriesChart() {
|
||||||
@@ -99,7 +115,7 @@
|
|||||||
function handleTrendArticlesChart() {
|
function handleTrendArticlesChart() {
|
||||||
trandArticleChart.value.data = statistics.value.articles.map(item => ({
|
trandArticleChart.value.data = statistics.value.articles.map(item => ({
|
||||||
date: item.date,
|
date: item.date,
|
||||||
count: item.count,
|
count: item.articleTotal,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +173,10 @@
|
|||||||
handleGetData()
|
handleGetData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onPullDownRefresh(() => {
|
||||||
if (!uniHaloPluginAvailable.value) {
|
if (!uniHaloPluginAvailable.value) {
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
@@ -171,7 +191,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="bg-page box-border min-h-screen w-screen p-3">
|
<view class="bg-page box-border min-h-screen w-screen p-3">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="数据看板" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="数据看板" title-color="text-gray-900" />
|
||||||
|
|
||||||
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
||||||
:checking="checking" @on-refresh="handlePluginRefresh" />
|
:checking="checking" @on-refresh="handlePluginRefresh" />
|
||||||
@@ -196,7 +216,7 @@
|
|||||||
</uh-section-title>
|
</uh-section-title>
|
||||||
<view v-show="tagChart.isExpand" class="box-border w-full mt-3">
|
<view v-show="tagChart.isExpand" class="box-border w-full mt-3">
|
||||||
<qiun-data-charts type="ring" :chart-data="tagChart.data"
|
<qiun-data-charts type="ring" :chart-data="tagChart.data"
|
||||||
:opts="{ color: chartColors, padding: [5, 5, 5, 5], dataLabel: false, legend: { show: false }, extra: { ring: { ringWidth: 36, offsetAngle: -90, border: true, borderWidth: 1, borderColor: '#FFFFFF' } } }" />
|
:opts="{ color: chartColors, padding: [5, 5, 5, 5], dataLabel: false, legend: { show: false }, title: tagChart.title, subtitle: tagChart.subtitle, extra: { ring: { ringWidth: 36, offsetAngle: -90, border: true, borderWidth: 1, borderColor: '#FFFFFF' } } }" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -214,7 +234,7 @@
|
|||||||
</uh-section-title>
|
</uh-section-title>
|
||||||
<view v-show="categoryChart.isExpand" class="box-border w-full mt-3">
|
<view v-show="categoryChart.isExpand" class="box-border w-full mt-3">
|
||||||
<qiun-data-charts type="column" :chart-data="categoryChart.data"
|
<qiun-data-charts type="column" :chart-data="categoryChart.data"
|
||||||
:opts="{ color: chartColors, padding: [20, 15, 10, 15], legend: { show: false }, xAxis: { disableGrid: true, fontSize: 10, itemCount: 6 }, yAxis: { gridType: 'dash', dashLength: 4 }, extra: { column: { type: 'group', width: 22, linearType: 'custom', seriesGap: 5, barBorderCircle: true, customColor: ['#F59E0B'] } } }" />
|
:opts="{ color: chartColors, padding: [20, 15, 10, 15], legend: { show: false }, xAxis: { disableGrid: true, fontSize: 10, itemCount: 6 }, yAxis: { gridType: 'dash', dashLength: 4 }, extra: { column: { type: 'group', width: 22, linearType: 'custom', seriesGap: 5, barBorderCircle: true, customColor: [themeColor] } } }" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -249,7 +269,7 @@
|
|||||||
</uh-section-title>
|
</uh-section-title>
|
||||||
<view v-show="userCommentsChart.isExpand" class="box-border w-full mt-3">
|
<view v-show="userCommentsChart.isExpand" class="box-border w-full mt-3">
|
||||||
<qiun-data-charts type="column" :chart-data="userCommentsChart.data"
|
<qiun-data-charts type="column" :chart-data="userCommentsChart.data"
|
||||||
:opts="{ color: chartColors, padding: [20, 15, 10, 10], legend: { show: false }, xAxis: { disableGrid: true, fontSize: 10, itemCount: 5 }, yAxis: { gridType: 'dash', dashLength: 4 }, extra: { column: { type: 'group', width: 22, linearType: 'custom', seriesGap: 5, barBorderCircle: true, customColor: ['#F59E0B'] } } }" />
|
:opts="{ color: chartColors, padding: [20, 15, 10, 10], legend: { show: false }, xAxis: { disableGrid: true, fontSize: 10, itemCount: 5 }, yAxis: { gridType: 'dash', dashLength: 4 }, extra: { column: { type: 'group', width: 22, linearType: 'custom', seriesGap: 5, barBorderCircle: true, customColor: [themeColor] } } }" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -267,7 +287,7 @@
|
|||||||
</uh-section-title>
|
</uh-section-title>
|
||||||
<view v-show="top10ArticlesChart.isExpand" class="box-border w-full mt-3">
|
<view v-show="top10ArticlesChart.isExpand" class="box-border w-full mt-3">
|
||||||
<qiun-data-charts type="column" :chart-data="top10ArticlesChart.data"
|
<qiun-data-charts type="column" :chart-data="top10ArticlesChart.data"
|
||||||
:opts="{ color: chartColors, padding: [20, 15, 10, 10], legend: { show: false }, xAxis: { disableGrid: true, fontSize: 10, itemCount: 5 }, yAxis: { gridType: 'dash', dashLength: 4 }, extra: { column: { type: 'group', width: 22, linearType: 'custom', seriesGap: 5, barBorderCircle: true, customColor: ['#F59E0B'] } } }" />
|
:opts="{ color: chartColors, padding: [20, 15, 10, 10], legend: { show: false }, xAxis: { disableGrid: true, fontSize: 10, itemCount: 5 }, yAxis: { gridType: 'dash', dashLength: 4 }, extra: { column: { type: 'group', width: 22, linearType: 'custom', seriesGap: 5, barBorderCircle: true, customColor: [themeColor] } } }" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 免责声明页(源自旧项目 pagesA/disclaimers,新建复刻)
|
* 免责声明页
|
||||||
*/
|
*/
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
@@ -12,6 +14,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
const haloConfigs = computed(() => appConfigStore.configs)
|
||||||
|
|
||||||
@@ -37,12 +40,16 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen bg-page p-3 pt-2">
|
<view class="box-border min-h-screen bg-page p-3 pt-2">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="免责声明" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="免责声明" title-color="text-gray-900" />
|
||||||
|
|
||||||
<view class="w-full h-full uh-global-card-glass uh-shadow-xs rounded-xl">
|
<view class="w-full h-full uh-global-card-glass uh-shadow-xs rounded-xl">
|
||||||
<!-- 通过配置 -->
|
<!-- 通过配置 -->
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, watchEffect } from 'vue'
|
import { computed, ref, watchEffect } from 'vue'
|
||||||
|
import { onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { formatTime } from '@/utils/formatTime'
|
import { formatTime } from '@/utils/formatTime'
|
||||||
import { useFavoritesStore } from '@/store/favorites'
|
import { useFavoritesStore } from '@/store/favorites'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import type { FavoriteKind, IFavoriteItem } from '@/utils/favorite'
|
import type { FavoriteKind, IFavoriteItem } from '@/utils/favorite'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
@@ -12,6 +15,8 @@ definePage({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const favoritesStore = useFavoritesStore()
|
const favoritesStore = useFavoritesStore()
|
||||||
|
|
||||||
/* ---------------- Tab(文章/瞬间) ---------------- */
|
/* ---------------- Tab(文章/瞬间) ---------------- */
|
||||||
@@ -65,26 +70,29 @@ function handleRemove(item: IFavoriteItem) {
|
|||||||
|
|
||||||
/* ---------------- 空态文案 ---------------- */
|
/* ---------------- 空态文案 ---------------- */
|
||||||
const emptyText = computed(() => (activeKind.value === 'post' ? '还没有收藏文章' : '还没有收藏瞬间'))
|
const emptyText = computed(() => (activeKind.value === 'post' ? '还没有收藏文章' : '还没有收藏瞬间'))
|
||||||
|
|
||||||
|
/* ---------------- 滚动 ---------------- */
|
||||||
|
onPageScroll((option: Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen bg-page pb-10">
|
<view class="box-border min-h-screen w-screen bg-page pb-10">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="我的收藏" title-color="text-gray-900"></uh-navbar>
|
<uh-navbar :scroll-y="scrollY" default-title="我的收藏" title-color="text-gray-900"></uh-navbar>
|
||||||
|
|
||||||
<!-- 顶部类型 Tab(与图库页同款:吸顶玻璃胶囊 chip) -->
|
<!-- 顶部类型 Tab(与图库页同款:吸顶玻璃胶囊 chip) -->
|
||||||
<wd-sticky>
|
<wd-sticky :offset-top="offsetTop">
|
||||||
<scroll-view scroll-x class="w-full whitespace-nowrap">
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
<view class="flex gap-2 px-3 pb-1 pt-3">
|
<view
|
||||||
<view
|
v-for="tab in tabList" :key="tab.key"
|
||||||
v-for="tab in tabList" :key="tab.key"
|
class="uh-global-card-glass shadow-none mb-2 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
class="uh-global-card-glass uh-shadow-xs inline-block border rounded-2xl px-5 py-1.5 text-sm"
|
:class="{ 'bg-primary text-gray-900 font-semibold': tab.key === activeKind }"
|
||||||
:class="tab.key === activeKind ? 'bg-primary font-bold' : 'text-gray-500'"
|
@click="handleSwitchTab(tab.key)"
|
||||||
@click="handleSwitchTab(tab.key)"
|
>
|
||||||
>
|
{{ tab.label }}
|
||||||
{{ tab.label }}
|
<text v-if="tab.count > 0">({{ tab.count }})</text>
|
||||||
<text v-if="tab.count > 0">({{ tab.count }})</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</wd-sticky>
|
</wd-sticky>
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getFriendLinkGroupList, getFriendLinkList } from '@/api/halo'
|
import { getFriendLinkGroupList, getFriendLinkList } from '@/api/halo'
|
||||||
import { getMiniProgramLinkGroupedList } from '@/api/uni-halo'
|
import { getMiniProgramLinkGroupedList } from '@/api/uni-halo'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { useSettingStore } from '@/store/setting'
|
import { useSettingStore } from '@/store/setting'
|
||||||
import { sleep } from '@/utils/common'
|
import { sleep } from '@/utils/common'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
||||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||||
import type { ILink, ILinkGroup } from '@/api/types/halo'
|
import type { ILink, ILinkGroup } from '@/api/types/halo'
|
||||||
@@ -20,6 +22,8 @@ definePage({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
@@ -68,7 +72,7 @@ async function handleMiniPluginRefresh() {
|
|||||||
handleGetMiniProgramLinks()
|
handleGetMiniProgramLinks()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 是否开放公开提交申请(通用配置-友链信息-基本配置 submissionEnabled,2026-09-11 由 setting linkConfig 迁入;默认 true) */
|
/** 是否开放公开提交申请(通用配置-友链信息-基本配置 submissionEnabled;默认 true) */
|
||||||
const submissionEnabled = computed(() => (haloPluginConfigs.value?.linkInfo?.submissionEnabled ?? true))
|
const submissionEnabled = computed(() => (haloPluginConfigs.value?.linkInfo?.submissionEnabled ?? true))
|
||||||
|
|
||||||
/* ---------------- tabs ---------------- */
|
/* ---------------- tabs ---------------- */
|
||||||
@@ -92,12 +96,9 @@ watch(() => appConfigStore.auditModeEnabled, (enabled) => {
|
|||||||
|
|
||||||
/* ==================== 站点 tab(plugin-links) ==================== */
|
/* ==================== 站点 tab(plugin-links) ==================== */
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus: siteLoadingStatus, updateLoadingStatus: updateSiteLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus: siteLoadingStatus, loadMoreStatus: siteLoadMoreStatus, updateLoadingStatus: updateSiteLoadingStatus, updateLoadMoreStatus: updateSiteLoadMoreStatus, resetLoadMoreStatus: resetSiteLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const queryParams = ref({ size: 10, page: 1 })
|
const queryParams = ref({ size: 10, page: 1 })
|
||||||
const detail = ref<{ show: boolean, data: ILink | null }>({ show: false, data: null })
|
const detail = ref<{ show: boolean, data: ILink | null }>({ show: false, data: null })
|
||||||
const hasNext = ref(false)
|
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref('')
|
|
||||||
const linkGroupList = ref<ILinkGroup[]>([])
|
const linkGroupList = ref<ILinkGroup[]>([])
|
||||||
const dataList = ref<ILink[]>([])
|
const dataList = ref<ILink[]>([])
|
||||||
|
|
||||||
@@ -122,14 +123,12 @@ async function handleGetLinkGroupData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
if (!isLoadMore.value) {
|
if (!siteLoadMoreStatus.value.active) {
|
||||||
updateSiteLoadingStatus(DataLoadingStatusEnum.Loading)
|
updateSiteLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
loadMoreText.value = ''
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getFriendLinkList({ ...queryParams.value })
|
const res = await getFriendLinkList({ ...queryParams.value })
|
||||||
hasNext.value = res.data.hasNext
|
|
||||||
// 审核模式:站点链接仅展示选中 LinkGroup 分组内的
|
// 审核模式:站点链接仅展示选中 LinkGroup 分组内的
|
||||||
let items = res.data.items
|
let items = res.data.items
|
||||||
if (appConfigStore.auditModeEnabled) {
|
if (appConfigStore.auditModeEnabled) {
|
||||||
@@ -145,17 +144,30 @@ async function handleGetData() {
|
|||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
// 分页加载时累加,首次/刷新时覆盖(修复重复数据)
|
// 分页加载时累加,首次/刷新时覆盖(修复重复数据)
|
||||||
dataList.value = isLoadMore.value ? dataList.value.concat(list) : list
|
dataList.value = siteLoadMoreStatus.value.active ? dataList.value.concat(list) : list
|
||||||
await sleep(600)
|
if (!siteLoadMoreStatus.value.active) {
|
||||||
updateSiteLoadingStatus(
|
await sleep(600)
|
||||||
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
updateSiteLoadingStatus(
|
||||||
)
|
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
loadMoreText.value = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'
|
)
|
||||||
|
}
|
||||||
|
updateSiteLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateSiteLoadingStatus(DataLoadingStatusEnum.Error)
|
if (siteLoadMoreStatus.value.active) {
|
||||||
loadMoreText.value = '加载失败,请下拉刷新!'
|
updateSiteLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateSiteLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
@@ -339,6 +351,10 @@ function handleSaveMiniProgramCode(link: IMiniProgramLink) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option: Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(async () => {
|
onLoad(async () => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
checkSitePluginAvailable(),
|
checkSitePluginAvailable(),
|
||||||
@@ -358,7 +374,7 @@ onPullDownRefresh(() => {
|
|||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isLoadMore.value = false
|
resetSiteLoadMoreStatus()
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
dataList.value = []
|
dataList.value = []
|
||||||
handleGetData()
|
handleGetData()
|
||||||
@@ -376,13 +392,18 @@ onReachBottom(() => {
|
|||||||
if (activeTabIndex.value === 0) {
|
if (activeTabIndex.value === 0) {
|
||||||
if (!sitePluginAvailable.value)
|
if (!sitePluginAvailable.value)
|
||||||
return
|
return
|
||||||
if (hasNext.value) {
|
// 正在加载时阻止重复请求
|
||||||
queryParams.value.page += 1
|
if (siteLoadMoreStatus.value.active) {
|
||||||
isLoadMore.value = true
|
return
|
||||||
handleGetData()
|
|
||||||
}
|
}
|
||||||
else {
|
// 有更多数据时继续加载
|
||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
if (siteLoadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateSiteLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -394,20 +415,18 @@ onReachBottom(() => {
|
|||||||
<template>
|
<template>
|
||||||
<view class="app-page min-h-screen w-screen flex flex-col bg-page">
|
<view class="app-page min-h-screen w-screen flex flex-col bg-page">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="友情链接" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="友情链接" title-color="text-gray-900" />
|
||||||
|
|
||||||
<!-- 顶部 -->
|
<!-- 顶部 -->
|
||||||
<wd-sticky>
|
<wd-sticky :offset-top="offsetTop">
|
||||||
<scroll-view scroll-x class="w-full whitespace-nowrap">
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
<view class="flex gap-2 px-3 pb-1 pt-3">
|
<view
|
||||||
<view
|
v-for="(tab, index) in friendLinkTabs" :key="tab.key"
|
||||||
v-for="(tab, index) in friendLinkTabs" :key="tab.key"
|
class="uh-global-card-glass shadow-none mb-2 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
class="uh-global-card-glass uh-shadow-xs inline-block border rounded-2xl px-5 py-1.5 text-sm"
|
:class="{ 'bg-primary text-gray-900 font-semibold': activeTabIndex === index }"
|
||||||
:class="activeTabIndex === index ? 'bg-primary font-bold' : 'text-gray-500'"
|
@click="handleOnTabChange({ index })"
|
||||||
@click="handleOnTabChange({ index })"
|
>
|
||||||
>
|
{{ tab.label }}
|
||||||
{{ tab.label }}
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</wd-sticky>
|
</wd-sticky>
|
||||||
@@ -513,9 +532,7 @@ onReachBottom(() => {
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
</uh-glass-popup>
|
</uh-glass-popup>
|
||||||
|
|
||||||
<view class="load-text py-5 text-center text-xs text-gray-400">
|
<uh-data-loadmore :status="siteLoadMoreStatus.status" :text="siteLoadMoreStatus.text" />
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
@@ -578,7 +595,7 @@ onReachBottom(() => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 底部悬浮操作栏(通用组件);提交申请入口按 submissionEnabled 显隐(2026-09-11) -->
|
<!-- 底部悬浮操作栏(通用组件);提交申请入口按 submissionEnabled 显隐 -->
|
||||||
<uh-links-actions :actions="submissionEnabled ? ['apply', 'info'] : ['info']" @apply="handleOpenApply" @info="handleOpenMiniInfo" />
|
<uh-links-actions :actions="submissionEnabled ? ['apply', 'info'] : ['info']" @apply="handleOpenApply" @info="handleOpenMiniInfo" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
+147
-38
@@ -1,13 +1,17 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { getLoveAlbumByName, getLoveAlbums } from '@/api/uni-halo'
|
import { getLoveAlbumByName, getLoveAlbums, unlockAlbum } from '@/api/uni-halo'
|
||||||
|
import type { ICaptchaQuery } from '@/api/uni-halo'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { checkImageUrl } from '@/utils/url'
|
import { checkImageUrl } from '@/utils/url'
|
||||||
import { getCache, setCache } from '@/utils/storage'
|
import { getCache, setCache } from '@/utils/storage'
|
||||||
import { handleLoveModuleLocked } from '@/utils/loveModuleToken'
|
import { getLoveModuleToken, handleLoveModuleLocked } from '@/utils/loveModuleToken'
|
||||||
|
import { useLoveModuleUnlock } from '@/hooks/useLoveModuleUnlock'
|
||||||
|
import { sleep } from '@/utils/common'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import type { ILoveAlbum, ILovePhoto } from '@/api/types/uni-halo'
|
import type { ILoveAlbum, ILovePhoto } from '@/api/types/uni-halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
@@ -18,6 +22,7 @@ definePage({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const loveConfig = computed(() => appConfigStore.configs.loveConfig)
|
const loveConfig = computed(() => appConfigStore.configs.loveConfig)
|
||||||
|
|
||||||
@@ -57,10 +62,42 @@ function mapAlbumCard(item: ILoveAlbum): ILoveAlbumCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
|
const queryParams = ref({ page: 1, size: 10 })
|
||||||
const dataList = ref<ILoveAlbumCard[]>([])
|
const dataList = ref<ILoveAlbumCard[]>([])
|
||||||
const unlockedAlbums = ref<Record<string, string>>({})
|
const unlockedAlbums = ref<Record<string, string>>({})
|
||||||
|
|
||||||
|
/* ---------------- 恋爱模块解锁(防分享直达:锁定未解锁时不加载数据) ---------------- */
|
||||||
|
const {
|
||||||
|
unlockModalVisible,
|
||||||
|
unlockTip,
|
||||||
|
isModuleLocked,
|
||||||
|
openUnlock,
|
||||||
|
handleUnlockRequest,
|
||||||
|
handleUnlockSuccess,
|
||||||
|
} = useLoveModuleUnlock()
|
||||||
|
|
||||||
|
/** 是否放行数据加载(锁定未解锁时为 false,解锁成功置 true) */
|
||||||
|
const canLoad = ref(false)
|
||||||
|
|
||||||
|
/** 锁定则弹不可关闭解锁弹窗,返回是否放行 */
|
||||||
|
function ensureUnlocked(): boolean {
|
||||||
|
if (isModuleLocked('lovePhoto')) {
|
||||||
|
openUnlock('lovePhoto')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解锁成功:存 token 后恢复数据加载 */
|
||||||
|
function handlePageUnlockSuccess(data: { token?: string }) {
|
||||||
|
handleUnlockSuccess(data)
|
||||||
|
if (getLoveModuleToken('lovePhoto')) {
|
||||||
|
canLoad.value = true
|
||||||
|
handleGetData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 密码解锁弹窗 */
|
/** 密码解锁弹窗 */
|
||||||
const showUnlockModal = ref(false)
|
const showUnlockModal = ref(false)
|
||||||
const currentUnlockAlbum = ref<ILoveAlbumCard | null>(null)
|
const currentUnlockAlbum = ref<ILoveAlbumCard | null>(null)
|
||||||
@@ -70,7 +107,6 @@ const showPhotoViewer = ref(false)
|
|||||||
const currentViewerAlbum = ref<ILoveAlbumCard | null>(null)
|
const currentViewerAlbum = ref<ILoveAlbumCard | null>(null)
|
||||||
|
|
||||||
const unlockAlbumName = computed(() => currentUnlockAlbum.value?.displayName || '')
|
const unlockAlbumName = computed(() => currentUnlockAlbum.value?.displayName || '')
|
||||||
const unlockAlbumKey = computed(() => currentUnlockAlbum.value?.name || '')
|
|
||||||
const viewerAlbumName = computed(() => currentViewerAlbum.value?.displayName || '')
|
const viewerAlbumName = computed(() => currentViewerAlbum.value?.displayName || '')
|
||||||
const viewerAlbumKey = computed(() => currentViewerAlbum.value?.name || '')
|
const viewerAlbumKey = computed(() => currentViewerAlbum.value?.name || '')
|
||||||
const viewerAlbumToken = computed(() => currentViewerAlbum.value
|
const viewerAlbumToken = computed(() => currentViewerAlbum.value
|
||||||
@@ -101,25 +137,45 @@ function handleSaveUnlockedAlbums() {
|
|||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
if (!loadMoreStatus.value.active) {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getLoveAlbums({})
|
const res = await getLoveAlbums({ ...queryParams.value })
|
||||||
const items = res.data?.items || []
|
const items = (res.data?.items || []).map(mapAlbumCard)
|
||||||
dataList.value = items.map(mapAlbumCard)
|
dataList.value = loadMoreStatus.value.active
|
||||||
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
? dataList.value.concat(items)
|
||||||
|
: items
|
||||||
|
if (!loadMoreStatus.value.active) {
|
||||||
|
await sleep(600)
|
||||||
|
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
|
}
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data?.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: !!res.data?.hasNext,
|
||||||
|
})
|
||||||
if (dataList.value.length > 0)
|
if (dataList.value.length > 0)
|
||||||
handleLoadUnlockedAlbumPhotos()
|
handleLoadUnlockedAlbumPhotos()
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('获取相册失败', e)
|
console.error('获取相册失败', e)
|
||||||
// 模块锁 401:清除 token 并提示
|
// 模块锁 401:清除 token 并弹不可关闭解锁弹窗(解锁后恢复加载)
|
||||||
handleLoveModuleLocked('lovePhoto', e)
|
if (handleLoveModuleLocked('lovePhoto', e)) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
openUnlock('lovePhoto')
|
||||||
|
}
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setTimeout(() => {
|
uni.stopPullDownRefresh()
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
}, 200)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,13 +219,28 @@ function handleOpenPhotoViewer(item: ILoveAlbumCard) {
|
|||||||
// 照片数据由 uh-album-photo-viewer 内部自请求(见组件 handleLoadPhotos)
|
// 照片数据由 uh-album-photo-viewer 内部自请求(见组件 handleLoadPhotos)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnUnlockSuccess(data: { albumKey: string, token: string, photos: unknown[] }) {
|
/** 相册解锁请求(uh-unlock-popup 注入;返回含 token + photos 表示成功) */
|
||||||
unlockedAlbums.value[data.albumKey] = data.token
|
async function handleAlbumUnlockRequest(password: string, captcha?: ICaptchaQuery | null) {
|
||||||
|
const album = currentUnlockAlbum.value
|
||||||
|
if (!album) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const res = await unlockAlbum(album.name, password, captcha)
|
||||||
|
return res.data as { token?: string, photos?: unknown[] } | null | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 相册解锁成功:存 token + photos,自动打开相册查看 */
|
||||||
|
function handleAlbumUnlockSuccess(data: { token?: string, photos?: unknown[] }) {
|
||||||
|
const album = currentUnlockAlbum.value
|
||||||
|
if (!album || !data.token) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
unlockedAlbums.value[album.name] = data.token
|
||||||
handleSaveUnlockedAlbums()
|
handleSaveUnlockedAlbums()
|
||||||
|
|
||||||
const albumIndex = dataList.value.findIndex(a => a.name === data.albumKey)
|
const albumIndex = dataList.value.findIndex(a => a.name === album.name)
|
||||||
if (albumIndex !== -1) {
|
if (albumIndex !== -1) {
|
||||||
dataList.value[albumIndex].photos = data.photos as ILovePhoto[]
|
dataList.value[albumIndex].photos = (data.photos || []) as ILovePhoto[]
|
||||||
dataList.value[albumIndex].locked = false
|
dataList.value[albumIndex].locked = false
|
||||||
}
|
}
|
||||||
currentUnlockAlbum.value = null
|
currentUnlockAlbum.value = null
|
||||||
@@ -189,28 +260,57 @@ function handleToTopPage(duration = 500) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option: Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
|
handlePageInit()
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 页面初始化:先判定模块锁定(防分享直达),解锁或未设密码才加载数据 */
|
||||||
|
async function handlePageInit() {
|
||||||
handleRestoreUnlockedAlbums()
|
handleRestoreUnlockedAlbums()
|
||||||
|
await appConfigStore.bootstrap()
|
||||||
|
if (!ensureUnlocked()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
canLoad.value = true
|
||||||
|
handleGetData()
|
||||||
|
}
|
||||||
|
|
||||||
|
onPullDownRefresh(() => {
|
||||||
|
resetLoadMoreStatus()
|
||||||
|
queryParams.value.page = 1
|
||||||
handleGetData()
|
handleGetData()
|
||||||
})
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onReachBottom(() => {
|
||||||
handleGetData()
|
// 正在加载时阻止重复请求
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 有更多数据时继续加载
|
||||||
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="app-page box-border min-h-screen w-screen flex flex-col pb-safe">
|
<view class="app-page box-border min-h-screen w-screen flex flex-col pb-safe">
|
||||||
<!-- 自定义导航 -->
|
<uh-navbar :scroll-y="scrollY" default-title="恋爱相册" title-color="text-love" back-class="text-love" />
|
||||||
<uh-navbar default-title="恋爱相册" title-color="text-love" back-class="text-love" />
|
|
||||||
|
|
||||||
<!-- 加载/错误/空占位(状态机) -->
|
|
||||||
<uh-data-loading
|
<uh-data-loading
|
||||||
v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
min-height="75vh" empty-text="相册暂时还没有数据~" @refresh="handleGetData"
|
min-height="75vh" empty-text="相册暂时还没有数据~" @refresh="handleGetData"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 相册列表(两列网格) -->
|
|
||||||
<view v-else class="grid grid-cols-2 box-border gap-3 p-3 pt-2">
|
<view v-else class="grid grid-cols-2 box-border gap-3 p-3 pt-2">
|
||||||
<view
|
<view
|
||||||
v-for="(item) in dataList" :key="item.name"
|
v-for="(item) in dataList" :key="item.name"
|
||||||
@@ -220,7 +320,7 @@ onPullDownRefresh(() => {
|
|||||||
<image class="h-full w-full" :src="item.image" mode="aspectFill" lazy-load />
|
<image class="h-full w-full" :src="item.image" mode="aspectFill" lazy-load />
|
||||||
<view
|
<view
|
||||||
v-if="item.locked && !unlockedAlbums[item.name]"
|
v-if="item.locked && !unlockedAlbums[item.name]"
|
||||||
class="absolute right-0 top-0 px-2 py-1 rounded-lb-md flex items-center justify-center gap-1 bg-black/30"
|
class="absolute right-0 top-0 flex items-center justify-center gap-1 rounded-lb-md bg-black/30 px-2 py-1"
|
||||||
>
|
>
|
||||||
<wd-icon name="lock" size="30rpx" class="text-white" />
|
<wd-icon name="lock" size="30rpx" class="text-white" />
|
||||||
<view class="text-xs text-white">
|
<view class="text-xs text-white">
|
||||||
@@ -229,23 +329,25 @@ onPullDownRefresh(() => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="absolute left-0 right-0 bottom-0 box-border p-3 pt-6 bg-gradient-to-b from-white/0 to-white/60">
|
<view
|
||||||
<view
|
class="absolute bottom-0 left-0 right-0 box-border from-white/0 to-white/60 bg-gradient-to-b p-3 pt-6"
|
||||||
class="truncate text-sm text-love font-bold"
|
>
|
||||||
>
|
<view class="truncate text-sm text-love font-bold">
|
||||||
{{ item.displayName }}
|
{{ item.displayName }}
|
||||||
</view>
|
</view>
|
||||||
<view class="album-count mt-1 text-xs text-white">
|
<view class="album-count mt-1 text-xs text-white">
|
||||||
{{ item.photoCount }} 张照片
|
{{ item.photoCount }} 张照片
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
<!-- 密码解锁弹窗 -->
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
<uh-album-unlock-popup
|
|
||||||
v-if="currentUnlockAlbum" v-model="showUnlockModal" :show="showUnlockModal" :album-name="unlockAlbumName"
|
<!-- 相册密码解锁弹窗(通用解锁弹窗;解锁成功自动打开相册查看) -->
|
||||||
:album-key="unlockAlbumKey" @update:show="showUnlockModal = $event" @success="handleOnUnlockSuccess"
|
<uh-unlock-popup
|
||||||
|
v-if="currentUnlockAlbum" v-model:show="showUnlockModal" title="解锁相册" captcha-enabled
|
||||||
|
:tip="`【${unlockAlbumName}】已加密,请输入密码查看`" placeholder="请输入相册密码" confirm-text="解锁"
|
||||||
|
:request="handleAlbumUnlockRequest" @success="handleAlbumUnlockSuccess"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 相册图片查看弹窗(数据在组件内部自请求) -->
|
<!-- 相册图片查看弹窗(数据在组件内部自请求) -->
|
||||||
@@ -254,11 +356,18 @@ onPullDownRefresh(() => {
|
|||||||
:album-name="viewerAlbumName" :album-key="viewerAlbumKey" :token="viewerAlbumToken"
|
:album-name="viewerAlbumName" :album-key="viewerAlbumKey" :token="viewerAlbumToken"
|
||||||
@update:show="showPhotoViewer = $event"
|
@update:show="showPhotoViewer = $event"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- 模块级密码解锁弹窗(强制不可关闭,防分享直达) -->
|
||||||
|
<uh-unlock-popup
|
||||||
|
v-model:show="unlockModalVisible" title="请解锁" captcha-enabled :tip="unlockTip"
|
||||||
|
placeholder="请输入密码" confirm-text="进入" :closeable="false" :request="handleUnlockRequest"
|
||||||
|
@success="handlePageUnlockSuccess"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.app-page {
|
.app-page {
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
-135deg,
|
-135deg,
|
||||||
rgb(247 149 51 / 10%),
|
rgb(247 149 51 / 10%),
|
||||||
|
|||||||
+127
-39
@@ -1,14 +1,15 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
|
||||||
* 恋爱清单页(源自旧项目 pagesA/love/list.vue,新建复刻)
|
|
||||||
* 恋爱清单卡片列表(未开始/进行中/已完成),展开查看详情与回忆图片
|
|
||||||
*/
|
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getLoveDailyItems } from '@/api/uni-halo'
|
import { getLoveDailyItems } from '@/api/uni-halo'
|
||||||
import { handleLoveModuleLocked } from '@/utils/loveModuleToken'
|
import { getLoveModuleToken, handleLoveModuleLocked } from '@/utils/loveModuleToken'
|
||||||
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
|
import { useLoveModuleUnlock } from '@/hooks/useLoveModuleUnlock'
|
||||||
import { checkImageUrl } from '@/utils/url'
|
import { checkImageUrl } from '@/utils/url'
|
||||||
|
import { sleep } from '@/utils/common'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import type { ILoveDailyItem } from '@/api/types/uni-halo'
|
import type { ILoveDailyItem } from '@/api/types/uni-halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
@@ -19,6 +20,9 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
|
|
||||||
/* ---------------- 展示层类型 ---------------- */
|
/* ---------------- 展示层类型 ---------------- */
|
||||||
/** 清单展示卡片(script 预处理后的干净展示数据) */
|
/** 清单展示卡片(script 预处理后的干净展示数据) */
|
||||||
interface ILoveItemCard {
|
interface ILoveItemCard {
|
||||||
@@ -53,9 +57,42 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
|
const queryParams = ref({ page: 1, size: 10 })
|
||||||
const list = ref<ILoveItemCard[]>([])
|
const list = ref<ILoveItemCard[]>([])
|
||||||
|
|
||||||
|
/* ---------------- 恋爱模块解锁(防分享直达:锁定未解锁时不加载数据) ---------------- */
|
||||||
|
const appConfigStore = useAppConfigStore()
|
||||||
|
const {
|
||||||
|
unlockModalVisible,
|
||||||
|
unlockTip,
|
||||||
|
isModuleLocked,
|
||||||
|
openUnlock,
|
||||||
|
handleUnlockRequest,
|
||||||
|
handleUnlockSuccess,
|
||||||
|
} = useLoveModuleUnlock()
|
||||||
|
|
||||||
|
/** 是否放行数据加载(锁定未解锁时为 false,解锁成功置 true) */
|
||||||
|
const canLoad = ref(false)
|
||||||
|
|
||||||
|
/** 锁定则弹不可关闭解锁弹窗,返回是否放行 */
|
||||||
|
function ensureUnlocked() : boolean {
|
||||||
|
if (isModuleLocked('loveDaily')) {
|
||||||
|
openUnlock('loveDaily')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解锁成功:存 token 后恢复数据加载 */
|
||||||
|
function handlePageUnlockSuccess(data : { token ?: string }) {
|
||||||
|
handleUnlockSuccess(data)
|
||||||
|
if (getLoveModuleToken('loveDaily')) {
|
||||||
|
canLoad.value = true
|
||||||
|
handleGetList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------- 筛选与排序 ---------------- */
|
/* ---------------- 筛选与排序 ---------------- */
|
||||||
interface IFilterOption {
|
interface IFilterOption {
|
||||||
label : string
|
label : string
|
||||||
@@ -164,23 +201,43 @@
|
|||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetList() {
|
async function handleGetList() {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
if (!loadMoreStatus.value.active) {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getLoveDailyItems({})
|
const res = await getLoveDailyItems({ ...queryParams.value })
|
||||||
const items = res.data?.items || []
|
const items = (res.data?.items || []).map(mapItemCard)
|
||||||
list.value = items.map(mapItemCard)
|
list.value = loadMoreStatus.value.active
|
||||||
updateLoadingStatus(list.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
? list.value.concat(items)
|
||||||
|
: items
|
||||||
|
if (!loadMoreStatus.value.active) {
|
||||||
|
await sleep(600)
|
||||||
|
updateLoadingStatus(list.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
|
}
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data?.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: !!res.data?.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('获取清单失败', e)
|
console.error('获取清单失败', e)
|
||||||
// 模块锁 401:清除 token 并提示
|
// 模块锁 401:清除 token 并弹不可关闭解锁弹窗(解锁后恢复加载)
|
||||||
handleLoveModuleLocked('loveDaily', e)
|
if (handleLoveModuleLocked('loveDaily', e)) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
openUnlock('loveDaily')
|
||||||
|
}
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setTimeout(() => {
|
uni.stopPullDownRefresh()
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
}, 200)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,35 +290,63 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
|
handlePageInit()
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 页面初始化:先判定模块锁定(防分享直达),解锁或未设密码才加载数据 */
|
||||||
|
async function handlePageInit() {
|
||||||
|
await appConfigStore.bootstrap()
|
||||||
|
if (!ensureUnlocked()) { return }
|
||||||
|
canLoad.value = true
|
||||||
|
handleGetList()
|
||||||
|
}
|
||||||
|
|
||||||
|
onPullDownRefresh(() => {
|
||||||
|
resetLoadMoreStatus()
|
||||||
|
queryParams.value.page = 1
|
||||||
handleGetList()
|
handleGetList()
|
||||||
})
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onReachBottom(() => {
|
||||||
handleGetList()
|
// 正在加载时阻止重复请求
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 有更多数据时继续加载
|
||||||
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetList()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="uh-global-love-page box-border min-h-screen w-screen flex flex-col">
|
<view class="uh-global-love-page box-border min-h-screen w-screen flex flex-col">
|
||||||
<uh-navbar default-title="恋爱清单" title-color="text-love" back-class="text-love"/>
|
<uh-navbar :scroll-y="scrollY" default-title="恋爱清单" title-color="text-love" back-class="text-love"/>
|
||||||
|
|
||||||
<wd-sticky>
|
<wd-sticky :offset-top="offsetTop">
|
||||||
<view class="box-border px-3 pb-1 pt-2">
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
<view class="box-border flex items-center justify-between gap-x-2">
|
<view v-for="f in filterConfig" :key="f.key"
|
||||||
<view v-for="f in filterConfig" :key="f.key"
|
class="uh-global-card-glass shadow-none mb-2 ml-3 inline-flex items-center gap-1 border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
class="uh-global-card-glass box-border flex flex-1 items-center justify-center gap-1 border rounded-full px-4 py-2 text-gray-500"
|
:class="[filterValues[f.key] !== f.options[0].value ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500']"
|
||||||
:class="[filterValues[f.key] !== f.options[0].value ? 'bg-love/90 text-white font-bold' : 'bg-white/80 text-gray-600']"
|
@click="handleOpenFilter(f)">
|
||||||
@click="handleOpenFilter(f)">
|
<text class="truncate text-xs">{{ filterLabels[f.key] }}</text>
|
||||||
<text class="truncate text-xs">{{ filterLabels[f.key] }}</text>
|
<template v-if="f.key!=='status'">
|
||||||
<template v-if="f.key!=='status'">
|
<wd-icon v-if="f.key === 'sort' && filterValues.sort !== 'default'"
|
||||||
<wd-icon v-if="f.key === 'sort' && filterValues.sort !== 'default'"
|
:name="filterValues.sortDir === 'desc' ? 'arrow-down' : 'arrow-up'" size="26rpx" />
|
||||||
:name="filterValues.sortDir === 'desc' ? 'arrow-down' : 'arrow-up'" size="26rpx" />
|
<wd-icon v-else name="arrow-down" size="26rpx" />
|
||||||
<wd-icon v-else name="arrow-down" size="26rpx" />
|
</template>
|
||||||
</template>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</scroll-view>
|
||||||
</wd-sticky>
|
</wd-sticky>
|
||||||
|
|
||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
@@ -341,9 +426,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<view class="box-border py-10 text-center text-xs text-gray-500">
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
|
|
||||||
</view>
|
|
||||||
<uh-data-loading v-if="showList.length === 0" :loading-status="DataLoadingStatusEnum.Empty"
|
<uh-data-loading v-if="showList.length === 0" :loading-status="DataLoadingStatusEnum.Empty"
|
||||||
min-height="42vh" empty-text="该筛选条件下暂无清单~" :use-refresh-button="false" />
|
min-height="42vh" empty-text="该筛选条件下暂无清单~" :use-refresh-button="false" />
|
||||||
</view>
|
</view>
|
||||||
@@ -378,5 +461,10 @@
|
|||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</uh-glass-popup>
|
</uh-glass-popup>
|
||||||
|
|
||||||
|
<!-- 模块级密码解锁弹窗(强制不可关闭,防分享直达) -->
|
||||||
|
<uh-unlock-popup v-model:show="unlockModalVisible" title="请解锁" captcha-enabled
|
||||||
|
:tip="unlockTip" placeholder="请输入密码" confirm-text="进入" :closeable="false"
|
||||||
|
:request="handleUnlockRequest" @success="handlePageUnlockSuccess" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
+130
-204
@@ -1,10 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onBeforeUnmount, ref } from 'vue'
|
import { onBeforeUnmount, ref } from 'vue'
|
||||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onShow } from '@dcloudio/uni-app'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
||||||
import { unlockLoveModule } from '@/api/uni-halo'
|
import { getLoveModuleToken, type LoveModuleKey } from '@/utils/loveModuleToken'
|
||||||
import { getLoveModuleToken, setLoveModuleToken, type LoveModuleKey } from '@/utils/loveModuleToken'
|
import { useLoveModuleUnlock } from '@/hooks/useLoveModuleUnlock'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
import type { ILoveConfigGroup, ILoveModuleConfig } from '@/api/types/uni-halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
@@ -13,166 +15,113 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
/* ---------------- 恋爱配置 ---------------- */
|
/* ---------------- 恋爱配置 ---------------- */
|
||||||
interface ILoveConfigPage {
|
/** 恋爱配置(数据源为 getConfigs.loveConfig 组:恋爱日记仅密码状态;
|
||||||
|
* 三模块入口即 app 端入口列表数据,2026-09-12 起 /love-config 已下线) */
|
||||||
|
interface ILoveConfigPage extends Partial<ILoveConfigGroup> {
|
||||||
enabled : boolean
|
enabled : boolean
|
||||||
loveDateTitle : string
|
loveDateTitle : string
|
||||||
loveDate : string
|
loveDate : string
|
||||||
loveInfo : {
|
|
||||||
boyNickname : string
|
|
||||||
boyAvatar : string
|
|
||||||
girlNickname : string
|
|
||||||
girlAvatar : string
|
|
||||||
}
|
|
||||||
pageImages : {
|
|
||||||
bgImageUrl : string
|
|
||||||
waveImageUrl : string
|
|
||||||
heartImageUrl : string
|
|
||||||
}
|
|
||||||
ourStory : { enabled : boolean, passwordEnabled ?: boolean }
|
|
||||||
lovePhoto : { enabled : boolean, passwordEnabled ?: boolean }
|
|
||||||
loveDaily : { enabled : boolean, passwordEnabled ?: boolean }
|
|
||||||
/** 恋爱页入口列表(插件端 spec.love.navList 经 getConfigs 下发,additive;
|
|
||||||
* 字段 key/title/subTitle/priority/visible,desc 已改名 subTitle) */
|
|
||||||
navList ?: ILoveNavItem[]
|
|
||||||
[key : string] : unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 恋爱页入口项(对齐插件端 GeneralConfig.LoveNavItem;key 固定 stories/album/list) */
|
|
||||||
interface ILoveNavItem {
|
|
||||||
key : string
|
|
||||||
title ?: string
|
|
||||||
/** 副标题(原 app 端 desc 文案改名 subTitle) */
|
|
||||||
subTitle ?: string
|
|
||||||
/** 排序(越大越靠前) */
|
|
||||||
priority ?: number
|
|
||||||
/** 是否展示(不可删除,仅禁用/启用) */
|
|
||||||
visible ?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const loveConfig = ref<ILoveConfigPage>({
|
const loveConfig = ref<ILoveConfigPage>({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
loveDateTitle: '',
|
loveDateTitle: '',
|
||||||
loveDate: '',
|
loveDate: '',
|
||||||
loveInfo: {
|
loveDiary: { passwordEnabled: false },
|
||||||
boyNickname: '',
|
|
||||||
boyAvatar: '',
|
|
||||||
girlNickname: '',
|
|
||||||
girlAvatar: '',
|
|
||||||
},
|
|
||||||
pageImages: {
|
|
||||||
bgImageUrl: '',
|
|
||||||
waveImageUrl: '',
|
|
||||||
heartImageUrl: '',
|
|
||||||
},
|
|
||||||
ourStory: { enabled: false, passwordEnabled: false },
|
ourStory: { enabled: false, passwordEnabled: false },
|
||||||
lovePhoto: { enabled: false, passwordEnabled: false },
|
lovePhoto: { enabled: false, passwordEnabled: false },
|
||||||
loveDaily: { enabled: false, passwordEnabled: false },
|
loveDaily: { enabled: false, passwordEnabled: false },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 恋爱页背景图 */
|
||||||
|
const loveBgImage = ref('')
|
||||||
|
|
||||||
const loveDayCount = ref({ d: 0, h: 0, m: 0, s: 0 })
|
const loveDayCount = ref({ d: 0, h: 0, m: 0, s: 0 })
|
||||||
let loveDayTimer : ReturnType<typeof setTimeout> | null = null
|
let loveDayTimer : ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
||||||
/** 恋爱页入口渲染项(字段由 initList 从插件端 loveConfig.navList 合成:key 映射图标/路径、desc→subTitle) */
|
|
||||||
interface ILoveNavRenderItem {
|
interface ILoveNavRenderItem {
|
||||||
key : string
|
moduleKey : LoveModuleKey
|
||||||
use : boolean
|
use : boolean
|
||||||
|
locked : boolean
|
||||||
iconPrefix : string
|
iconPrefix : string
|
||||||
icon : string
|
icon : string
|
||||||
|
/** 跳转路径(插件下发,直接 navigateTo) */
|
||||||
|
path : string
|
||||||
title : string
|
title : string
|
||||||
subTitle : string
|
subTitle : string
|
||||||
}
|
titleColor : string
|
||||||
|
subTitleColor : string
|
||||||
// 是否使用本地的恋爱页入口数据(本地的可以任意修改图标/路径/文案,插件端的仅可配置 title/subTitle/排序/显隐)
|
iconBgColor : string
|
||||||
const useLocalNav = false
|
|
||||||
|
|
||||||
/** 内置默认入口项(未配置时回退;字段命名与插件端 loveConfig.navList 一致,desc 文案改名 subTitle) */
|
|
||||||
const DEFAULT_NAV_LIST : ILoveNavItem[] = [
|
|
||||||
{ key: 'stories', title: '恋爱故事', subTitle: '我们一起度过的那些经历', priority: 1, visible: true },
|
|
||||||
{ key: 'album', title: '恋爱相册', subTitle: '定格了我们的那些小美好', priority: 2, visible: true },
|
|
||||||
{ key: 'list', title: '恋爱清单', subTitle: '你我之间的约定我们都在努力实现', priority: 3, visible: true },
|
|
||||||
]
|
|
||||||
|
|
||||||
/** 入口 key → 图标与跳转页映射(固定:key=stories/album/list,对应恋爱三模块) */
|
|
||||||
const NAV_META: Record<string, { iconPrefix: string, icon: string, page: string }> = {
|
|
||||||
stories: { iconPrefix: 'uhlove-icon', icon: 'gushi', page: 'stories' },
|
|
||||||
album: { iconPrefix: 'uhlove-icon', icon: 'xiangce', page: 'album' },
|
|
||||||
list: { iconPrefix: 'uhlove-icon', icon: 'liebiao', page: 'list' },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const navList = ref<ILoveNavRenderItem[]>([])
|
const navList = ref<ILoveNavRenderItem[]>([])
|
||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
function syncLoveConfigFromStore() {
|
function syncLoveConfigFromStore() {
|
||||||
const storeLove = appConfigStore.loveConfig
|
const loveConfigs = appConfigStore.configs.loveConfig
|
||||||
const appConfigs = appConfigStore.configs
|
|
||||||
|
|
||||||
loveConfig.value = {
|
loveConfig.value = {
|
||||||
...loveConfig.value,
|
...loveConfig.value,
|
||||||
...(storeLove.loveDateTitle ? { loveDateTitle: storeLove.loveDateTitle } : {}),
|
...(loveConfigs?.loveInfo?.loveDateTitle ? { loveDateTitle: loveConfigs.loveInfo.loveDateTitle } : {}),
|
||||||
...(storeLove.loveDate ? { loveDate: storeLove.loveDate } : {}),
|
...(loveConfigs?.loveInfo?.loveDate ? { loveDate: loveConfigs.loveInfo.loveDate } : {}),
|
||||||
...(storeLove.enabled !== undefined ? { enabled: storeLove.enabled } : {}),
|
|
||||||
loveInfo: {
|
|
||||||
...loveConfig.value.loveInfo,
|
|
||||||
...(storeLove.loveInfo || {}),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从 getConfigs.loveConfig 取模块开关与页面图片(缺省保留默认)
|
// 恋爱页背景图:读自 pageConfig.loveDiaryConfig.bgImageUrl
|
||||||
const loveModuleConfig = appConfigs.loveConfig as Partial<ILoveConfigPage> | undefined
|
const loveDiaryPageConfig = appConfigStore.configs.pageConfig?.loveDiaryConfig as
|
||||||
if (loveModuleConfig) {
|
{ bgImageUrl ?: string } | undefined
|
||||||
|
loveBgImage.value = loveDiaryPageConfig?.bgImageUrl || ''
|
||||||
|
if (loveConfigs) {
|
||||||
loveConfig.value = {
|
loveConfig.value = {
|
||||||
...loveConfig.value,
|
...loveConfig.value,
|
||||||
pageImages: loveModuleConfig.pageImages || loveConfig.value.pageImages,
|
// 恋爱信息(纪念日 + 恋人信息)需透传,否则模板 loveInfo 恒为空
|
||||||
ourStory: loveModuleConfig.ourStory || loveConfig.value.ourStory,
|
loveInfo: loveConfigs.loveInfo || loveConfig.value.loveInfo,
|
||||||
lovePhoto: loveModuleConfig.lovePhoto || loveConfig.value.lovePhoto,
|
loveDiary: loveConfigs.loveDiary || loveConfig.value.loveDiary,
|
||||||
loveDaily: loveModuleConfig.loveDaily || loveConfig.value.loveDaily,
|
ourStory: loveConfigs.ourStory || loveConfig.value.ourStory,
|
||||||
navList: loveModuleConfig.navList || loveConfig.value.navList,
|
lovePhoto: loveConfigs.lovePhoto || loveConfig.value.lovePhoto,
|
||||||
|
loveDaily: loveConfigs.loveDaily || loveConfig.value.loveDaily,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initList()
|
initList()
|
||||||
// 未配置纪念日(loveDate 为空)不启动倒计时,避免 NaN
|
|
||||||
if (loveConfig.value.loveDate) {
|
if (loveConfig.value.loveDate) {
|
||||||
handleInitLoveDayCount()
|
handleInitLoveDayCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 恋爱页入口:优先读插件端 loveConfig.navList(visible 过滤 + priority 排序,desc→subTitle,
|
/** 入口列表:由三模块配置构建(模块 key 即唯一标识,图标/跳转路径均用插件下发字段) */
|
||||||
* key 映射图标/路径,模块开关 enabled 与条目 visible 均 true 才展示);未配置/为空回退内置默认 */
|
|
||||||
function initList() {
|
function initList() {
|
||||||
const configs = loveConfig.value
|
const configs = loveConfig.value
|
||||||
const configured = configs.navList
|
const moduleKeys : LoveModuleKey[] = ['ourStory', 'lovePhoto', 'loveDaily']
|
||||||
let source : ILoveNavItem[]
|
// 插件端已按 priority 降序输出,此处仍按 priority 排序兜底(缺失视为 0)
|
||||||
if (!useLocalNav && configured && configured.length) {
|
const sorted = [...moduleKeys].sort((a, b) =>
|
||||||
source = configured
|
((configs[b] as ILoveModuleConfig | undefined)?.priority ?? 0) -
|
||||||
} else {
|
((configs[a] as ILoveModuleConfig | undefined)?.priority ?? 0))
|
||||||
source = DEFAULT_NAV_LIST;
|
navList.value = sorted.map((moduleKey) => {
|
||||||
}
|
const moduleCfg = configs[moduleKey] as ILoveModuleConfig | undefined
|
||||||
// priority 排序(越大越靠前;缺失按默认顺序兜底)
|
if (!moduleCfg) {
|
||||||
const sorted = [...source].sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
|
|
||||||
navList.value = sorted.map((item) => {
|
|
||||||
const meta = NAV_META[item.key]
|
|
||||||
if (!meta) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const moduleKey = MODULE_KEY_MAP[item.key]
|
|
||||||
const moduleCfg = moduleKey
|
|
||||||
? (configs[moduleKey] as { enabled ?: boolean } | undefined)
|
|
||||||
: undefined
|
|
||||||
const fallback = DEFAULT_NAV_LIST.find((d) => d.key === item.key)
|
|
||||||
return {
|
return {
|
||||||
key: item.key,
|
moduleKey,
|
||||||
// 模块开关与条目显示开关均开启才展示(与插件端语义一致)
|
use: !!moduleCfg.enabled,
|
||||||
use: !!moduleCfg?.enabled && item.visible !== false,
|
// 模块设了密码且本地无有效 token → 锁定态;解锁后恢复箭头
|
||||||
iconPrefix: meta.iconPrefix,
|
locked: !!moduleCfg.passwordEnabled && !getLoveModuleToken(moduleKey),
|
||||||
icon: meta.icon,
|
// 图标/跳转路径直接消费插件下发字段(不再本地映射)
|
||||||
title: item.title || fallback?.title || '',
|
iconPrefix: moduleCfg.iconPrefix || 'uhlove-icon',
|
||||||
subTitle: item.subTitle || fallback?.subTitle || '',
|
icon: moduleCfg.icon || '',
|
||||||
|
path: moduleCfg.path || '',
|
||||||
|
title: moduleCfg.title || '',
|
||||||
|
subTitle: moduleCfg.subTitle || '',
|
||||||
|
// 颜色直接消费插件下发的 hex8(#rrggbbaa),缺失回退内置默认
|
||||||
|
titleColor: moduleCfg.titleColor || '#f83856',
|
||||||
|
subTitleColor: moduleCfg.subTitleColor || '#f8385699',
|
||||||
|
iconBgColor: moduleCfg.iconBgColor || '#fce7f3',
|
||||||
}
|
}
|
||||||
}).filter((item): item is ILoveNavRenderItem => item !== null)
|
}).filter((item) : item is ILoveNavRenderItem => item !== null)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 恋爱计时 ---------------- */
|
/* ---------------- 恋爱计时 ---------------- */
|
||||||
@@ -201,66 +150,44 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 跳转(模块密码拦截) ---------------- */
|
/* ---------------- 跳转(模块密码拦截) ---------------- */
|
||||||
/** 页面名 → 恋爱模块 scope 映射(stories→ourStory、album→lovePhoto、list→loveDaily) */
|
/** 恋爱模块解锁流程(弹窗状态/请求/成功回调统一由 hook 管理) */
|
||||||
const MODULE_KEY_MAP: Record<string, LoveModuleKey> = {
|
const {
|
||||||
stories: 'ourStory',
|
unlockModalVisible,
|
||||||
album: 'lovePhoto',
|
pendingModule,
|
||||||
list: 'loveDaily',
|
unlockTip,
|
||||||
}
|
isModuleLocked,
|
||||||
|
openUnlock,
|
||||||
|
handleUnlockRequest,
|
||||||
|
handleUnlockSuccess,
|
||||||
|
} = useLoveModuleUnlock({
|
||||||
|
onUnlocked: (moduleKey) => {
|
||||||
|
// 恋爱日记入口解锁:恋爱配置已并入 getConfigs loveConfig 组,刷新后重读
|
||||||
|
if (moduleKey === 'loveDiary') {
|
||||||
|
appConfigStore.refreshStatic().then(() => syncLoveConfigFromStore())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
/** 模块密码弹窗状态 */
|
function handleToPage(moduleKey : LoveModuleKey) {
|
||||||
const passwordModalVisible = ref(false)
|
const moduleCfg = loveConfig.value[moduleKey] as ILoveModuleConfig | undefined
|
||||||
const pendingPage = ref('')
|
|
||||||
const pendingModule = ref<LoveModuleKey>('ourStory')
|
|
||||||
const modulePassword = ref('')
|
|
||||||
const unlocking = ref(false)
|
|
||||||
|
|
||||||
function handleToPage(pageName : string) {
|
|
||||||
const module = MODULE_KEY_MAP[pageName]
|
|
||||||
const moduleCfg = module
|
|
||||||
? (loveConfig.value[module] as { enabled ?: boolean, passwordEnabled ?: boolean })
|
|
||||||
: undefined
|
|
||||||
// 模块设了密码且本地无有效 token → 先弹密码框验证
|
// 模块设了密码且本地无有效 token → 先弹密码框验证
|
||||||
if (moduleCfg?.passwordEnabled && !getLoveModuleToken(module)) {
|
if (isModuleLocked(moduleKey)) {
|
||||||
pendingPage.value = pageName
|
openUnlock(moduleKey, moduleCfg?.path || '')
|
||||||
pendingModule.value = module
|
|
||||||
modulePassword.value = ''
|
|
||||||
passwordModalVisible.value = true
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uni.navigateTo({
|
// 跳转直接使用插件下发的 path
|
||||||
url: `/pages-blog/love/${pageName}`,
|
if (moduleCfg?.path) {
|
||||||
})
|
uni.navigateTo({
|
||||||
}
|
url: moduleCfg.path,
|
||||||
|
})
|
||||||
/** 密码确认:unlock 签发 token 后进入模块 */
|
|
||||||
async function handleConfirmPassword() {
|
|
||||||
if (!modulePassword.value.trim()) {
|
|
||||||
uni.showToast({ icon: 'none', title: '请输入密码' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
unlocking.value = true
|
|
||||||
const res = await unlockLoveModule(pendingModule.value, modulePassword.value)
|
|
||||||
const token = res.data?.token
|
|
||||||
if (token) {
|
|
||||||
setLoveModuleToken(pendingModule.value, token)
|
|
||||||
passwordModalVisible.value = false
|
|
||||||
uni.navigateTo({ url: `/pages-blog/love/${pendingPage.value}` })
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
uni.showToast({ icon: 'none', title: '解锁失败,请重试' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
uni.showToast({ icon: 'none', title: '密码不正确' })
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
unlocking.value = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
syncLoveConfigFromStore()
|
syncLoveConfigFromStore()
|
||||||
})
|
})
|
||||||
@@ -268,6 +195,10 @@
|
|||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
await appConfigStore.bootstrap()
|
await appConfigStore.bootstrap()
|
||||||
syncLoveConfigFromStore()
|
syncLoveConfigFromStore()
|
||||||
|
// 恋爱日记入口(love 页本身)设了密码且本地无 token → 弹不可关闭密码框,解锁后才能查看
|
||||||
|
if (isModuleLocked('loveDiary')) {
|
||||||
|
openUnlock('loveDiary')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -278,35 +209,35 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="bg-pink-100 min-h-screen w-screen">
|
<view class="bg-pink-50 min-h-screen w-screen">
|
||||||
<uh-navbar default-title="恋爱日记" :need-placeholder="false" back-class="text-love"
|
<uh-navbar :scroll-y="scrollY" default-title="恋爱日记" :need-placeholder="false" back-class="text-love"
|
||||||
title-color="!text-love"></uh-navbar>
|
title-color="!text-love"></uh-navbar>
|
||||||
|
|
||||||
<!-- 情侣信息 -->
|
<!-- 情侣信息 -->
|
||||||
<view class="relative z-10 h-92 w-screen flex flex-col items-center justify-center">
|
<view class="box-border pt-12 relative z-10 h-92 w-screen flex flex-col items-center justify-center">
|
||||||
<view class="relative z-10 w-full h-full flex items-center justify-center rounded-xl">
|
<view class="relative z-10 w-full h-full flex items-center justify-center rounded-xl">
|
||||||
<view class="boy flex flex-col items-center justify-center translate-x-0.5">
|
<view class="boy flex flex-col items-center justify-center uh-boy-offset">
|
||||||
<image class="uh-global-card-glass border-3 box-border border-blue-400 h-26 w-26 rounded-full"
|
<image class="uh-global-card-glass border-3 box-border border-blue-400 h-26 w-26 rounded-full"
|
||||||
:src="checkAvatarUrl(loveConfig.loveInfo.boyAvatar)" mode="aspectFill" />
|
:src="checkAvatarUrl(loveConfig.loveInfo?.boyAvatar)" mode="aspectFill" />
|
||||||
<view class="bg-blue-500 mt-2 text-center text-xs text-white font-bold px-2 py-1 rounded-lg">
|
<view class="bg-blue-500 mt-2 text-center text-xs text-white font-bold px-2 py-1 rounded-lg">
|
||||||
{{ loveConfig.loveInfo.boyNickname }}
|
{{ loveConfig.loveInfo?.boyNickname }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 心动呼吸动画 -->
|
<!-- 心动呼吸动画 -->
|
||||||
<text class="heart-beat absolute z-10"><wd-icon class-prefix="uhlove-icon" name="aixin" size="72rpx"></wd-icon></text>
|
<text class="heart-beat absolute z-10"><wd-icon class-prefix="uhlove-icon" name="aixin"
|
||||||
<view class="girl flex flex-col items-center justify-center -translate-x-0.5">
|
size="72rpx"></wd-icon></text>
|
||||||
|
<view class="girl flex flex-col items-center justify-center uh-girl-offset">
|
||||||
<image class="uh-global-card-glass border-3 box-border border-love h-26 w-26 rounded-full"
|
<image class="uh-global-card-glass border-3 box-border border-love h-26 w-26 rounded-full"
|
||||||
:src="checkAvatarUrl(loveConfig.loveInfo.girlAvatar)" mode="aspectFill" />
|
:src="checkAvatarUrl(loveConfig.loveInfo?.girlAvatar)" mode="aspectFill" />
|
||||||
<view class="bg-love mt-2 text-center text-xs text-white font-bold px-2 py-1 rounded-lg">
|
<view class="bg-love mt-2 text-center text-xs text-white font-bold px-2 py-1 rounded-lg">
|
||||||
{{ loveConfig.loveInfo.girlNickname }}
|
{{ loveConfig.loveInfo?.girlNickname }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<image :src="checkImageUrl(loveConfig.pageImages.bgImageUrl)" class="absolute z-0 inset-0 w-full h-full"
|
<image :src="checkImageUrl(loveBgImage)" class="absolute z-0 inset-0 w-full h-full" mode="aspectFill" />
|
||||||
mode="aspectFill" />
|
<view
|
||||||
<view class="absolute z-2 left-0 bottom-0 w-full h-12 bg-gradient-to-b from-white/0 to-pink-100" />
|
class="absolute z-2 left-0 bottom-0 w-full h-36 bg-gradient-to-b from-white/0 via-pink-50/50 to-pink-50" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 恋爱记时 -->
|
<!-- 恋爱记时 -->
|
||||||
<view class="love-time-wrap mt-8 w-screen flex flex-col items-center justify-center">
|
<view class="love-time-wrap mt-8 w-screen flex flex-col items-center justify-center">
|
||||||
<view class="title text-xl text-love font-bold">
|
<view class="title text-xl text-love font-bold">
|
||||||
@@ -335,51 +266,35 @@
|
|||||||
|
|
||||||
<!-- 功能导航 -->
|
<!-- 功能导航 -->
|
||||||
<view class="mt-6 box-border flex flex-col items-center justify-center gap-y-4 px-4">
|
<view class="mt-6 box-border flex flex-col items-center justify-center gap-y-4 px-4">
|
||||||
<block v-for="(nav, index) in navList" :key="index">
|
<block v-for="(nav, index) in navList" :key="nav.moduleKey">
|
||||||
<view v-if="nav.use"
|
<view v-if="nav.use"
|
||||||
class="box-border list-item uh-global-card-glass bg-white/60 p-3 w-full flex items-center justify-around gap-x-4 rounded-2xl"
|
class="box-border list-item uh-global-card-glass bg-white/60 p-3 w-full flex items-center justify-around gap-x-4 rounded-2xl"
|
||||||
:class="`list-item-${index + 1}`" @click="handleToPage(nav.key)">
|
:class="`list-item-${index + 1}`" @click="handleToPage(nav.moduleKey)">
|
||||||
<view class="flex items-center justify-center h-12 w-12 rounded-xl opacity-70" :class="[index%2===0?'bg-pink-100':'bg-blue-100']">
|
<view class="flex items-center justify-center h-12 w-12 rounded-xl opacity-70"
|
||||||
|
:style="{ backgroundColor: nav.iconBgColor }">
|
||||||
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="66rpx" />
|
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="66rpx" />
|
||||||
</view>
|
</view>
|
||||||
<view class="box-border flex flex-1 flex-col justify-center gap-y-1">
|
<view class="box-border flex flex-1 flex-col justify-center gap-y-1">
|
||||||
<view class="name text-md font-bold" :class="[index%2===0?'text-love':'text-blue-400']">
|
<view class="name text-md font-bold" :style="{ color: nav.titleColor }">
|
||||||
{{ nav.title }}
|
{{ nav.title }}
|
||||||
</view>
|
</view>
|
||||||
<view class="text-xs truncate" :class="[index%2===0?'text-love/60':'text-blue-300']">
|
<view class="text-xs truncate" :style="{ color: nav.subTitleColor }">
|
||||||
{{ nav.subTitle }}
|
{{ nav.subTitle }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="shrink-0">
|
<view class="shrink-0">
|
||||||
<wd-icon name="arrow-right" :class="[index%2===0?'text-love':'text-blue-400']"
|
<wd-icon :name="nav.locked ? 'lock' : 'arrow-right'"
|
||||||
size="32rpx"></wd-icon>
|
:style="{ color: nav.titleColor }" size="32rpx"></wd-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 模块密码验证弹窗 -->
|
<!-- 模块密码验证弹窗(恋爱日记入口强制解锁不可关闭;模块入口点击可取消) -->
|
||||||
<view v-if="passwordModalVisible" class="fixed inset-0 z-50 flex items-center justify-center bg-black/40"
|
<uh-unlock-popup v-model:show="unlockModalVisible" title="请解锁" captcha-enabled
|
||||||
@click="passwordModalVisible = false">
|
:tip="unlockTip" :closeable="pendingModule !== 'loveDiary'"
|
||||||
<view class="box-border w-4/5 rounded-2xl bg-white p-6" @click.stop>
|
placeholder="请输入密码" confirm-text="进入" :request="handleUnlockRequest" @success="handleUnlockSuccess" />
|
||||||
<view class="text-center text-lg font-bold text-love">请输入访问密码</view>
|
|
||||||
<view class="mt-2 text-center text-xs text-gray-500">
|
|
||||||
{{ pendingModule === 'ourStory' ? '恋爱故事' : pendingModule === 'lovePhoto' ? '恋爱相册' : '恋爱清单' }}已设置访问密码,输入后进入
|
|
||||||
</view>
|
|
||||||
<input v-model="modulePassword" password
|
|
||||||
class="mt-4 h-11 w-full rounded-xl border border-gray-200 bg-gray-50 px-4 text-sm outline-none"
|
|
||||||
placeholder="请输入密码" />
|
|
||||||
<view class="mt-5 flex items-center gap-3">
|
|
||||||
<view class="flex-1 rounded-xl bg-gray-100 py-2.5 text-center text-sm text-gray-600"
|
|
||||||
@click="passwordModalVisible = false">取消</view>
|
|
||||||
<view class="flex-1 rounded-xl bg-love py-2.5 text-center text-sm text-white"
|
|
||||||
:class="unlocking ? 'opacity-60' : ''" @click="handleConfirmPassword">
|
|
||||||
{{ unlocking ? '验证中…' : '进入' }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -389,6 +304,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@keyframes heartBeat {
|
@keyframes heartBeat {
|
||||||
|
|
||||||
0%,
|
0%,
|
||||||
100% {
|
100% {
|
||||||
transform: translateY(-1rem) scale(1);
|
transform: translateY(-1rem) scale(1);
|
||||||
@@ -460,4 +376,14 @@
|
|||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 男孩头像微偏右 */
|
||||||
|
.uh-boy-offset {
|
||||||
|
transform: translateX(0.125rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 女孩头像微偏左 */
|
||||||
|
.uh-girl-offset {
|
||||||
|
transform: translateX(-0.125rem);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
+125
-17
@@ -1,12 +1,15 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { getLoveStories } from '@/api/uni-halo'
|
import { getLoveStories } from '@/api/uni-halo'
|
||||||
import { handleLoveModuleLocked } from '@/utils/loveModuleToken'
|
import { getLoveModuleToken, handleLoveModuleLocked } from '@/utils/loveModuleToken'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
|
import { useLoveModuleUnlock } from '@/hooks/useLoveModuleUnlock'
|
||||||
import { checkImageUrl } from '@/utils/url'
|
import { checkImageUrl } from '@/utils/url'
|
||||||
|
import { sleep } from '@/utils/common'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import type { ILoveStory } from '@/api/types/uni-halo'
|
import type { ILoveStory } from '@/api/types/uni-halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
@@ -17,6 +20,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
/* ---------------- 展示层类型 ---------------- */
|
/* ---------------- 展示层类型 ---------------- */
|
||||||
@@ -41,6 +45,8 @@
|
|||||||
images : string[]
|
images : string[]
|
||||||
/** 时间轴封面图(最多 3 张,已预处理 URL) */
|
/** 时间轴封面图(最多 3 张,已预处理 URL) */
|
||||||
coverImages : string[]
|
coverImages : string[]
|
||||||
|
/** 排序优先级(仅脚本跨页排序用,模板不展示) */
|
||||||
|
priority : number
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 空故事占位(弹窗未打开时) */
|
/** 空故事占位(弹窗未打开时) */
|
||||||
@@ -56,6 +62,7 @@
|
|||||||
content: '',
|
content: '',
|
||||||
images: [],
|
images: [],
|
||||||
coverImages: [],
|
coverImages: [],
|
||||||
|
priority: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 中文星期(dayjs day():0=周日) */
|
/** 中文星期(dayjs day():0=周日) */
|
||||||
@@ -88,27 +95,81 @@
|
|||||||
content: spec.content || '',
|
content: spec.content || '',
|
||||||
images,
|
images,
|
||||||
coverImages: images.slice(0, 3),
|
coverImages: images.slice(0, 3),
|
||||||
|
priority: spec.priority || 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 故事列表排序(priority 越大越靠前;跨页 concat 后整体重排) */
|
||||||
|
function sortStories(list : IStoryCard[]) : IStoryCard[] {
|
||||||
|
return [...list].sort((a, b) => (b.priority || 0) - (a.priority || 0))
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
|
const queryParams = ref({ page: 1, size: 10 })
|
||||||
const stories = ref<IStoryCard[]>([])
|
const stories = ref<IStoryCard[]>([])
|
||||||
const showDetail = ref(false)
|
const showDetail = ref(false)
|
||||||
const currentStory = ref<IStoryCard>(EMPTY_STORY)
|
const currentStory = ref<IStoryCard>(EMPTY_STORY)
|
||||||
const storyImageIndex = ref(0)
|
const storyImageIndex = ref(0)
|
||||||
|
|
||||||
|
/* ---------------- 恋爱模块解锁(防分享直达:锁定未解锁时不加载数据) ---------------- */
|
||||||
|
const {
|
||||||
|
unlockModalVisible,
|
||||||
|
unlockTip,
|
||||||
|
isModuleLocked,
|
||||||
|
openUnlock,
|
||||||
|
handleUnlockRequest,
|
||||||
|
handleUnlockSuccess,
|
||||||
|
} = useLoveModuleUnlock()
|
||||||
|
|
||||||
|
/** 是否放行数据加载(锁定未解锁时为 false,解锁成功置 true) */
|
||||||
|
const canLoad = ref(false)
|
||||||
|
|
||||||
|
/** 锁定则弹不可关闭解锁弹窗,返回是否放行 */
|
||||||
|
function ensureUnlocked() : boolean {
|
||||||
|
if (isModuleLocked('ourStory')) {
|
||||||
|
openUnlock('ourStory')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解锁成功:存 token 后恢复数据加载 */
|
||||||
|
function handlePageUnlockSuccess(data : { token ?: string }) {
|
||||||
|
handleUnlockSuccess(data)
|
||||||
|
if (getLoveModuleToken('ourStory')) {
|
||||||
|
canLoad.value = true
|
||||||
|
handleGetStories()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetStories() {
|
async function handleGetStories() {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
if (!loadMoreStatus.value.active) {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getLoveStories({})
|
const res = await getLoveStories({ ...queryParams.value })
|
||||||
const items = res.data?.items || []
|
const items = res.data?.items || []
|
||||||
if (items.length > 0) {
|
if (loadMoreStatus.value.active) {
|
||||||
// 按 priority 排序(越大越靠前)
|
// 分页加载:追加并按 priority 整体重排(跨页保持全局有序)
|
||||||
const sorted = [...items].sort((a, b) => (b.spec?.priority || 0) - (a.spec?.priority || 0))
|
stories.value = sortStories([...stories.value, ...items.map(mapStoryCard)])
|
||||||
stories.value = sorted.map(mapStoryCard)
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data?.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: !!res.data?.hasNext,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if (items.length > 0) {
|
||||||
|
// 首屏:按 priority 排序(越大越靠前)
|
||||||
|
stories.value = sortStories(items.map(mapStoryCard))
|
||||||
|
await sleep(600)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Success)
|
updateLoadingStatus(DataLoadingStatusEnum.Success)
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data?.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: !!res.data?.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 降级:从旧配置读取单条故事
|
// 降级:从旧配置读取单条故事
|
||||||
@@ -117,15 +178,25 @@
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('获取故事失败', e)
|
console.error('获取故事失败', e)
|
||||||
// 模块锁 401:清除 token 并提示;命中 locked 时不做旧配置降级(需回入口重新解锁)
|
// 模块锁 401:清除 token 并弹不可关闭解锁弹窗(解锁后恢复加载);命中 locked 不做旧配置降级
|
||||||
if (!handleLoveModuleLocked('ourStory', e)) {
|
if (handleLoveModuleLocked('ourStory', e)) {
|
||||||
|
openUnlock('ourStory')
|
||||||
|
}
|
||||||
|
else {
|
||||||
handleLoadFromLegacy()
|
handleLoadFromLegacy()
|
||||||
}
|
}
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setTimeout(() => {
|
uni.stopPullDownRefresh()
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
}, 200)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +215,7 @@
|
|||||||
content: loveModuleConfig.ourStory.content,
|
content: loveModuleConfig.ourStory.content,
|
||||||
images: [],
|
images: [],
|
||||||
coverImages: [],
|
coverImages: [],
|
||||||
|
priority: 0,
|
||||||
}]
|
}]
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Success)
|
updateLoadingStatus(DataLoadingStatusEnum.Success)
|
||||||
return
|
return
|
||||||
@@ -189,19 +261,49 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
|
handlePageInit()
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 页面初始化:先判定模块锁定(防分享直达),解锁或未设密码才加载数据 */
|
||||||
|
async function handlePageInit() {
|
||||||
|
await appConfigStore.bootstrap()
|
||||||
|
if (!ensureUnlocked()) { return }
|
||||||
|
canLoad.value = true
|
||||||
|
handleGetStories()
|
||||||
|
}
|
||||||
|
|
||||||
|
onPullDownRefresh(() => {
|
||||||
|
resetLoadMoreStatus()
|
||||||
|
queryParams.value.page = 1
|
||||||
handleGetStories()
|
handleGetStories()
|
||||||
})
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onReachBottom(() => {
|
||||||
handleGetStories()
|
// 正在加载时阻止重复请求
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 有更多数据时继续加载
|
||||||
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetStories()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="app-page box-border min-h-screen w-screen flex flex-col">
|
<view class="app-page box-border min-h-screen w-screen flex flex-col">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="恋爱故事" title-color="text-love" back-class="text-love" />
|
<uh-navbar :scroll-y="scrollY" default-title="恋爱故事" title-color="text-love" back-class="text-love" />
|
||||||
|
|
||||||
<!-- 加载/错误/空占位(状态机) -->
|
<!-- 加载/错误/空占位(状态机) -->
|
||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
@@ -252,6 +354,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 故事详情弹窗 -->
|
<!-- 故事详情弹窗 -->
|
||||||
@@ -293,6 +396,11 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</uh-glass-popup>
|
</uh-glass-popup>
|
||||||
|
|
||||||
|
<!-- 模块级密码解锁弹窗(强制不可关闭,防分享直达) -->
|
||||||
|
<uh-unlock-popup v-model:show="unlockModalVisible" title="请解锁" captcha-enabled
|
||||||
|
:tip="unlockTip" placeholder="请输入密码" confirm-text="进入" :closeable="false"
|
||||||
|
:request="handleUnlockRequest" @success="handlePageUnlockSuccess" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||||
import { getMomentByName } from '@/api/halo'
|
import { getMomentByName } from '@/api/halo'
|
||||||
import { useUpvote } from '@/hooks/useUpvote'
|
import { useUpvote } from '@/hooks/useUpvote'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
import { randomTagColor } from '@/utils/random'
|
import { randomTagColor } from '@/utils/random'
|
||||||
import { markdownConfig } from '@/config/markdown'
|
import { markdownConfig } from '@/config/markdown'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import type { IMoment } from '@/api/types/halo'
|
import type { IMoment } from '@/api/types/halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const favoritesStore = useFavoritesStore()
|
const favoritesStore = useFavoritesStore()
|
||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
const haloConfigs = computed(() => appConfigStore.configs)
|
||||||
@@ -90,7 +92,7 @@
|
|||||||
const res = await getMomentByName(queryName.value)
|
const res = await getMomentByName(queryName.value)
|
||||||
const card = buildMomentCard(res.data)
|
const card = buildMomentCard(res.data)
|
||||||
moment.value = card
|
moment.value = card
|
||||||
// 对象无键视为空 → 空态(与原 useDataLoading 默认判空一致)
|
|
||||||
updateLoadingStatus(
|
updateLoadingStatus(
|
||||||
Object.keys(card).length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
Object.keys(card).length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
)
|
)
|
||||||
@@ -132,8 +134,7 @@
|
|||||||
/** 切换收藏(收藏/取消),收藏时按当前详情内容生成快照入库 */
|
/** 切换收藏(收藏/取消),收藏时按当前详情内容生成快照入库 */
|
||||||
function handleToggleMomentFavorite() {
|
function handleToggleMomentFavorite() {
|
||||||
const card = moment.value
|
const card = moment.value
|
||||||
if (!card)
|
if (!card) { return }
|
||||||
return
|
|
||||||
const favorited = favoritesStore.toggle(buildMomentFavoriteItem(card))
|
const favorited = favoritesStore.toggle(buildMomentFavoriteItem(card))
|
||||||
uni.showToast({ icon: 'none', title: favorited ? '收藏成功' : '已取消收藏' })
|
uni.showToast({ icon: 'none', title: favorited ? '收藏成功' : '已取消收藏' })
|
||||||
}
|
}
|
||||||
@@ -156,6 +157,7 @@
|
|||||||
isComment: false,
|
isComment: false,
|
||||||
postName: '',
|
postName: '',
|
||||||
title: '',
|
title: '',
|
||||||
|
quoteReply: '',
|
||||||
})
|
})
|
||||||
/** 评论列表组件实例(评论成功后刷新) */
|
/** 评论列表组件实例(评论成功后刷新) */
|
||||||
const commentListRef = ref<{ refresh : () => void } | null>(null)
|
const commentListRef = ref<{ refresh : () => void } | null>(null)
|
||||||
@@ -173,16 +175,18 @@
|
|||||||
isComment: true,
|
isComment: true,
|
||||||
postName: current.metadata.name,
|
postName: current.metadata.name,
|
||||||
title: '新增评论',
|
title: '新增评论',
|
||||||
|
quoteReply: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 评论列表触发(回复某条评论/新增) */
|
/** 评论列表触发(回复某条评论/新增) */
|
||||||
function handleOnComment(data : { isComment : boolean, postName : string, title : string }) {
|
function handleOnComment(data : { isComment : boolean, postName : string, title : string, quoteReply ?: string }) {
|
||||||
commentModal.value = {
|
commentModal.value = {
|
||||||
show: true,
|
show: true,
|
||||||
isComment: data.isComment,
|
isComment: data.isComment,
|
||||||
postName: data.postName,
|
postName: data.postName,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
|
quoteReply: data.quoteReply ?? '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +251,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
queryName.value = options?.name || ''
|
queryName.value = options?.name || ''
|
||||||
loadMoment()
|
loadMoment()
|
||||||
@@ -272,15 +280,12 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="app-page box-border min-h-screen w-screen bg-page pb-safe">
|
<view class="app-page box-border min-h-screen w-screen bg-page pb-safe">
|
||||||
<!-- 自定义导航 -->
|
<uh-navbar :scroll-y="scrollY" default-title="瞬间详情" title-color="text-gray-900" />
|
||||||
<uh-navbar default-title="瞬间详情" title-color="text-gray-900" />
|
|
||||||
|
|
||||||
<!-- 状态区(加载中/失败可重试/空) -->
|
|
||||||
<uh-data-loading v-if="status !== 'success'" :loading-status="status" min-height="60vh" error-text="瞬间内容加载失败"
|
<uh-data-loading v-if="status !== 'success'" :loading-status="status" min-height="60vh" error-text="瞬间内容加载失败"
|
||||||
empty-text="瞬间不存在或已被删除" @refresh="loadMoment" />
|
empty-text="瞬间不存在或已被删除" @refresh="loadMoment" />
|
||||||
|
|
||||||
<!-- 瞬间内页(日记式:大字日期刊头 + 阅读正文 + 媒体 + 互动脚注) -->
|
<view v-else-if="moment" class="box-border px-3 pt-2 pb-14">
|
||||||
<view v-else-if="moment" class="box-border px-3 pt-2 pb-12">
|
|
||||||
<view class="mb-3 uh-global-card-glass uh-shadow-xs overflow-hidden rounded-2xl box-border pb-4">
|
<view class="mb-3 uh-global-card-glass uh-shadow-xs overflow-hidden rounded-2xl box-border pb-4">
|
||||||
<!-- 刊头:大字日期 -->
|
<!-- 刊头:大字日期 -->
|
||||||
<view v-if="moment.spec.releaseTime" class="px-4 pt-4">
|
<view v-if="moment.spec.releaseTime" class="px-4 pt-4">
|
||||||
@@ -298,22 +303,21 @@
|
|||||||
<image class="h-[80rpx] w-[80rpx] shrink-0 rounded-full"
|
<image class="h-[80rpx] w-[80rpx] shrink-0 rounded-full"
|
||||||
:src="checkAvatarUrl(moment.owner?.avatar || bloggerInfo.avatar)" mode="aspectFill" />
|
:src="checkAvatarUrl(moment.owner?.avatar || bloggerInfo.avatar)" mode="aspectFill" />
|
||||||
<view class="ml-3 flex flex-col">
|
<view class="ml-3 flex flex-col">
|
||||||
<view class="text-[30rpx] text-[#5c7c0f] font-bold">
|
<view class="text-md text-gray-600 font-medium">
|
||||||
{{ moment.owner?.displayName || bloggerInfo.nickname }}
|
{{ moment.owner?.displayName || bloggerInfo.nickname }}
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-0.5 text-[22rpx] text-gray-400">
|
<view class="mt-0.5 text-xs text-gray-400">
|
||||||
记录了这美好的一刻
|
记录了这美好的一刻
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 正文 -->
|
<!-- 正文 -->
|
||||||
<view class="content px-4 mt-6 text-gray-900 text-sm">
|
<view class="content px-4 mt-6 text-gray-900 text-2xs">
|
||||||
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
|
<mp-html lazy-load :domain="markdownConfig.domain ?? ''" :loading-img="markdownConfig.loadingGif"
|
||||||
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
scroll-table selectable :tag-style="markdownConfig.tagStyle"
|
||||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
:container-style="markdownConfig.containStyle" :content="moment.spec.newHtml || ''"
|
||||||
:content="moment.spec.newHtml || ''" :markdown="true" :show-line-number="true"
|
:markdown="true" :show-line-number="true" :show-language-name="true" copy-by-long-press />
|
||||||
:show-language-name="true" copy-by-long-press />
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 图片附件 -->
|
<!-- 图片附件 -->
|
||||||
@@ -351,7 +355,7 @@
|
|||||||
<view v-if="moment.spec.tags && moment.spec.tags.length !== 0"
|
<view v-if="moment.spec.tags && moment.spec.tags.length !== 0"
|
||||||
class="tags flex flex-wrap gap-2 px-4 pt-6">
|
class="tags flex flex-wrap gap-2 px-4 pt-6">
|
||||||
<view v-for="(tag, tagIndex) in moment.spec.tags" :key="tagIndex"
|
<view v-for="(tag, tagIndex) in moment.spec.tags" :key="tagIndex"
|
||||||
class="rounded-full bg-primary px-3 py-1 text-xs font-bold" >
|
class="rounded-full bg-primary px-3 py-1 text-xs font-bold">
|
||||||
# {{ tag }}
|
# {{ tag }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -361,31 +365,33 @@
|
|||||||
<uh-comment-list v-if="moment" ref="commentListRef" :post-name="moment.metadata.name" :post="moment"
|
<uh-comment-list v-if="moment" ref="commentListRef" :post-name="moment.metadata.name" :post="moment"
|
||||||
kind="Moment" :disallow-comment="!moment.spec.allowComment" @on-comment="handleOnComment" />
|
kind="Moment" :disallow-comment="!moment.spec.allowComment" @on-comment="handleOnComment" />
|
||||||
</view>
|
</view>
|
||||||
<!-- 悬浮操作(与文章详情一致:点赞/评论/收藏) -->
|
|
||||||
<view v-if="moment" class="fixed bottom-8 left-1/2 z-10 flex items-center justify-center pb-safe -translate-x-1/2">
|
<!-- 悬浮操作 -->
|
||||||
|
<view v-if="moment"
|
||||||
|
class="fixed bottom-0 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
||||||
<!-- 点赞 -->
|
<!-- 点赞 -->
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||||
:class="{ active: hasUpvoted() }" @click="handleDoLikesClick">
|
:class="[hasUpvoted()?'text-primary':'text-gray-900']" @click="handleDoLikesClick">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="36rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="36rpx" />
|
||||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">点赞</text>
|
<text class="shrink-0 text-xs text-gray-900 font-semibold">点赞</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 评论 -->
|
<!-- 评论 -->
|
||||||
<view v-if="moment.spec.allowComment"
|
<view v-if="moment.spec.allowComment"
|
||||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||||
@click="handleToComment()">
|
@click="handleToComment()">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="36rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="36rpx" />
|
||||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">评论</text>
|
<text class="shrink-0 text-xs text-gray-900 font-semibold">评论</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 收藏 -->
|
<!-- 收藏 -->
|
||||||
<view
|
<view
|
||||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||||
@click="handleToggleMomentFavorite">
|
@click="handleToggleMomentFavorite">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
|
||||||
<text class="shrink-0 text-sm font-semibold"
|
<text class="shrink-0 text-xs font-semibold"
|
||||||
:class="momentFavorited ? 'text-primary' : 'text-gray-900'">{{ momentFavorited ? '已收藏' : '收藏' }}</text>
|
:class="[momentFavorited ? 'text-primary' : 'text-gray-900']">{{ momentFavorited ? '已收藏' : '收藏' }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -393,6 +399,13 @@
|
|||||||
<!-- 评论弹窗 -->
|
<!-- 评论弹窗 -->
|
||||||
<uh-comment-modal v-if="commentModal.show" :show="commentModal.show" :is-comment="commentModal.isComment"
|
<uh-comment-modal v-if="commentModal.show" :show="commentModal.show" :is-comment="commentModal.isComment"
|
||||||
:title="commentModal.title" :post-name="commentModal.postName" subject-kind="Moment"
|
:title="commentModal.title" :post-name="commentModal.postName" subject-kind="Moment"
|
||||||
@on-close="handleOnCommentModalClose" />
|
:quote-reply="commentModal.quoteReply" @on-close="handleOnCommentModalClose" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
/* 水平居中定位 */
|
||||||
|
.uh-translate-x-center {
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,337 +0,0 @@
|
|||||||
<script lang="ts" setup>
|
|
||||||
/**
|
|
||||||
* 瞬间详情页(源自旧项目 pagesA/moment-detail,新建复刻)
|
|
||||||
* 展示瞬间内容(mp-html) + 图片/音频/视频附件
|
|
||||||
* 试点:useDataLoading 状态机接管加载四态 + 壁纸光斑玻璃卡设计
|
|
||||||
*/
|
|
||||||
import { computed, ref } from 'vue'
|
|
||||||
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
|
||||||
import { getMomentByName } from '@/api/halo'
|
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
|
||||||
import { checkAvatarUrl, checkThumbnailUrl } from '@/utils/url'
|
|
||||||
import { generateUUID } from '@/utils/uuid'
|
|
||||||
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
|
||||||
import { randomTagColor } from '@/utils/random'
|
|
||||||
import { markdownConfig } from '@/config/markdown'
|
|
||||||
import { useDataLoading } from '@/hooks/useDataLoading'
|
|
||||||
import type { IMoment } from '@/api/types/halo'
|
|
||||||
|
|
||||||
definePage({
|
|
||||||
style: {
|
|
||||||
navigationBarTitleText: '瞬间详情',
|
|
||||||
enablePullDownRefresh: true,
|
|
||||||
// 下拉/回弹露出的窗口底色对齐页面底色,壁纸光斑由页面内提供
|
|
||||||
backgroundColor: '#f6f3ee',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const appConfigStore = useAppConfigStore()
|
|
||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
|
||||||
|
|
||||||
const bloggerInfo = computed(() => {
|
|
||||||
const blogger = haloConfigs.value.authorConfig?.blogger as { nickname?: string, avatar?: string } | undefined
|
|
||||||
return {
|
|
||||||
nickname: blogger?.nickname || '',
|
|
||||||
avatar: checkAvatarUrl(blogger?.avatar),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const calcUseTagRandomColor = computed(() => !!haloConfigs.value.pageConfig?.momentConfig?.useTagRandomColor)
|
|
||||||
|
|
||||||
/** 站点名称(原 startConfig.title 已随启动页下线,改读 appConfig.appInfo.name) */
|
|
||||||
const siteName = computed(() => {
|
|
||||||
const appInfo = haloConfigs.value.appConfig?.appInfo as { name?: string } | undefined
|
|
||||||
return appInfo?.name || bloggerInfo.value.nickname || 'uni-halo'
|
|
||||||
})
|
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
|
||||||
const queryName = ref('')
|
|
||||||
const videoContexts = ref<Record<string, UniApp.VideoContext | undefined>>({})
|
|
||||||
const currentVideoId = ref<string | null>(null)
|
|
||||||
|
|
||||||
/** 瞬间卡片(medium 按类型拆为 images/videos/audios + 正文 tag 清理) */
|
|
||||||
type MomentCard = IMoment & {
|
|
||||||
images?: { type?: string, url: string }[]
|
|
||||||
videos?: { id?: string, url: string }[]
|
|
||||||
audios?: { type?: string, url: string }[]
|
|
||||||
spec: IMoment['spec'] & { newHtml?: string }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 移除 tag 链接 */
|
|
||||||
function removeTagLinksCompletely(htmlString: string): string {
|
|
||||||
const regex = /<a\b[^>]+class=(['"])[^'"]*\btag\b[^'"]*\1[^>]*>[\s\S]*?<\/a>/gi
|
|
||||||
return htmlString.replace(regex, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 瞬间详情 → 展示卡片(作者兜底 + medium 拆分 + tag 清理) */
|
|
||||||
function buildMomentCard(res: IMoment): MomentCard {
|
|
||||||
const medium = (res.spec.content?.medium || [])
|
|
||||||
.map(x => ({ ...x, url: x.url || '' }))
|
|
||||||
const owner = res.owner
|
|
||||||
return {
|
|
||||||
...res,
|
|
||||||
// 无顶层 owner(如个别历史接口)时兜底为博主信息
|
|
||||||
owner: owner?.displayName
|
|
||||||
? owner
|
|
||||||
: { displayName: bloggerInfo.value.nickname || '', name: bloggerInfo.value.nickname || '', avatar: bloggerInfo.value.avatar },
|
|
||||||
spec: {
|
|
||||||
...res.spec,
|
|
||||||
newHtml: removeTagLinksCompletely(res.spec.content?.html || ''),
|
|
||||||
},
|
|
||||||
images: medium.filter(x => x.type === 'PHOTO').map(x => ({ ...x, url: checkThumbnailUrl(x.url, true) })),
|
|
||||||
videos: medium.filter(x => x.type === 'VIDEO').map(x => ({ ...x, id: generateUUID() })),
|
|
||||||
audios: medium.filter(x => x.type === 'AUDIO'),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------- 数据加载(useDataLoading 试点:状态由 hook 接管) ---------------- */
|
|
||||||
const { data: moment, status, run: loadMoment } = useDataLoading(
|
|
||||||
async (): Promise<MomentCard> => {
|
|
||||||
const res = await getMomentByName(queryName.value)
|
|
||||||
uni.setNavigationBarTitle({ title: '瞬间详情' })
|
|
||||||
return buildMomentCard(res.data)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
onSuccess: (card) => {
|
|
||||||
nextTick(() => {
|
|
||||||
createVideoContexts(card.videos || [])
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onError: () => {
|
|
||||||
uni.setNavigationBarTitle({ title: '瞬间详情' })
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 标签颜色(随机模式下按数据稳定,避免每次渲染重新随机变色) */
|
|
||||||
const calcTagColors = computed(() => {
|
|
||||||
const tags = moment.value?.spec.tags || []
|
|
||||||
return tags.map(() => (calcUseTagRandomColor.value ? randomTagColor() : '#4d7c0f'))
|
|
||||||
})
|
|
||||||
|
|
||||||
function formatTime(time?: string): string {
|
|
||||||
// 与旧项目一致:yyyy年MM月dd日 星期w
|
|
||||||
return time ? formatTimeUtil({ d: time, f: 'yyyy年MM月dd日 星期w' }) : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------- 视频互斥 ---------------- */
|
|
||||||
function createVideoContexts(videos: { id?: string }[]) {
|
|
||||||
stopAllVideos()
|
|
||||||
videos.forEach((item) => {
|
|
||||||
if (item.id) {
|
|
||||||
videoContexts.value[item.id] = uni.createVideoContext(`video_${item.id}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopAllVideos(excludesVideoId: string | null = null) {
|
|
||||||
Object.keys(videoContexts.value).forEach((videoId) => {
|
|
||||||
if (!excludesVideoId || excludesVideoId !== videoId) {
|
|
||||||
videoContexts.value[videoId]?.pause()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function onVideoPlay(videoId: string) {
|
|
||||||
currentVideoId.value = videoId
|
|
||||||
stopAllVideos(videoId)
|
|
||||||
}
|
|
||||||
|
|
||||||
function onVideoPause(videoId: string) {
|
|
||||||
if (currentVideoId.value === videoId) {
|
|
||||||
currentVideoId.value = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onVideoEnded() {
|
|
||||||
currentVideoId.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------- 交互 ---------------- */
|
|
||||||
function handlePreview(index: number, list: { url: string }[]) {
|
|
||||||
uni.previewImage({
|
|
||||||
current: index,
|
|
||||||
urls: list.map(item => item.url),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleToTopPage(duration = 500) {
|
|
||||||
uni.pageScrollTo({
|
|
||||||
scrollTop: 0,
|
|
||||||
duration,
|
|
||||||
fail: (err) => {
|
|
||||||
console.error('回顶失败', err)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
|
||||||
onLoad((options) => {
|
|
||||||
uni.setNavigationBarTitle({ title: '瞬间加载中...' })
|
|
||||||
queryName.value = options?.name || ''
|
|
||||||
loadMoment()
|
|
||||||
})
|
|
||||||
|
|
||||||
onPullDownRefresh(async () => {
|
|
||||||
videoContexts.value = {}
|
|
||||||
currentVideoId.value = null
|
|
||||||
await loadMoment()
|
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
})
|
|
||||||
|
|
||||||
onShareAppMessage(() => ({
|
|
||||||
path: `/pages-blog/moment-detail/moment-detail?name=${moment.value?.metadata.name}`,
|
|
||||||
title: moment.value?.owner?.displayName || '',
|
|
||||||
}))
|
|
||||||
|
|
||||||
onShareTimeline(() => ({
|
|
||||||
title: moment.value?.owner?.displayName || '',
|
|
||||||
query: moment.value ? `name=${moment.value.metadata.name}` : '',
|
|
||||||
}))
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="app-page relative box-border min-h-screen w-screen bg-page pb-8">
|
|
||||||
<!-- 壁纸(柔和光斑为卡片毛玻璃取色,固定不随滚动) -->
|
|
||||||
<view class="pointer-events-none fixed inset-0 z-0 overflow-hidden">
|
|
||||||
<view class="absolute h-[420rpx] w-[420rpx] rounded-full bg-[rgba(103,164,242,0.16)] -left-[120rpx] -top-[60rpx]" />
|
|
||||||
<view class="absolute top-[240rpx] h-[360rpx] w-[360rpx] rounded-full bg-[rgba(244,143,177,0.15)] -right-[130rpx]" />
|
|
||||||
<view class="absolute top-[760rpx] h-[400rpx] w-[400rpx] rounded-full bg-[rgba(179,157,219,0.14)] -left-[150rpx]" />
|
|
||||||
<view class="absolute top-[1220rpx] h-[380rpx] w-[380rpx] rounded-full bg-[rgba(185,228,36,0.15)] -right-[120rpx]" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 状态区(加载中/失败可重试/空) -->
|
|
||||||
<uh-data-loading
|
|
||||||
v-if="status !== 'success'"
|
|
||||||
class="relative z-1"
|
|
||||||
:loading-status="status"
|
|
||||||
min-height="60vh"
|
|
||||||
error-text="瞬间内容加载失败"
|
|
||||||
empty-text="瞬间不存在或已被删除"
|
|
||||||
@refresh="loadMoment"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 瞬间内容(悬浮玻璃卡) -->
|
|
||||||
<view v-else-if="moment" class="moment-card uh-global-card-glass relative z-1 mx-4 mt-5 flex flex-col rounded-[32rpx] p-5">
|
|
||||||
<!-- 用户区 -->
|
|
||||||
<view class="user flex items-center gap-3">
|
|
||||||
<image class="h-[96rpx] w-[96rpx] shrink-0 border-4 border-white/90 rounded-full shadow-lg" :src="moment.owner?.avatar || bloggerInfo.avatar" mode="aspectFill" />
|
|
||||||
<view class="nickname min-w-0 flex flex-1 flex-col">
|
|
||||||
<view class="nickname-text text-[32rpx] text-gray-900 font-bold">
|
|
||||||
{{ moment.owner?.displayName || bloggerInfo.nickname }}
|
|
||||||
</view>
|
|
||||||
<view class="release-time mt-1 text-[24rpx] text-gray-400">
|
|
||||||
{{ formatTime(moment.spec.releaseTime) }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<!-- 互动数据(点赞/评论) -->
|
|
||||||
<view v-if="moment.stats && ((moment.stats.totalComment ?? 0) > 0 || (moment.stats.upvote ?? 0) > 0)" class="stats flex shrink-0 items-center gap-2">
|
|
||||||
<view class="flex items-center gap-1 rounded-full bg-black/5 px-2.5 py-1 text-[22rpx] text-gray-500">
|
|
||||||
<wd-icon name="heart" size="12px" color="#f08585" />
|
|
||||||
<text>{{ moment.stats.upvote || 0 }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="flex items-center gap-1 rounded-full bg-black/5 px-2.5 py-1 text-[22rpx] text-gray-500">
|
|
||||||
<wd-icon name="message" size="12px" color="#7f8ea3" />
|
|
||||||
<text>{{ moment.stats.totalComment || 0 }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 标签 -->
|
|
||||||
<view v-if="moment.spec.tags && moment.spec.tags.length !== 0" class="tags mt-4 flex flex-wrap gap-2">
|
|
||||||
<view v-for="(tag, tagIndex) in moment.spec.tags" :key="tagIndex" class="rounded-full bg-black/5 px-3 py-1 text-[22rpx] font-bold" :style="{ color: calcTagColors[tagIndex] }">
|
|
||||||
# {{ tag }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 内容 -->
|
|
||||||
<view class="content mt-4">
|
|
||||||
<mp-html
|
|
||||||
class="evan-markdown"
|
|
||||||
lazy-load
|
|
||||||
:domain="markdownConfig.domain ?? ''"
|
|
||||||
:loading-img="markdownConfig.loadingGif"
|
|
||||||
scroll-table
|
|
||||||
selectable
|
|
||||||
:tag-style="markdownConfig.tagStyle"
|
|
||||||
:container-style="markdownConfig.containStyle"
|
|
||||||
:content="moment.spec.newHtml || ''"
|
|
||||||
:markdown="true"
|
|
||||||
:show-line-number="true"
|
|
||||||
:show-language-name="true"
|
|
||||||
copy-by-long-press
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 图片附件 -->
|
|
||||||
<view v-if="moment.images && moment.images.length !== 0" class="mt-5">
|
|
||||||
<view class="mb-3 flex items-center gap-2">
|
|
||||||
<view class="h-[24rpx] w-[6rpx] rounded-full bg-secondary" />
|
|
||||||
<text class="text-[26rpx] text-gray-500 font-bold">图片附件</text>
|
|
||||||
</view>
|
|
||||||
<view class="images flex flex-wrap items-start">
|
|
||||||
<view
|
|
||||||
v-for="(image, mediumIndex) in moment.images"
|
|
||||||
:key="mediumIndex"
|
|
||||||
class="image-item box-border p-1.5"
|
|
||||||
:class="moment.images && moment.images.length === 1 ? 'h-[350rpx] w-full' : (moment.images && moment.images.length === 2 ? 'h-[250rpx] w-1/2' : 'h-[200rpx] w-1/3')"
|
|
||||||
>
|
|
||||||
<image
|
|
||||||
mode="aspectFill"
|
|
||||||
class="image-src h-full w-full rounded-lg"
|
|
||||||
:src="image.url"
|
|
||||||
@click="handlePreview(mediumIndex, moment.images || [])"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 音频附件 -->
|
|
||||||
<view v-if="moment.audios && moment.audios.length !== 0" class="mt-5">
|
|
||||||
<view class="mb-3 flex items-center gap-2">
|
|
||||||
<view class="h-[24rpx] w-[6rpx] rounded-full bg-secondary" />
|
|
||||||
<text class="text-[26rpx] text-gray-500 font-bold">音频附件</text>
|
|
||||||
</view>
|
|
||||||
<view class="audio-list flex flex-col gap-3">
|
|
||||||
<uh-audio-player
|
|
||||||
v-for="audio in moment.audios"
|
|
||||||
:key="audio.url"
|
|
||||||
:src="audio.url"
|
|
||||||
:poster="bloggerInfo.avatar"
|
|
||||||
:name="`来自${siteName}的声音`"
|
|
||||||
:author="bloggerInfo.nickname"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 视频附件 -->
|
|
||||||
<view v-if="moment.videos && moment.videos.length !== 0" class="mt-5">
|
|
||||||
<view class="mb-3 flex items-center gap-2">
|
|
||||||
<view class="h-[24rpx] w-[6rpx] rounded-full bg-secondary" />
|
|
||||||
<text class="text-[26rpx] text-gray-500 font-bold">视频附件</text>
|
|
||||||
</view>
|
|
||||||
<view class="video-list w-full flex flex-col gap-3">
|
|
||||||
<video
|
|
||||||
v-for="(video, index) in moment.videos"
|
|
||||||
:id="`video_${video.id}`"
|
|
||||||
:key="index"
|
|
||||||
class="video-src h-[400rpx] w-full rounded-xl"
|
|
||||||
:src="video.url"
|
|
||||||
:show-mute-btn="true"
|
|
||||||
:controls="true"
|
|
||||||
:show-center-play-btn="true"
|
|
||||||
:enable-progress-gesture="true"
|
|
||||||
@play="onVideoPlay(video.id || '')"
|
|
||||||
@pause="onVideoPause(video.id || '')"
|
|
||||||
@ended="onVideoEnded"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 回顶 -->
|
|
||||||
<view class="to-top-btn uh-global-card-glass fixed bottom-[100rpx] right-6 z-6 h-[72rpx] w-[72rpx] flex items-center justify-center rounded-full" @click="handleToTopPage()">
|
|
||||||
<wd-icon name="arrow-up" size="20px" color="#6b7280" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { getNoticeDetail } from '@/api/uni-halo'
|
import { getNoticeDetail } from '@/api/uni-halo'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { checkImageUrl, checkIsUrl } from '@/utils/url'
|
import { checkImageUrl, checkIsUrl } from '@/utils/url'
|
||||||
import { sleep } from '@/utils/common'
|
import { sleep } from '@/utils/common'
|
||||||
import { markdownConfig } from '@/config/markdown'
|
import { markdownConfig } from '@/config/markdown'
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||||
const name = ref('')
|
const name = ref('')
|
||||||
const detail = ref<INoticeDetail | null>(null)
|
const detail = ref<INoticeDetail | null>(null)
|
||||||
@@ -81,6 +83,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
name.value = options?.name || ''
|
name.value = options?.name || ''
|
||||||
loadDetail()
|
loadDetail()
|
||||||
@@ -90,7 +96,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen bg-page pb-safe">
|
<view class="box-border min-h-screen w-screen bg-page pb-safe">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="公告详情" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="公告详情" title-color="text-gray-900" />
|
||||||
|
|
||||||
<!-- 加载/错误/空态(状态机) -->
|
<!-- 加载/错误/空态(状态机) -->
|
||||||
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="75vh"
|
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="75vh"
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getNotices } from '@/api/uni-halo'
|
import { getNotices } from '@/api/uni-halo'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import { checkImageUrl } from '@/utils/url'
|
import { checkImageUrl } from '@/utils/url'
|
||||||
import { sleep } from '@/utils/common'
|
import { sleep } from '@/utils/common'
|
||||||
import type { INoticeListVo } from '@/api/types/uni-halo'
|
import type { INoticeListVo } from '@/api/types/uni-halo'
|
||||||
@@ -15,6 +17,8 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const PAGE_SIZE = 100
|
const PAGE_SIZE = 100
|
||||||
|
|
||||||
/** 状态机:首屏/下拉刷新 loading、empty、error;触底加载失败仅提示,不切整页错误态 */
|
/** 状态机:首屏/下拉刷新 loading、empty、error;触底加载失败仅提示,不切整页错误态 */
|
||||||
@@ -154,6 +158,10 @@
|
|||||||
loadNotices(false)
|
loadNotices(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
loadNotices(true)
|
loadNotices(true)
|
||||||
})
|
})
|
||||||
@@ -180,34 +188,36 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="app-page min-h-screen w-screen flex flex-col bg-page">
|
<view class="app-page min-h-screen w-screen flex flex-col bg-page">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="公告中心" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="公告中心" title-color="text-gray-900" />
|
||||||
|
|
||||||
<wd-sticky>
|
<wd-sticky :offset-top="offsetTop">
|
||||||
<scroll-view scroll-x class="w-full whitespace-nowrap" :show-scrollbar="false">
|
<view class="w-screen overflow-hidden">
|
||||||
<view class="box-border flex gap-2 px-3 pb-1 pt-2">
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
<view class="flex-1 uh-global-card-glass uh-shadow-xs inline-flex border rounded-2xl px-4 py-1.5 text-sm"
|
<view class="uh-global-card-glass shadow-none mb-2 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
:class="activeType === '' ? 'bg-primary font-bold' : 'text-gray-500'" @click="activeType = ''">
|
:class="activeType === '' ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500'" @click="activeType = ''">
|
||||||
全部
|
全部
|
||||||
</view>
|
</view>
|
||||||
<view v-for="(type) in typeOptions" :key="type.typeDisplayName"
|
<view v-for="(type) in typeOptions" :key="type.typeDisplayName"
|
||||||
class="flex-1 box-border uh-global-card-glass uh-shadow-xs inline-flex items-center gap-1 border rounded-2xl px-4 py-1.5 text-sm"
|
class="mb-2 ml-3 box-border uh-global-card-glass shadow-none inline-flex items-center gap-1 border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
:class="activeType === type.typeName ? 'bg-primary font-bold' : 'text-gray-500'"
|
:class="activeType === type.typeName ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500'"
|
||||||
@click="activeType = activeType === type.typeName ? '' : type.typeName">
|
@click="activeType = activeType === type.typeName ? '' : type.typeName">
|
||||||
<view v-if="type.typeColor" class="shrink-0 h-2 w-2 rounded-full"
|
<view v-if="type.typeColor" class="shrink-0 h-2 w-2 rounded-full"
|
||||||
:style="{ backgroundColor: type.typeColor }" />
|
:style="{ backgroundColor: type.typeColor }" />
|
||||||
<view class="shrink-0">{{ type.typeDisplayName }}</view>
|
<view class="shrink-0">{{ type.typeDisplayName }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</scroll-view>
|
||||||
</scroll-view>
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
</wd-sticky>
|
<view class="box-border flex gap-2 px-3 pb-1.5">
|
||||||
|
<view v-for="opt in SORT_OPTIONS" :key="opt.id"
|
||||||
<view class="flex items-center gap-2 px-3 py-2">
|
class="uh-global-card-glass shadow-none inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
<view v-for="opt in SORT_OPTIONS" :key="opt.id"
|
:class="{ 'bg-primary text-gray-900 font-semibold': sortKey === opt.id, 'text-gray-500': sortKey !== opt.id }"
|
||||||
class="uh-global-card-glass uh-shadow-xs inline-block border rounded-2xl px-4 py-1 text-xs"
|
@click="sortKey = opt.id">
|
||||||
:class="sortKey === opt.id ? 'bg-primary font-bold' : 'text-gray-500'" @click="sortKey = opt.id">
|
{{ opt.label }}
|
||||||
{{ opt.label }}
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</wd-sticky>
|
||||||
|
|
||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
empty-text="暂无公告" empty-sub-text="" @refresh="loadNotices(true)" />
|
empty-text="暂无公告" empty-sub-text="" @refresh="loadNotices(true)" />
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getPostListByKeyword } from '@/api/halo'
|
import { getPostListByKeyword } from '@/api/halo'
|
||||||
import { sleep } from '@/utils/common'
|
import { sleep } from '@/utils/common'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||||
import { markdownConfig } from '@/config/markdown'
|
import { markdownConfig } from '@/config/markdown'
|
||||||
import { debounce } from '@/utils/debounce'
|
import { debounce } from '@/utils/debounce'
|
||||||
@@ -17,6 +19,8 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
|
|
||||||
@@ -38,10 +42,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
keyword: '',
|
keyword: '',
|
||||||
limit: 50,
|
page: 1,
|
||||||
|
size: 10,
|
||||||
highlightPreTag: '',
|
highlightPreTag: '',
|
||||||
highlightPostTag: '',
|
highlightPostTag: '',
|
||||||
})
|
})
|
||||||
@@ -54,7 +59,7 @@
|
|||||||
updateTimestamp ?: string
|
updateTimestamp ?: string
|
||||||
}[]>([])
|
}[]>([])
|
||||||
|
|
||||||
/* ---------------- 动画(对应旧版 mixin calcAniWait) ---------------- */
|
/* ---------------- 动画 ---------------- */
|
||||||
/** 预计算列表项入场延迟(每 10 项重置一轮,每项递增 50ms);必须在渲染外算好,渲染中修改响应式状态会导致递归更新 */
|
/** 预计算列表项入场延迟(每 10 项重置一轮,每项递增 50ms);必须在渲染外算好,渲染中修改响应式状态会导致递归更新 */
|
||||||
const calcAniDelays = computed(() => {
|
const calcAniDelays = computed(() => {
|
||||||
let wait = 0
|
let wait = 0
|
||||||
@@ -73,37 +78,58 @@
|
|||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
if (calcAuditModeEnabled.value)
|
if (calcAuditModeEnabled.value)
|
||||||
{return}
|
{return}
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
if (!loadMoreStatus.value.active) {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getPostListByKeyword({ ...queryParams.value })
|
const res = await getPostListByKeyword({ ...queryParams.value })
|
||||||
dataList.value = (res.data as unknown as { hits ?: typeof dataList.value }).hits || []
|
const hits = (res.data as unknown as { hits ?: typeof dataList.value }).hits || []
|
||||||
await sleep(600)
|
dataList.value = loadMoreStatus.value.active
|
||||||
updateLoadingStatus(
|
? dataList.value.concat(hits)
|
||||||
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
: hits
|
||||||
)
|
if (!loadMoreStatus.value.active) {
|
||||||
|
await sleep(600)
|
||||||
|
updateLoadingStatus(
|
||||||
|
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
if (loadMoreStatus.value.active) {
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setTimeout(() => {
|
uni.stopPullDownRefresh()
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
}, 800)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnSearch() {
|
function handleOnSearch() {
|
||||||
if (!queryParams.value.keyword) {
|
if (!queryParams.value.keyword) {
|
||||||
dataList.value = []
|
dataList.value = []
|
||||||
|
resetLoadMoreStatus()
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Empty)
|
updateLoadingStatus(DataLoadingStatusEnum.Empty)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
resetLoadMoreStatus()
|
||||||
|
queryParams.value.page = 1
|
||||||
handleGetData()
|
handleGetData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 实时搜索:输入防抖 400ms 后触发(对应旧版 tm-search 的 @input) */
|
/** 实时搜索:输入防抖 400ms 后触发 */
|
||||||
const handleOnInput = debounce(() => {
|
const handleOnInput = debounce(() => {
|
||||||
handleOnSearch()
|
handleOnSearch()
|
||||||
}, 400)
|
}, 400)
|
||||||
@@ -134,6 +160,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(async () => {
|
onLoad(async () => {
|
||||||
await checkPluginAvailable()
|
await checkPluginAvailable()
|
||||||
if (!uniHaloPluginAvailable.value) {
|
if (!uniHaloPluginAvailable.value) {
|
||||||
@@ -156,21 +186,44 @@
|
|||||||
}
|
}
|
||||||
handleOnSearch()
|
handleOnSearch()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onReachBottom(() => {
|
||||||
|
if (!uniHaloPluginAvailable.value)
|
||||||
|
return
|
||||||
|
if (calcAuditModeEnabled.value)
|
||||||
|
return
|
||||||
|
// 无关键词不触发分页
|
||||||
|
if (!queryParams.value.keyword)
|
||||||
|
return
|
||||||
|
// 正在加载时阻止重复请求
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 有更多数据时继续加载
|
||||||
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-6">
|
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-6">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar default-title="内容搜索" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="内容搜索" title-color="text-gray-900" />
|
||||||
|
|
||||||
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" custom-class="min-h-[80vh]" :plugin-id="pluginId" :error-text="tips"
|
||||||
:checking="checking" @on-refresh="handlePluginRefresh" />
|
:checking="checking" @on-refresh="handlePluginRefresh" />
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<!-- 顶部搜索框-->
|
<!-- 顶部搜索框(玻璃胶囊,与 gallery 吸顶胶囊同视觉) -->
|
||||||
<wd-sticky class="">
|
<wd-sticky :offset-top="offsetTop">
|
||||||
<view class="w-screen box-border px-3 py-2">
|
<view class="w-screen box-border px-3 py-2">
|
||||||
<view class="box-border uh-global-card-glass h-9 flex items-center gap-3 rounded-full pl-1 pr-3">
|
<view class="box-border uh-global-card-glass h-9 flex items-center gap-3 rounded-full border pl-3 pr-3">
|
||||||
<wd-icon name="search" size="16px" />
|
<wd-icon name="search" size="16px" />
|
||||||
<input v-model="queryParams.keyword" class="flex-1 text-sm text-gray-900"
|
<input v-model="queryParams.keyword" class="flex-1 text-sm text-gray-900"
|
||||||
placeholder="哈喽,想看些什么呢~" placeholder-class="text-gray-400" confirm-type="search"
|
placeholder="哈喽,想看些什么呢~" placeholder-class="text-gray-400" confirm-type="search"
|
||||||
@@ -208,6 +261,7 @@
|
|||||||
:show-language-name="true" copy-by-long-press />
|
:show-language-name="true" copy-by-long-press />
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { useSettingStore } from '@/store/setting'
|
import { useSettingStore } from '@/store/setting'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { collectSiteDefaults } from '@/utils/preference'
|
import { collectSiteDefaults } from '@/utils/preference'
|
||||||
import { usePreferenceRows } from '@/hooks/usePreferenceRows'
|
import { usePreferenceRows } from '@/hooks/usePreferenceRows'
|
||||||
import type { PrefDef } from '@/hooks/usePreferenceRows'
|
import type { PrefDef } from '@/hooks/usePreferenceRows'
|
||||||
@@ -14,6 +15,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
@@ -31,6 +33,10 @@
|
|||||||
} = usePreferenceRows()
|
} = usePreferenceRows()
|
||||||
|
|
||||||
/** 确保启动合并已执行(入口页未跑或 H5 直达时兜底) */
|
/** 确保启动合并已执行(入口页未跑或 H5 直达时兜底) */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
if (!settingStore.siteDefaults) {
|
if (!settingStore.siteDefaults) {
|
||||||
settingStore.applySiteDefaults(collectSiteDefaults(appConfigStore.configs))
|
settingStore.applySiteDefaults(collectSiteDefaults(appConfigStore.configs))
|
||||||
@@ -116,14 +122,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen bg-page">
|
<view class="box-border min-h-screen bg-page">
|
||||||
<!-- 自定义标题 -->
|
<!-- 自定义标题 -->
|
||||||
<uh-navbar default-title="偏好设置" title-color="text-gray-900" :need-placeholder="true" />
|
<uh-navbar :scroll-y="scrollY" default-title="偏好设置" title-color="text-gray-900" :need-placeholder="true" />
|
||||||
|
|
||||||
<!-- 内容区域 -->
|
<!-- 内容区域 -->
|
||||||
<view class="box-border flex flex-col gap-y-6 p-3">
|
<view class="box-border flex flex-col gap-y-6 p-3">
|
||||||
<!-- 顶部分段器:布局 / 功能 -->
|
<!-- 顶部分段器:布局 / 功能 -->
|
||||||
<view class="uh-global-card-glass flex rounded-full p-1">
|
<view class="uh-global-card-glass uh-shadow-xs flex rounded-xl p-1">
|
||||||
<view v-for="tab in SETTING_TABS" :key="tab.key" class="flex-1 rounded-full py-1.5 text-center text-sm"
|
<view v-for="tab in SETTING_TABS" :key="tab.key" class="flex-1 rounded-lg py-2 text-center text-2xs"
|
||||||
:class="activeTab === tab.key ? 'bg-primary font-bold' : 'text-gray-500'"
|
:class="activeTab === tab.key ? 'bg-primary font-medium' : 'text-gray-500'"
|
||||||
@click="activeTab = tab.key">
|
@click="activeTab = tab.key">
|
||||||
{{ tab.label }}
|
{{ tab.label }}
|
||||||
</view>
|
</view>
|
||||||
@@ -133,24 +139,24 @@
|
|||||||
<template v-if="activeTab === 'layout'">
|
<template v-if="activeTab === 'layout'">
|
||||||
<view v-for="group in layoutGroups" :key="group.key" class="flex flex-col gap-y-3">
|
<view v-for="group in layoutGroups" :key="group.key" class="flex flex-col gap-y-3">
|
||||||
<uh-section-title>{{ group.label }}</uh-section-title>
|
<uh-section-title>{{ group.label }}</uh-section-title>
|
||||||
<view class="uh-global-card-glass overflow-hidden rounded-2xl">
|
<view class="uh-global-card-glass uh-shadow-xs overflow-hidden rounded-2xl">
|
||||||
<view v-for="(row, index) in group.rows" :key="row.key"
|
<view v-for="(row, index) in group.rows" :key="row.key"
|
||||||
class="pick-row flex items-center justify-between px-4 py-4"
|
class="pick-row flex items-center justify-between px-4 py-4"
|
||||||
:class="index < group.rows.length - 1 ? 'border-b border-black/5' : ''"
|
:class="index < group.rows.length - 1 ? 'border-b border-black/5' : ''"
|
||||||
@click="handleOpenEnum(row)">
|
@click="handleOpenEnum(row)">
|
||||||
<view class="row-left flex flex-col gap-1">
|
<view class="row-left flex flex-col gap-1">
|
||||||
<text class="row-label text-[28rpx] text-gray-900 font-bold">{{ row.label }}</text>
|
<text class="row-label text-sm text-gray-900 font-bold">{{ row.label }}</text>
|
||||||
<view class="flex items-center gap-2">
|
<view class="flex items-center gap-2">
|
||||||
<text v-if="row.following" class="row-sub text-2xs text-gray-400">跟随站点默认</text>
|
<text v-if="row.following" class="row-sub text-xs text-gray-400">跟随站点默认</text>
|
||||||
<view v-else
|
<view v-else
|
||||||
class="rounded-full bg-secondary px-2 py-0.5 text-[20rpx] text-[#4d7c0f] leading-none">
|
class="rounded-full bg-secondary px-2 py-0.5 text-xs text-[#4d7c0f] leading-none">
|
||||||
已自定义
|
已自定义
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="row-value flex items-center gap-2">
|
<view class="flex items-center gap-2 text-gray-400">
|
||||||
<text class="value-text text-[26rpx] text-gray-400">{{ row.displayValue }}</text>
|
<text class="text-xs">{{ row.displayValue }}</text>
|
||||||
<wd-icon name="arrow-right" size="12px" color="#c8c2b4" />
|
<wd-icon name="arrow-right" size="24rpx" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -166,15 +172,15 @@
|
|||||||
<text class="text-2xs text-gray-400">一些常用的功能性设置</text>
|
<text class="text-2xs text-gray-400">一些常用的功能性设置</text>
|
||||||
</template>
|
</template>
|
||||||
</uh-section-title>
|
</uh-section-title>
|
||||||
<view class="setting-sheet uh-global-card-glass overflow-hidden rounded-2xl">
|
<view class="setting-sheet uh-global-card-glass uh-shadow-xs overflow-hidden rounded-2xl">
|
||||||
<template v-for="(row, index) in featureRows" :key="row.key">
|
<template v-for="(row, index) in featureRows" :key="row.key">
|
||||||
<!-- 布尔项:内联分段器(默认 / 开 / 关) -->
|
<!-- 布尔项:内联分段器(默认 / 开 / 关) -->
|
||||||
<view v-if="row.kind === 'bool'" class="box-border p-3"
|
<view v-if="row.kind === 'bool'" class="box-border p-3"
|
||||||
:class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''">
|
:class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''">
|
||||||
<view class="flex items-center justify-between">
|
<view class="flex items-center justify-between">
|
||||||
<text class="row-label text-[28rpx] text-gray-900 font-bold">{{ row.label }}</text>
|
<text class="row-label text-sm text-gray-900 font-bold">{{ row.label }}</text>
|
||||||
<view class="flex items-center gap-2">
|
<view class="flex items-center gap-2">
|
||||||
<text v-if="row.following" class="row-sub text-2xs text-gray-400">默认</text>
|
<text v-if="row.following" class="row-sub text-xs text-gray-400">默认</text>
|
||||||
<view v-else
|
<view v-else
|
||||||
class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">
|
class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">
|
||||||
已自定义
|
已自定义
|
||||||
@@ -219,9 +225,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="row-value flex items-center gap-2">
|
<view class="flex items-center gap-2 text-gray-400">
|
||||||
<text class="value-text text-[26rpx] text-gray-400">{{ row.displayValue }}</text>
|
<text class="text-xs">{{ row.displayValue }}</text>
|
||||||
<wd-icon name="arrow-right" size="12px" color="#c8c2b4" />
|
<wd-icon name="arrow-right" size="24rpx" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -230,7 +236,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<!-- 底部操作栏-->
|
<!-- 底部操作栏-->
|
||||||
<view class="box-border w-full">
|
<view class="box-border w-full">
|
||||||
<uh-button custom-class="uh-global-card-glass py-2 !rounded-xl" @click="handleResetAll">
|
<uh-button custom-class="uh-global-card-glass py-2.5 text-xs !rounded-xl" @click="handleResetAll">
|
||||||
恢复默认
|
恢复默认
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
@@ -269,7 +275,8 @@
|
|||||||
.wd-picker-view__mask {
|
.wd-picker-view__mask {
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
}
|
}
|
||||||
.wd-picker-view__roller{
|
|
||||||
|
.wd-picker-view__roller {
|
||||||
border-radius: 16rpx !important;
|
border-radius: 16rpx !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 标签详情页(源自旧项目 pagesA/tag-detail,新建复刻)
|
* 标签详情页
|
||||||
* 展示某标签下的文章列表,分页加载
|
* 展示某标签下的文章列表,分页加载
|
||||||
*/
|
*/
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 文章标签页(源自旧项目 pagesA/tags,新建复刻)
|
* 文章标签页
|
||||||
*/
|
*/
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { onPageScroll } from '@dcloudio/uni-app'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
@@ -7,8 +9,13 @@
|
|||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Success)
|
updateLoadingStatus(DataLoadingStatusEnum.Success)
|
||||||
}, 3000)
|
}, 3000)
|
||||||
@@ -16,7 +23,7 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="w-full min-h-screen bg-page">
|
<view class="w-full min-h-screen bg-page">
|
||||||
<uh-navbar default-title="测试页面" :need-placeholder="true" title-color="text-gray-900"></uh-navbar>
|
<uh-navbar :scroll-y="scrollY" default-title="测试页面" :need-placeholder="true" title-color="text-gray-900"></uh-navbar>
|
||||||
|
|
||||||
<!-- 内容区:由于 uh-navbar 内置有占位,所以我们的页面的主要内容应该从这里开始,比如这里就可以设置内边距或者其他样式,最外层的 <view class="w-full min-h-screen bg-page"> 仅作为容器-->
|
<!-- 内容区:由于 uh-navbar 内置有占位,所以我们的页面的主要内容应该从这里开始,比如这里就可以设置内边距或者其他样式,最外层的 <view class="w-full min-h-screen bg-page"> 仅作为容器-->
|
||||||
<view class="box-border px-3">
|
<view class="box-border px-3">
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||||
import { getVoteDetail, submitVote } from '@/api/uni-halo'
|
import { getVoteDetail, submitVote } from '@/api/uni-halo'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { calcVotePercent, calcVoteState, VOTE_TYPES, voteCacheUtil } from '@/utils/vote'
|
import { calcVotePercent, calcVoteState, VOTE_TYPES, voteCacheUtil } from '@/utils/vote'
|
||||||
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
||||||
import type { IVote, IVoteDetail, IVoteOption } from '@/api/types/uni-halo'
|
import type { IVote, IVoteDetail, IVoteOption } from '@/api/types/uni-halo'
|
||||||
@@ -16,10 +17,10 @@ definePage({
|
|||||||
})
|
})
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||||
const submitLoading = ref(false)
|
const submitLoading = ref(false)
|
||||||
const pageTitle = ref('加载中...')
|
const pageTitle = ref('加载中...')
|
||||||
const safeAreaBottom = ref(24)
|
|
||||||
const name = ref('')
|
const name = ref('')
|
||||||
const detail = ref<unknown>(null)
|
const detail = ref<unknown>(null)
|
||||||
const vote = ref<(IVote & {
|
const vote = ref<(IVote & {
|
||||||
@@ -57,7 +58,7 @@ const isEnded = computed(() => vote.value?.spec?.hasEnded || false)
|
|||||||
|
|
||||||
/* ---------------- 工具 ---------------- */
|
/* ---------------- 工具 ---------------- */
|
||||||
function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
|
function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
|
||||||
// 与旧项目一致:yyyy-MM-dd HH:mm
|
// yyyy-MM-dd HH:mm
|
||||||
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ async function handleGetData() {
|
|||||||
tempVote.spec.disabled = isVoted.value
|
tempVote.spec.disabled = isVoted.value
|
||||||
tempVote.spec._uh_type = VOTE_TYPES[typeKey] || tempVote.spec.type
|
tempVote.spec._uh_type = VOTE_TYPES[typeKey] || tempVote.spec.type
|
||||||
|
|
||||||
// 计算状态(与旧项目 calcVoteState 一致,含 timeLimit 非 custom 时 hasEnded 兜底)
|
// 计算状态(含 timeLimit 非 custom 时 hasEnded 兜底)
|
||||||
tempVote.spec._uh_state = calcVoteState(tempVote)
|
tempVote.spec._uh_state = calcVoteState(tempVote)
|
||||||
if (tempVote.spec._uh_state.state === '已结束')
|
if (tempVote.spec._uh_state.state === '已结束')
|
||||||
tempVote.spec.hasEnded = true
|
tempVote.spec.hasEnded = true
|
||||||
@@ -233,12 +234,12 @@ async function handleSubmit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option: Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
name.value = options?.name || ''
|
name.value = options?.name || ''
|
||||||
// #ifndef H5
|
|
||||||
const systemInfo = uni.getSystemInfoSync()
|
|
||||||
safeAreaBottom.value = systemInfo.safeAreaInsets?.bottom ? systemInfo.safeAreaInsets.bottom + 12 : 24
|
|
||||||
// #endif
|
|
||||||
handleGetData()
|
handleGetData()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -262,7 +263,7 @@ onShareTimeline(() => ({
|
|||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-safe">
|
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-safe">
|
||||||
<!-- 自定义导航 -->
|
<!-- 自定义导航 -->
|
||||||
<uh-navbar :default-title="pageTitle" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" :default-title="pageTitle" title-color="text-gray-900" />
|
||||||
|
|
||||||
<!-- 加载/错误/空占位(状态机) -->
|
<!-- 加载/错误/空占位(状态机) -->
|
||||||
<uh-data-loading
|
<uh-data-loading
|
||||||
@@ -274,7 +275,7 @@ onShareTimeline(() => ({
|
|||||||
<!-- 投票信息 -->
|
<!-- 投票信息 -->
|
||||||
<view class="uh-global-card-glass box-border flex flex-col gap-y-3 rounded-2xl p-3">
|
<view class="uh-global-card-glass box-border flex flex-col gap-y-3 rounded-2xl p-3">
|
||||||
<uh-section-title> 投票信息 </uh-section-title>
|
<uh-section-title> 投票信息 </uh-section-title>
|
||||||
<view class="flex flex-col gap-2 rounded-xl bg-gray-100 px-4 py-3 text-sm text-gray-900">
|
<view class="flex flex-col gap-2 rounded-xl bg-gray-100 px-4 py-3 text-xs text-gray-900">
|
||||||
<view class="info-row">
|
<view class="info-row">
|
||||||
<text>投票类型:</text>
|
<text>投票类型:</text>
|
||||||
<text class="tag">{{ vote.spec?._uh_type }}</text>
|
<text class="tag">{{ vote.spec?._uh_type }}</text>
|
||||||
@@ -327,7 +328,7 @@ onShareTimeline(() => ({
|
|||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="options flex flex-col gap-3 w-full">
|
<view class="options flex flex-col gap-3 w-full">
|
||||||
<!-- PK 对抗条(与旧项目 pk-container 一致;样式需顶层定义,勿嵌套在 .vote-card 下) -->
|
<!-- PK 对抗条 -->
|
||||||
<view v-if="vote.spec?.type === 'pk'" class="pk-container box-border w-full flex">
|
<view v-if="vote.spec?.type === 'pk'" class="pk-container box-border w-full flex">
|
||||||
<view
|
<view
|
||||||
v-for="(option, optionIndex) in vote.spec?.options" :key="optionIndex"
|
v-for="(option, optionIndex) in vote.spec?.options" :key="optionIndex"
|
||||||
@@ -335,7 +336,7 @@ onShareTimeline(() => ({
|
|||||||
:style="{ width: `${option._uh_percent}%` }"
|
:style="{ width: `${option._uh_percent}%` }"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
class="option-item box-border w-full rounded-xl px-3 py-3"
|
class="option-item box-border w-full rounded-xl px-3 py-2"
|
||||||
:class="optionIndex === 0 ? 'option-item-left' : 'option-item-right'"
|
:class="optionIndex === 0 ? 'option-item-left' : 'option-item-right'"
|
||||||
>
|
>
|
||||||
{{ option._uh_percent }}%
|
{{ option._uh_percent }}%
|
||||||
@@ -389,34 +390,34 @@ onShareTimeline(() => ({
|
|||||||
<view
|
<view
|
||||||
class="uh-global-card-glass mb-2 w-full flex items-center justify-center gap-x-2 border rounded-xl"
|
class="uh-global-card-glass mb-2 w-full flex items-center justify-center gap-x-2 border rounded-xl"
|
||||||
>
|
>
|
||||||
<uh-button v-if="isVoted" custom-class="flex-1 py-2 !rounded-xl">
|
<uh-button v-if="isVoted" class="flex-1" custom-class="flex-1 py-2 !rounded-xl">
|
||||||
您已参与投票
|
您已参与投票
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<uh-button
|
<uh-button
|
||||||
v-else-if="vote.spec?._uh_state?.state === '未开始'" custom-class="flex-1 py-2 !rounded-xl"
|
v-else-if="vote.spec?._uh_state?.state === '未开始'" class="flex-1" custom-class="flex-1 py-2 !rounded-xl"
|
||||||
@click="handleSubmitTip('投票未开始')"
|
@click="handleSubmitTip('投票未开始')"
|
||||||
>
|
>
|
||||||
投票未开始
|
投票未开始
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<uh-button
|
<uh-button
|
||||||
v-else-if="vote.spec?._uh_state?.state === '已结束'" custom-class="flex-1 py-2 !rounded-xl"
|
v-else-if="vote.spec?._uh_state?.state === '已结束'" class="flex-1" custom-class="flex-1 py-2 !rounded-xl"
|
||||||
@click="handleSubmitTip('投票已结束')"
|
@click="handleSubmitTip('投票已结束')"
|
||||||
>
|
>
|
||||||
投票已结束
|
投票已结束
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<uh-button
|
<uh-button
|
||||||
v-else-if="!vote.spec?.canAnonymously" custom-class="flex-1 py-2 !rounded-xl"
|
v-else-if="!vote.spec?.canAnonymously" class="flex-1" custom-class="flex-1 py-2 !rounded-xl"
|
||||||
@click="handleSubmit()"
|
@click="handleSubmit()"
|
||||||
>
|
>
|
||||||
不支持匿名投票
|
不支持匿名投票
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<uh-button
|
<uh-button
|
||||||
v-else-if="submitForm.voteData.length === 0" custom-class="flex-1 py-2 !rounded-xl"
|
v-else-if="submitForm.voteData.length === 0" class="flex-1" custom-class="flex-1 py-2 !rounded-xl"
|
||||||
@click="handleSubmitTip('请选择选项')"
|
@click="handleSubmitTip('请选择选项')"
|
||||||
>
|
>
|
||||||
提交投票(请选择选项)
|
提交投票(请选择选项)
|
||||||
</uh-button>
|
</uh-button>
|
||||||
<uh-button v-else custom-class="flex-1 py-2 !rounded-xl" @click="handleSubmit()">
|
<uh-button v-else class="flex-1" custom-class="flex-1 py-2 !rounded-xl" @click="handleSubmit()">
|
||||||
提交投票
|
提交投票
|
||||||
</uh-button>
|
</uh-button>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getVoteList } from '@/api/uni-halo'
|
import { getVoteList } from '@/api/uni-halo'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { debounce } from '@/utils/debounce'
|
import { debounce } from '@/utils/debounce'
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
|
|
||||||
@@ -40,11 +42,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const dataList = ref<IVoteItem[]>([])
|
const dataList = ref<IVoteItem[]>([])
|
||||||
const hasNext = ref(false)
|
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref('加载中...')
|
|
||||||
const filterIsVoted = ref<boolean | undefined>(undefined)
|
const filterIsVoted = ref<boolean | undefined>(undefined)
|
||||||
const queryParams = ref<Record<string, unknown>>({
|
const queryParams = ref<Record<string, unknown>>({
|
||||||
keyword: '',
|
keyword: '',
|
||||||
@@ -67,7 +66,7 @@
|
|||||||
options : IFilterOption[]
|
options : IFilterOption[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 筛选维度(与旧项目 tm-dropDownMenu 一致) */
|
/** 筛选维度 */
|
||||||
const filterConfig : IFilterItem[] = [
|
const filterConfig : IFilterItem[] = [
|
||||||
{
|
{
|
||||||
key: 'type',
|
key: 'type',
|
||||||
@@ -145,43 +144,47 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
handleGetData()
|
handleGetData()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 搜索 ---------------- */
|
/* ---------------- 搜索 ---------------- */
|
||||||
/** 实时搜索:输入防抖 400ms 后触发(对应旧版 tm-search 的 @input) */
|
/** 实时搜索:输入防抖 400ms 后触发 */
|
||||||
const handleOnInput = debounce(() => {
|
const handleOnInput = debounce(() => {
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
handleGetData()
|
handleGetData()
|
||||||
}, 400)
|
}, 400)
|
||||||
|
|
||||||
function handleOnSearch() {
|
function handleOnSearch() {
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
handleGetData()
|
handleGetData()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
|
// 审核模式:一次拉取不分页
|
||||||
|
resetLoadMoreStatus()
|
||||||
updateLoadingStatus(
|
updateLoadingStatus(
|
||||||
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
)
|
)
|
||||||
loadMoreText.value = '呜呜,没有更多数据啦~'
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'noMore',
|
||||||
|
hasNext: false,
|
||||||
|
})
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadMore.value) {
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
loadMoreText.value = '加载中...'
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getVoteList({ ...queryParams.value })
|
const res = await getVoteList({ ...queryParams.value })
|
||||||
hasNext.value = res.data.hasNext || false
|
|
||||||
|
|
||||||
const tempItems = res.data.items.map((item) => {
|
const tempItems = res.data.items.map((item) => {
|
||||||
item.spec = item.spec || {}
|
item.spec = item.spec || {}
|
||||||
@@ -192,36 +195,49 @@
|
|||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
|
|
||||||
dataList.value = isLoadMore.value
|
dataList.value = loadMoreStatus.value.active
|
||||||
? dataList.value.concat(tempItems)
|
? dataList.value.concat(tempItems)
|
||||||
: tempItems
|
: tempItems
|
||||||
|
|
||||||
// 未投优先排序(与旧项目一致)
|
// 未投优先排序
|
||||||
dataList.value = dataList.value.sort((a, b) => {
|
dataList.value = dataList.value.sort((a, b) => {
|
||||||
return Number(a.spec?.isVoted) - Number(b.spec?.isVoted)
|
return Number(a.spec?.isVoted) - Number(b.spec?.isVoted)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 是否已投过滤(与旧项目一致)
|
// 是否已投过滤
|
||||||
if (filterIsVoted.value !== undefined) {
|
if (filterIsVoted.value !== undefined) {
|
||||||
dataList.value = dataList.value.filter(x => x.spec?.isVoted === filterIsVoted.value)
|
dataList.value = dataList.value.filter(x => x.spec?.isVoted === filterIsVoted.value)
|
||||||
}
|
}
|
||||||
await sleep(600)
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(
|
await sleep(600)
|
||||||
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
updateLoadingStatus(
|
||||||
)
|
dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
|
||||||
loadMoreText.value = hasNext.value ? '上拉加载更多' : '呜呜,没有更多数据啦~'
|
)
|
||||||
|
}
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
if (loadMoreStatus.value.active) {
|
||||||
loadMoreText.value = '加载失败,请下拉刷新!'
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 卡片点击跳详情(与旧项目 VoteCard @on-click 一致) */
|
/** 卡片点击跳详情 */
|
||||||
function handleOnVoteClick(vote : IVoteItem) {
|
function handleOnVoteClick(vote : IVoteItem) {
|
||||||
const name = vote.metadata?.name
|
const name = vote.metadata?.name
|
||||||
if (!name)
|
if (!name)
|
||||||
@@ -242,6 +258,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(async () => {
|
onLoad(async () => {
|
||||||
await checkPluginAvailable()
|
await checkPluginAvailable()
|
||||||
if (!uniHaloPluginAvailable.value) {
|
if (!uniHaloPluginAvailable.value) {
|
||||||
@@ -256,7 +276,7 @@
|
|||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
handleGetData()
|
handleGetData()
|
||||||
})
|
})
|
||||||
@@ -268,20 +288,25 @@
|
|||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (hasNext.value) {
|
// 正在加载时阻止重复请求
|
||||||
queryParams.value.page = Number(queryParams.value.page) + 1
|
if (loadMoreStatus.value.active) {
|
||||||
isLoadMore.value = true
|
return
|
||||||
handleGetData()
|
|
||||||
}
|
}
|
||||||
else {
|
// 有更多数据时继续加载
|
||||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page = Number(queryParams.value.page) + 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="app-page min-h-screen w-screen flex flex-col bg-page">
|
<view class="app-page min-h-screen w-screen flex flex-col bg-page">
|
||||||
<uh-navbar default-title="投票中心" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" default-title="投票中心" title-color="text-gray-900" />
|
||||||
|
|
||||||
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
||||||
:checking="checking" @on-refresh="handlePluginRefresh" />
|
:checking="checking" @on-refresh="handlePluginRefresh" />
|
||||||
@@ -319,9 +344,7 @@
|
|||||||
<block v-if="dataList.length !== 0">
|
<block v-if="dataList.length !== 0">
|
||||||
<uh-vote-card v-for="vote in dataList" :key="vote.metadata?.name" :vote="vote"
|
<uh-vote-card v-for="vote in dataList" :key="vote.metadata?.name" :vote="vote"
|
||||||
@click="handleOnVoteClick(vote)" />
|
@click="handleOnVoteClick(vote)" />
|
||||||
<view class="box-border py-5 text-center text-xs text-gray-400">
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -334,7 +357,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="flex flex-col gap-2">
|
<view class="flex flex-col gap-2">
|
||||||
<view v-for="opt in filterPopup.item.options" :key="opt.label"
|
<view v-for="opt in filterPopup.item.options" :key="opt.label"
|
||||||
class="uh-global-card-glass shadow-none border box-border rounded-xl px-5 py-2 text-center text-sm"
|
class="uh-global-card-glass shadow-none border box-border rounded-xl px-5 py-2 text-center text-xs"
|
||||||
:class="filterValues[filterPopup.item.key] === opt.value ? 'bg-primary text-gray-900 font-bold' : 'text-gray-700'"
|
:class="filterValues[filterPopup.item.key] === opt.value ? 'bg-primary text-gray-900 font-bold' : 'text-gray-700'"
|
||||||
@click="handleSelectFilter(opt)">
|
@click="handleSelectFilter(opt)">
|
||||||
{{ opt.label }}
|
{{ opt.label }}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 网站浏览页(源自旧项目 pagesC/website,新建复刻)
|
* 网站浏览页
|
||||||
* 内嵌 web-view 展示外部链接
|
* 内嵌 web-view 展示外部链接
|
||||||
*/
|
*/
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|||||||
@@ -266,17 +266,17 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="relative min-h-screen flex flex-col justify-center bg-[#f5fae8]">
|
<view class="relative min-h-screen w-screen flex flex-col justify-center bg-[#f5fae8] overflow-hidden">
|
||||||
<!-- 背景 -->
|
<!-- 背景 -->
|
||||||
<view
|
<view
|
||||||
class="absolute lef-0 top-0 w-full h-[46vh] from-[#d9f77f] via-[#e8fbaf] to-[#f5fae8] bg-gradient-to-b" />
|
class="fixed lef-0 top-0 z-0 w-full h-[46vh] from-[#d9f77f] via-[#e8fbaf] to-[#f5fae8] bg-gradient-to-b" />
|
||||||
|
|
||||||
<!-- 刷新 -->
|
<!-- 刷新 -->
|
||||||
<uh-data-loading v-if="viewState === 'loading'" />
|
<uh-data-loading v-if="viewState === 'loading'" />
|
||||||
|
|
||||||
<!-- 拉取失败(手动进入,通常为服务器停机中) -->
|
<!-- 拉取失败 -->
|
||||||
<view v-else-if="viewState === 'error'"
|
<view v-else-if="viewState === 'error'"
|
||||||
class="relative z-10 flex flex-col items-center justify-center px-10 py-48 text-center">
|
class="w-full relative z-10 flex flex-col items-center justify-center px-10 py-48 text-center">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="140rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="140rpx" />
|
||||||
<text class="mt-6 text-md text-gray-900 font-bold">
|
<text class="mt-6 text-md text-gray-900 font-bold">
|
||||||
服务暂时无法访问
|
服务暂时无法访问
|
||||||
@@ -290,38 +290,37 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 维护页-->
|
<!-- 维护页-->
|
||||||
<view v-else class="relative z-10 w-full min-h-screen flex items-center justify-center flex-col ">
|
<view v-else class="w-full relative z-10 w-full min-h-screen flex items-center justify-center flex-col">
|
||||||
<view
|
<view class="w-full relative px-[40rpx] pb-[64rpx] pt-[calc(var(--status-bar-height)+76rpx)] text-center">
|
||||||
class="w-full relative overflow-hidden px-[40rpx] pb-[64rpx] pt-[calc(var(--status-bar-height)+76rpx)] text-center">
|
|
||||||
<view
|
<view
|
||||||
class="breathe pointer-events-none absolute left-[-60rpx] top-[104rpx] z-0 h-[260rpx] w-[260rpx] rounded-full bg-white/40 blur-[52rpx]" />
|
class="breathe pointer-events-none absolute left-[-60rpx] top-[104rpx] z-0 h-[260rpx] w-[260rpx] rounded-full bg-white/40 uh-blur-52" />
|
||||||
<view
|
<view
|
||||||
class="pointer-events-none absolute right-[-48rpx] top-[40rpx] z-0 h-[200rpx] w-[200rpx] rounded-full bg-[rgba(184,236,63,0.28)] blur-[52rpx]" />
|
class="pointer-events-none absolute right-[-48rpx] top-[40rpx] z-0 h-[200rpx] w-[200rpx] rounded-full bg-[rgba(184,236,63,0.28)] uh-blur-52" />
|
||||||
<view
|
<view
|
||||||
class="pointer-events-none absolute bottom-[-40rpx] right-[72rpx] z-0 h-[160rpx] w-[160rpx] rounded-full bg-white/40 blur-[52rpx]" />
|
class="pointer-events-none absolute bottom-[-40rpx] right-[72rpx] z-0 h-[160rpx] w-[160rpx] rounded-full bg-white/40 uh-blur-52" />
|
||||||
|
|
||||||
<view class="relative z-2 mx-auto mt-[44rpx] h-[236rpx] w-[236rpx]">
|
<view class="relative z-2 mx-auto mt-[44rpx] h-[236rpx] w-[236rpx]">
|
||||||
<view
|
<view
|
||||||
class="bob flex items-center justify-center absolute inset-0 rounded-full from-[#ebfabf] to-[#b8ec3f] bg-gradient-to-br shadow-[0_0_0_12rpx_#fff,0_28rpx_60rpx_rgba(98,124,44,0.22)]">
|
class="bob flex items-center justify-center absolute inset-0 rounded-full from-[#ebfabf] to-[#b8ec3f] bg-gradient-to-br uh-global-card-glass border-4 border-white">
|
||||||
<image v-if="appLogo" class="h-full w-full rounded-full" :src="appLogo" mode="aspectFill" />
|
<image v-if="appLogo" class="h-full w-full rounded-full" :src="appLogo" mode="aspectFill" />
|
||||||
<wd-icon v-else class-prefix="uhemoji-icon" name="-thinking" size="140rpx"
|
<wd-icon v-else class-prefix="uhemoji-icon" name="-thinking" size="140rpx"
|
||||||
class="text-gray-900" />
|
class="text-gray-900" />
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="gear-spin absolute right-[-28rpx] top-[-16rpx] h-[68rpx] w-[68rpx] flex items-center justify-center">
|
class="gear-spin absolute right-[-28rpx] top-[-16rpx] h-[68rpx] w-[68rpx] flex items-center justify-center">
|
||||||
<wd-icon name="settings" size="24px" />
|
<wd-icon name="settings" size="45rpx" />
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="gear-spin-reverse absolute bottom-[16rpx] left-[-32rpx] h-[48rpx] w-[48rpx] flex items-center justify-center">
|
class="gear-spin-reverse absolute bottom-[16rpx] left-[-32rpx] h-[48rpx] w-[48rpx] flex items-center justify-center">
|
||||||
<wd-icon name="settings" size="16px" />
|
<wd-icon name="settings" size="32rpx" />
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="absolute bottom-[-28rpx] left-1/2 inline-flex items-center whitespace-nowrap border-2 border-solid border-[#ebfabf] rounded-full bg-[#ebfabf] px-[24rpx] py-[12rpx] text-[22rpx] font-extrabold leading-none shadow-[0_10rpx_28rpx_rgba(90,110,45,0.18)] -translate-x-1/2 -rotate-5">
|
class="absolute bottom-[-28rpx] left-1/2 inline-flex items-center whitespace-nowrap border-2 border-solid border-[#ebfabf] rounded-full bg-[#ebfabf] px-[24rpx] py-[12rpx] text-[22rpx] font-extrabold leading-none uh-shadow-sm uh-badge">
|
||||||
MAINTENANCE
|
MAINTENANCE
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="relative z-2 mt-8 text-6 font-black leading-8">
|
<view class="relative z-2 mt-8 text-5 font-black leading-8">
|
||||||
<uh-text-underline>{{ title }}</uh-text-underline>
|
<uh-text-underline>{{ title }}</uh-text-underline>
|
||||||
</view>
|
</view>
|
||||||
<view class="relative z-2 mt-6 px-[16rpx] text-[25rpx] text-balck/50 font-medium leading-[1.7]">
|
<view class="relative z-2 mt-6 px-[16rpx] text-[25rpx] text-balck/50 font-medium leading-[1.7]">
|
||||||
@@ -329,7 +328,7 @@
|
|||||||
<text v-for="(line, index) in noticeLines" :key="index" class="block">{{ line }}</text>
|
<text v-for="(line, index) in noticeLines" :key="index" class="block">{{ line }}</text>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<text>为了给你带来更好的体验,站点正在维护升级中</text>
|
<text>为了给你带来更好的体验,正在维护升级中</text>
|
||||||
<text class="block">
|
<text class="block">
|
||||||
别担心,我们很快就回来!
|
别担心,我们很快就回来!
|
||||||
</text>
|
</text>
|
||||||
@@ -340,14 +339,14 @@
|
|||||||
<!-- ===== 内容区 ===== -->
|
<!-- ===== 内容区 ===== -->
|
||||||
<view class="relative z-10 w-full">
|
<view class="relative z-10 w-full">
|
||||||
<view
|
<view
|
||||||
class="pointer-events-none absolute left-[64rpx] top-[-52rpx] z-0 h-[192rpx] w-[192rpx] rounded-full bg-[#ebfabf] opacity-90 blur-[44rpx]" />
|
class="pointer-events-none absolute left-[64rpx] top-[-52rpx] z-0 h-[192rpx] w-[192rpx] rounded-full bg-[#ebfabf] opacity-90 uh-blur-44" />
|
||||||
<view
|
<view
|
||||||
class="pointer-events-none absolute right-[-52rpx] top-[300rpx] z-0 h-[168rpx] w-[168rpx] rounded-full bg-[#ffd53d] opacity-20 blur-[44rpx]" />
|
class="pointer-events-none absolute right-[-52rpx] top-[300rpx] z-0 h-[168rpx] w-[168rpx] rounded-full bg-[#ffd53d] opacity-20 uh-blur-44" />
|
||||||
<view
|
<view
|
||||||
class="relative box-border w-full z-1 flex flex-col items-center gap-[28rpx] px-6 pb-[68rpx] pt-[32rpx]">
|
class="relative box-border w-full z-1 flex flex-col items-center gap-[28rpx] px-6 pb-[68rpx] pt-[32rpx]">
|
||||||
<!-- 恢复倒计时 -->
|
<!-- 恢复倒计时 -->
|
||||||
<view v-if="countdownParts"
|
<view v-if="countdownParts"
|
||||||
class="relative w-full uh-global-card-glass overflow-hidden border rounded-2xl p-[32rpx] text-center shadow-[0_4rpx_24rpx_rgba(98,124,44,0.08)]">
|
class="relative w-full uh-global-card-glass border rounded-2xl overflow-hidden p-[32rpx] text-center shadow-[0_4rpx_24rpx_rgba(98,124,44,0.08)]">
|
||||||
<view
|
<view
|
||||||
class="absolute bottom-[-48rpx] right-[-12rpx] text-[176rpx] text-[#a7e93b] font-black leading-none opacity-10">
|
class="absolute bottom-[-48rpx] right-[-12rpx] text-[176rpx] text-[#a7e93b] font-black leading-none opacity-10">
|
||||||
GO!
|
GO!
|
||||||
@@ -393,10 +392,11 @@
|
|||||||
|
|
||||||
<!-- 操作 -->
|
<!-- 操作 -->
|
||||||
<view class="mt-2 w-full flex flex-col gap-4">
|
<view class="mt-2 w-full flex flex-col gap-4">
|
||||||
<uh-button custom-class="uh-global-card-glass border flex-1 py-3 !rounded-full font-semibold"
|
<uh-button
|
||||||
|
custom-class="uh-global-card-glass w-full border flex-1 py-3 !rounded-full font-semibold"
|
||||||
@click="handleRefresh">{{ spinning?'请稍等...':'刷新试试'}}</uh-button>
|
@click="handleRefresh">{{ spinning?'请稍等...':'刷新试试'}}</uh-button>
|
||||||
<view v-if="detailHtml"
|
<view v-if="detailHtml"
|
||||||
class="uh-global-card-glass py-2 flex flex-1 items-center justify-center rounded-full bg-white text-sm text-primary font-extrabold uh-shadow-xs"
|
class="uh-global-card-glass w-full py-2 flex flex-1 items-center justify-center rounded-full bg-white text-sm text-primary font-extrabold uh-shadow-xs"
|
||||||
@click="showDetail = true">
|
@click="showDetail = true">
|
||||||
维护详情
|
维护详情
|
||||||
</view>
|
</view>
|
||||||
@@ -414,7 +414,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="toast"
|
<view v-if="toast"
|
||||||
class="uh-global-card-glass border fixed bottom-[calc(72rpx+env(safe-area-inset-bottom))] left-1/2 z-60 whitespace-nowrap rounded-full px-6 py-2 text-xs font-bold -translate-x-1/2">
|
class="uh-global-card-glass border fixed bottom-[calc(72rpx+env(safe-area-inset-bottom))] left-1/2 z-60 whitespace-nowrap rounded-full px-6 py-2 text-xs font-bold uh-translate-x-center">
|
||||||
{{ toast }}
|
{{ toast }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -424,6 +424,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.uh-blur-44 {
|
||||||
|
filter: blur(44rpx);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uh-blur-52 {
|
||||||
|
filter: blur(52rpx);
|
||||||
|
}
|
||||||
|
|
||||||
/* 光斑呼吸 */
|
/* 光斑呼吸 */
|
||||||
.breathe {
|
.breathe {
|
||||||
animation: breathe 5s ease-in-out infinite;
|
animation: breathe 5s ease-in-out infinite;
|
||||||
@@ -492,4 +500,14 @@
|
|||||||
.press:active {
|
.press:active {
|
||||||
transform: scale(0.94);
|
transform: scale(0.94);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* MAINTENANCE 徽章:居中 + 轻微旋转 */
|
||||||
|
.uh-badge {
|
||||||
|
transform: translateX(-50%) rotate(-5deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 水平居中定位 */
|
||||||
|
.uh-translate-x-center {
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,462 +0,0 @@
|
|||||||
<script lang="ts" setup>
|
|
||||||
/**
|
|
||||||
* 关于页(源自旧项目 pages/tabbar/about/about.vue,新建复刻)
|
|
||||||
* 功能:博主信息 + 站点统计 + 功能导航 + 版权
|
|
||||||
* 风格:对齐全站设计语言(bg-page + uh-global-card-glass + uh-section-title + 彩色图标块)
|
|
||||||
*/
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app'
|
|
||||||
import { getBlogStatistics } from '@/api/halo'
|
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
|
||||||
import { useFavoritesStore } from '@/store/favorites'
|
|
||||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
|
||||||
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
|
||||||
import { checkHasAdminLogin } from '@/utils/auth'
|
|
||||||
import { t } from '@/locale'
|
|
||||||
import type { IBlogStats } from '@/api/types/halo'
|
|
||||||
|
|
||||||
definePage({
|
|
||||||
style: {
|
|
||||||
navigationBarTitleText: '关于',
|
|
||||||
enablePullDownRefresh: true,
|
|
||||||
navigationStyle: 'custom',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const appConfigStore = useAppConfigStore()
|
|
||||||
const favoritesStore = useFavoritesStore()
|
|
||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
|
||||||
/** 数据看板插件可用性(供导航项显隐判断,参考 gallery 对象传参模式) */
|
|
||||||
const { check: checkDataVisualPlugin } = usePluginAvailable({
|
|
||||||
pluginId: NeedPluginIds.PluginDataStatistics,
|
|
||||||
})
|
|
||||||
/** 投票插件可用性(投票中心导航项显隐;pluginConfig.votePlugin 已下线,2026-09-10 改插件启用检测) */
|
|
||||||
const { check: checkVotePluginAvailable } = usePluginAvailable({
|
|
||||||
pluginId: NeedPluginIds.PluginVote,
|
|
||||||
})
|
|
||||||
/** 链接插件可用性(友情链接导航项显隐;pluginConfig.linksPlugin 已下线,2026-09-10 改插件启用检测) */
|
|
||||||
const { check: checkLinksPluginAvailable } = usePluginAvailable({
|
|
||||||
pluginId: NeedPluginIds.PluginLinks,
|
|
||||||
})
|
|
||||||
|
|
||||||
/* ---------------- 计算属性 ---------------- */
|
|
||||||
const bloggerInfo = computed(() => {
|
|
||||||
const blogger = haloConfigs.value.authorConfig?.blogger as
|
|
||||||
| { nickname ?: string, avatar ?: string, description ?: string }
|
|
||||||
| undefined
|
|
||||||
return {
|
|
||||||
nickname: blogger?.nickname || '',
|
|
||||||
avatar: checkAvatarUrl(blogger?.avatar),
|
|
||||||
description: blogger?.description || '',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const pageConfig = computed(() => haloConfigs.value.pageConfig?.aboutConfig as
|
|
||||||
| { bgImageUrl ?: string, waveImageUrl ?: string, copyrightConfig ?: { enabled ?: boolean, content ?: string } }
|
|
||||||
| undefined)
|
|
||||||
|
|
||||||
const calcProfileStyle = computed(() => ({
|
|
||||||
backgroundImage: `url(${checkImageUrl(pageConfig.value?.bgImageUrl)})`,
|
|
||||||
}))
|
|
||||||
|
|
||||||
const calcWaveUrl = computed(() => checkImageUrl(pageConfig.value?.waveImageUrl))
|
|
||||||
|
|
||||||
/** 免责声明(2026-09-10 起插件端从 basicConfig 迁入 pageConfig.disclaimers,无 enabled 开关,按内容判定入口显隐) */
|
|
||||||
const pageDisclaimers = computed(() => (haloConfigs.value.pageConfig as { disclaimers ?: { content ?: string } } | undefined)?.disclaimers)
|
|
||||||
|
|
||||||
/** 页脚版权(2026-09-10 起插件端从 basicConfig.copyrightConfig 迁入 pageConfig.aboutConfig.copyrightConfig) */
|
|
||||||
const copyrightConfig = computed(() => pageConfig.value?.copyrightConfig)
|
|
||||||
|
|
||||||
/** 恋爱入口:总开关 loveEnabled 2026-09-10 下线,改按模块入口开关判定(任一开启即展示) */
|
|
||||||
const loveEnabled = computed(() => {
|
|
||||||
const love = haloConfigs.value.loveConfig as
|
|
||||||
| { ourStory ?: { enabled ?: boolean }, lovePhoto ?: { enabled ?: boolean }, loveDaily ?: { enabled ?: boolean } }
|
|
||||||
| undefined
|
|
||||||
return !!(love?.ourStory?.enabled || love?.lovePhoto?.enabled || love?.loveDaily?.enabled)
|
|
||||||
})
|
|
||||||
/** 社交信息入口:2026-09-10 起去 enabled 开关,改按社交项列表判定(存在可见且有内容的社交项即展示) */
|
|
||||||
const socialEnabled = computed(() => {
|
|
||||||
const social = haloConfigs.value.authorConfig?.social as
|
|
||||||
| { items ?: Array<{ visible ?: boolean, content ?: string }> }
|
|
||||||
| undefined
|
|
||||||
return !!(social?.items?.some(item => item.visible !== false && !!item.content))
|
|
||||||
})
|
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
|
||||||
const statisticsShowMore = ref(false)
|
|
||||||
const statistics = ref<IBlogStats>({ post: 0, comment: 0, category: 0, visit: 0, upvote: 0 })
|
|
||||||
|
|
||||||
/** 主行统计(常驻展示) */
|
|
||||||
const allStats = computed(() => [
|
|
||||||
{ key: 'post', label: '内容', value: statistics.value.post },
|
|
||||||
{ key: 'visit', label: '访客', value: statistics.value.visit },
|
|
||||||
{ key: 'category', label: '分类', value: statistics.value.category },
|
|
||||||
{ key: 'comment', label: '评论', value: statistics.value.comment },
|
|
||||||
{ key: 'upvote', label: '点赞', value: statistics.value.upvote },
|
|
||||||
])
|
|
||||||
|
|
||||||
interface INavItem {
|
|
||||||
key : string
|
|
||||||
title : string
|
|
||||||
iconPrefix ?: string
|
|
||||||
icon : string
|
|
||||||
/** 图标块背景色(与首页快捷导航同色板,同一功能同色) */
|
|
||||||
bgColor : string
|
|
||||||
/** 图标颜色(插件端 myPageConfig 条目 color;本地默认缺省由 toSolidColor(bgColor) 派生) */
|
|
||||||
color ?: string
|
|
||||||
rightText : string
|
|
||||||
path : string | null
|
|
||||||
isAdmin ?: boolean
|
|
||||||
openType ?: string
|
|
||||||
show : boolean
|
|
||||||
/** 分组:blog=博客功能 more=更多信息 */
|
|
||||||
group : 'blog' | 'more'
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 插件端 myPageConfig 条目(pageConfig.myPageConfig.commonFeatures/otherFeatures;
|
|
||||||
* 字段命名与插件端一致:key/title/subTitle/color/bgColor/iconPrefix/icon/path/visible) */
|
|
||||||
interface IMyPageEntry {
|
|
||||||
key ?: string
|
|
||||||
title ?: string
|
|
||||||
subTitle ?: string
|
|
||||||
color ?: string
|
|
||||||
bgColor ?: string
|
|
||||||
iconPrefix ?: string
|
|
||||||
icon ?: string
|
|
||||||
path ?: string
|
|
||||||
visible ?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
// 是否使用本地的功能入口数据(true=忽略插件端 myPageConfig,用内置默认;便于二次开发本地定制)
|
|
||||||
const useLocalNav = false
|
|
||||||
|
|
||||||
/** 插件端 myPageConfig(additive:未配置/为空返回 null,回退本地内置默认) */
|
|
||||||
const configuredFeatures = computed(() => {
|
|
||||||
const mp = haloConfigs.value.pageConfig?.myPageConfig as
|
|
||||||
| { commonFeatures ?: IMyPageEntry[], otherFeatures ?: IMyPageEntry[] }
|
|
||||||
| undefined
|
|
||||||
if (useLocalNav || !mp || (!mp.commonFeatures?.length && !mp.otherFeatures?.length)) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return mp
|
|
||||||
})
|
|
||||||
|
|
||||||
const navList = ref<INavItem[]>([])
|
|
||||||
|
|
||||||
/** 分组渲染(过滤后空组整组隐藏;组标题对齐插件端:常用功能/其他功能) */
|
|
||||||
const calcNavGroups = computed(() => {
|
|
||||||
const visible = navList.value.filter(n => n.show)
|
|
||||||
const groupDefs : { key : 'blog' | 'more', title : string }[] = [
|
|
||||||
{ key: 'blog', title: '常用功能' },
|
|
||||||
{ key: 'more', title: '其他功能' },
|
|
||||||
]
|
|
||||||
return groupDefs
|
|
||||||
.map(def => ({ ...def, items: visible.filter(n => n.group === def.key) }))
|
|
||||||
.filter(group => group.items.length > 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
/* ---------------- 功能导航 ---------------- */
|
|
||||||
/** 图标块浅色背景:品牌深色 rgba 降透明度 → 轻量底色 */
|
|
||||||
function toLightBg(rgba : string) {
|
|
||||||
return rgba.replace('0.95)', '0.15)')
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 图标颜色:品牌深色实色 */
|
|
||||||
function toSolidColor(rgba : string) {
|
|
||||||
return rgba.replace('0.95)', '1)')
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 收藏导航项右侧文案跟随收藏总数(收藏页返回/切回时刷新) */
|
|
||||||
function syncFavoritesNavText() {
|
|
||||||
const nav = navList.value.find(n => n.key === 'favorites')
|
|
||||||
if (nav) {
|
|
||||||
nav.rightText = `共 ${favoritesStore.counts.total} 条收藏`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleGetNavList() {
|
|
||||||
// 配置模式:插件端 myPageConfig 两组(常用功能→blog、其他功能→more),
|
|
||||||
// 未配置/为空时回退本地内置默认(保留原显隐推导)
|
|
||||||
const mp = configuredFeatures.value
|
|
||||||
if (mp) {
|
|
||||||
const mapEntry = (e : IMyPageEntry, group : 'blog' | 'more') : INavItem | null => {
|
|
||||||
if (!e.key)
|
|
||||||
return null
|
|
||||||
return {
|
|
||||||
key: e.key,
|
|
||||||
title: e.title || '',
|
|
||||||
iconPrefix: e.iconPrefix,
|
|
||||||
icon: e.icon || '',
|
|
||||||
bgColor: e.bgColor || 'rgba(150, 150, 150, 0.95)',
|
|
||||||
color: e.color,
|
|
||||||
rightText: e.subTitle || '',
|
|
||||||
path: e.path || null,
|
|
||||||
show: e.visible !== false,
|
|
||||||
group,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
navList.value = [
|
|
||||||
...(mp.commonFeatures || []).map(e => mapEntry(e, 'blog')).filter((n): n is INavItem => n !== null),
|
|
||||||
...(mp.otherFeatures || []).map(e => mapEntry(e, 'more')).filter((n): n is INavItem => n !== null),
|
|
||||||
]
|
|
||||||
syncFavoritesNavText()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const [dataVisualAvailable, voteAvailable, linksAvailable] = await Promise.all([
|
|
||||||
checkDataVisualPlugin(),
|
|
||||||
checkVotePluginAvailable(),
|
|
||||||
checkLinksPluginAvailable(),
|
|
||||||
])
|
|
||||||
|
|
||||||
navList.value = [
|
|
||||||
{
|
|
||||||
key: 'favorites',
|
|
||||||
title: '我的收藏',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-smiling',
|
|
||||||
bgColor: 'rgba(255, 179, 0, 0.95)',
|
|
||||||
rightText: '',
|
|
||||||
path: '/pages-blog/favorites/favorites',
|
|
||||||
show: true,
|
|
||||||
group: 'blog',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'data-visual',
|
|
||||||
title: '数据看板',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-surprised',
|
|
||||||
bgColor: 'rgba(102, 60, 201, 0.95)',
|
|
||||||
rightText: '站点数据可视化',
|
|
||||||
path: '/pages-blog/data-visual/data-visual',
|
|
||||||
show: dataVisualAvailable,
|
|
||||||
group: 'blog',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'archives',
|
|
||||||
title: calcAuditModeEnabled.value ? '内容归档' : '文章归档',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-mask',
|
|
||||||
bgColor: 'rgba(3, 169, 244, 0.95)',
|
|
||||||
rightText: calcAuditModeEnabled.value ? '全部已归档内容' : '全部已归档文章',
|
|
||||||
path: '/pages-blog/archives/archives',
|
|
||||||
show: true,
|
|
||||||
group: 'blog',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'love',
|
|
||||||
title: '恋爱日记',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-in-love',
|
|
||||||
bgColor: 'rgba(255, 76, 103, 0.95)',
|
|
||||||
rightText: '博主的恋爱日记',
|
|
||||||
path: '/pages-blog/love/love',
|
|
||||||
show: loveEnabled.value,
|
|
||||||
// show: true,
|
|
||||||
group: 'blog',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'vote',
|
|
||||||
title: '投票中心',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-confused',
|
|
||||||
bgColor: 'rgba(0, 188, 212, 0.95)',
|
|
||||||
rightText: '查看和进行投票',
|
|
||||||
path: '/pages-blog/votes/votes',
|
|
||||||
show: !calcAuditModeEnabled.value && voteAvailable,
|
|
||||||
// show: true,
|
|
||||||
group: 'blog',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'friend-links',
|
|
||||||
title: '友情链接',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-cool',
|
|
||||||
bgColor: 'rgba(0, 150, 136, 0.95)',
|
|
||||||
rightText: '看看博主朋友们吧',
|
|
||||||
path: '/pages-blog/friend-links/friend-links',
|
|
||||||
show: linksAvailable,
|
|
||||||
// show: true,
|
|
||||||
group: 'blog',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'disclaimers',
|
|
||||||
title: '免责声明',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-smirking',
|
|
||||||
bgColor: 'rgba(121, 85, 72, 0.95)',
|
|
||||||
rightText: '博客内容免责声明',
|
|
||||||
path: '/pages-blog/disclaimers/disclaimers',
|
|
||||||
// 2026-09-10 起无 enabled 开关,按内容非空判定入口显隐
|
|
||||||
show: !!pageDisclaimers.value?.content,
|
|
||||||
// show: true,
|
|
||||||
group: 'more',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'contact-blogger',
|
|
||||||
title: '联系博主',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-wink',
|
|
||||||
bgColor: 'rgba(255, 152, 0, 0.95)',
|
|
||||||
rightText: '博主常用联系方式',
|
|
||||||
path: '/pages-blog/contact/contact',
|
|
||||||
show: socialEnabled.value,
|
|
||||||
// show: true,
|
|
||||||
group: 'more',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'about',
|
|
||||||
title: '关于项目',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-happy-',
|
|
||||||
bgColor: 'rgba(96, 125, 139, 0.95)',
|
|
||||||
rightText: '小莫唐尼开源项目',
|
|
||||||
path: '/pages-blog/about/about',
|
|
||||||
// showAboutSystem 2026-09-10 下线(入口由插件端功能入口 myPageConfig 统一管理),默认展示
|
|
||||||
show: true,
|
|
||||||
// show: true,
|
|
||||||
group: 'more',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'setting',
|
|
||||||
title: '偏好设置',
|
|
||||||
iconPrefix: 'uhemoji2-icon',
|
|
||||||
icon: '-tired',
|
|
||||||
bgColor: 'rgba(121, 134, 203, 0.95)',
|
|
||||||
rightText: '首页布局、卡片样式等本地偏好',
|
|
||||||
path: '/pages-blog/setting/setting',
|
|
||||||
show: true,
|
|
||||||
group: 'more',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
syncFavoritesNavText()
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
|
||||||
async function handleGetData() {
|
|
||||||
try {
|
|
||||||
const res = await getBlogStatistics()
|
|
||||||
statistics.value = res.data
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error('获取统计失败', err)
|
|
||||||
uni.showToast({ icon: 'none', title: t('common.loadFailedRetry') })
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------- 交互 ---------------- */
|
|
||||||
function handleOnNav(data : { path : string | null, isAdmin ?: boolean }) {
|
|
||||||
const { path, isAdmin } = data
|
|
||||||
if (!path)
|
|
||||||
return
|
|
||||||
|
|
||||||
// 拦截后台管理页面(需超管登录)
|
|
||||||
if (isAdmin && !checkHasAdminLogin()) {
|
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '未登录超管账号或登录状态已过期,是否立即登录?',
|
|
||||||
showCancel: true,
|
|
||||||
cancelText: '否',
|
|
||||||
cancelColor: '#999999',
|
|
||||||
confirmText: '是',
|
|
||||||
confirmColor: '#03a9f4',
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
uni.navigateTo({ url: '/pages/auth/login' })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
uni.navigateTo({ url: path })
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
|
||||||
watch(haloConfigs, () => {
|
|
||||||
handleGetNavList()
|
|
||||||
}, { deep: true, immediate: true })
|
|
||||||
|
|
||||||
handleGetData()
|
|
||||||
|
|
||||||
// 从收藏页返回/切回时刷新收藏数文案
|
|
||||||
onShow(() => {
|
|
||||||
syncFavoritesNavText()
|
|
||||||
})
|
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
|
||||||
handleGetData()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="box-border min-h-screen w-screen bg-page pb-8">
|
|
||||||
<!-- 头部:博主信息(背景图 + 遮罩 + wave,内容区做状态栏适配) -->
|
|
||||||
<view class="blogger-info relative h-76 w-full bg-cover bg-no-repeat" :style="[calcProfileStyle]">
|
|
||||||
<!-- 背景遮罩 -->
|
|
||||||
<view class="absolute left-0 top-0 z-0 h-full w-full bg-black/30 backdrop-blur-[2rpx]" />
|
|
||||||
<view class="relative z-6 h-full flex flex-col items-center justify-center pb-[140rpx] pt-safe">
|
|
||||||
<image class="uh-global-card-glass h-20 w-20 rounded-full" :src="bloggerInfo.avatar"
|
|
||||||
mode="aspectFill" />
|
|
||||||
<view class="mt-4 text-lg text-white font-bold text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">
|
|
||||||
{{ bloggerInfo.nickname }}
|
|
||||||
</view>
|
|
||||||
<view
|
|
||||||
class="desc mt-2 px-10 text-center text-[26rpx] text-white/90 leading-relaxed text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">
|
|
||||||
{{ bloggerInfo.description || '这个博主很懒,竟然没写介绍~' }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<image v-if="calcWaveUrl" :src="calcWaveUrl" mode="scaleToFill"
|
|
||||||
class="gif-wave absolute bottom-0 left-0 z-99 h-[100rpx] w-full" style="mix-blend-mode: screen;" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 站点统计 -->
|
|
||||||
<view class="uh-global-card-glass uh-shadow-xs relative z-100 mx-4 flex border rounded-2xl -mt-12">
|
|
||||||
<view v-for="item in allStats" :key="item.key" class="flex-1 py-4 text-center">
|
|
||||||
<wd-count-to
|
|
||||||
:key="`${item.key}-${item.value}`" :start-val="0" :end-val="item.value"
|
|
||||||
:duration="900" separator="" color="#111827" custom-class="text-lg font-bold"
|
|
||||||
/>
|
|
||||||
<view class="mt-1 text-xs text-gray-500">
|
|
||||||
{{ item.label }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 功能导航-->
|
|
||||||
<template v-for="group in calcNavGroups" :key="group.key">
|
|
||||||
<uh-section-title class="mx-4 mb-3 mt-8">
|
|
||||||
{{ group.title }}
|
|
||||||
</uh-section-title>
|
|
||||||
<view class="uh-global-card-glass mx-4 overflow-hidden rounded-2xl">
|
|
||||||
<view v-for="(nav, index) in group.items" :key="nav.key"
|
|
||||||
class="nav-item flex items-center justify-between px-4"
|
|
||||||
:class="index < group.items.length - 1 ? 'border-b border-b-solid border-black/5' : ''"
|
|
||||||
@click="handleOnNav(nav)">
|
|
||||||
<view class="nav-left flex items-center gap-3 py-3">
|
|
||||||
<view
|
|
||||||
class="uh-global-card-glass border uh-shadow-xs h-8 w-8 flex items-center justify-center rounded-xl"
|
|
||||||
:style="{ backgroundColor: toLightBg(nav.bgColor) }">
|
|
||||||
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx"
|
|
||||||
:color="nav.color || toSolidColor(nav.bgColor)" />
|
|
||||||
</view>
|
|
||||||
<text class="nav-title text-sm text-gray-900 font-bold">{{ nav.title }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="nav-right flex items-center gap-2">
|
|
||||||
<text class="nav-right-text text-xs text-gray-400">{{ nav.rightText }}</text>
|
|
||||||
<wd-icon name="arrow-right" size="12px" color="#c8c2b4" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 版权 -->
|
|
||||||
<view v-if="copyrightConfig?.enabled" class="mt-6 px-6 text-center text-xs text-gray-400">
|
|
||||||
<view>{{ copyrightConfig.content }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getCategoryList } from '@/api/halo'
|
import { getCategoryList } from '@/api/halo'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { checkThumbnailUrl } from '@/utils/url'
|
import { checkThumbnailUrl } from '@/utils/url'
|
||||||
import { sleep } from '@/utils/common'
|
import { sleep } from '@/utils/common'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { t } from '@/locale'
|
import { t } from '@/locale'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
import type { ICategory } from '@/api/types/halo'
|
import type { ICategory } from '@/api/types/halo'
|
||||||
@@ -18,30 +19,28 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
|
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
const haloConfigs = computed(() => appConfigStore.configs)
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
|
|
||||||
const categoryConfig = computed(() => haloConfigs.value.pageConfig?.categoryConfig)
|
const categoryConfig = computed(() => haloConfigs.value.pageConfig?.categoryConfig)
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadingStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
size: 20,
|
size: 10,
|
||||||
page: 1,
|
page: 1,
|
||||||
fieldSelector: ['spec.hideFromList=false'],
|
fieldSelector: ['spec.hideFromList=false'],
|
||||||
})
|
})
|
||||||
const hasNext = ref(false)
|
|
||||||
const dataList = ref<ICategory[]>([])
|
const dataList = ref<ICategory[]>([])
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref(t('common.loading'))
|
|
||||||
|
|
||||||
function handleResetInit() {
|
function handleResetInit() {
|
||||||
dataList.value = []
|
dataList.value = []
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
hasNext.value = false
|
resetLoadingStatus()
|
||||||
isLoadMore.value = false
|
|
||||||
loadMoreText.value = t('common.loading')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInitPage() {
|
function handleInitPage() {
|
||||||
@@ -51,11 +50,12 @@
|
|||||||
|
|
||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
if (!loadMoreStatus.value.active) {
|
||||||
// 增加延迟,提升用户体验
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
await sleep(800)
|
}
|
||||||
// 审核模式:直接使用审核配置分类快照(categoryDetails)映射 ICategory,免请求
|
// 审核模式
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
|
resetLoadMoreStatus()
|
||||||
const auditCategoryDetails = appConfigStore.auditData.categoryDetails || []
|
const auditCategoryDetails = appConfigStore.auditData.categoryDetails || []
|
||||||
try {
|
try {
|
||||||
dataList.value = auditCategoryDetails.map(item => ({
|
dataList.value = auditCategoryDetails.map(item => ({
|
||||||
@@ -68,51 +68,60 @@
|
|||||||
},
|
},
|
||||||
postCount: item.postCount ?? 0,
|
postCount: item.postCount ?? 0,
|
||||||
} as ICategory))
|
} as ICategory))
|
||||||
|
await sleep(600)
|
||||||
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
loadMoreText.value = t('common.noMore')
|
updateLoadMoreStatus({
|
||||||
uni.hideLoading()
|
active: false,
|
||||||
|
status: 'noMore',
|
||||||
|
hasNext: false
|
||||||
|
})
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
loadMoreText.value = t('common.loadFailed')
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadMore.value) {
|
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
|
||||||
}
|
|
||||||
loadMoreText.value = t('common.loading')
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getCategoryList({ ...queryParams.value })
|
const res = await getCategoryList({ ...queryParams.value })
|
||||||
|
|
||||||
loadMoreText.value = res.data.hasNext ? t('common.loadMore') : t('common.noMore')
|
|
||||||
hasNext.value = res.data.hasNext
|
|
||||||
|
|
||||||
const tempItems = res.data.items.map(item => ({
|
const tempItems = res.data.items.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
postCount: item.postCount ?? 0,
|
postCount: item.postCount ?? 0,
|
||||||
spec: { ...item.spec, cover: checkThumbnailUrl(item.spec.cover, true) },
|
spec: { ...item.spec, cover: checkThumbnailUrl(item.spec.cover, true) },
|
||||||
}))
|
}))
|
||||||
|
|
||||||
dataList.value = isLoadMore.value
|
dataList.value = loadMoreStatus.value.active
|
||||||
? dataList.value.concat(tempItems)
|
? dataList.value.concat(tempItems)
|
||||||
: tempItems
|
: tempItems
|
||||||
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
|
||||||
|
if (!loadMoreStatus.value.active) {
|
||||||
|
await sleep(600)
|
||||||
|
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
if (loadMoreStatus.value.active) {
|
||||||
loadMoreText.value = t('common.loadFailed')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setTimeout(() => {
|
uni.stopPullDownRefresh()
|
||||||
uni.hideLoading()
|
|
||||||
uni.stopPullDownRefresh()
|
|
||||||
}, 500)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,30 +138,35 @@
|
|||||||
handleInitPage()
|
handleInitPage()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onPullDownRefresh(() => {
|
||||||
handleResetInit()
|
handleResetInit()
|
||||||
handleGetData()
|
handleGetData()
|
||||||
})
|
})
|
||||||
|
|
||||||
onReachBottom(() => {
|
onReachBottom(() => {
|
||||||
if (calcAuditModeEnabled.value) {
|
// 如果正在请求,需要阻止继续发起请求
|
||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
if (loadMoreStatus.value.active && loadMoreStatus.value.loading) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (hasNext.value) {
|
// 有更多数据时,继续加载数据
|
||||||
|
if (loadMoreStatus.value.hasNext) {
|
||||||
queryParams.value.page += 1
|
queryParams.value.page += 1
|
||||||
isLoadMore.value = true
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading'
|
||||||
|
})
|
||||||
handleGetData()
|
handleGetData()
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen flex flex-col bg-page">
|
<view class="box-border min-h-screen w-screen flex flex-col bg-page">
|
||||||
<uh-navbar :use-back="false" default-title="分类" title-color="text-gray-900"></uh-navbar>
|
<uh-navbar :scroll-y="scrollY" :use-back="false" default-title="分类" title-color="text-gray-900"></uh-navbar>
|
||||||
|
|
||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus" />
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus" />
|
||||||
|
|
||||||
@@ -165,7 +179,7 @@
|
|||||||
<view
|
<view
|
||||||
class="absolute bottom-0 left-0 h-[140rpx] w-full from-black/0 to-black/30 bg-gradient-to-b" />
|
class="absolute bottom-0 left-0 h-[140rpx] w-full from-black/0 to-black/30 bg-gradient-to-b" />
|
||||||
<view class="absolute bottom-0 left-0 box-border w-full flex flex-col gap-1 p-2.5">
|
<view class="absolute bottom-0 left-0 box-border w-full flex flex-col gap-1 p-2.5">
|
||||||
<text class="truncate text-sm text-white font-bold">
|
<text class="truncate text-2xs text-white font-bold">
|
||||||
{{ item.spec.displayName }}
|
{{ item.spec.displayName }}
|
||||||
</text>
|
</text>
|
||||||
<text class="text-xs text-white opacity-80">
|
<text class="text-xs text-white opacity-80">
|
||||||
@@ -174,9 +188,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="w-full py-5 text-center text-xs text-gray-400">
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text"></uh-data-loadmore>
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import { getPhotoGroupList, getPhotoListByGroupName } from '@/api/halo'
|
import { getPhotoGroupList, getPhotoListByGroupName } from '@/api/halo'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { checkImageUrl } from '@/utils/url'
|
import { checkImageUrl } from '@/utils/url'
|
||||||
import { usePluginAvailable } from '@/hooks/usePluginAvailable'
|
import { usePluginAvailable } from '@/hooks/usePluginAvailable'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { sleep } from '@/utils/common'
|
import { sleep } from '@/utils/common'
|
||||||
import { t } from '@/locale'
|
import { t } from '@/locale'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
|
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||||
import type { IPhoto, IPhotoGroup } from '@/api/types/halo'
|
import type { IPhoto, IPhotoGroup } from '@/api/types/halo'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
@@ -18,6 +20,8 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
const haloConfigs = computed(() => appConfigStore.configs)
|
||||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
@@ -39,15 +43,12 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const category = ref<{ activeIndex : number, list : IPhotoGroup[] }>({
|
const category = ref<{ activeIndex : number, list : IPhotoGroup[] }>({
|
||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
list: [],
|
list: [],
|
||||||
})
|
})
|
||||||
const queryParams = ref({ size: 10, page: 1, group: '' })
|
const queryParams = ref({ size: 10, page: 1, group: '' })
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref('')
|
|
||||||
const hasNext = ref(false)
|
|
||||||
const dataList = ref<IPhoto[]>([])
|
const dataList = ref<IPhoto[]>([])
|
||||||
const lock = ref(false)
|
const lock = ref(false)
|
||||||
|
|
||||||
@@ -67,7 +68,11 @@
|
|||||||
handleGetData(true)
|
handleGetData(true)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loadMoreText.value = t('common.noMore')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'noMore',
|
||||||
|
hasNext: false,
|
||||||
|
})
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,33 +102,45 @@
|
|||||||
if (isClearList) {
|
if (isClearList) {
|
||||||
dataList.value = []
|
dataList.value = []
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
|
resetLoadMoreStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadMore.value) {
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
loadMoreText.value = ''
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getPhotoListByGroupName({ ...queryParams.value })
|
const res = await getPhotoListByGroupName({ ...queryParams.value })
|
||||||
hasNext.value = res.data.hasNext
|
|
||||||
if (res.data.items.length !== 0) {
|
if (res.data.items.length !== 0) {
|
||||||
const list = res.data.items.map(item => ({
|
const list = res.data.items.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
spec: { ...item.spec, url: checkImageUrl(item.spec.url || item.spec.cover) },
|
spec: { ...item.spec, url: checkImageUrl(item.spec.url || item.spec.cover) },
|
||||||
}))
|
}))
|
||||||
dataList.value = isLoadMore.value
|
dataList.value = loadMoreStatus.value.active
|
||||||
? dataList.value.concat(list)
|
? dataList.value.concat(list)
|
||||||
: list
|
: list
|
||||||
}
|
}
|
||||||
await sleep(600)
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
await sleep(600)
|
||||||
loadMoreText.value = res.data.hasNext ? t('common.loadMore') : t('common.noMore')
|
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
|
}
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
if (loadMoreStatus.value.active) {
|
||||||
loadMoreText.value = t('common.loadFailed')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
@@ -151,6 +168,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(async () => {
|
onLoad(async () => {
|
||||||
// 检查插件可用性
|
// 检查插件可用性
|
||||||
await checkPluginAvailable()
|
await checkPluginAvailable()
|
||||||
@@ -167,7 +188,6 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dataList.value = []
|
dataList.value = []
|
||||||
isLoadMore.value = false
|
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
handleGetData(true)
|
handleGetData(true)
|
||||||
})
|
})
|
||||||
@@ -178,30 +198,35 @@
|
|||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (hasNext.value) {
|
// 正在加载时阻止重复请求
|
||||||
queryParams.value.page += 1
|
if (loadMoreStatus.value.active) {
|
||||||
isLoadMore.value = true
|
return
|
||||||
handleGetData(false)
|
|
||||||
}
|
}
|
||||||
else {
|
// 有更多数据时继续加载
|
||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-6">
|
<view class="box-border min-h-screen w-screen flex flex-col bg-page">
|
||||||
<uh-navbar :use-back="false" default-title="我的图库" title-color="text-gray-900"></uh-navbar>
|
<uh-navbar :scroll-y="scrollY" :use-back="false" default-title="我的图库" title-color="text-gray-900"></uh-navbar>
|
||||||
|
|
||||||
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
||||||
:checking="checking" @on-refresh="checkPluginAvailable" />
|
:checking="checking" @on-refresh="checkPluginAvailable" />
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<wd-sticky v-if="category.list.length!==0" class="w-full">
|
<wd-sticky v-if="category.list.length!==0" class="w-full" :offset-top="offsetTop">
|
||||||
<scroll-view :scroll-x="true" class="w-full whitespace-nowrap pt-2">
|
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||||
<view v-for="(cate, index) in category.list" :key="cate.spec.displayName"
|
<view v-for="(cate, index) in category.list" :key="cate.spec.displayName"
|
||||||
class="uh-global-card-glass uh-shadow-xs mb-1 ml-3 inline-flex border rounded-2xl px-4 py-1 text-sm"
|
class="uh-global-card-glass shadow-none mb-2 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||||
:class="{ 'bg-primary text-gray-900 font-bold': index === category.activeIndex }"
|
:class="{ 'bg-primary text-gray-900 font-semibold': index === category.activeIndex }"
|
||||||
@click="handleGetDataByCategory(index, cate)">
|
@click="handleGetDataByCategory(index, cate)">
|
||||||
{{ cate.spec.displayName }}
|
{{ cate.spec.displayName }}
|
||||||
<text v-if="cate.spec.displayName!=='全部'">
|
<text v-if="cate.spec.displayName!=='全部'">
|
||||||
@@ -214,7 +239,7 @@
|
|||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
@refresh="handleGetCategory" />
|
@refresh="handleGetCategory" />
|
||||||
|
|
||||||
<view v-else class="box-border w-full p-3">
|
<view v-else class="box-border w-full p-3 pb-0">
|
||||||
<view class="grid grid-cols-2 gap-2.5">
|
<view class="grid grid-cols-2 gap-2.5">
|
||||||
<view v-for="(item, index) in dataList" :key="index"
|
<view v-for="(item, index) in dataList" :key="index"
|
||||||
class="relative uh-global-card-glass h-38 w-full overflow-hidden rounded-xl">
|
class="relative uh-global-card-glass h-38 w-full overflow-hidden rounded-xl">
|
||||||
@@ -226,9 +251,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="load-text w-full py-4 text-center text-xs text-gray-500">
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { useSettingStore } from '@/store/setting'
|
import { useSettingStore } from '@/store/setting'
|
||||||
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
||||||
|
import { sleep } from '@/utils/common'
|
||||||
import { t } from '@/locale'
|
import { t } from '@/locale'
|
||||||
import { useMaintenanceIntercept } from '@/hooks/useMaintenanceIntercept'
|
import { useMaintenanceIntercept } from '@/hooks/useMaintenanceIntercept'
|
||||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||||
@@ -12,7 +13,6 @@
|
|||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '首页',
|
|
||||||
enablePullDownRefresh: true,
|
enablePullDownRefresh: true,
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
},
|
},
|
||||||
@@ -29,13 +29,9 @@
|
|||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
const haloConfigs = computed(() => appConfigStore.configs)
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref(t('common.loading'))
|
|
||||||
const articleList = ref<IPost[]>([])
|
const articleList = ref<IPost[]>([])
|
||||||
|
|
||||||
const result = ref<{ hasNext : boolean }>({ hasNext: false })
|
|
||||||
|
|
||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
size: 10,
|
size: 10,
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -65,7 +61,7 @@
|
|||||||
if (recommendMode.value === mode)
|
if (recommendMode.value === mode)
|
||||||
return
|
return
|
||||||
recommendMode.value = mode
|
recommendMode.value = mode
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
articleList.value = []
|
articleList.value = []
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
queryParams.value.sort = recommendSortMap[mode]
|
queryParams.value.sort = recommendSortMap[mode]
|
||||||
@@ -104,7 +100,8 @@
|
|||||||
/** 文章列表 */
|
/** 文章列表 */
|
||||||
async function handleGetArticleList() {
|
async function handleGetArticleList() {
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
// 审核模式:真实文章按 audit-data posts 过滤(数组顺序即展示顺序)
|
// 审核模式:真实文章按 audit-data posts 过滤(数组顺序即展示顺序),一次拉取不分页
|
||||||
|
resetLoadMoreStatus()
|
||||||
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
||||||
try {
|
try {
|
||||||
const res = await getPostList({ page: 1, size: 0, sort: ['spec.publishTime,desc'] })
|
const res = await getPostList({ page: 1, size: 0, sort: ['spec.publishTime,desc'] })
|
||||||
@@ -114,12 +111,19 @@
|
|||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
loadMoreText.value = t('common.noMore')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'noMore',
|
||||||
|
hasNext: false,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error('获取审核文章失败', err)
|
console.error('获取审核文章失败', err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
loadMoreText.value = t('common.loadFailed')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
@@ -128,27 +132,39 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadMore.value) {
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
loadMoreText.value = t('common.loading')
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getPostList({ ...toRaw(queryParams.value) })
|
const res = await getPostList({ ...toRaw(queryParams.value) })
|
||||||
result.value.hasNext = res.data.hasNext
|
articleList.value = (loadMoreStatus.value.active
|
||||||
articleList.value = (isLoadMore.value
|
|
||||||
? articleList.value.concat(res.data.items)
|
? articleList.value.concat(res.data.items)
|
||||||
: res.data.items).map((item) => {
|
: res.data.items).map((item) => {
|
||||||
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
if (!loadMoreStatus.value.active) {
|
||||||
loadMoreText.value = res.data.hasNext ? t('common.loadMore') : t('common.noMore')
|
await sleep(600)
|
||||||
|
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
|
}
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
|
||||||
loadMoreText.value = t('common.loadFailed')
|
|
||||||
console.error('获取文章失败', err)
|
console.error('获取文章失败', err)
|
||||||
|
if (loadMoreStatus.value.active) {
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
@@ -182,23 +198,29 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
onPullDownRefresh(() => {
|
onPullDownRefresh(() => {
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
handleQuery()
|
handleQuery()
|
||||||
})
|
})
|
||||||
|
|
||||||
onReachBottom(() => {
|
onReachBottom(() => {
|
||||||
|
// 审核模式:一次拉取不分页,直接提示到底
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (result.value.hasNext) {
|
// 正在加载时阻止重复请求
|
||||||
queryParams.value.page += 1
|
if (loadMoreStatus.value.active) {
|
||||||
isLoadMore.value = true
|
return
|
||||||
handleGetArticleList()
|
|
||||||
}
|
}
|
||||||
else {
|
// 有更多数据时继续加载
|
||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetArticleList()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -218,29 +240,27 @@
|
|||||||
<uh-home-category />
|
<uh-home-category />
|
||||||
|
|
||||||
<!-- 最新文章 -->
|
<!-- 最新文章 -->
|
||||||
<uh-section-title class="mb-4 box-border px-3">
|
<view class="mb-4 box-border px-3">
|
||||||
最新推荐
|
<uh-section-title>
|
||||||
<template #right>
|
最新推荐
|
||||||
<view class="flex items-center gap-2">
|
<template #right>
|
||||||
<!-- 推荐模式分段器:默认 / 置顶 / 最新 -->
|
<view class="flex items-center gap-2">
|
||||||
<view class="uh-global-card-glass uh-shadow-xs flex items-center border rounded-lg p-0.5">
|
<view class="uh-global-card-glass uh-shadow-xs flex items-center border rounded-lg p-0.5">
|
||||||
<view v-for="tab in recommendTabs" :key="tab.value" class="rounded-md px-2 py-0.5 text-xs"
|
<view v-for="tab in recommendTabs" :key="tab.value" class="rounded-md px-2 py-0.5 text-10px"
|
||||||
:class="recommendMode === tab.value ? 'bg-secondary text-gray-900' : 'text-gray-500'"
|
:class="recommendMode === tab.value ? 'bg-secondary text-gray-900' : 'text-gray-500'"
|
||||||
@click="handleRecommendModeChange(tab.value as 'default' | 'pinned' | 'latest' | 'oldest')">
|
@click="handleRecommendModeChange(tab.value as 'default' | 'pinned' | 'latest' | 'oldest')">
|
||||||
{{ tab.label }}
|
{{ tab.label }}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="false" class="rounded-md px-2 py-0.5 text-xs text-gray-500" @click="handleToArticles()">
|
<view
|
||||||
更多
|
class="uh-global-card-glass uh-shadow-xs border flex items-center justify-center rounded-md p-1 text-gray-400"
|
||||||
|
@click="handleToArticles()">
|
||||||
|
<wd-icon name="arrow-right" size="14px" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
</template>
|
||||||
class="uh-global-card-glass uh-shadow-xs border flex items-center justify-center rounded-md p-1 text-gray-400"
|
</uh-section-title>
|
||||||
@click="handleToArticles()">
|
</view>
|
||||||
<wd-icon name="arrow-right" size="28rpx" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
</uh-section-title>
|
|
||||||
|
|
||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
min-height="36vh" @refresh="handleQuery" />
|
min-height="36vh" @refresh="handleQuery" />
|
||||||
@@ -251,10 +271,9 @@
|
|||||||
<uh-article-card v-for="(article, index) in articleList" :key="index" from="home" :article="article"
|
<uh-article-card v-for="(article, index) in articleList" :key="index" from="home" :article="article"
|
||||||
:variant="homeListLayout === 'double' ? 'grid' : 'list'" :audit-mode="calcAuditModeEnabled" />
|
:variant="homeListLayout === 'double' ? 'grid' : 'list'" :audit-mode="calcAuditModeEnabled" />
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-3 box-border pb-5 text-center text-xs text-gray-400">
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<uh-notify-dialog />
|
<uh-notify-dialog />
|
||||||
</template>
|
</template>
|
||||||
@@ -0,0 +1,316 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app'
|
||||||
|
import { getBlogStatistics } from '@/api/halo'
|
||||||
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
|
import { useFavoritesStore } from '@/store/favorites'
|
||||||
|
import { useLoveModuleUnlock } from '@/hooks/useLoveModuleUnlock'
|
||||||
|
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
||||||
|
import { t } from '@/locale'
|
||||||
|
import type { IBlogStats } from '@/api/types/halo'
|
||||||
|
|
||||||
|
definePage({
|
||||||
|
style: {
|
||||||
|
navigationBarTitleText: '关于',
|
||||||
|
enablePullDownRefresh: true,
|
||||||
|
navigationStyle: 'custom',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const appConfigStore = useAppConfigStore()
|
||||||
|
const favoritesStore = useFavoritesStore()
|
||||||
|
const haloConfigs = computed(() => appConfigStore.configs)
|
||||||
|
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||||
|
|
||||||
|
/* ---------------- 计算属性 ---------------- */
|
||||||
|
const bloggerInfo = computed(() => {
|
||||||
|
const blogger = haloConfigs.value.authorConfig?.blogger as
|
||||||
|
| { nickname ?: string, avatar ?: string, description ?: string }
|
||||||
|
| undefined
|
||||||
|
return {
|
||||||
|
nickname: blogger?.nickname || '',
|
||||||
|
avatar: checkAvatarUrl(blogger?.avatar),
|
||||||
|
description: blogger?.description || '',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const pageConfig = computed(() => haloConfigs.value.pageConfig?.aboutConfig as
|
||||||
|
| { bgImageUrl ?: string, waveImageUrl ?: string }
|
||||||
|
| undefined)
|
||||||
|
|
||||||
|
const calcProfileStyle = computed(() => ({
|
||||||
|
backgroundImage: `url(${checkImageUrl(pageConfig.value?.bgImageUrl)})`,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const calcWaveUrl = computed(() => checkImageUrl(pageConfig.value?.waveImageUrl))
|
||||||
|
|
||||||
|
/* ---------------- 状态 ---------------- */
|
||||||
|
const statistics = ref<IBlogStats>({ post: 0, comment: 0, category: 0, visit: 0, upvote: 0 })
|
||||||
|
|
||||||
|
/** 主行统计 */
|
||||||
|
const allStats = computed(() => [
|
||||||
|
{ key: 'post', label: '内容', value: statistics.value.post },
|
||||||
|
{ key: 'visit', label: '访客', value: statistics.value.visit },
|
||||||
|
{ key: 'category', label: '分类', value: statistics.value.category },
|
||||||
|
{ key: 'comment', label: '评论', value: statistics.value.comment },
|
||||||
|
{ key: 'upvote', label: '点赞', value: statistics.value.upvote },
|
||||||
|
])
|
||||||
|
|
||||||
|
interface INavItem {
|
||||||
|
key : string
|
||||||
|
title : string
|
||||||
|
iconPrefix ?: string
|
||||||
|
icon : string
|
||||||
|
bgColor : string
|
||||||
|
color ?: string
|
||||||
|
subTitle ?: string
|
||||||
|
path : string | null
|
||||||
|
openType ?: string
|
||||||
|
show : boolean
|
||||||
|
group : 'blog' | 'more'
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IMyPageEntry {
|
||||||
|
key ?: string
|
||||||
|
title ?: string
|
||||||
|
subTitle ?: string
|
||||||
|
color ?: string
|
||||||
|
bgColor ?: string
|
||||||
|
iconPrefix ?: string
|
||||||
|
icon ?: string
|
||||||
|
path ?: string
|
||||||
|
visible ?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const configuredFeatures = computed(() => {
|
||||||
|
const mp = haloConfigs.value.pageConfig?.myPageConfig as
|
||||||
|
| { commonFeatures ?: IMyPageEntry[], otherFeatures ?: IMyPageEntry[] }
|
||||||
|
| undefined
|
||||||
|
if (!mp || (!mp.commonFeatures?.length && !mp.otherFeatures?.length)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return mp
|
||||||
|
})
|
||||||
|
|
||||||
|
const navList = ref<INavItem[]>([])
|
||||||
|
const featureMode = ref<'base' | 'list'>('base')
|
||||||
|
/** 分组渲染(过滤后空组整组隐藏;组标题对齐插件端:常用功能/其他功能) */
|
||||||
|
const calcNavGroups = computed(() => {
|
||||||
|
const visible = navList.value.filter(n => n.show)
|
||||||
|
const groupDefs : { key : 'blog' | 'more', title : string }[] = [
|
||||||
|
{ key: 'blog', title: '常用功能' },
|
||||||
|
{ key: 'more', title: '其他功能' },
|
||||||
|
]
|
||||||
|
return groupDefs
|
||||||
|
.map(def => ({ ...def, items: visible.filter(n => n.group === def.key) }))
|
||||||
|
.filter(group => group.items.length > 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
const commonFeatures = computed(() => {
|
||||||
|
return navList.value.filter(f => f.show && f.group === 'blog')
|
||||||
|
})
|
||||||
|
const otherFeatures = computed(() => {
|
||||||
|
return navList.value.filter(f => f.show && f.group === 'more')
|
||||||
|
})
|
||||||
|
|
||||||
|
/* ---------------- 功能导航 ---------------- */
|
||||||
|
|
||||||
|
async function handleGetNavList() {
|
||||||
|
// 配置模式:插件端 myPageConfig 两组(常用功能→blog、其他功能→more),
|
||||||
|
// 未配置/为空时回退本地内置默认(保留原显隐推导)
|
||||||
|
const mp = configuredFeatures.value
|
||||||
|
if (mp) {
|
||||||
|
const mapEntry = (e : IMyPageEntry, group : 'blog' | 'more') : INavItem | null => {
|
||||||
|
if (!e.key) { return null }
|
||||||
|
return {
|
||||||
|
key: e.key,
|
||||||
|
title: e.title || '',
|
||||||
|
iconPrefix: e.iconPrefix,
|
||||||
|
icon: e.icon || '',
|
||||||
|
bgColor: e.bgColor || '#969696F2',
|
||||||
|
color: e.color,
|
||||||
|
subTitle: e.subTitle || '',
|
||||||
|
path: e.path || null,
|
||||||
|
show: e.visible !== false,
|
||||||
|
group,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navList.value = [
|
||||||
|
...(mp.commonFeatures || []).map(e => mapEntry(e, 'blog')).filter((n) : n is INavItem => n !== null),
|
||||||
|
...(mp.otherFeatures || []).map(e => mapEntry(e, 'more')).filter((n) : n is INavItem => n !== null),
|
||||||
|
]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------- 数据加载 ---------------- */
|
||||||
|
async function handleGetData() {
|
||||||
|
try {
|
||||||
|
const res = await getBlogStatistics()
|
||||||
|
statistics.value = res.data
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error('获取统计失败', err)
|
||||||
|
uni.showToast({ icon: 'none', title: t('common.loadFailedRetry') })
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uni.stopPullDownRefresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------- 交互 ---------------- */
|
||||||
|
/* 恋爱模块解锁拦截(目前仅恋爱日记设密码,命中锁定则先解锁再跳转;样式不变) */
|
||||||
|
const {
|
||||||
|
unlockModalVisible,
|
||||||
|
unlockTip,
|
||||||
|
handleUnlockRequest,
|
||||||
|
handleUnlockSuccess,
|
||||||
|
interceptNavigateByPath,
|
||||||
|
} = useLoveModuleUnlock()
|
||||||
|
|
||||||
|
function handleNavGoTo(data : { path : string }) {
|
||||||
|
const { path } = data
|
||||||
|
if (!path) { return }
|
||||||
|
|
||||||
|
// 命中恋爱模块且锁定 → 弹解锁弹窗,解锁成功后由 hook 自动跳转
|
||||||
|
if (interceptNavigateByPath(path)) { return }
|
||||||
|
|
||||||
|
uni.navigateTo({ url: path })
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
watch(haloConfigs, () => {
|
||||||
|
handleGetNavList()
|
||||||
|
}, { deep: true, immediate: true })
|
||||||
|
|
||||||
|
handleGetData()
|
||||||
|
|
||||||
|
onPullDownRefresh(() => {
|
||||||
|
handleGetData()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="box-border min-h-screen w-screen bg-page pb-2">
|
||||||
|
<!-- 头部:博主信息(背景图 + 遮罩 + wave,内容区做状态栏适配) -->
|
||||||
|
<view class="relative h-96 w-full bg-cover bg-no-repeat" :style="[calcProfileStyle]">
|
||||||
|
<view class="relative z-6 h-full flex flex-col items-center justify-center">
|
||||||
|
<image class="uh-global-card-glass border-3 h-22 w-22 rounded-full" :src="bloggerInfo.avatar"
|
||||||
|
mode="aspectFill" />
|
||||||
|
<view class="mt-4 text-lg text-white font-bold text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">
|
||||||
|
{{ bloggerInfo.nickname }}
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="desc mt-2 px-10 text-center text-2xs text-white/90 leading-relaxed text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">
|
||||||
|
{{ bloggerInfo.description || '这个博主很懒,竟然没写介绍~' }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 遮罩 -->
|
||||||
|
<view class="absolute left-0 top-0 z-0 h-full w-full bg-white/5" style="backdrop-filter:blur(4rpx)" />
|
||||||
|
<image v-if="calcWaveUrl" :src="calcWaveUrl" mode="scaleToFill"
|
||||||
|
class="gif-wave absolute bottom-0 left-0 z-90 h-18 w-full" style="mix-blend-mode: screen;" />
|
||||||
|
<!-- 过渡 -->
|
||||||
|
<view class="absolute bottom-0 left-0 z-100 h-18 w-full bg-gradient-to-b from-black/0 to-page" />
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 站点统计 -->
|
||||||
|
<view v-if="featureMode==='list'"
|
||||||
|
class="uh-global-card-glass uh-shadow-xs relative z-100 mx-4 flex border rounded-2xl -mt-16">
|
||||||
|
<view v-for="item in allStats" :key="item.key" class="flex-1 py-4 text-center">
|
||||||
|
<wd-count-to :key="`${item.key}-${item.value}`" :start-val="0" :end-val="item.value" :duration="900"
|
||||||
|
separator="" color="#111827" custom-class="text-lg font-bold" />
|
||||||
|
<view class="mt-1 text-xs text-gray-500">
|
||||||
|
{{ item.label }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 功能导航:非分组模式 -->
|
||||||
|
<template v-if="featureMode==='base'">
|
||||||
|
<view v-if="commonFeatures.length!==0" class="relative z-100 -mt-20 box-border overflow-hidden p-4">
|
||||||
|
<view class="box-border uh-global-card-glass uh-shadow-xs border p-3 grid grid-cols-4 gap-2 rounded-lb-2xl rounded-rb-2xl rounded-lt-3xl rounded-rt-3xl">
|
||||||
|
<view v-for="(nav) in commonFeatures" :key="nav.key"
|
||||||
|
class="uh-global-card-glass uh-shadow-xs rounded-2xl flex flex-col items-center justify-between p-2"
|
||||||
|
@click="handleNavGoTo(nav)">
|
||||||
|
<view
|
||||||
|
class="uh-global-card-glass uh-shadow-xs h-8 w-8 flex items-center justify-center border rounded-xl"
|
||||||
|
:style="{ backgroundColor: nav.bgColor }">
|
||||||
|
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx" />
|
||||||
|
</view>
|
||||||
|
<text class="mt-1 text-xs text-gray-900" :style="{ color: nav.color }">
|
||||||
|
{{ nav.title }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<template v-if="otherFeatures.length!==0">
|
||||||
|
<view class="box-border px-4 mt-2 mb-3">
|
||||||
|
<uh-section-title>
|
||||||
|
其他功能
|
||||||
|
</uh-section-title>
|
||||||
|
</view>
|
||||||
|
<view class="uh-global-card-glass uh-shadow-xs mx-4 overflow-hidden rounded-2xl">
|
||||||
|
<view v-for="(nav, index) in otherFeatures" :key="nav.key"
|
||||||
|
class="flex items-center justify-between px-4"
|
||||||
|
:class="index < otherFeatures.length - 1 ? 'border-b border-b-solid border-black/5' : ''"
|
||||||
|
@click="handleNavGoTo(nav)">
|
||||||
|
<view class="nav-left flex items-center gap-3 py-3">
|
||||||
|
<view
|
||||||
|
class="uh-global-card-glass uh-shadow-xs h-8 w-8 flex items-center justify-center border rounded-xl"
|
||||||
|
:style="{ backgroundColor: nav.bgColor }">
|
||||||
|
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx" />
|
||||||
|
</view>
|
||||||
|
<text class="nav-title text-sm text-gray-900" :style="{ color: nav.color }">
|
||||||
|
{{ nav.title }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="nav-right flex items-center gap-2">
|
||||||
|
<text class="nav-right-text text-xs text-gray-400">{{ nav.subTitle }}</text>
|
||||||
|
<wd-icon name="arrow-right" size="24rpx" class="text-gray-400" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 功能导航:分组模式 -->
|
||||||
|
<template v-else-if="featureMode==='list'">
|
||||||
|
<template v-for="group in calcNavGroups" :key="group.key">
|
||||||
|
<view class="box-border px-4">
|
||||||
|
<uh-section-title class="mb-3 mt-8">
|
||||||
|
{{ group.title }}
|
||||||
|
</uh-section-title>
|
||||||
|
</view>
|
||||||
|
<view class="uh-global-card-glass mx-4 overflow-hidden rounded-2xl">
|
||||||
|
<view v-for="(nav, index) in group.items" :key="nav.key"
|
||||||
|
class="nav-item flex items-center justify-between px-4"
|
||||||
|
:class="index < group.items.length - 1 ? 'border-b border-b-solid border-black/5' : ''"
|
||||||
|
@click="handleNavGoTo(nav)">
|
||||||
|
<view class="nav-left flex items-center gap-3 py-3">
|
||||||
|
<view
|
||||||
|
class="uh-global-card-glass uh-shadow-xs h-8 w-8 flex items-center justify-center border rounded-xl"
|
||||||
|
:style="{ backgroundColor: nav.bgColor }">
|
||||||
|
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx" />
|
||||||
|
</view>
|
||||||
|
<text class="nav-title text-sm text-gray-900" :style="{ color: nav.color }">
|
||||||
|
{{ nav.title }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="nav-right flex items-center gap-2">
|
||||||
|
<text class="nav-right-text text-xs text-gray-400">{{ nav.subTitle }}</text>
|
||||||
|
<wd-icon name="arrow-right" size="24rpx" class="text-gray-400" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<uh-page-copyright />
|
||||||
|
|
||||||
|
<!-- 恋爱模块解锁弹窗(解锁成功自动跳转) -->
|
||||||
|
<uh-unlock-popup v-model:show="unlockModalVisible" title="请解锁" captcha-enabled
|
||||||
|
:tip="unlockTip" placeholder="请输入密码" confirm-text="进入" :request="handleUnlockRequest"
|
||||||
|
@success="handleUnlockSuccess" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { getMomentList } from '@/api/halo'
|
import { getMomentList } from '@/api/halo'
|
||||||
import { useAppConfigStore } from '@/store/appConfig'
|
import { useAppConfigStore } from '@/store/appConfig'
|
||||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||||
|
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||||
import { useFavoritesStore } from '@/store/favorites'
|
import { useFavoritesStore } from '@/store/favorites'
|
||||||
import { checkAvatarUrl, checkThumbnailUrl } from '@/utils/url'
|
import { checkAvatarUrl, checkThumbnailUrl } from '@/utils/url'
|
||||||
import { buildMomentFavoriteItem } from '@/utils/favorite'
|
import { buildMomentFavoriteItem } from '@/utils/favorite'
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const favoritesStore = useFavoritesStore()
|
const favoritesStore = useFavoritesStore()
|
||||||
const haloConfigs = computed(() => appConfigStore.configs)
|
const haloConfigs = computed(() => appConfigStore.configs)
|
||||||
@@ -62,9 +64,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 状态 ---------------- */
|
/* ---------------- 状态 ---------------- */
|
||||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||||
const queryParams = ref({ size: 10, page: 1 })
|
const queryParams = ref({ size: 10, page: 1 })
|
||||||
const hasNext = ref(false)
|
|
||||||
/** 列表卡片 */
|
/** 列表卡片 */
|
||||||
type MomentCard = IMoment & {
|
type MomentCard = IMoment & {
|
||||||
images ?: { type ?: string, url : string }[]
|
images ?: { type ?: string, url : string }[]
|
||||||
@@ -77,8 +78,6 @@
|
|||||||
weekend : string
|
weekend : string
|
||||||
}
|
}
|
||||||
const dataList = ref<MomentCard[]>([])
|
const dataList = ref<MomentCard[]>([])
|
||||||
const isLoadMore = ref(false)
|
|
||||||
const loadMoreText = ref(t('common.loading'))
|
|
||||||
const videoContexts = ref<Record<string, UniApp.VideoContext | undefined>>({})
|
const videoContexts = ref<Record<string, UniApp.VideoContext | undefined>>({})
|
||||||
const currentVideoId = ref<string | null>(null)
|
const currentVideoId = ref<string | null>(null)
|
||||||
|
|
||||||
@@ -125,6 +124,8 @@
|
|||||||
/* ---------------- 数据加载 ---------------- */
|
/* ---------------- 数据加载 ---------------- */
|
||||||
async function handleGetData() {
|
async function handleGetData() {
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
|
// 审核模式:按 audit-data moments 顺序展示,一次拉取不分页
|
||||||
|
resetLoadMoreStatus()
|
||||||
const auditMomentNames = appConfigStore.auditData.spec?.moments || []
|
const auditMomentNames = appConfigStore.auditData.spec?.moments || []
|
||||||
try {
|
try {
|
||||||
const res = await getMomentList({ page: 1, size: 0 })
|
const res = await getMomentList({ page: 1, size: 0 })
|
||||||
@@ -136,42 +137,61 @@
|
|||||||
dataList.value = tempItems
|
dataList.value = tempItems
|
||||||
await sleep(600)
|
await sleep(600)
|
||||||
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
loadMoreText.value = t('common.noMore')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'noMore',
|
||||||
|
hasNext: false,
|
||||||
|
})
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
loadMoreText.value = t('common.loadFailed')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadMore.value) {
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||||
}
|
}
|
||||||
loadMoreText.value = t('common.loading')
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getMomentList({ ...queryParams.value })
|
const res = await getMomentList({ ...queryParams.value })
|
||||||
loadMoreText.value = res.data.hasNext ? t('common.loadMore') : t('common.noMore')
|
|
||||||
hasNext.value = res.data.hasNext
|
|
||||||
|
|
||||||
const tempItems = res.data.items
|
const tempItems = res.data.items
|
||||||
.filter(x => x.spec.visible === 'PUBLIC')
|
.filter(x => x.spec.visible === 'PUBLIC')
|
||||||
.map(mapMomentItem)
|
.map(mapMomentItem)
|
||||||
|
|
||||||
dataList.value = isLoadMore.value
|
dataList.value = loadMoreStatus.value.active
|
||||||
? dataList.value.concat(tempItems)
|
? dataList.value.concat(tempItems)
|
||||||
: tempItems
|
: tempItems
|
||||||
|
|
||||||
await sleep(600)
|
if (!loadMoreStatus.value.active) {
|
||||||
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
await sleep(600)
|
||||||
|
updateLoadingStatus(dataList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||||
|
hasNext: res.data.hasNext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
if (loadMoreStatus.value.active) {
|
||||||
loadMoreText.value = t('common.loadFailed')
|
updateLoadMoreStatus({
|
||||||
|
active: false,
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
@@ -267,6 +287,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------- 生命周期 ---------------- */
|
/* ---------------- 生命周期 ---------------- */
|
||||||
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
|
updatePageScrollValue(option.scrollTop)
|
||||||
|
})
|
||||||
|
|
||||||
onLoad(async () => {
|
onLoad(async () => {
|
||||||
uni.setNavigationBarTitle({ title: t('page.moments.title') })
|
uni.setNavigationBarTitle({ title: t('page.moments.title') })
|
||||||
await checkPluginAvailable()
|
await checkPluginAvailable()
|
||||||
@@ -282,7 +306,7 @@
|
|||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isLoadMore.value = false
|
resetLoadMoreStatus()
|
||||||
queryParams.value.page = 1
|
queryParams.value.page = 1
|
||||||
videoContexts.value = {}
|
videoContexts.value = {}
|
||||||
currentVideoId.value = null
|
currentVideoId.value = null
|
||||||
@@ -292,24 +316,30 @@
|
|||||||
onReachBottom(() => {
|
onReachBottom(() => {
|
||||||
if (!uniHaloPluginAvailable.value)
|
if (!uniHaloPluginAvailable.value)
|
||||||
return
|
return
|
||||||
|
// 审核模式:一次拉取不分页,直接提示到底
|
||||||
if (calcAuditModeEnabled.value) {
|
if (calcAuditModeEnabled.value) {
|
||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (hasNext.value) {
|
// 正在加载时阻止重复请求
|
||||||
queryParams.value.page += 1
|
if (loadMoreStatus.value.active) {
|
||||||
isLoadMore.value = true
|
return
|
||||||
handleGetData()
|
|
||||||
}
|
}
|
||||||
else {
|
// 有更多数据时继续加载
|
||||||
uni.showToast({ icon: 'none', title: t('common.noMoreData') })
|
if (loadMoreStatus.value.hasNext) {
|
||||||
|
queryParams.value.page += 1
|
||||||
|
updateLoadMoreStatus({
|
||||||
|
active: true,
|
||||||
|
status: 'loading',
|
||||||
|
})
|
||||||
|
handleGetData()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen flex flex-col bg-page">
|
<view class="box-border min-h-screen w-screen flex flex-col bg-page">
|
||||||
<uh-navbar :use-back="false" default-title="我的日常" title-color="text-gray-900" />
|
<uh-navbar :scroll-y="scrollY" :use-back="false" default-title="我的日常" title-color="text-gray-900" />
|
||||||
|
|
||||||
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
||||||
:checking="checking" @on-refresh="handlePluginRefresh" />
|
:checking="checking" @on-refresh="handlePluginRefresh" />
|
||||||
@@ -318,7 +348,7 @@
|
|||||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||||
min-height="75vh" @refresh="handleGetData" />
|
min-height="75vh" @refresh="handleGetData" />
|
||||||
|
|
||||||
<view v-else class="box-border flex flex-col gap-3 p-3 pt-0">
|
<view v-else class="box-border flex flex-col gap-3 px-3">
|
||||||
<!-- 瞬间卡片 -->
|
<!-- 瞬间卡片 -->
|
||||||
<view v-for="moment in dataList" :key="moment.metadata.name" class="flex gap-x-2">
|
<view v-for="moment in dataList" :key="moment.metadata.name" class="flex gap-x-2">
|
||||||
<view class="shrink-0 flex flex-col gap-y-2 w-13">
|
<view class="shrink-0 flex flex-col gap-y-2 w-13">
|
||||||
@@ -339,8 +369,8 @@
|
|||||||
<image class="avatar h-9 w-9 shrink-0 rounded-full"
|
<image class="avatar h-9 w-9 shrink-0 rounded-full"
|
||||||
:src="checkAvatarUrl(moment.owner?.avatar || bloggerInfo.avatar)"
|
:src="checkAvatarUrl(moment.owner?.avatar || bloggerInfo.avatar)"
|
||||||
mode="aspectFill" />
|
mode="aspectFill" />
|
||||||
<view class="ml-2 flex flex-col">
|
<view class="ml-2 flex flex-col gap-y-1">
|
||||||
<view class="text-sm text-gray-900 font-bold">
|
<view class="text-3xs text-gray-900 font-bold">
|
||||||
{{ moment.owner?.displayName || bloggerInfo.nickname }}
|
{{ moment.owner?.displayName || bloggerInfo.nickname }}
|
||||||
</view>
|
</view>
|
||||||
<view class="text-xs text-gray-400">
|
<view class="text-xs text-gray-400">
|
||||||
@@ -349,7 +379,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="shrink-0">
|
<view class="shrink-0">
|
||||||
<uh-button custom-class="!py-1 bg-secondary text-xs font-semibold"
|
<uh-button custom-class="!py-1.5 bg-secondary text-xs"
|
||||||
@click="handleToMomentDetail(moment)">
|
@click="handleToMomentDetail(moment)">
|
||||||
详情
|
详情
|
||||||
</uh-button>
|
</uh-button>
|
||||||
@@ -358,7 +388,7 @@
|
|||||||
|
|
||||||
<!-- 正文 -->
|
<!-- 正文 -->
|
||||||
<view class="box-border px-4 pt-3">
|
<view class="box-border px-4 pt-3">
|
||||||
<view class="relative box-border rounded-lg bg-page p-3 text-gray-900 text-sm">
|
<view class="relative box-border rounded-lg bg-page p-3 text-gray-900 text-3xs">
|
||||||
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
|
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
|
||||||
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
||||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||||
@@ -388,10 +418,11 @@
|
|||||||
|
|
||||||
<!-- (点赞/评论) -->
|
<!-- (点赞/评论) -->
|
||||||
<view
|
<view
|
||||||
class="mb-1 mt-2 box-border w-full flex items-center justify-between border-t border-black/5 px-4 py-3 text-xs text-gray-400">
|
class="mb-1 mt-2 box-border w-full flex items-center border-t border-black/5 px-4 py-3 text-xs text-gray-400"
|
||||||
|
:class="[moment.spec.allowComment?'justify-between':'gap-x-6']">
|
||||||
<view class="flex items-center gap-x-1" @click.stop="handleMomentLike(moment)">
|
<view class="flex items-center gap-x-1" @click.stop="handleMomentLike(moment)">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="32rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="32rpx" />
|
||||||
<text class="text-sm"
|
<text class="text-3xs"
|
||||||
:class="hasUpvoted(moment.metadata.name) ? 'text-primary' : 'text-gray-600'">
|
:class="hasUpvoted(moment.metadata.name) ? 'text-primary' : 'text-gray-600'">
|
||||||
点赞 {{ moment.stats.upvote || 0 }}
|
点赞 {{ moment.stats.upvote || 0 }}
|
||||||
</text>
|
</text>
|
||||||
@@ -399,11 +430,11 @@
|
|||||||
<view v-if="moment.spec.allowComment" class="flex items-center gap-x-1"
|
<view v-if="moment.spec.allowComment" class="flex items-center gap-x-1"
|
||||||
@click.stop="handleMomentComment(moment)">
|
@click.stop="handleMomentComment(moment)">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="32rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="32rpx" />
|
||||||
<text class="text-sm text-gray-600">评论 {{ moment.stats.totalComment || 0 }}</text>
|
<text class="text-3xs text-gray-600">评论 {{ moment.stats.totalComment || 0 }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex items-center gap-x-1" @click.stop="handleToggleMomentFavorite(moment)">
|
<view class="flex items-center gap-x-1" @click.stop="handleToggleMomentFavorite(moment)">
|
||||||
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="32rpx" />
|
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="32rpx" />
|
||||||
<text class="text-sm"
|
<text class="text-3xs"
|
||||||
:class="isMomentFavorite(moment) ? 'text-primary' : 'text-gray-600'">
|
:class="isMomentFavorite(moment) ? 'text-primary' : 'text-gray-600'">
|
||||||
{{ isMomentFavorite(moment) ? '已收藏' : '收藏' }}
|
{{ isMomentFavorite(moment) ? '已收藏' : '收藏' }}
|
||||||
</text>
|
</text>
|
||||||
@@ -411,9 +442,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="load-text pb-5 pt-1 text-center text-xs text-gray-500">
|
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||||
{{ loadMoreText }}
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
+8
-54
@@ -1,37 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* 应用配置 store(源自旧项目 store/config.js 的 configs/auditData 部分)
|
* 应用配置
|
||||||
* 注意:旧 fetchConfigs 中会把 basicConfig.tokenConfig 写入缓存,供 getPersonalToken 使用,此处保留
|
|
||||||
*/
|
*/
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { getAppConfigs, getAuditData, getLoveConfig } from '@/api/uni-halo'
|
import { getAppConfigs, getAuditData } from '@/api/uni-halo'
|
||||||
import { DefaultAppConfigs } from '@/config/appConfig'
|
import { DefaultAppConfigs } from '@/config/appConfig'
|
||||||
import { deepMerge } from '@/utils/merge'
|
import { deepMerge } from '@/utils/merge'
|
||||||
import { setCache } from '@/utils/storage'
|
import { setCache } from '@/utils/storage'
|
||||||
import type { IAppConfig, IAuditDataResult } from '@/api/types/uni-halo'
|
import type { IAppConfig, IAuditDataResult } from '@/api/types/uni-halo'
|
||||||
|
|
||||||
/** 个人令牌存储 key(与 src/store/token.ts 的 getPersonalToken 保持一致) */
|
|
||||||
const APP_TOKENS_KEY = 'APP_TOKENS'
|
|
||||||
/** 合并后配置缓存 key(与 utils/url.ts / api/uni-halo.ts 的 APP_GLOBAL_CONFIGS 读取保持一致) */
|
/** 合并后配置缓存 key(与 utils/url.ts / api/uni-halo.ts 的 APP_GLOBAL_CONFIGS 读取保持一致) */
|
||||||
const APP_GLOBAL_CONFIGS_KEY = 'APP_GLOBAL_CONFIGS'
|
const APP_GLOBAL_CONFIGS_KEY = 'APP_GLOBAL_CONFIGS'
|
||||||
/**
|
/**
|
||||||
* 恋爱配置内容(公开 GET /love-config 返回: enabled + 纪念日/恋人信息;
|
* 静态配置后台刷新间隔(ms): onShow 距上次拉取在 TTL 内则不再重复请求
|
||||||
* 恋爱开关与页面图片仍在 configs.loveConfig, 由 love.vue 组合读取)
|
|
||||||
*/
|
|
||||||
export interface IStaticLoveConfig {
|
|
||||||
enabled?: boolean
|
|
||||||
loveDateTitle?: string
|
|
||||||
loveDate?: string
|
|
||||||
loveInfo?: {
|
|
||||||
boyNickname?: string
|
|
||||||
boyAvatar?: string
|
|
||||||
girlNickname?: string
|
|
||||||
girlAvatar?: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 静态配置后台刷新间隔(ms): onShow 距上次拉取在 TTL 内则不再重复请求(设计见
|
|
||||||
* .docs/static-config-unified-fetch-design.md)
|
|
||||||
*/
|
*/
|
||||||
const STATIC_TTL = 5 * 60 * 1000
|
const STATIC_TTL = 5 * 60 * 1000
|
||||||
|
|
||||||
@@ -45,8 +26,6 @@ export const useAppConfigStore = defineStore(
|
|||||||
const auditModeEnabled = computed(() => !!auditData.value.enabled)
|
const auditModeEnabled = computed(() => !!auditData.value.enabled)
|
||||||
/** 维护模式信息(configs 顶层 additive maintenance 键;undefined=未维护/已到点自动结束) */
|
/** 维护模式信息(configs 顶层 additive maintenance 键;undefined=未维护/已到点自动结束) */
|
||||||
const maintenance = computed(() => configs.value.maintenance)
|
const maintenance = computed(() => configs.value.maintenance)
|
||||||
/** 恋爱配置内容(公开 /love-config;bootstrap 统一拉取,随 store persist 持久化) */
|
|
||||||
const loveConfig = ref<IStaticLoveConfig>({ enabled: false })
|
|
||||||
/** 最近一次静态配置拉取时间戳(ms,0=从未拉取;TTL 判定依据) */
|
/** 最近一次静态配置拉取时间戳(ms,0=从未拉取;TTL 判定依据) */
|
||||||
const fetchedAt = ref(0)
|
const fetchedAt = ref(0)
|
||||||
|
|
||||||
@@ -54,7 +33,6 @@ export const useAppConfigStore = defineStore(
|
|||||||
const setDefaultAppSettings = () => {
|
const setDefaultAppSettings = () => {
|
||||||
configs.value = JSON.parse(JSON.stringify(DefaultAppConfigs))
|
configs.value = JSON.parse(JSON.stringify(DefaultAppConfigs))
|
||||||
auditData.value = { enabled: false }
|
auditData.value = { enabled: false }
|
||||||
loveConfig.value = { enabled: false }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取应用配置(与默认值深合并,并存储 token) */
|
/** 获取应用配置(与默认值深合并,并存储 token) */
|
||||||
@@ -65,14 +43,7 @@ export const useAppConfigStore = defineStore(
|
|||||||
if (body) {
|
if (body) {
|
||||||
configs.value = deepMerge(JSON.parse(JSON.stringify(DefaultAppConfigs)), body)
|
configs.value = deepMerge(JSON.parse(JSON.stringify(DefaultAppConfigs)), body)
|
||||||
|
|
||||||
// 合并结果写入 APP_GLOBAL_CONFIGS 缓存,供 utils/url.ts 图片兜底与
|
|
||||||
// api/uni-halo.ts 第三方插件授权头等按 storage 路径读取
|
|
||||||
setCache(APP_GLOBAL_CONFIGS_KEY, configs.value)
|
setCache(APP_GLOBAL_CONFIGS_KEY, configs.value)
|
||||||
|
|
||||||
// 存储个人令牌(供 getPersonalToken 使用,如非匿名投票)
|
|
||||||
if (body?.basicConfig?.tokenConfig) {
|
|
||||||
setCache(APP_TOKENS_KEY, body.basicConfig.tokenConfig)
|
|
||||||
}
|
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
setDefaultAppSettings()
|
setDefaultAppSettings()
|
||||||
@@ -98,35 +69,20 @@ export const useAppConfigStore = defineStore(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取恋爱配置内容(公开 /love-config) */
|
|
||||||
const fetchLoveConfig = async () => {
|
|
||||||
try {
|
|
||||||
const res = await getLoveConfig()
|
|
||||||
const body = res.data as unknown as IStaticLoveConfig | undefined
|
|
||||||
loveConfig.value = body && Object.keys(body).length > 0
|
|
||||||
? body
|
|
||||||
: { enabled: false }
|
|
||||||
return loveConfig.value
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error('获取恋爱配置失败', err)
|
|
||||||
loveConfig.value = { enabled: false }
|
|
||||||
return loveConfig.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统一拉取静态配置(设计见 .docs/static-config-unified-fetch-design.md):
|
* 统一拉取静态配置:
|
||||||
* getConfigs + audit-data + love-config 并行一次;TTL 内(默认 5 分钟,persist 恢复后
|
* getConfigs + audit-data 并行一次;TTL 内(默认 5 分钟,persist 恢复后
|
||||||
* 亦生效)直接返回缓存,避免每次冷启动/onShow 重复请求;force=true 强制刷新。
|
* 亦生效)直接返回缓存,避免每次冷启动/onShow 重复请求;force=true 强制刷新。
|
||||||
* 返回 ok = getConfigs 是否成功(失败时走内置默认/旧缓存,由调用方决定后续)。
|
* 返回 ok = getConfigs 是否成功(失败时走内置默认/旧缓存,由调用方决定后续)。
|
||||||
|
* 恋爱配置已并入 getConfigs 的 loveConfig 组(2026-09-12 起 /love-config 下线),
|
||||||
|
* 由 love.vue 直接读 configs.loveConfig。
|
||||||
*/
|
*/
|
||||||
const bootstrap = async (options?: { force?: boolean }): Promise<{ ok: boolean, fromCache: boolean }> => {
|
const bootstrap = async (options?: { force?: boolean }): Promise<{ ok: boolean, fromCache: boolean }> => {
|
||||||
const force = options?.force ?? false
|
const force = options?.force ?? false
|
||||||
if (!force && fetchedAt.value > 0 && Date.now() - fetchedAt.value < STATIC_TTL) {
|
if (!force && fetchedAt.value > 0 && Date.now() - fetchedAt.value < STATIC_TTL) {
|
||||||
return { ok: true, fromCache: true }
|
return { ok: true, fromCache: true }
|
||||||
}
|
}
|
||||||
const [cfg] = await Promise.all([fetchConfigs(), fetchAuditData(), fetchLoveConfig()])
|
const [cfg] = await Promise.all([fetchConfigs(), fetchAuditData()])
|
||||||
fetchedAt.value = Date.now()
|
fetchedAt.value = Date.now()
|
||||||
return { ok: !!cfg, fromCache: false }
|
return { ok: !!cfg, fromCache: false }
|
||||||
}
|
}
|
||||||
@@ -139,12 +95,10 @@ export const useAppConfigStore = defineStore(
|
|||||||
auditData,
|
auditData,
|
||||||
auditModeEnabled,
|
auditModeEnabled,
|
||||||
maintenance,
|
maintenance,
|
||||||
loveConfig,
|
|
||||||
fetchedAt,
|
fetchedAt,
|
||||||
fetchConfigs,
|
fetchConfigs,
|
||||||
setDefaultAppSettings,
|
setDefaultAppSettings,
|
||||||
fetchAuditData,
|
fetchAuditData,
|
||||||
fetchLoveConfig,
|
|
||||||
bootstrap,
|
bootstrap,
|
||||||
refreshStatic,
|
refreshStatic,
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Halo 全局配置 store(源自旧项目 store/config.js 的 haloConfig 部分)
|
* Halo 全局配置 store
|
||||||
*/
|
*/
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
* - applySiteDefaults(site):启动 fetchConfigs 后把 getConfigs 收集的 L0 与本地差异合并(含旧数据迁移);
|
* - applySiteDefaults(site):启动 fetchConfigs 后把 getConfigs 收集的 L0 与本地差异合并(含旧数据迁移);
|
||||||
* - savePreference(patch):写本地差异(uh_pref_local_v1)并立即重合并;
|
* - savePreference(patch):写本地差异(uh_pref_local_v1)并立即重合并;
|
||||||
* - resetPreferences:清本地差异,立即回退「站点默认」(无 L0 时回退内置默认)。
|
* - resetPreferences:清本地差异,立即回退「站点默认」(无 L0 时回退内置默认)。
|
||||||
*
|
|
||||||
* 设计依据:插件仓库 .docs/config-system-v2-redesign.md §3-4(v2.2:远端=站点默认,无用户级远端层)。
|
|
||||||
*/
|
*/
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
@@ -36,7 +34,7 @@ export const useSettingStore = defineStore(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用站点默认并合并本地差异(启动 fetchConfigs 成功后调用;site 为 null/空时仅本地差异覆盖内置默认)
|
* 应用站点默认并合并本地差异(启动 fetchConfigs 成功后调用;site 为 null/空时仅本地差异覆盖内置默认)
|
||||||
* 首次运行时顺带迁移旧版全量 persist(见 utils/preference.migrateLegacyLocalPrefs)
|
* 首次运行时顺带迁移旧版全量 persist
|
||||||
*/
|
*/
|
||||||
const applySiteDefaults = (site: LocalPrefs | null): void => {
|
const applySiteDefaults = (site: LocalPrefs | null): void => {
|
||||||
siteDefaults.value = site && typeof site === 'object' ? site : null
|
siteDefaults.value = site && typeof site === 'object' ? site : null
|
||||||
|
|||||||
+2
-2
@@ -15,11 +15,11 @@ import { isDoubleTokenRes, isSingleTokenRes } from '@/api/types/login'
|
|||||||
import { useUserStore } from './user'
|
import { useUserStore } from './user'
|
||||||
import { getCache } from '@/utils/storage'
|
import { getCache } from '@/utils/storage'
|
||||||
|
|
||||||
/** 个人令牌存储 key(源自旧项目 utils/token.js,含 basicConfig.tokenConfig) */
|
/** 个人令牌存储 key */
|
||||||
const APP_TOKENS_KEY = 'APP_TOKENS'
|
const APP_TOKENS_KEY = 'APP_TOKENS'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取个人令牌(旧项目 getPersonalToken)
|
* 获取个人令牌
|
||||||
* 用于需要个人 token 的接口(如非匿名投票 submitVote)
|
* 用于需要个人 token 的接口(如非匿名投票 submitVote)
|
||||||
* @returns 个人令牌,未配置时为空字符串
|
* @returns 个人令牌,未配置时为空字符串
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ page {
|
|||||||
box-shadow: inset 0 1rpx 0 rgb(255 255 255 / 75%), 0 8rpx 32rpx rgb(90 105 200 / 7%);
|
box-shadow: inset 0 1rpx 0 rgb(255 255 255 / 75%), 0 8rpx 32rpx rgb(90 105 200 / 7%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.uh-shadow-sm{
|
||||||
|
box-shadow: 0 0 24rpx rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
.uh-global-love-page {
|
.uh-global-love-page {
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
135deg,
|
135deg,
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
import type { CustomTabBarItem } from './types'
|
|
||||||
import { mount } from '@vue/test-utils'
|
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
||||||
import TabbarItem from './TabbarItem.vue'
|
|
||||||
|
|
||||||
// mock tabbar store,避免 uni.getStorageSync 在模块加载时执行
|
|
||||||
vi.mock('./store', () => ({
|
|
||||||
tabbarStore: { curIdx: 0 },
|
|
||||||
}))
|
|
||||||
|
|
||||||
const baseItem: CustomTabBarItem = {
|
|
||||||
text: '首页',
|
|
||||||
pagePath: 'pages/index/index',
|
|
||||||
iconType: 'unocss',
|
|
||||||
icon: 'i-carbon-home',
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('tabbarItem', () => {
|
|
||||||
let wrapper: ReturnType<typeof mount>
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper?.unmount()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('渲染 text 文本', () => {
|
|
||||||
wrapper = mount(TabbarItem, {
|
|
||||||
props: { item: baseItem, index: 0 },
|
|
||||||
})
|
|
||||||
expect(wrapper.text()).toContain('首页')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('isBulge=true 时不渲染文本', () => {
|
|
||||||
wrapper = mount(TabbarItem, {
|
|
||||||
props: { item: baseItem, index: 0, isBulge: true },
|
|
||||||
})
|
|
||||||
expect(wrapper.text()).not.toContain('首页')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('iconType=unocss 时渲染图标 class', () => {
|
|
||||||
wrapper = mount(TabbarItem, {
|
|
||||||
props: { item: baseItem, index: 0 },
|
|
||||||
})
|
|
||||||
expect(wrapper.html()).toContain('i-carbon-home')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('badge=dot 时渲染小红点(包含 rounded-full 样式)', () => {
|
|
||||||
const item: CustomTabBarItem = { ...baseItem, badge: 'dot' }
|
|
||||||
wrapper = mount(TabbarItem, {
|
|
||||||
props: { item, index: 0 },
|
|
||||||
})
|
|
||||||
expect(wrapper.html()).toContain('rounded-full')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('badge 为数字时渲染数字角标', () => {
|
|
||||||
const item: CustomTabBarItem = { ...baseItem, badge: 5 }
|
|
||||||
wrapper = mount(TabbarItem, {
|
|
||||||
props: { item, index: 0 },
|
|
||||||
})
|
|
||||||
expect(wrapper.text()).toContain('5')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('badge > 99 时显示 99+', () => {
|
|
||||||
const item: CustomTabBarItem = { ...baseItem, badge: 100 }
|
|
||||||
wrapper = mount(TabbarItem, {
|
|
||||||
props: { item, index: 0 },
|
|
||||||
})
|
|
||||||
expect(wrapper.text()).toContain('99+')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user