1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-11-13 22:11:42 +08:00

feat&refactor: 完成项目多轮优化与功能迭代

1. 调整开发环境与生产环境接口地址为局域网地址
2. 新增页面滚动监听hook、版权组件与小尺寸阴影工具类
3. 优化多处组件样式、导航栏与tabbar配置
4. 重构恋爱模块配置类型与移除冗余接口
5. 修复多处代码细节与优化用户体验
This commit is contained in:
小莫唐尼
2026-09-12 22:33:50 +08:00
parent 885646ec0c
commit e5e3ad3d8b
74 changed files with 2262 additions and 2238 deletions
Vendored
+7 -6
View File
@@ -1,5 +1,5 @@
VITE_APP_TITLE = 'uni-halo'
VITE_APP_PORT = 9520
VITE_APP_PORT = 5200
VITE_UNI_APPID = '__UNI__5748B6E'
VITE_WX_APPID = 'wx1bb161867082c72f'
@@ -8,7 +8,7 @@ VITE_WX_APPID = 'wx1bb161867082c72f'
# macOS 示例:
# WECHAT_DEVTOOLS_CLI_PATH = '/Applications/wechatwebdevtools.app/Contents/MacOS/cli'
# 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
# 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。
# 微信小程序如果没有配置下面的专用地址,也会回退使用这个值。
VITE_SERVER_BASEURL = 'http://localhost:8090'
# VITE_SERVER_BASEURL = 'http://localhost:8090'
VITE_SERVER_BASEURL = 'http://192.168.1.2:8090'
# 微信小程序专用后台请求地址,按微信开发者工具 envVersion 区分。
# 不配置时会回退使用 VITE_SERVER_BASEURL。
VITE_SERVER_BASEURL__WEIXIN_DEVELOP = ''
VITE_SERVER_BASEURL__WEIXIN_TRIAL = ''
VITE_SERVER_BASEURL__WEIXIN_RELEASE = ''
VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'http://192.168.1.2:8090'
VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'http://192.168.1.2:8090'
VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'http://192.168.1.2:8090'
# h5是否需要配置代理
VITE_APP_PROXY_ENABLE = false
+2 -1
View File
@@ -9,4 +9,5 @@ VITE_SHOW_SOURCEMAP = false
VITE_APP_HALO_TOKEN = ''
# 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
View File
@@ -2,10 +2,13 @@
import { ref } from 'vue'
import { isPageTabbar } from './tabbar/store'
import { currRoute } from './utils'
import { useSettingsPopup } from '@/hooks/useSettingsPopup'
import CustomTabbar from '@/tabbar/index.vue'
const isCurrentPageTabbar = ref(true)
const globalSettingsVisible = ref(false)
const { settingsPopupVisible, openSettingsPopup } = useSettingsPopup()
onShow(() => {
const { path } = currRoute()
if (path === '/') {
@@ -21,10 +24,10 @@
<view>
<uh-global-actions>
<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-settings-popup v-model="globalSettingsVisible" @close="globalSettingsVisible = false" />
<uh-settings-popup v-model="settingsPopupVisible" />
<KuRootView />
+56 -12
View File
@@ -112,8 +112,7 @@ export interface IPageConfig {
categoryConfig?: { type?: string }
momentConfig?: { useTagRandomColor?: boolean }
galleryConfig?: { pageTitle?: string }
/** 恋爱日记页(插件端「通用配置 → 页面设置 → 恋爱日记」配置;
* 2026-09-11 起恋爱页背景图由 loveConfig.pageImages 迁入此处) */
/** 恋爱日记页(插件端「通用配置 → 页面设置 → 恋爱日记」配置) */
loveDiaryConfig?: {
pageTitle?: string
/** 恋爱页背景图(留空客户端内置回退) */
@@ -188,10 +187,11 @@ export interface IAppConfig {
}
}
/**
* 恋爱配置(入口显隐由模块入口开关
* (ourStory/lovePhoto/loveDaily.enabled)与 navList 统一管理,客户端按模块开关判定)
* 恋爱配置(恋爱日记入口仅密码状态无开关;三模块入口自身即 app 端入口列表数据:
* title/subTitle/颜色(hex8)/iconBgColor/path/priority,按 priority 降序下发;
* app 端按模块 key 直接渲染入口列表,locked=passwordEnabled 且本地无有效 token)
*/
loveConfig?: Record<string, unknown>
loveConfig?: ILoveConfigGroup
imagesConfig?: IImagesConfig
/**
* 博主与社交(blogger 含
@@ -482,13 +482,57 @@ export interface INoticeDetail {
/* ---------- 恋爱模块(plugin-uni-halo love) ---------- */
export interface ILoveConfig {
/** 纪念日 */
anniversary?: string
/** 恋人信息 */
lovers?: {
name?: string
avatar?: string
/** 恋爱模块入口(三模块共用;loveDiary 仅使用密码相关字段) */
export interface ILoveModuleConfig {
/** 是否在恋爱页展示该模块入口(loveDiary 不使用:入口显隐由快捷导航/功能入口注册表控制) */
enabled?: boolean
/** 入口名称(app 端入口列表标题) */
title?: 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
-14
View File
@@ -19,7 +19,6 @@ import type {
ILoveAlbum,
ILoveAlbumListReq,
ILoveAlbumListRes,
ILoveConfig,
ILoveDailyItem,
ILoveDailyItemListReq,
ILoveDailyItemListRes,
@@ -201,19 +200,6 @@ export function getNoticeDetail(name: string) {
/* ==================== 恋爱模块 ==================== */
/**
* 获取恋爱配置(纪念日 + 恋人信息;恋爱日记入口 loveDiary 设密码时
* 需携带模块解锁 token,未解锁返回 401 locked)
*/
export function getLoveConfig() {
const token = getLoveModuleToken('loveDiary')
return http.Get<IResponse<ILoveConfig>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-config', {
params: token ? { token } : {},
cacheFor: 0,
meta: { requestFrom: RequestFrom.Halo },
})
}
/**
* 获取恋爱相册列表(lovePhoto 模块设密码时需携带模块解锁 token)
*/
@@ -38,11 +38,10 @@
const isGrid = computed(() => props.variant === 'grid')
/** 单一事实源:每种布局的完整形态,模板不再有任何 order / 条件分支 */
const CARD_LAYOUTS = computed(()=> ({
image_top: {
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' : ''}`,
footer: 'flex items-center',
authorGroup: 'flex-1 items-center justify-start gap-x-1',
@@ -159,17 +158,16 @@
</text>
<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 />
<!-- <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 class="flex flex-col gap-y-2 text-sm" :class="cardLayout.contentWrapper">
<view class="truncate font-bold">
<view class="flex flex-col gap-y-3 text-sm" :class="cardLayout.contentWrapper">
<view class="truncate font-bold text-3xs">
{{ article.spec.title }}
</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 }}
</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">
<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">
+12 -4
View File
@@ -1,4 +1,10 @@
<script setup lang="ts">
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
interface IProps {
customClass ?: string | Array<string>;
}
@@ -8,11 +14,13 @@
}
const props = defineProps<IProps>();
const emit = defineEmits<IEmits>();
const emits = defineEmits<IEmits>();
</script>
<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')">
<slot></slot>
<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="emits('click')">
<slot />
</view>
</template>
</template>
@@ -146,13 +146,8 @@
</view>
<block v-else>
<view v-if="disallowComment && dataList.length !== 0"
class="rounded-xl bg-gray-50 px-3 py-2 text-xs text-red-400">
Ծ‸Ծ 博主已设置该文章禁止评论!
</view>
<view v-if="dataList.length === 0" class="empty py-12">
<view class="empty-box flex flex-col items-center">
<view v-if="dataList.length === 0" class=" py-12">
<view class=" flex flex-col items-center">
<wd-icon class-prefix="uhemoji-icon" name="-confused" size="100rpx" class="text-primary" />
<text class="mt-2 text-sm text-gray-500">暂无评论</text>
<view v-if="disallowComment" class="mt-2 text-xs text-red-400">
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed } from 'vue'
import { checkUrl } from '@/utils/url'
import type { DataLoadingStatus } from '@/hooks/useDataLoading'
import type { DataLoadingStatus } from '@/hooks/useDataLoadingStatus'
interface IProps {
loadingStatus ?: DataLoadingStatus
@@ -9,7 +9,7 @@
</script>
<template>
<view class="w-full py-5 flex items-center justify-center gap-x-2 text-xs text-gray-400">
<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">
import { computed } from 'vue'
import { computed } from 'vue'
/** 单列选项(wd-picker PickerOption 的宽松形态,label/value 与 wot 一致) */
interface IPickerOption {
label?: string | number
value?: string | number
disabled?: boolean
children?: IPickerOption[]
[key: string]: unknown
}
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
interface IPickerOption {
label ?: string | number
value ?: string | number
disabled ?: boolean
children ?: IPickerOption[]
[key : string] : unknown
}
interface IProps {
/** v-model:visible 是否显示 */
visible: boolean
/** 弹层标题 */
title?: string
/** 选择器数据(单列/多列;与 wd-picker columns 一致) */
columns?: Array<IPickerOption | IPickerOption[]>
/** 选中项(单列如 ['value']) */
modelValue?: (string | number)[]
/** 确认/取消按钮文案 */
confirmButtonText?: string
cancelButtonText?: string
/** 自定义层级 */
zIndex?: number
/** 点击遮罩是否关闭 */
closeOnClickModal?: boolean
/** 底部安全距离适配 */
safeAreaInsetBottom?: boolean
/** 追加到选择器根元素的自定义类 */
customClass?: string
}
interface IProps {
visible : boolean
/** 弹层标题 */
title ?: string
/** 选择器数据(单列/多列;与 wd-picker columns 一致) */
columns ?: Array<IPickerOption | IPickerOption[]>
/** 选中项(单列如 ['value']) */
modelValue ?: (string | number)[]
/** 确认/取消按钮文案 */
confirmButtonText ?: string
cancelButtonText ?: string
/** 自定义层级 */
zIndex ?: number
/** 点击遮罩是否关闭 */
closeOnClickModal ?: boolean
/** 底部安全距离适配 */
safeAreaInsetBottom ?: boolean
/** 追加到选择器根元素的自定义类 */
customClass ?: string
}
interface IEmits {
(e: 'update:visible', value: boolean): void
(e: 'update:modelValue', value: (string | number)[]): void
(e: 'confirm', payload: { value: (string | number)[] }): void
(e: 'open'): void
(e: 'cancel'): void
}
interface IEmits {
(e : 'update:visible', value : boolean) : void
(e : 'update:modelValue', value : (string | number)[]) : void
(e : 'confirm', payload : { value : (string | number)[] }) : void
(e : 'open') : void
(e : 'cancel') : void
}
const props = withDefaults(defineProps<IProps>(), {
title: '',
columns: () => [],
modelValue: () => [],
confirmButtonText: '确定',
cancelButtonText: '取消',
zIndex: 15,
closeOnClickModal: true,
safeAreaInsetBottom: true,
customClass: '',
})
const props = withDefaults(defineProps<IProps>(), {
title: '',
columns: () => [],
modelValue: () => [],
confirmButtonText: '确定',
cancelButtonText: '取消',
zIndex: 15,
closeOnClickModal: true,
safeAreaInsetBottom: true,
customClass: '',
})
const emit = defineEmits<IEmits>()
const emit = defineEmits<IEmits>()
const pickerClass = computed(() => `uh-picker ${props.customClass}`.trim())
const pickerClass = computed(() => `uh-picker ${props.customClass}`.trim())
/* ---------------- wd-picker 事件转发(在 script 处理,模板只做绑定) ---------------- */
function handleUpdateVisible(value: boolean) {
emit('update:visible', value)
}
/* ---------------- wd-picker 事件转发(在 script 处理,模板只做绑定) ---------------- */
function handleUpdateVisible(value : boolean) {
emit('update:visible', value)
}
function handleUpdateModelValue(value: (string | number)[]) {
emit('update:modelValue', value)
}
function handleUpdateModelValue(value : (string | number)[]) {
emit('update:modelValue', value)
}
function handleConfirm(payload: { value: (string | number)[] }) {
emit('confirm', payload)
}
function handleConfirm(payload : { value : (string | number)[] }) {
emit('confirm', payload)
}
function handleOpen() {
emit('open')
}
function handleOpen() {
emit('open')
}
function handleCancel() {
emit('cancel')
}
function handleCancel() {
emit('cancel')
}
</script>
<template>
<wd-picker
:visible="visible" :title="title" :columns="columns" :model-value="modelValue"
:confirm-button-text="confirmButtonText" :cancel-button-text="cancelButtonText" :z-index="zIndex"
:close-on-click-modal="closeOnClickModal" :safe-area-inset-bottom="safeAreaInsetBottom"
:custom-class="pickerClass" @update:visible="handleUpdateVisible" @update:model-value="handleUpdateModelValue"
@confirm="handleConfirm" @open="handleOpen" @cancel="handleCancel"
>
<slot />
</wd-picker>
<wd-picker :visible="visible" :title="title" :columns="columns" :model-value="modelValue"
:confirm-button-text="confirmButtonText" :cancel-button-text="cancelButtonText" :z-index="zIndex"
:close-on-click-modal="closeOnClickModal" :safe-area-inset-bottom="safeAreaInsetBottom"
:custom-class="pickerClass" @update:visible="handleUpdateVisible" @update:model-value="handleUpdateModelValue"
@confirm="handleConfirm" @open="handleOpen" @cancel="handleCancel">
<slot />
</wd-picker>
</template>
<style scoped lang="scss">
/* 弹层面板玻璃质感(与 uh-glass-popup 同款;wd-picker 内层 popup 挂 .wd-picker__popup) */
:deep(.wd-picker__popup .wd-popup) {
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%);
}
:deep(.wd-picker__popup .wd-popup) {
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-picker__popup .wd-popup) {
background-color: rgb(255 255 255 / 88%);
}
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
:deep(.wd-picker__popup .wd-popup) {
background-color: rgb(255 255 255 / 88%);
}
}
:deep(.wd-popup--bottom) {
left: 24rpx;
bottom: 24rpx;
right: 24rpx;
}
</style>
:deep(.wd-popup--bottom) {
left: 24rpx;
bottom: 24rpx;
right: 24rpx;
}
</style>
+374 -64
View File
@@ -1,9 +1,30 @@
<script lang="ts" setup>
/**
* 玻璃质感弹窗:对 wd-popup 的二层封装。
* wd-popup 无背景/边框配置能力(index.scss 仅暴露 --wot-popup-bg 纯色变量),
* 故通过 custom-class 落到面板根元素后,用 :deep 覆盖为 uh-global-card-glass 同款效果。
*/
defineOptions({
options: {
styleIsolation: 'apply-shared',
},
})
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 {
/** v-model:是否显示 */
modelValue : boolean
@@ -19,15 +40,18 @@
closeOnClickModal ?: boolean
/** 底部安全距离适配(iphone X 类机型) */
safeAreaInsetBottom ?: boolean
/** 面板圆角(内联生效,优先级最高);传 wot 自带 round 时圆角由位置自动适配 */
/** 面板圆角(内联生效,优先级最高);与 round 二选一 */
radius ?: string
/** 是否开启 wot 位置自适应圆角(bottom→上圆角 / center→四圆角等),与 radius 二选一 */
/** 位置自适应圆角(bottom→上圆角 / center→四圆角等),与 radius 二选一 */
round ?: boolean
/** 弹层内容懒渲染,首次显示时才渲染 */
lazyRender ?: boolean
hideWhenClose?: boolean
/** 关闭动画结束后是否隐藏面板(display:none);false 时保留渲染(内部状态不丢) */
hideWhenClose ?: boolean
/** 追加到面板的内联样式,如宽度:width:640rpx; */
customStyle ?: string
customClass? :string
/** 追加到面板的类名(如 UnoCSS 原子类) */
customClass ?: string
}
interface IEmits {
@@ -37,76 +61,362 @@
(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:''
/* ---------------- 动画状态机 ---------------- */
/** 首次显示后才渲染(lazyRender) */
const inited = ref(false)
/** 是否渲染显示(关闭动画结束后 hideWhenClose 时置 false) */
const display = ref(false)
/** 动画阶段: enter / enter-to / leave / leave-to / '' */
const phase = ref('')
/** 动画名称(按位置):center 组合 zoom-in + fade */
const transitionName = computed(() => {
switch (props.position) {
case 'center':
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(() => {
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(() =>{
return `uh-glass-popup-panel ${props.customClass}`
const maskStyle = computed(() => {
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>
<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></slot>
</wd-popup>
<view v-if="isShow">
<!-- 遮罩层 -->
<view v-if="modal" class="uh-glass-popup__mask" :class="maskClasses" :style="maskStyle"
@click="handleClickModal" @touchmove.stop.prevent />
<!-- 面板层 -->
<view :class="panelClasses" :style="panelStyle">
<slot />
<view v-if="closable" class="uh-glass-popup__close" @click="close">
<text class="uh-glass-popup__close-icon">×</text>
</view>
</view>
</view>
</template>
<style scoped lang="scss">
/* 面板根元素(.wd-popup)同挂 custom-class,双类选择器提高优先级,覆盖 wot 默认纯白底 */
: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%);
.uh-glass-popup__mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgb(0 0 0 / 55%);
transition-timing-function: ease;
transition-duration: 300ms;
}
/* 低端 WebView 不支持 backdrop-filter 的兜底:提高不透明度保证可读性 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
:deep(.wd-popup.uh-glass-popup-panel) {
.uh-glass-popup-panel {
box-sizing: border-box;
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%);
}
}
:deep(.wd-popup--bottom){
left:24rpx;
bottom:24rpx;
right:24rpx;
/* 位置 */
.uh-glass-popup-panel--center {
left: 50%;
top: 50%;
transform: translate3d(-50%, -50%, 0);
transform-origin: 0 0;
}
</style>
.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>
@@ -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,5 +1,9 @@
<script setup lang="ts">
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
</script>
<template>
@@ -120,7 +120,7 @@
</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 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
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"
@click="handleToSearch()">
@@ -129,4 +129,11 @@
</view>
</view>
</view>
</template>
</template>
<style scoped lang="scss">
/* 向上偏移定位 */
.uh-translate-y-n6 {
transform: translateY(-1.5rem);
}
</style>
@@ -75,8 +75,8 @@
</script>
<template>
<view v-if="isEnableCategoryModule" class="mb-6">
<uh-section-title class="mb-4 px-3 box-border">
<view v-if="isEnableCategoryModule" class="overflow-hidden box-border mb-6 px-3">
<uh-section-title>
精选分类
<template #right>
<view class="uh-global-card-glass uh-shadow-xs border flex items-center justify-center rounded-md p-1 text-gray-400"
@@ -86,21 +86,21 @@
</template>
</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">
<uh-data-loading :loading-status="loading" min-height="28vh" size="small" :use-refresh-button="true"
@refresh="handleGetCategoryList()" />
</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"
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)">
<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">
<text class="text-sm font-bold">
<text class="text-2xs font-semibold">
{{ category.spec.displayName }}
</text>
<text class="mt-1 text-xs text-gray-200">共 {{ category.postCount ?? 0 }} 篇</text>
@@ -8,106 +8,26 @@
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
const calcIsShowQuickNavigationEnabled = computed(() => haloConfigs.value.pageConfig?.homeConfig?.useQuickNavigation)
interface QuickNavItem {
key : string
title ?: string
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: '#03A9F424',
iconPrefix: 'uhemoji2-icon',
icon: '-mask',
path: '/pages-blog/archives/archives',
visible: true,
},
{
key: 'vote',
title: '投票中心',
color: '#00BCD4',
bgColor: '#00BCD424',
iconPrefix: 'uhemoji2-icon',
icon: '-confused',
path: '/pages-blog/votes/votes',
visible: true,
},
{
key: 'disclaimers',
title: '友情链接',
color: '#009688',
bgColor: '#00968824',
iconPrefix: 'uhemoji2-icon',
icon: '-wink',
path: '/pages-blog/friend-links/friend-links',
visible: true,
},
{
key: 'love',
title: '恋爱日记',
color: '#FF4C67',
bgColor: '#FF4C6724',
iconPrefix: 'uhemoji2-icon',
icon: '-in-love',
path: '/pages-blog/love/love',
visible: true,
},
{
key: 'contact-blogger',
title: '联系博主',
color: '#FF9800',
bgColor: '#FF980024',
iconPrefix: 'uhemoji2-icon',
icon: '-cool',
path: '/pages-blog/contact/contact',
visible: true,
},
]
const navList = computed(() => {
const configured = haloConfigs.value.pageConfig?.homeConfig?.quickNavigation
let list : QuickNavItem[]
if (!useLocalNav && configured && configured.length) {
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)
return configured.filter(item => item.visible !== false)
})
function handleClickNav(item : { path ?: string }) {
if (!item.path)
return
if (!item.path) { return }
uni.navigateTo({ url: item.path })
}
</script>
<template>
<view v-if="calcIsShowQuickNavigationEnabled && navList.length"
class="box-border overflow-hidden rounded-xl p-3 px-4 mb-3">
<uh-section-title class="mb-4">
快捷导航
</uh-section-title>
<view class="grid grid-cols-5 gap-4">
class="box-border overflow-hidden rounded-xl p-3 mb-3">
<uh-section-title> 快捷导航 </uh-section-title>
<view class="mt-4 grid grid-cols-5 gap-4">
<view v-for="item in navList" :key="item.key" class="flex flex-col items-center gap-2"
@click="handleClickNav(item)">
<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="{
backgroundColor: item.bgColor
}">
@@ -121,4 +41,4 @@
</view>
</view>
</view>
</template>
</template>
@@ -1,41 +1,45 @@
<script lang="ts" setup>
/**
* 友链底部悬浮操作栏(通用组件)
* 通过 :actions 控制显示的按钮,事件回调 emit('apply') / emit('info')
* 站点 tab / 小程序 tab 分别引入(如 :actions="['apply','info']" @apply=... @info=...)
*/
withDefaults(defineProps<{
/** 需要显示的按钮:apply=提交申请,info=友链信息;包含即显示 */
actions?: string[]
}>(), {
actions: () => ['apply', 'info'],
})
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
const props = withDefaults(defineProps<{
/** 需要显示的按钮:apply=提交申请,info=友链信息;包含即显示 */
actions ?: string[]
}>(), {
actions: () => ['apply', 'info'],
})
const emit = defineEmits<{
(e: 'apply'): void
(e: 'info'): void
}>()
const emit = defineEmits<{
(e : 'apply') : void
(e : 'info') : void
}>()
</script>
<template>
<view class="fixed bottom-8 left-1/2 z-10 flex items-center justify-center pb-safe -translate-x-1/2">
<view class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
<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"
@click="emit('apply')"
>
<wd-icon name="edit" size="36rpx" />
<text class="shrink-0 text-sm text-gray-900 font-semibold">提交申请</text>
</view>
<view
v-if="actions.includes('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"
@click="emit('info')"
>
<wd-icon name="info" size="36rpx" />
<text class="shrink-0 text-sm text-gray-900 font-semibold">友链信息</text>
</view>
</view>
</view>
<view class="fixed bottom-8 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 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"
@click="emit('apply')">
<wd-icon name="edit" size="36rpx" />
<text class="shrink-0 text-sm text-gray-900 font-semibold">提交申请</text>
</view>
<view v-if="actions.includes('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"
@click="emit('info')">
<wd-icon name="info" size="36rpx" />
<text class="shrink-0 text-sm text-gray-900 font-semibold">友链信息</text>
</view>
</view>
</view>
</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 type { ICaptchaQuery, IPluginCaptcha } from '@/api/uni-halo'
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
const props = withDefaults(defineProps<{
show ?: boolean
}>(), {
@@ -1,213 +1,195 @@
<script lang="ts" setup>
/**
* 小程序友链信息弹窗
* 展示本站小程序申请提交的信息,字段结构与小程序提交申请弹窗(uh-links-mini-apply)一致:
* 小程序名称/太阳码/跳转地址/作者昵称/作者头像/作者网站/描述/申请说明/邮箱
* 数据源:插件端 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'
import { computed, ref, watch } from 'vue'
import { useAppConfigStore } from '@/store/appConfig'
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
const props = withDefaults(defineProps<{
show?: boolean
}>(), {
show: false,
})
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
const emit = defineEmits<{
(e: 'on-close'): void
}>()
const props = withDefaults(defineProps<{
show ?: boolean
}>(), {
show: false,
})
const isShow = ref(false)
const appConfigStore = useAppConfigStore()
const emit = defineEmits<{
(e : 'on-close') : void
}>()
/** 小程序申请信息(字段与 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 isShow = ref(false)
const appConfigStore = useAppConfigStore()
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'),
}
})
/** 复制跳转地址 */
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: '复制失败!' })
},
})
}
const hasInfo = computed(() => !!(miniInfo.value.displayName || miniInfo.value.miniProgramCode))
/** 复制小程序申请信息(拼接文案) */
function handleCopyInfo() {
const info = miniInfo.value
const text = [
info.displayName ? `小程序名称:${info.displayName}` : '',
info.link ? `小程序地址:${info.link}` : '',
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 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 handlePreviewCode() {
if (!miniInfo.value.miniProgramCode)
return
uni.previewImage({
urls: [checkImageUrl(miniInfo.value.miniProgramCode)],
current: checkImageUrl(miniInfo.value.miniProgramCode),
})
}
/** 复制小程序申请信息(拼接文案) */
function handleCopyInfo() {
const info = miniInfo.value
const text = [
info.displayName ? `小程序名称:${info.displayName}` : '',
info.link ? `小程序地址:${info.link}` : '',
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
emit('on-close')
}
/** 预览太阳码 */
function handlePreviewCode() {
if (!miniInfo.value.miniProgramCode)
return
uni.previewImage({
urls: [checkImageUrl(miniInfo.value.miniProgramCode)],
current: checkImageUrl(miniInfo.value.miniProgramCode),
})
}
watch(() => props.show, (val) => {
isShow.value = val
})
function handleClose() {
isShow.value = false
emit('on-close')
}
watch(() => props.show, (val) => {
isShow.value = val
})
</script>
<template>
<uh-glass-popup
v-model="isShow" :z-index="100" position="bottom"
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">
<text class="text-md font-bold">小程序友链信息</text>
<text class="text-xs text-gray-500">本站小程序申请提交的信息,欢迎互换</text>
</view>
<view
class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
@click="handleClose"
>
<wd-icon name="close" size="32rpx" class="text-gray-500" />
</view>
</view>
<uh-glass-popup v-model="isShow" :z-index="100" position="bottom" 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">
<text class="text-md font-bold">小程序友链信息</text>
<text class="text-xs text-gray-500">本站小程序申请提交的信息,欢迎互换</text>
</view>
<view class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
@click="handleClose">
<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">
<!-- 未配置信息占位 -->
<view v-if="!hasInfo" class="py-10 text-center text-xs text-gray-400">
暂未配置小程序申请信息
</view>
<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>
<template v-else>
<!-- 太阳码大图(点击预览) -->
<view v-if="miniInfo.miniProgramCode" class="code-area flex flex-col items-center">
<image
class="code-img h-32 w-32 rounded-xl"
:src="checkImageUrl(miniInfo.miniProgramCode)" mode="aspectFill"
@click="handlePreviewCode"
/>
<view class="code-tip mt-3 flex items-center text-xs text-gray-400">
<wd-icon name="picture" size="14px" color="#a8a294" />
<text class="ml-1">点击预览太阳码</text>
</view>
</view>
<template v-else>
<!-- 太阳码大图(点击预览) -->
<view v-if="miniInfo.miniProgramCode" class="code-area flex flex-col items-center">
<image class="code-img h-32 w-32 rounded-xl" :src="checkImageUrl(miniInfo.miniProgramCode)"
mode="aspectFill" @click="handlePreviewCode" />
<view class="code-tip mt-3 flex items-center text-xs text-gray-400">
<wd-icon name="picture" size="14px" color="#a8a294" />
<text class="ml-1">点击预览太阳码</text>
</view>
</view>
<!-- 名称 -->
<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>
</view>
<!-- 名称 -->
<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>
</view>
<!-- 描述 -->
<view v-if="miniInfo.description" class="mini-desc mt-4 text-[28rpx] text-gray-600 leading-[1.6]">
{{ miniInfo.description }}
</view>
<!-- 描述 -->
<view v-if="miniInfo.description" class="mini-desc mt-4 text-[28rpx] text-gray-600 leading-[1.6]">
{{ miniInfo.description }}
</view>
<!-- 作者信息 -->
<view
v-if="miniInfo.authorName || miniInfo.avatar || miniInfo.website"
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"
/>
<view class="author-detail ml-4 flex flex-1 flex-col">
<text
v-if="miniInfo.authorName"
class="author-name text-[28rpx] text-gray-900 font-medium"
>
{{ miniInfo.authorName }}
</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.authorName || miniInfo.avatar || miniInfo.website"
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" />
<view class="author-detail ml-4 flex flex-1 flex-col">
<text v-if="miniInfo.authorName" class="author-name text-[28rpx] text-gray-900 font-medium">
{{ miniInfo.authorName }}
</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 class="link-text flex-1 overflow-hidden truncate whitespace-nowrap text-[26rpx] text-[#4d7c0f]">
{{ miniInfo.link }}
</view>
<text class="ml-3 shrink-0 text-[26rpx] text-[#4d7c0f] font-bold" @click="handleCopyLink">复制</text>
</view>
<!-- 跳转地址 -->
<view v-if="miniInfo.link"
class="mini-link mt-5 flex items-center justify-between rounded-xl bg-secondary p-4">
<view
class="link-text flex-1 overflow-hidden truncate whitespace-nowrap text-[26rpx] text-[#4d7c0f]">
{{ miniInfo.link }}
</view>
<text class="ml-3 shrink-0 text-[26rpx] text-[#4d7c0f] font-bold" @click="handleCopyLink">复制</text>
</view>
<!-- 申请说明 / 邮箱 -->
<view
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"
>
<view v-if="miniInfo.applyRemark">
<text class="text-gray-400">申请说明:</text>{{ miniInfo.applyRemark }}
</view>
<view v-if="miniInfo.email">
<text class="text-gray-400">通知邮箱:</text>{{ miniInfo.email }}
</view>
</view>
<!-- 申请说明 / 邮箱 -->
<view 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">
<view v-if="miniInfo.applyRemark">
<text class="text-gray-400">申请说明:</text>{{ miniInfo.applyRemark }}
</view>
<view v-if="miniInfo.email">
<text class="text-gray-400">通知邮箱:</text>{{ miniInfo.email }}
</view>
</view>
<view class="my-6">
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyInfo">
复制小程序申请信息
</uh-button>
</view>
</template>
</scroll-view>
</uh-glass-popup>
</template>
<view class="my-6">
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyInfo">
复制小程序申请信息
</uh-button>
</view>
</template>
</scroll-view>
</uh-glass-popup>
</template>
@@ -1,202 +1,186 @@
<script lang="ts" setup>
/**
* 友链申请表单弹窗(站点版)
* 提交后等待站长审核,通过后展示在「站点」列表中
*/
import { ref, watch } from 'vue'
import { ref, watch } from 'vue'
const props = withDefaults(defineProps<{
show?: boolean
}>(), {
show: false,
})
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
const emit = defineEmits<{
(e: 'on-close', data: { isSubmit: boolean, refresh: boolean }): void
}>()
const props = withDefaults(defineProps<{
show ?: boolean
}>(), {
show: false,
})
const isShow = ref(false)
const emit = defineEmits<{
(e : 'on-close', data : { isSubmit : boolean, refresh : boolean }) : void
}>()
interface IApplyForm {
name: string
url: string
logo: string
linkPageUrl: string
email: string
rssUrl: string
description: string
}
const isShow = ref(false)
const form = ref<IApplyForm>({
name: '',
url: '',
logo: '',
linkPageUrl: '',
email: '',
rssUrl: '',
description: '',
})
interface IApplyForm {
name : string
url : string
logo : string
linkPageUrl : string
email : string
rssUrl : string
description : string
}
const submitting = ref(false)
const form = ref<IApplyForm>({
name: '',
url: '',
logo: '',
linkPageUrl: '',
email: '',
rssUrl: '',
description: '',
})
function handleResetForm() {
form.value = {
name: '',
url: '',
logo: '',
linkPageUrl: '',
email: '',
rssUrl: '',
description: '',
}
}
const submitting = ref(false)
function checkIsUrl(url: string): boolean {
return /^https?:\/\//i.test(url)
}
function handleResetForm() {
form.value = {
name: '',
url: '',
logo: '',
linkPageUrl: '',
email: '',
rssUrl: '',
description: '',
}
}
function checkIsEmail(email: string): boolean {
return /^[\w.-]+@[\w-]+(?:\.[\w-]+)+$/.test(email)
}
function checkIsUrl(url : string) : boolean {
return /^https?:\/\//i.test(url)
}
/** 提交校验 */
function validateForm(): boolean {
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
}
function checkIsEmail(email : string) : boolean {
return /^[\w.-]+@[\w-]+(?:\.[\w-]+)+$/.test(email)
}
/** 提交申请 */
async function handleSubmit() {
if (!validateForm())
return
/** 提交校验 */
function validateForm() : boolean {
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
}
// 第三方友链自助提交暂未开放
uni.showToast({ icon: 'none', title: '友链申请功能暂未开放,请联系站长' })
}
/** 提交申请 */
async function handleSubmit() {
if (!validateForm())
return
function handleOnChange(isOpen: boolean) {
isShow.value = isOpen
if (!isOpen)
emit('on-close', { isSubmit: false, refresh: false })
}
// 第三方友链自助提交暂未开放
uni.showToast({ icon: 'none', title: '友链申请功能暂未开放,请联系站长' })
}
function handleClose(refresh = false) {
isShow.value = false
emit('on-close', { isSubmit: true, refresh })
}
function handleOnChange(isOpen : boolean) {
isShow.value = isOpen
if (!isOpen)
emit('on-close', { isSubmit: false, refresh: false })
}
watch(() => props.show, (val) => {
if (!val)
return
isShow.value = true
handleResetForm()
})
function handleClose(refresh = false) {
isShow.value = false
emit('on-close', { isSubmit: true, refresh })
}
watch(() => props.show, (val) => {
if (!val)
return
isShow.value = true
handleResetForm()
})
</script>
<template>
<uh-glass-popup
v-model="isShow" :z-index="100" position="bottom"
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">
<text class="text-md font-bold">申请友链</text>
<text class="text-xs text-gray-500">提交后等待站长审核,通过后展示在「站点」列表中</text>
</view>
<view
class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
@click="handleClose(false)"
>
<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 pt-0">
<view class="mb-5 flex items-center">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">名称 *</text>
<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>
<uh-glass-popup v-model="isShow" :z-index="100" position="bottom" 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">
<text class="text-md font-bold">申请友链</text>
<text class="text-xs text-gray-500">提交后等待站长审核,通过后展示在「站点」列表中</text>
</view>
<view class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
@click="handleClose(false)">
<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 pt-0">
<view class="mb-5 flex items-center">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">名称 *</text>
<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">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">网址 *</text>
<input
v-model="form.url"
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">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">网址 *</text>
<input v-model="form.url"
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">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">Logo</text>
<input
v-model="form.logo"
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
placeholder="请输入网站Logo(选填)"
>
</view>
<view class="mb-5 flex items-center">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">Logo</text>
<input v-model="form.logo"
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
placeholder="请输入网站Logo(选填)">
</view>
<view class="mb-5 flex items-center">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">邮箱</text>
<input
v-model="form.email"
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">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">邮箱</text>
<input v-model="form.email"
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">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">友链页面</text>
<input
v-model="form.linkPageUrl"
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
placeholder="贵站友情链接页面地址(选填)"
>
</view>
<view class="mb-2 pl-[140rpx] text-xs text-gray-400 -mt-3">
(即包含本站链接的页面)
</view>
<view class="mb-5 flex items-center">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">友链页面</text>
<input v-model="form.linkPageUrl"
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
placeholder="贵站友情链接页面地址(选填)">
</view>
<view class="mb-2 pl-[140rpx] text-xs text-gray-400 -mt-3">
(即包含本站链接的页面)
</view>
<view class="mb-5 flex items-center">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">RSS地址</text>
<input
v-model="form.rssUrl"
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">
<text class="label w-[140rpx] shrink-0 text-sm text-[#666]">RSS地址</text>
<input v-model="form.rssUrl"
class="uh-global-card-glass h-9 flex-1 border rounded-xl px-4 text-sm shadow-none"
placeholder="用于抓取文章(选填)">
</view>
<view class="mb-5">
<text class="label mb-2 block text-sm text-[#666]">网站描述</text>
<textarea
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"
placeholder="请输入网站描述,不超过30字符(选填)" :maxlength="30"
/>
</view>
<view class="mb-5">
<text class="label mb-2 block text-sm text-[#666]">网站描述</text>
<textarea 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"
placeholder="请输入网站描述,不超过30字符(选填)" :maxlength="30" />
</view>
<view class="my-6">
<uh-button custom-class="py-2 !rounded-xl" :loading="submitting" @click="handleSubmit">
提交申请
</uh-button>
</view>
</scroll-view>
</uh-glass-popup>
</template>
<view class="my-6">
<uh-button custom-class="py-2 !rounded-xl" :loading="submitting" @click="handleSubmit">
提交申请
</uh-button>
</view>
</scroll-view>
</uh-glass-popup>
</template>
@@ -1,123 +1,115 @@
<script lang="ts" setup>
/**
* 站点友链信息弹窗
* 展示本站友链交换信息(博客名片 + 复制交换信息 + 站点缩略图)
* 数据源为插件端 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'
import { computed, ref, watch } from 'vue'
import { useAppConfigStore } from '@/store/appConfig'
import { checkAvatarUrl } from '@/utils/url'
const props = withDefaults(defineProps<{
show?: boolean
}>(), {
show: false,
})
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
const emit = defineEmits<{
(e: 'on-close'): void
}>()
const props = withDefaults(defineProps<{
show ?: boolean
}>(), {
show: false,
})
const isShow = ref(false)
const appConfigStore = useAppConfigStore()
const emit = defineEmits<{
(e : 'on-close') : void
}>()
const blogDetail = computed(() => (appConfigStore.configs.pluginConfig?.linkInfo?.siteInfo as {
displayName?: string
url?: string
logo?: string
description?: string
backlink?: string
feedUrls?: string[]
} | undefined) || {})
const isShow = ref(false)
const appConfigStore = useAppConfigStore()
/** 友链交换信息文案(复制用) */
const calcBlogContent = computed(() => `
博客名称:${blogDetail.value.displayName || ''}
博客地址:${blogDetail.value.url || ''}
博客logo:${checkAvatarUrl(blogDetail.value.logo)}
博客简介:${blogDetail.value.description || ''}
`)
const blogDetail = computed(() => (appConfigStore.configs.pluginConfig?.linkInfo?.siteInfo as {
displayName ?: string
url ?: string
logo ?: string
description ?: string
backlink ?: string
feedUrls ?: string[]
} | undefined) || {})
function calcSiteThumbnail(val?: string): string {
if (!val)
return ''
const _val = val.endsWith('/') ? val : `${val}/`
return `https://image.thum.io/get/width/1000/crop/800/${_val}`
}
/** 友链交换信息文案(复制用) */
const calcBlogContent = computed(() => `
博客名称:${blogDetail.value.displayName || ''}
博客地址:${blogDetail.value.url || ''}
博客logo:${checkAvatarUrl(blogDetail.value.logo)}
博客简介:${blogDetail.value.description || ''}
`)
function handleCopyLink() {
uni.setClipboardData({
data: calcBlogContent.value,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: '复制成功!' })
},
fail: () => {
uni.showToast({ icon: 'none', title: '复制失败!' })
},
})
}
function calcSiteThumbnail(val ?: string) : string {
if (!val) { return '' }
const _val = val.endsWith('/') ? val : `${val}/`
return `https://image.thum.io/get/width/1000/crop/800/${_val}`
}
function handleClose() {
isShow.value = false
emit('on-close')
}
function handleCopyLink() {
uni.setClipboardData({
data: calcBlogContent.value,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: '复制成功!' })
},
fail: () => {
uni.showToast({ icon: 'none', title: '复制失败!' })
},
})
}
watch(() => props.show, (val) => {
isShow.value = val
})
function handleClose() {
isShow.value = false
emit('on-close')
}
watch(() => props.show, (val) => {
isShow.value = val
})
</script>
<template>
<uh-glass-popup
v-model="isShow" :z-index="100" position="bottom"
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">
<text class="text-md font-bold">友链信息</text>
<text class="text-xs text-gray-500">本站友链交换信息,欢迎申请互换友链</text>
</view>
<view
class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
@click="handleClose"
>
<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">
<!-- 博客名片 -->
<view class="flex items-center">
<image
class="uh-global-card-glass h-20 w-20 shrink-0 rounded-2xl"
:src="checkAvatarUrl(blogDetail.logo)" mode="aspectFill"
/>
<view class="ml-4 flex flex-1 flex-col justify-center gap-y-1">
<text class="text-md text-gray-900 font-bold">
{{ blogDetail.displayName || '未命名博客' }}
</text>
<text class="text-xs text-gray-500">
{{ blogDetail.description || '这个博主很懒,没写简介~' }}
</text>
</view>
</view>
<uh-glass-popup v-model="isShow" :z-index="100" position="bottom" 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">
<text class="text-md font-bold">友链信息</text>
<text class="text-xs text-gray-500">本站友链交换信息,欢迎申请互换友链</text>
</view>
<view class="uh-global-card-glass absolute right-4 top-4 h-6 w-6 border rounded-lg text-center shadow-none"
@click="handleClose">
<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">
<!-- 博客名片 -->
<view class="flex items-center">
<image class="uh-global-card-glass h-20 w-20 shrink-0 rounded-2xl"
:src="checkAvatarUrl(blogDetail.logo)" mode="aspectFill" />
<view class="ml-4 flex flex-1 flex-col justify-center gap-y-1">
<text class="text-md text-gray-900 font-bold">
{{ blogDetail.displayName || '未命名博客' }}
</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">
<text>{{ calcBlogContent }}</text>
</view>
<!-- 交换信息文案 -->
<view class="mt-4 whitespace-pre-wrap text-xs text-gray-600 leading-5">
<text>{{ calcBlogContent }}</text>
</view>
<!-- 站点缩略图 -->
<image
v-if="blogDetail.url" class="mt-4 h-[320rpx] w-full rounded-xl"
:src="calcSiteThumbnail(blogDetail.url)" mode="aspectFill"
/>
<!-- 站点缩略图 -->
<image v-if="blogDetail.url" class="mt-4 h-[320rpx] w-full rounded-xl"
:src="calcSiteThumbnail(blogDetail.url)" mode="aspectFill" />
<view class="my-6">
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyLink">
复制友链交换信息
</uh-button>
</view>
</scroll-view>
</uh-glass-popup>
</template>
<view class="my-6">
<uh-button custom-class="py-2 !rounded-xl" @click="handleCopyLink">
复制友链交换信息
</uh-button>
</view>
</scroll-view>
</uh-glass-popup>
</template>
@@ -2,6 +2,12 @@
import { computed } from 'vue'
import { markdownConfig } from '@/config/markdown'
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
const props = withDefaults(defineProps<{
modelValue ?: boolean
content ?: string
@@ -30,18 +36,18 @@
<uh-glass-popup v-model="show" position="bottom" :z-index="100" :safe-area-inset-bottom="true"
custom-class="rounded-xl">
<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>
</view>
<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
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
copy-by-long-press />
</scroll-view>
<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>
</uh-glass-popup>
</template>
+48 -53
View File
@@ -1,39 +1,41 @@
<script setup lang="ts">
import { onPageScroll } from '@dcloudio/uni-app'
import { ref, computed, useSlots, onMounted } from 'vue'
import { computed, ref } from 'vue'
import { tabbarList } from '@/tabbar/config'
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
interface IProps {
useBack : boolean;
useTitle : boolean;
defaultTitle ?: string;
titleColor ?: string;
scrollTitle ?: string;
needPlaceholder ?: boolean;
backClass ?: string;
backStyle ?: string;
useBack : boolean
useTitle : boolean
defaultTitle ?: string
titleColor ?: string
scrollTitle ?: string
needPlaceholder ?: boolean
backClass ?: string
backStyle ?: string
scrollY ?: number
}
const props = withDefaults(defineProps<IProps>(), {
useBack: true,
useTitle: true,
needPlaceholder: true,
backClass: 'text-gray-900'
backClass: 'text-gray-900',
})
const slots = useSlots()
const scrollY = ref(0)
const maxAlpha = ref(0.65)
const maxAlpha = ref(0.65)
const customStyle = computed(() => {
const alpha = Math.min(scrollY.value / 360, maxAlpha.value)
const alpha = Math.min(props.scrollY / 360, maxAlpha.value)
return {
backgroundColor: `rgba(255, 255, 255, ${alpha})`,
}
})
const scrollThreshold = computed(() => {
return scrollY.value / 360 <= 0.5;
return props.scrollY / 360 <= 0.5
})
const customCalss = computed(() => {
@@ -44,7 +46,7 @@
else {
_class.push('text-gray-900')
}
return _class;
return _class
})
const titleColorClass = computed(() => {
@@ -53,12 +55,12 @@
const visibleTitle = computed(() => {
if (!props.scrollTitle) {
return props.defaultTitle;
return props.defaultTitle
}
if (scrollThreshold.value) {
return props.defaultTitle;
return props.defaultTitle
}
return props.scrollTitle;
return props.scrollTitle
})
// 如果是从分享进来的,我们需要处理为返回 home页面
@@ -69,52 +71,45 @@
homePage,
'pages/maintenance/maintenance',
...tabbarList.map((item : any) => item.pagePath),
] as string[];
] as string[]
})
function handleBack() {
const currentPage = getCurrentPages()[0]
if (!allEntryPages.value.some(pagePath => pagePath == currentPage.route)) {
uni.reLaunch({
url: `/${homePage}`
url: `/${homePage}`,
})
return;
return
}
uni.navigateBack({ delta: 1 })
}
onPageScroll((e : any) => {
scrollY.value = e.scrollTop
})
</script>
<template>
<view class="w-full box-border">
<view class="box-border pt-safe w-full fixed left-0 top-0 z-100" :class="customCalss" :style="[customStyle]">
<view class="w-full h-[46px] flex items-center gap-x-4 box-border px-3 backdrop-blur-[2rpx]">
<!-- 左边 -->
<view class="shrink-0 min-w-18" @click="handleBack()">
<view v-if="props.useBack"
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]">
<wd-icon name="arrow-left" size="34rpx"></wd-icon>
<view class="w-[1px] h-4 bg-white/60" />
<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 class="fixed left-0 top-0 z-100 box-border w-full pt-safe" :class="customCalss" :style="[customStyle]">
<view class="box-border h-[46px] w-full flex items-center gap-x-4 px-3" style="backdrop-filter: blur(2rpx);">
<!-- 左边 -->
<view class="min-w-18 shrink-0" @click="handleBack()">
<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="props.backClass" :style="[props.backStyle]">
<wd-icon name="arrow-left" size="30rpx" />
<view class="h-4 w-[1px] bg-white/60" />
<text class="text-[26rpx] font-bold">返回</text>
</view>
</view>
</view>
<view v-if="props.needPlaceholder" class="box-border w-full pt-safe">
<view class="w-full h-[46px]"></view>
<!-- 中间 -->
<view class="flex-1 truncate text-center font-bold transition-colors duration-300" :class="titleColorClass">
{{props.scrollY}} <slot> {{ visibleTitle }} </slot>
</view>
<!-- 右边 -->
<view class="min-w-18 shrink-0">
<slot name="right" />
</view>
</view>
</view>
<view v-if="props.needPlaceholder" class="box-border w-full pt-safe">
<view class="h-[46px] w-full" />
</view>
</template>
@@ -82,7 +82,7 @@
<view class="flex items-center justify-between">
<view class="flex items-center gap-2">
<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>
<view v-if="notice.typeDisplayName" class="rounded px-1.5 py-0.5 text-xs" :style="{
@@ -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>
@@ -74,7 +74,7 @@ function onTouchEnd() {
<slot />
</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
v-if="tipText"
class="tip-text mb-5 text-center leading-[1.4]"
@@ -154,4 +154,9 @@ function onTouchEnd() {
background-position: 0 50%;
}
}
/* 完全居中定位 */
.uh-translate-center {
transform: translate(-50%, -50%);
}
</style>
@@ -1,20 +1,16 @@
<script setup lang="ts">
import { useSlots } from 'vue'
const slots = useSlots();
const hasRightSlot = computed(() => !!slots.right?.())
</script>
<template>
<view class="w-full flex items-center justify-between">
<view class="shrink-0 relative">
<text class="font-bold relative z-2">
<slot></slot>
</text>
<view class="absolute z-1 -right-1 -bottom-0.5 rounded-xl bg-secondary h-4 w-4/5"></view>
</view>
<view v-if="hasRightSlot" class="flex-1 flex items-center justify-end">
<slot name="right"></slot>
</view>
</view>
</template>
<template>
<view class="w-full flex items-center justify-between">
<view class="relative shrink-0">
<text class="relative z-2 text-2xs font-semibold">
<slot />
</text>
<view class="absolute z-1 h-4 w-4/5 rounded-xl bg-secondary -bottom-0.5 -right-1" />
</view>
<view class="flex flex-1 items-center justify-end">
<slot name="right" />
</view>
</view>
</template>
@@ -5,6 +5,10 @@
fixed ?: boolean;
}
const emits = defineEmits<{
(e : 'action-click') : void
}>()
const props = withDefaults(defineProps<IProps>(), {
customClass: '',
fixed: true,
@@ -17,10 +21,15 @@
const visible = computed(() => {
return whiteList.includes(currentPage.route)
})
function handleClick() {
emits('action-click')
}
</script>
<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"
:class="props.customClass">
<wd-icon name="settings" size="42rpx" />
@@ -2,9 +2,23 @@
import { ref } from 'vue'
import { useSettingStore } from '@/store/setting'
import { usePreferenceRows } from '@/hooks/usePreferenceRows'
import { useSettingsPopup } from '@/hooks/useSettingsPopup'
import { isWechat } from '@/utils/platform'
const settingStore = useSettingStore()
defineOptions({
options: {
styleIsolation: 'apply-shared'
}
})
interface IProps {
/** v-model:是否显示 */
modelValue : boolean
}
const props = defineProps<IProps>()
const {
SETTING_TABS,
layoutGroups,
@@ -17,13 +31,21 @@
isCardTypeOptionDisabled,
} = 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 pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const filterLayoutGroups = computed(() => {
@@ -31,7 +53,7 @@
return currentPage.route.split('/').pop() === group.key
})
})
/* ---------------- 交互 ---------------- */
function currentValueOf(path : string[]) : string | null {
return isFollowing(path) ? null : String(prefValueOf(path) ?? '')
@@ -59,23 +81,20 @@
})
}
function onClose() {
emits('close')
}
function onOpen() {
emits('open')
function handleClose() {
emits('update:modelValue', false)
}
</script>
<template>
<uh-glass-popup v-model="settingsPopupVisible" position="bottom" custom-class="rounded-xl !border"
safe-area-inset-bottom :z-index="110" hide-when-close @close="onClose" @open="onOpen">
<uh-glass-popup v-model="popupVisible" position="bottom" custom-class="rounded-xl !border"
safe-area-inset-bottom :z-index="110" hide-when-close>
<view class="box-border px-3 pt-3">
<view class="mb-3 flex items-center justify-between">
<text class="text-md font-bold">偏好设置</text>
<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"
@click="onClose()">
@click="handleClose()">
<wd-icon name="close" size="16px" />
</view>
</view>
@@ -123,8 +142,7 @@
:class="[
currentValueOf(row.path) === opt.value ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500',
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 }}
</view>
</view>
@@ -148,9 +166,11 @@
<view v-if="row.kind === 'bool'" class="box-border p-3"
:class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''">
<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">
<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
class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">
已自定义
@@ -215,15 +235,16 @@
</scroll-view>
<!-- 底部操作栏 -->
<view class="box-border w-full pb-4 pt-3 flex items-center gap-x-2">
<uh-button custom-class="flex-1 uh-global-card-glass bg-white/90 border py-2 !rounded-xl"
@click="onClose()">
<view class="box-border w-full pt-3 flex items-center gap-x-2" :class="[isWechat?'':'pb-3']">
<uh-button class="flex-1" custom-class="flex-1 uh-global-card-glass bg-white/90 border py-2 !rounded-xl"
@click="handleClose()">
关闭
</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>
</view>
</view>
</uh-glass-popup>
</template>
</template>
@@ -6,7 +6,7 @@
}
const props = withDefaults(defineProps<IProps>(), {
customClass: '',
lineClass: '!h-2/5 -rotate-5',
lineClass: '!h-2/5 uh-rotate-n5',
textClass: 'font-bold'
})
</script>
@@ -19,4 +19,10 @@
<text class="absolute z-1 -right-1 -bottom-0.5 transform rounded-xl bg-secondary h-3/5 w-4/5" :class="[props.lineClass]"></text>
</text>
</template>
<style scoped lang="scss">
/* 下划线轻微旋转 */
.uh-rotate-n5 {
transform: rotate(-5deg);
}
</style>
+25 -27
View File
@@ -16,43 +16,41 @@ const LoadMoreStatusText = {
noNetwork: '呜呜,网络好像有点问题哦~'
} as const;
export type LoadMoreStatus = keyof typeof LoadMoreStatusText
export type LoadMoreStatus = keyof typeof LoadMoreStatusText;
/** 加载更多内部状态(完整形态,区别于可选的 LoadMoreStatusOption) */
export interface LoadMoreStatusState {
active: boolean;
hasNext: boolean;
status: LoadMoreStatus;
text: string;
active: boolean;
hasNext: boolean;
status: LoadMoreStatus;
text: string;
}
export interface LoadMoreStatusOption {
// 是否激活加载
active?: boolean;
status?: LoadMoreStatus;
text?: string;
hasNext?: boolean;
active?: boolean;
status?: LoadMoreStatus;
text?: string;
hasNext?: boolean;
}
export function useDataLoadingStatus(defaultStatus?: DataLoadingStatus) {
const loadingStatus = ref<DataLoadingStatus>(defaultStatus ?? DataLoadingStatusEnum.Loading);
const loadingStatus = ref<DataLoadingStatus>(defaultStatus ?? DataLoadingStatusEnum.Loading);
const _loadMoreStatus = ref<LoadMoreStatusState>({
active: false,
hasNext: false,
status: 'loadMore',
text: ''
});
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;
});
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;
+13
View File
@@ -0,0 +1,13 @@
import { ref } from 'vue';
import { onPageScroll } from '@dcloudio/uni-app';
export function usePageScroll() {
const scrollY = ref(0);
onPageScroll((e: any) => {
scrollY.value = e.scrollTop;
console.log('滚动数据', scrollY.value);
});
return { scrollY };
}
-1
View File
@@ -9,7 +9,6 @@ export function useSettingsPopup() {
function closeSettingsPopup() {
settingsPopupVisible.value = false;
console.log('Settings popup closed', settingsPopupVisible.value);
}
return { settingsPopupVisible, openSettingsPopup, closeSettingsPopup };
+1 -3
View File
@@ -3,9 +3,7 @@
"tabbar.category": "Category",
"tabbar.gallery": "Gallery",
"tabbar.moments": "Moments",
"tabbar.about": "About",
"tabbar.me": "Me",
"tabbar.i18n": "I18n",
"tabbar.mine": "About",
"page.home.title": "Home",
"page.category.title": "Category",
"page.gallery.title": "Gallery",
+1 -3
View File
@@ -3,9 +3,7 @@
"tabbar.category": "分类",
"tabbar.gallery": "图库",
"tabbar.moments": "瞬间",
"tabbar.about": "关于",
"tabbar.me": "我的",
"tabbar.i18n": "多语言",
"tabbar.mine": "关于",
"page.home.title": "首页",
"page.category.title": "分类",
"page.gallery.title": "图库",
+9 -10
View File
@@ -2,6 +2,7 @@
import { onLoad } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { checkUrl } from '@/utils/url'
import { usePageScroll } from '@/hooks/usePageScroll'
definePage({
style: {
@@ -10,7 +11,8 @@
},
})
const appConfigStore = useAppConfigStore()
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const appInfo = computed(() => {
return {
@@ -20,8 +22,7 @@
})
const links = [
{ title: '开源组织', value: '巷子工坊', copy: 'https://www.ialley.cn', tip: '巷子工坊官网已复制成功!', tileColor: '#5c6bc0', tileLetter: '组' },
{ title: '开源作者', value: '小莫唐尼', copy: 'https://www.xiaoxiaomo.cn', tip: '作者主页地址已复制', tileColor: '#26a69a', tileLetter: '作' },
{ title: '小莫唐尼', value: 'https://www.xiaoxiaomo.cn', 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://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: '码' },
@@ -46,14 +47,15 @@
<template>
<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)] blur-xl" />
<view class="fixed -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl" />
<view class="relative">
<view class="uh-global-card-glass relative flex flex-col items-center rounded-2xl px-6 pb-7 pt-10">
<image class="uh-global-card-glass uh-shadow-xs border h-18 w-18 rounded-2xl" :src="appInfo.logo" mode="aspectFill" />
<image class="uh-global-card-glass uh-shadow-xs border h-18 w-18 rounded-2xl" :src="appInfo.logo"
mode="aspectFill" />
<view class="mt-4 text-xl text- font-bold">
{{appInfo.name}}
</view>
@@ -68,7 +70,7 @@
</view>
<uh-section-title class="mb-3 mt-6"> 相关链接 </uh-section-title>
<view class="box-border uh-global-card-glass flex flex-col gap-y-6 rounded-2xl py-4">
<view v-for="(link) in links" :key="link.title" class="flex items-center gap-3 px-4"
@click="copyText(link.copy, link.tip)">
@@ -87,9 +89,6 @@
</view>
</view>
<!-- 版权 -->
<view class="copyright mt-auto pt-8 text-center text-[22rpx] text-gray-400">
<view>「 2022 uni-halo 丨 开源项目丨巷子工坊@小莫唐尼 」</view>
</view>
<uh-page-copyright />
</view>
</template>
+3 -1
View File
@@ -4,6 +4,7 @@ import { onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getPostList } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
import { useSettingStore } from '@/store/setting'
import { usePageScroll } from '@/hooks/usePageScroll'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { sleep } from '@/utils/common'
import type { IPost } from '@/api/types/halo'
@@ -16,6 +17,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -252,7 +254,7 @@ onReachBottom(() => {
<template>
<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>
@@ -3,6 +3,7 @@
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { getPostByName, getPostCommentReplyList, postTrackersCounter } from '@/api/halo'
import { useUpvote } from '@/hooks/useUpvote'
import { usePageScroll } from '@/hooks/usePageScroll'
import { createVerificationCode, requestRestrictReadCheck } from '@/api/uni-halo'
import { formatTime } from '@/utils/formatTime'
import { useAppConfigStore } from '@/store/appConfig'
@@ -25,6 +26,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const favoritesStore = useFavoritesStore()
const settingStore = useSettingStore()
@@ -297,8 +299,6 @@
/* ---------------- 评论 ---------------- */
function handleToComment() {
console.log('calcIsShowComment.value', calcIsShowComment.value)
console.log('result.value', result.value)
if (!result.value) {
return
}
@@ -442,17 +442,17 @@
})
const globalAppSettings = computed(() => settingStore.settings)
onMounted(() => {
console.log('获取当前所有的页面')
console.log(getCurrentPages())
onPageScroll((e : any) => {
console.log('滚动', e)
})
</script>
<template>
<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"
@refresh="handleGetData()" />
@@ -465,12 +465,12 @@
</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="{
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">
<image :src="result.owner.avatar" class="uh-global-card-glass block h-6 w-6 rounded-full"
mode="aspectFill" />
@@ -525,7 +525,7 @@
</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-3 p-4 pt-2 text-gray-900 text-3xs">
<!-- 受限阅读 -->
<template v-if="checkPostRestrictRead(result!)">
<view v-if="showContentArr.length === 0">
@@ -565,14 +565,14 @@
<view v-if="postDetailConfig?.copyrightEnabled" class="box-border px-2 mb-3">
<view class="uh-global-card-glass uh-shadow-xs rounded-xl p-3">
<uh-section-title>版权声明</uh-section-title>
<view class="mt-3 flex flex-col gap-y-2 text-gray-600">
<view v-if="postDetailConfig.copyrightAuthor" class="text-sm leading-5">
<view class="mt-3 flex flex-col gap-y-2 text-gray-600 text-2xs">
<view v-if="postDetailConfig.copyrightAuthor" class="leading-5">
版权归属:{{ postDetailConfig.copyrightAuthor }}
</view>
<view v-if="postDetailConfig.copyrightDesc" class="text-sm leading-5">
<view v-if="postDetailConfig.copyrightDesc" class="leading-5">
版权说明:{{ postDetailConfig.copyrightDesc }}
</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 }}
</view>
</view>
@@ -581,36 +581,38 @@
<!-- 评论区域 -->
<view class="box-border px-2">
<uh-comment-list v-if="calcIsShowComment && result" :disallow-comment="!result.spec.allowComment"
:post-name="result.metadata.name" :post="result" @on-comment="handleOnComment"
@on-comment-detail="handleOnShowCommentDetail" @on-loaded="handleCommentLoaded" />
<uh-comment-list v-if="calcIsShowComment && result"
:disallow-comment="!result.spec.allowComment" :post-name="result.metadata.name"
:post="result" @on-comment="handleOnComment" @on-comment-detail="handleOnShowCommentDetail"
@on-loaded="handleCommentLoaded" />
</view>
</view>
</view>
<!-- 悬浮操作 -->
<view class="fixed bottom-8 left-1/2 z-10 flex items-center justify-center pb-safe -translate-x-1/2">
<!-- #7BE200 -->
<view class="fixed bottom-4 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
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" />
<text class="shrink-0 text-sm text-gray-900 font-semibold">点赞</text>
<text class="shrink-0 text-3xs font-semibold">点赞</text>
</view>
<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"
@click="handleToComment()">
<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-3xs text-gray-900 font-semibold">评论</text>
</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"
@click="handleTogglePostFavorite">
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
<text class="shrink-0 text-sm text-gray-900 font-semibold"
:style="hasFavorited() ? { color: '#ffb300' } : ''">{{ hasFavorited() ? '已收藏' : '收藏' }}</text>
<text class="shrink-0 text-3xs font-semibold"
:class="[hasFavorited()?'text-primary':'text-gray-900']">
{{ hasFavorited() ? '已收藏' : '收藏' }}
</text>
</view>
</view>
</view>
@@ -638,4 +640,16 @@
<uh-comment-modal v-if="commentModal.show" :show="commentModal.show" :is-comment="commentModal.isComment"
:title="commentModal.title" :post-name="commentModal.postName" @on-close="handleOnCommentModalClose" />
</view>
</template>
</template>
<style scoped lang="scss">
/* 内容区域上移 */
.uh-content-lift {
transform: translateY(-3rem);
}
/* 水平居中定位 */
.uh-translate-x-center {
transform: translateX(-50%);
}
</style>
+3 -1
View File
@@ -4,6 +4,7 @@ import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getCategoryList, getCategoryPostList, getPostList } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
import { useSettingStore } from '@/store/setting'
import { usePageScroll } from '@/hooks/usePageScroll'
import { checkAvatarUrl } from '@/utils/url'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { sleep } from '@/utils/common'
@@ -17,6 +18,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -200,7 +202,7 @@ onReachBottom(() => {
<template>
<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">
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap pt-2">
@@ -13,6 +13,7 @@ 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'
definePage({
@@ -22,6 +23,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
const name = ref('')
const detail = ref<IBannerPublicDetail | null>(null)
@@ -106,7 +108,7 @@ function handleOpenLink() {
<template>
<view class="box-border min-h-screen w-screen bg-page pb-safe">
<!-- 自定义导航 -->
<uh-navbar default-title="轮播详情" title-color="text-gray-900" :scroll-title="detail?.title" />
<uh-navbar :scroll-y="scrollY" default-title="轮播详情" title-color="text-gray-900" :scroll-title="detail?.title" />
<!-- 加载/错误/空态(状态机) -->
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="75vh"
@@ -4,6 +4,7 @@ import { onLoad, onPullDownRefresh, onReachBottom, onShareAppMessage, onShareTim
import { getCategoryPostList } from '@/api/halo'
import { sleep } from '@/utils/common'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import type { IPost, IPostListReq } from '@/api/types/halo'
definePage({
@@ -14,6 +15,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
const queryParams = ref({ size: 10, page: 0 })
const name = ref('')
@@ -137,7 +139,7 @@ onShareTimeline(() => ({
<template>
<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">
+161 -144
View File
@@ -1,162 +1,179 @@
<script lang="ts" setup>
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { checkAvatarUrl } from '@/utils/url'
import { formatTime } from '@/utils/formatTime'
import { markdownConfig } from '@/config/markdown'
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { checkAvatarUrl } from '@/utils/url'
import { formatTime } from '@/utils/formatTime'
import { markdownConfig } from '@/config/markdown'
definePage({
style: {
navigationBarTitleText: '联系博主',
navigationStyle: 'custom',
},
})
definePage({
style: {
navigationBarTitleText: '联系博主',
navigationStyle: 'custom',
},
})
interface ISoical {
name : string
content : string
color : string,
bgColor : string,
priority ?: number,
visible ?: boolean,
}
interface ISoical {
name: string
content: string
color: string
bgColor: string
priority?: number
visible?: boolean
}
const appConfigStore = useAppConfigStore()
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
const bloggerInfo = computed(() => {
const blogger = authorConfig.value?.blogger as { nickname ?: string, avatar ?: string, description ?: string, intro ?: string } | undefined
return {
nickname: blogger?.nickname || '',
avatar: checkAvatarUrl(blogger?.avatar),
description: blogger?.description || '',
intro: blogger?.intro || '',
}
})
const bloggerInfo = computed(() => {
const blogger = authorConfig.value?.blogger as { nickname?: string, avatar?: string, description?: string, intro?: string } | undefined
return {
nickname: blogger?.nickname || '',
avatar: checkAvatarUrl(blogger?.avatar),
description: blogger?.description || '',
intro: blogger?.intro || '',
}
})
const socialConfig = computed(() => (authorConfig.value?.social as { items ?: ISoical[] } | undefined) || {})
const socialConfig = computed(() => (authorConfig.value?.social as { items?: ISoical[] } | undefined) || {})
const socialList = computed<Array<ISoical>>(() => {
const configured = socialConfig.value.items
if (!configured || !configured.length) {
return []
}
return [...configured]
.filter(item => item.visible && item.content.trim())
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
})
const socialList = computed<Array<ISoical>>(() => {
const configured = socialConfig.value.items
if (!configured || !configured.length) {
return []
}
return [...configured]
.filter(item => item.visible && item.content.trim())
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
})
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && item.content.trim()))
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && item.content.trim()))
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
watchEffect(() => {
updateLoadingStatus(isNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
})
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
watchEffect(() => {
updateLoadingStatus(isNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
})
function handleOnClick(item : ISoical) {
if (!item.content) { return }
uni.setClipboardData({
data: item.content,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
},
})
}
function handleOnClick(item: ISoical) {
if (!item.content) { return }
uni.setClipboardData({
data: item.content,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
},
})
}
const nowText = ref('')
let clock : ReturnType<typeof setInterval> | null = null
function refreshNowText() {
nowText.value = formatTime({ d: Date.now(), f: 'yyyy年MM月dd日' })
}
refreshNowText()
clock = setInterval(refreshNowText, 1000)
onUnmounted(() => {
if (clock) {
clearInterval(clock)
}
})
const nowText = ref('')
let clock: ReturnType<typeof setInterval> | null = null
function refreshNowText() {
nowText.value = formatTime({ d: Date.now(), f: 'yyyy年MM月dd日' })
}
refreshNowText()
clock = setInterval(refreshNowText, 1000)
onUnmounted(() => {
if (clock) {
clearInterval(clock)
}
})
</script>
<template>
<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" />
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
<!-- 自定义导航 -->
<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 -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl" />
<view class="fixed top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] blur-xl -right-8" />
<view class="fixed top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl -left-10" />
<view
class="box-border relative flex items-center justify-between uh-global-card-glass uh-shadow-xs rounded-xl p-4">
<view class="flex-1 relative flex flex-col rounded-2xl">
<view class="flex items-center gap-x-2 text-xs text-primary">
TO <text class="text-sm">·</text> 收
</view>
<view class="mt-2 text-md text-gray-900 tracking-wider">
素未谋面的朋友
</view>
<view class="mt-2 text-xs text-black/60">
展信安,见字如面。
</view>
<view class="mt-3 text-xs text-black/60">
自 · {{ bloggerInfo.nickname }}
</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">
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
<text class="text-xs font-normal truncate">{{ bloggerInfo.nickname }}</text>
</view>
</view>
<view
class="uh-global-card-glass uh-shadow-xs relative box-border flex items-center justify-between rounded-xl p-4"
>
<view class="relative flex flex-1 flex-col rounded-2xl">
<view class="flex items-center gap-x-2 text-xs text-primary">
TO <text class="text-sm">·</text> 收
</view>
<view class="text-md mt-2 text-gray-900 tracking-wider">
素未谋面的朋友
</view>
<view class="mt-2 text-xs text-black/60">
展信安,见字如面。
</view>
<view class="mt-3 text-xs text-black/60">
自 · {{ bloggerInfo.nickname }}
</view>
</view>
<view
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" />
<text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text>
</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">
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh"
empty-text="暂无联系方式" empty-sub-text="" />
<template v-else>
<view class="w-full flex flex-col gap-y-3">
<view class="text-md text-gray-900">
展信安:
</view>
<view v-if="bloggerInfo.intro" class="text-gray-900 text-sm">
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
:loading-img="markdownConfig.loadingGif" scroll-table selectable
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
:show-language-name="true" copy-by-long-press />
</view>
<view v-else class="text-gray-600 text-sm py-4">
祝你早安,午安,晚安。每天都有好心情,生活愉快!
</view>
<view class="mt-2 w-full flex items-end flex-col gap-y-3">
<text class="text-md font-semibold text-gray-900">{{ bloggerInfo.nickname }}</text>
<text class="text-xs text-black/60">{{ nowText }}</text>
</view>
</view>
<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"
empty-text="暂无联系方式" empty-sub-text=""
/>
<template v-else>
<view class="w-full flex flex-col gap-y-3">
<view class="text-md text-gray-900">
展信安:
</view>
<view v-if="bloggerInfo.intro" class="text-sm text-gray-900">
<mp-html
lazy-load :domain="markdownConfig.domain ?? ''"
:loading-img="markdownConfig.loadingGif" scroll-table selectable
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
:show-language-name="true" copy-by-long-press
/>
</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>
</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="mb-2 text-md text-gray-900">
若有意,可依此觅:
</view>
<view v-for="item in socialList" :key="item.name" class="flex items-center gap-3"
@click="handleOnClick(item)">
<view
class="uh-global-card-glass uh-shadow-xs border h-11 w-11 flex shrink-0 items-center justify-center rounded-xl"
:style="{ backgroundColor: item.bgColor ,color:item.color }">
<text class="text-sm font-bold" :style="{ color:item.color }">
{{ item.name ? item.name.charAt(0) : '' }}
</text>
</view>
<view class="min-w-0 flex flex-1 flex-col">
<text class="text-xs text-gray-500" >{{ item.name }}</text>
<view class="mt-1 break-all text-xs text-gray-900">
{{ item.content }}
</view>
</view>
<wd-icon name="copy" size="28rpx" class="shrink-0 text-primary" />
</view>
</view>
</template>
</view>
</view>
</template>
<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"
@click="handleOnClick(item)"
>
<view
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 }"
>
<text class="text-sm font-bold" :style="{ color: item.color }">
{{ item.name ? item.name.charAt(0) : '' }}
</text>
</view>
<view class="min-w-0 flex flex-1 flex-col">
<text class="text-xs text-gray-500">{{ item.name }}</text>
<view class="mt-1 break-all text-xs text-gray-900">
{{ item.content }}
</view>
</view>
<wd-icon name="copy" size="28rpx" class="shrink-0 text-primary" />
</view>
</view>
</template>
</view>
</view>
</template>
<style scoped lang="scss">
.uh-rotate-3 {
transform: rotate(3deg);
}
</style>
+3 -1
View File
@@ -3,6 +3,7 @@
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { getChartData } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
import type { IDataStatistics } from '@/api/uni-halo'
import { sleep } from '@/utils/common'
@@ -16,6 +17,7 @@
})
/** 依赖插件(plugin-data-statistics,参考 gallery 对象传参模式) */
const { scrollY } = usePageScroll()
const { pluginId, checking, tips, available: uniHaloPluginAvailable, check: checkPluginAvailable } = usePluginAvailable({
pluginId: NeedPluginIds.PluginDataStatistics,
tips: '阿偶,检测到当前插件没有安装或者启用,无法使用功能哦,请联系管理员',
@@ -171,7 +173,7 @@
<template>
<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"
:checking="checking" @on-refresh="handlePluginRefresh" />
+3 -1
View File
@@ -4,6 +4,7 @@
*/
import { computed } from 'vue'
import { useAppConfigStore } from '@/store/appConfig'
import { usePageScroll } from '@/hooks/usePageScroll'
definePage({
style: {
@@ -12,6 +13,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const haloConfigs = computed(() => appConfigStore.configs)
@@ -42,7 +44,7 @@
<template>
<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">
<!-- 通过配置 -->
+3 -1
View File
@@ -3,6 +3,7 @@ import { computed, ref, watchEffect } from 'vue'
import { formatTime } from '@/utils/formatTime'
import { useFavoritesStore } from '@/store/favorites'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import type { FavoriteKind, IFavoriteItem } from '@/utils/favorite'
definePage({
@@ -12,6 +13,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const favoritesStore = useFavoritesStore()
/* ---------------- Tab(文章/瞬间) ---------------- */
@@ -70,7 +72,7 @@ const emptyText = computed(() => (activeKind.value === 'post' ? '还没有收藏
<template>
<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) -->
<wd-sticky>
+3 -1
View File
@@ -7,6 +7,7 @@ import { useAppConfigStore } from '@/store/appConfig'
import { useSettingStore } from '@/store/setting'
import { sleep } from '@/utils/common'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
import type { ILink, ILinkGroup } from '@/api/types/halo'
@@ -20,6 +21,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const settingStore = useSettingStore()
@@ -407,7 +409,7 @@ onReachBottom(() => {
<template>
<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>
+3 -1
View File
@@ -9,6 +9,7 @@ import { getCache, setCache } from '@/utils/storage'
import { handleLoveModuleLocked } from '@/utils/loveModuleToken'
import { sleep } from '@/utils/common'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import type { ILoveAlbum, ILovePhoto } from '@/api/types/uni-halo'
definePage({
@@ -19,6 +20,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const loveConfig = computed(() => appConfigStore.configs.loveConfig)
@@ -240,7 +242,7 @@ onReachBottom(() => {
<template>
<view class="app-page box-border min-h-screen w-screen flex flex-col pb-safe">
<!-- 自定义导航 -->
<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
+4 -1
View File
@@ -6,6 +6,7 @@
import { checkImageUrl } from '@/utils/url'
import { sleep } from '@/utils/common'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import type { ILoveDailyItem } from '@/api/types/uni-halo'
definePage({
@@ -16,6 +17,8 @@
},
})
const { scrollY } = usePageScroll()
/* ---------------- 展示层类型 ---------------- */
/** 清单展示卡片(script 预处理后的干净展示数据) */
interface ILoveItemCard {
@@ -278,7 +281,7 @@
<template>
<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>
<view class="box-border px-3 pb-1 pt-2">
+111 -151
View File
@@ -5,6 +5,8 @@
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
import { getPluginCaptcha, unlockLoveModule, type ICaptchaQuery, type IPluginCaptcha } from '@/api/uni-halo'
import { getLoveModuleToken, setLoveModuleToken, type LoveModuleKey } from '@/utils/loveModuleToken'
import { usePageScroll } from '@/hooks/usePageScroll'
import type { ILoveConfigGroup, ILoveModuleConfig } from '@/api/types/uni-halo'
definePage({
style: {
@@ -13,127 +15,72 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
/* ---------------- 恋爱配置 ---------------- */
interface ILoveConfigPage {
/** 恋爱配置(数据源为 getConfigs.loveConfig 组:恋爱日记仅密码状态;
* 三模块入口即 app 端入口列表数据,2026-09-12 起 /love-config 已下线) */
interface ILoveConfigPage extends Partial<ILoveConfigGroup> {
enabled : boolean
loveDateTitle : string
loveDate : string
loveInfo : {
boyNickname : string
boyAvatar : string
girlNickname : string
girlAvatar : string
}
pageImages : {
bgImageUrl : string
waveImageUrl : string
heartImageUrl : string
}
loveDiary : { enabled : boolean, passwordEnabled ?: boolean }
ourStory : { enabled : boolean, passwordEnabled ?: boolean }
lovePhoto : { enabled : boolean, passwordEnabled ?: boolean }
loveDaily : { enabled : boolean, passwordEnabled ?: boolean }
navList ?: ILoveNavItem[]
[key : string] : unknown
}
interface ILoveNavItem {
key : string
title ?: string
subTitle ?: string
priority ?: number
visible ?: boolean
}
const loveConfig = ref<ILoveConfigPage>({
enabled: false,
loveDateTitle: '',
loveDate: '',
loveInfo: {
boyNickname: '',
boyAvatar: '',
girlNickname: '',
girlAvatar: '',
},
pageImages: {
bgImageUrl: '',
waveImageUrl: '',
heartImageUrl: '',
},
loveDiary: { enabled: false, passwordEnabled: false },
loveDiary: { passwordEnabled: false },
ourStory: { enabled: false, passwordEnabled: false },
lovePhoto: { enabled: false, passwordEnabled: false },
loveDaily: { enabled: false, passwordEnabled: false },
})
/** 恋爱页背景图 */
const loveBgImage = ref('')
const loveDayCount = ref({ d: 0, h: 0, m: 0, s: 0 })
let loveDayTimer : ReturnType<typeof setTimeout> | null = null
interface ILoveNavRenderItem {
key : string
moduleKey : LoveModuleKey
use : boolean
locked: boolean
locked : boolean
iconPrefix : string
icon : string
/** 跳转路径(插件下发,直接 navigateTo) */
path : string
title : string
subTitle : string
}
const useLocalNav = false
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 },
]
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' },
titleColor : string
subTitleColor : string
iconBgColor : string
}
const navList = ref<ILoveNavRenderItem[]>([])
/* ---------------- 数据加载 ---------------- */
function syncLoveConfigFromStore() {
const storeLove = appConfigStore.loveConfig
const appConfigs = appConfigStore.configs
const loveConfigs = appConfigStore.configs.loveConfig
loveConfig.value = {
...loveConfig.value,
...(storeLove.loveDateTitle ? { loveDateTitle: storeLove.loveDateTitle } : {}),
...(storeLove.loveDate ? { loveDate: storeLove.loveDate } : {}),
...(storeLove.enabled !== undefined ? { enabled: storeLove.enabled } : {}),
loveInfo: {
...loveConfig.value.loveInfo,
...(storeLove.loveInfo || {}),
},
...(loveConfigs?.loveInfo?.loveDateTitle ? { loveDateTitle: loveConfigs.loveInfo.loveDateTitle } : {}),
...(loveConfigs?.loveInfo?.loveDate ? { loveDate: loveConfigs.loveInfo.loveDate } : {}),
}
const loveModuleConfig = appConfigs.loveConfig as Partial<ILoveConfigPage> | undefined
// 恋爱页背景图:2026-09-11 起插件端由 loveConfig.pageImages 迁至
// pageConfig.loveDiaryConfig.bgImageUrl,优先读新位置、兼容回退旧值
const loveDiaryPageConfig = appConfigs.pageConfig?.loveDiaryConfig as
// 恋爱页背景图:读自 pageConfig.loveDiaryConfig.bgImageUrl
const loveDiaryPageConfig = appConfigStore.configs.pageConfig?.loveDiaryConfig as
{ bgImageUrl ?: string } | undefined
const pageImagesBg =
loveDiaryPageConfig?.bgImageUrl
|| loveModuleConfig?.pageImages?.bgImageUrl
|| loveConfig.value.pageImages.bgImageUrl
if (loveModuleConfig || loveDiaryPageConfig) {
loveBgImage.value = loveDiaryPageConfig?.bgImageUrl || ''
if (loveConfigs) {
loveConfig.value = {
...loveConfig.value,
pageImages: {
...loveConfig.value.pageImages,
bgImageUrl: pageImagesBg,
},
loveDiary: loveModuleConfig?.loveDiary || loveConfig.value.loveDiary,
ourStory: loveModuleConfig?.ourStory || loveConfig.value.ourStory,
lovePhoto: loveModuleConfig?.lovePhoto || loveConfig.value.lovePhoto,
loveDaily: loveModuleConfig?.loveDaily || loveConfig.value.loveDaily,
navList: loveModuleConfig?.navList || loveConfig.value.navList,
loveDiary: loveConfigs.loveDiary || loveConfig.value.loveDiary,
ourStory: loveConfigs.ourStory || loveConfig.value.ourStory,
lovePhoto: loveConfigs.lovePhoto || loveConfig.value.lovePhoto,
loveDaily: loveConfigs.loveDaily || loveConfig.value.loveDaily,
}
}
@@ -143,37 +90,36 @@
}
}
/** 入口列表:由三模块配置构建(模块 key 即唯一标识,图标/跳转路径均用插件下发字段) */
function initList() {
const configs = loveConfig.value
const configured = configs.navList
let source : ILoveNavItem[]
if (!useLocalNav && configured && configured.length) {
source = configured
} else {
source = DEFAULT_NAV_LIST;
}
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) {
const moduleKeys : LoveModuleKey[] = ['ourStory', 'lovePhoto', 'loveDaily']
// 插件端已按 priority 降序输出,此处仍按 priority 排序兜底(缺失视为 0)
const sorted = [...moduleKeys].sort((a, b) =>
((configs[b] as ILoveModuleConfig | undefined)?.priority ?? 0) -
((configs[a] as ILoveModuleConfig | undefined)?.priority ?? 0))
navList.value = sorted.map((moduleKey) => {
const moduleCfg = configs[moduleKey] as ILoveModuleConfig | undefined
if (!moduleCfg) {
return null
}
const moduleKey = MODULE_KEY_MAP[item.key]
const moduleCfg = moduleKey
? (configs[moduleKey] as { enabled ?: boolean, passwordEnabled ?: boolean } | undefined)
: undefined
const fallback = DEFAULT_NAV_LIST.find((d) => d.key === item.key)
return {
key: item.key,
use: !!moduleCfg?.enabled && item.visible !== false,
// 模块设了密码且本地无有效 token → 显示 lock;解锁后恢复箭头
locked: !!moduleCfg?.passwordEnabled && !(moduleKey && getLoveModuleToken(moduleKey)),
iconPrefix: meta.iconPrefix,
icon: meta.icon,
title: item.title || fallback?.title || '',
subTitle: item.subTitle || fallback?.subTitle || '',
moduleKey,
use: !!moduleCfg.enabled,
// 模块设了密码且本地无有效 token → 锁定态;解锁后恢复箭头
locked: !!moduleCfg.passwordEnabled && !getLoveModuleToken(moduleKey),
// 图标/跳转路径直接消费插件下发字段(不再本地映射)
iconPrefix: moduleCfg.iconPrefix || 'uhlove-icon',
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)
}
/* ---------------- 恋爱计时 ---------------- */
@@ -202,36 +148,37 @@
}
/* ---------------- 跳转(模块密码拦截) ---------------- */
const MODULE_KEY_MAP: Record<string, LoveModuleKey> = {
stories: 'ourStory',
album: 'lovePhoto',
list: 'loveDaily',
}
/** 模块密码弹窗状态 */
const unlockModalVisible = ref(false)
const pendingPage = ref('')
/** 待跳转路径(模块下发的完整 path,解锁成功后 navigateTo) */
const pendingPath = ref('')
const pendingModule = ref<LoveModuleKey>('ourStory')
/** 恋爱日记入口(love 页本身)是否锁定:设了密码且本地无有效 token */
const loveDiaryLocked = computed(() =>
!!loveConfig.value.loveDiary?.passwordEnabled && !getLoveModuleToken('loveDiary'))
function handleToPage(pageName : string) {
const module = MODULE_KEY_MAP[pageName]
const moduleCfg = module
? (loveConfig.value[module] as { enabled ?: boolean, passwordEnabled ?: boolean })
: undefined
const unlockTip = computed(() => {
const moduleCfg = loveConfig.value[pendingModule.value] as ILoveModuleConfig | undefined
const tip = moduleCfg?.title || ''
return `${tip}已设置访问密码,输入后进入`
})
function handleToPage(moduleKey : LoveModuleKey) {
const moduleCfg = loveConfig.value[moduleKey] as ILoveModuleConfig | undefined
// 模块设了密码且本地无有效 token → 先弹密码框验证
if (moduleCfg?.passwordEnabled && !getLoveModuleToken(module)) {
pendingPage.value = pageName
pendingModule.value = module
if (moduleCfg?.passwordEnabled && !getLoveModuleToken(moduleKey)) {
pendingPath.value = moduleCfg.path || ''
pendingModule.value = moduleKey
unlockModalVisible.value = true
return
}
uni.navigateTo({
url: `/pages-blog/love/${pageName}`,
})
// 跳转直接使用插件下发的 path
if (moduleCfg?.path) {
uni.navigateTo({
url: moduleCfg.path,
})
}
}
/** 通用解锁弹窗请求:unlock 签发 token(插件端要求验证码,403 附新码由弹窗展示重试) */
@@ -240,16 +187,16 @@
return res.data as { token ?: string, [key : string] : unknown } | null | undefined
}
/** 解锁成功:存 token;恋爱日记入口(loveDiary)重新拉取恋爱信息,其余进入模块 */
/** 解锁成功:存 token;恋爱日记入口(loveDiary)重新拉取配置,其余进入模块 */
function handleUnlockSuccess(data : { token ?: string }) {
if (data.token) {
setLoveModuleToken(pendingModule.value, data.token)
if (pendingModule.value === 'loveDiary') {
// 恋爱日记入口解锁:重新拉取 /love-config 并刷新页面状态
appConfigStore.fetchLoveConfig().then(() => syncLoveConfigFromStore())
// 恋爱日记入口解锁:恋爱配置已并入 getConfigs loveConfig 组,刷新后重读
appConfigStore.refreshStatic().then(() => syncLoveConfigFromStore())
}
else {
uni.navigateTo({ url: `/pages-blog/love/${pendingPage.value}` })
else if (pendingPath.value) {
uni.navigateTo({ url: pendingPath.value })
}
}
else {
@@ -267,7 +214,7 @@
syncLoveConfigFromStore()
// 恋爱日记入口(love 页本身)设了密码且本地无 token → 先弹密码框验证
if (loveDiaryLocked.value) {
pendingPage.value = ''
pendingPath.value = ''
pendingModule.value = 'loveDiary'
unlockModalVisible.value = true
}
@@ -282,32 +229,33 @@
<template>
<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>
<!-- 情侣信息 -->
<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="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"
: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">
{{ loveConfig.loveInfo.boyNickname }}
{{ loveConfig.loveInfo?.boyNickname }}
</view>
</view>
<!-- 心动呼吸动画 -->
<text class="heart-beat absolute z-10"><wd-icon class-prefix="uhlove-icon" name="aixin" size="72rpx"></wd-icon></text>
<view class="girl flex flex-col items-center justify-center -translate-x-0.5">
<text class="heart-beat absolute z-10"><wd-icon class-prefix="uhlove-icon" name="aixin"
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"
: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">
{{ loveConfig.loveInfo.girlNickname }}
{{ loveConfig.loveInfo?.girlNickname }}
</view>
</view>
</view>
<image :src="checkImageUrl(loveConfig.pageImages.bgImageUrl)" class="absolute z-0 inset-0 w-full h-full"
mode="aspectFill" />
<view 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" />
<image :src="checkImageUrl(loveBgImage)" class="absolute z-0 inset-0 w-full h-full" mode="aspectFill" />
<view
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>
<!-- 恋爱记时 -->
@@ -338,33 +286,34 @@
<!-- 功能导航 -->
<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"
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)">
<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']">
:class="`list-item-${index + 1}`" @click="handleToPage(nav.moduleKey)">
<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" />
</view>
<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 }}
</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 }}
</view>
</view>
<view class="shrink-0">
<wd-icon :name="nav.locked ? 'lock' : 'arrow-right'" :class="[index%2===0?'text-love':'text-blue-400']"
size="32rpx"></wd-icon>
<wd-icon :name="nav.locked ? 'lock' : 'arrow-right'"
:style="{ color: nav.titleColor }" size="32rpx"></wd-icon>
</view>
</view>
</block>
</view>
</view>
<!-- 模块密码验证弹窗(通用解锁弹窗;恋爱日记入口与模块共用;插件端要求验证码,403 附新码) -->
<!-- 模块密码验证弹窗-->
<uh-unlock-popup v-model:show="unlockModalVisible" title="请输入访问密码" captcha-enabled
:tip="`${pendingModule === 'loveDiary' ? '恋爱日记' : pendingModule === 'ourStory' ? '恋爱故事' : pendingModule === 'lovePhoto' ? '恋爱相册' : '恋爱清单'}已设置访问密码,输入后进入`"
:tip="unlockTip"
placeholder="请输入密码" confirm-text="进入" :request="handleUnlockRequest" @success="handleUnlockSuccess" />
</template>
@@ -375,6 +324,7 @@
}
@keyframes heartBeat {
0%,
100% {
transform: translateY(-1rem) scale(1);
@@ -446,4 +396,14 @@
transform: translateY(0);
}
}
</style>
/* 男孩头像微偏右 */
.uh-boy-offset {
transform: translateX(0.125rem);
}
/* 女孩头像微偏左 */
.uh-girl-offset {
transform: translateX(-0.125rem);
}
</style>
+3 -1
View File
@@ -8,6 +8,7 @@
import { checkImageUrl } from '@/utils/url'
import { sleep } from '@/utils/common'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import type { ILoveStory } from '@/api/types/uni-halo'
definePage({
@@ -18,6 +19,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
/* ---------------- 展示层类型 ---------------- */
@@ -254,7 +256,7 @@
<template>
<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"
+26 -15
View File
@@ -12,6 +12,7 @@
import { randomTagColor } from '@/utils/random'
import { markdownConfig } from '@/config/markdown'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import type { IMoment } from '@/api/types/halo'
definePage({
@@ -22,6 +23,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const favoritesStore = useFavoritesStore()
const haloConfigs = computed(() => appConfigStore.configs)
@@ -268,18 +270,19 @@
title: moment.value?.owner?.displayName || '',
query: moment.value ? `name=${moment.value.metadata.name}` : '',
}))
onPageScroll((e : any) => {
console.log('滚动', e)
})
</script>
<template>
<view class="app-page 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="status !== 'success'" :loading-status="status" min-height="60vh" error-text="瞬间内容加载失败"
empty-text="瞬间不存在或已被删除" @refresh="loadMoment" />
<!-- 瞬间内页(日记式:大字日期刊头 + 阅读正文 + 媒体 + 互动脚注) -->
<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">
<!-- 刊头:大字日期 -->
@@ -309,11 +312,10 @@
<!-- 正文 -->
<view class="content px-4 mt-6 text-gray-900 text-sm">
<mp-html 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 />
<mp-html 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>
<!-- 图片附件 -->
@@ -351,7 +353,7 @@
<view v-if="moment.spec.tags && moment.spec.tags.length !== 0"
class="tags flex flex-wrap gap-2 px-4 pt-6">
<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 }}
</view>
</view>
@@ -361,14 +363,16 @@
<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" />
</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-8 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
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" />
<text class="shrink-0 text-sm text-gray-900 font-semibold">点赞</text>
</view>
@@ -385,7 +389,7 @@
@click="handleToggleMomentFavorite">
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
<text class="shrink-0 text-sm font-semibold"
:class="momentFavorited ? 'text-primary' : 'text-gray-900'">{{ momentFavorited ? '已收藏' : '收藏' }}</text>
:class="[momentFavorited ? 'text-primary' : 'text-gray-900']">{{ momentFavorited ? '已收藏' : '收藏' }}</text>
</view>
</view>
</view>
@@ -395,4 +399,11 @@
:title="commentModal.title" :post-name="commentModal.postName" subject-kind="Moment"
@on-close="handleOnCommentModalClose" />
</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>
+3 -1
View File
@@ -3,6 +3,7 @@
import { onLoad } from '@dcloudio/uni-app'
import { getNoticeDetail } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { checkImageUrl, checkIsUrl } from '@/utils/url'
import { sleep } from '@/utils/common'
import { markdownConfig } from '@/config/markdown'
@@ -15,6 +16,7 @@
},
})
const { scrollY } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
const name = ref('')
const detail = ref<INoticeDetail | null>(null)
@@ -90,7 +92,7 @@
<template>
<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"
+3 -1
View File
@@ -3,6 +3,7 @@
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getNotices } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { checkImageUrl } from '@/utils/url'
import { sleep } from '@/utils/common'
import type { INoticeListVo } from '@/api/types/uni-halo'
@@ -15,6 +16,7 @@
},
})
const { scrollY } = usePageScroll()
const PAGE_SIZE = 100
/** 状态机:首屏/下拉刷新 loading、empty、error;触底加载失败仅提示,不切整页错误态 */
@@ -180,7 +182,7 @@
<template>
<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>
<scroll-view scroll-x class="w-full whitespace-nowrap" :show-scrollbar="false">
+3 -1
View File
@@ -5,6 +5,7 @@
import { sleep } from '@/utils/common'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
import { markdownConfig } from '@/config/markdown'
import { debounce } from '@/utils/debounce'
@@ -17,6 +18,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -206,7 +208,7 @@
<template>
<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"
:checking="checking" @on-refresh="handlePluginRefresh" />
+3 -1
View File
@@ -3,6 +3,7 @@
import { onLoad } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { useSettingStore } from '@/store/setting'
import { usePageScroll } from '@/hooks/usePageScroll'
import { collectSiteDefaults } from '@/utils/preference'
import { usePreferenceRows } from '@/hooks/usePreferenceRows'
import type { PrefDef } from '@/hooks/usePreferenceRows'
@@ -14,6 +15,7 @@
},
})
const { scrollY } = usePageScroll()
const settingStore = useSettingStore()
const appConfigStore = useAppConfigStore()
@@ -116,7 +118,7 @@
<template>
<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">
+3 -1
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
definePage({
style: {
@@ -7,6 +8,7 @@
navigationStyle: 'custom',
},
})
const { scrollY } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
setTimeout(() => {
@@ -16,7 +18,7 @@
<template>
<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"> 仅作为容器-->
<view class="box-border px-3">
+3 -1
View File
@@ -3,6 +3,7 @@ import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { getVoteDetail, submitVote } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { calcVotePercent, calcVoteState, VOTE_TYPES, voteCacheUtil } from '@/utils/vote'
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
import type { IVote, IVoteDetail, IVoteOption } from '@/api/types/uni-halo'
@@ -16,6 +17,7 @@ definePage({
})
/* ---------------- 状态 ---------------- */
const { scrollY } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
const submitLoading = ref(false)
const pageTitle = ref('加载中...')
@@ -262,7 +264,7 @@ onShareTimeline(() => ({
<template>
<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
+3 -1
View File
@@ -3,6 +3,7 @@
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getVoteList } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
import { useAppConfigStore } from '@/store/appConfig'
import { debounce } from '@/utils/debounce'
@@ -18,6 +19,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -300,7 +302,7 @@
<template>
<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"
:checking="checking" @on-refresh="handlePluginRefresh" />
+39 -21
View File
@@ -266,17 +266,17 @@
</script>
<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
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'" />
<!-- 拉取失败(手动进入,通常为服务器停机中) -->
<!-- 拉取失败 -->
<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" />
<text class="mt-6 text-md text-gray-900 font-bold">
服务暂时无法访问
@@ -290,38 +290,37 @@
</view>
</view>
<!-- 维护页-->
<view v-else class="relative z-10 w-full min-h-screen flex items-center justify-center flex-col ">
<view
class="w-full relative overflow-hidden px-[40rpx] pb-[64rpx] pt-[calc(var(--status-bar-height)+76rpx)] text-center">
<view v-else class="w-full relative z-10 w-full min-h-screen flex items-center justify-center flex-col">
<view class="w-full relative px-[40rpx] pb-[64rpx] pt-[calc(var(--status-bar-height)+76rpx)] text-center">
<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
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
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="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" />
<wd-icon v-else class-prefix="uhemoji-icon" name="-thinking" size="140rpx"
class="text-gray-900" />
</view>
<view
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
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
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
</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>
</view>
<view class="relative z-2 mt-6 px-[16rpx] text-[25rpx] text-balck/50 font-medium leading-[1.7]">
@@ -340,14 +339,14 @@
<!-- ===== 内容区 ===== -->
<view class="relative z-10 w-full">
<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
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
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"
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
class="absolute bottom-[-48rpx] right-[-12rpx] text-[176rpx] text-[#a7e93b] font-black leading-none opacity-10">
GO!
@@ -393,10 +392,11 @@
<!-- 操作 -->
<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>
<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">
维护详情
</view>
@@ -414,7 +414,7 @@
</view>
<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 }}
</view>
@@ -424,6 +424,14 @@
</template>
<style scoped lang="scss">
.uh-blur-44 {
filter: blur(44rpx);
}
.uh-blur-52 {
filter: blur(52rpx);
}
/* 光斑呼吸 */
.breathe {
animation: breathe 5s ease-in-out infinite;
@@ -492,4 +500,14 @@
.press:active {
transform: scale(0.94);
}
/* MAINTENANCE 徽章:居中 + 轻微旋转 */
.uh-badge {
transform: translateX(-50%) rotate(-5deg);
}
/* 水平居中定位 */
.uh-translate-x-center {
transform: translateX(-50%);
}
</style>
-266
View File
@@ -1,266 +0,0 @@
<script lang="ts" setup>
/**
* 关于页
* 功能:博主信息 + 站点统计 + 功能导航 + 版权
* 风格:对齐全站设计语言(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,
})
/** 投票插件可用性(投票中心导航项显隐) */
const { check: checkVotePluginAvailable } = usePluginAvailable({
pluginId: NeedPluginIds.PluginVote,
})
/** 链接插件可用性(友情链接导航项显隐) */
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))
const copyrightConfig = computed(() => pageConfig.value?.copyrightConfig)
/* ---------------- 状态 ---------------- */
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 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)
})
/* ---------------- 功能导航 ---------------- */
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
}
const [dataVisualAvailable, voteAvailable, linksAvailable] = await Promise.all([
checkDataVisualPlugin(),
checkVotePluginAvailable(),
checkLinksPluginAvailable(),
])
}
/* ---------------- 数据加载 ---------------- */
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
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-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: nav.bgColor }">
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx" />
</view>
<text class="nav-title text-sm text-gray-900 font-bold"
: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>
<!-- 版权 -->
<view v-if="copyrightConfig?.enabled" class="mt-6 px-6 text-center text-xs text-gray-400">
<view>{{ copyrightConfig.content }}</view>
</view>
</view>
</template>
+6 -2
View File
@@ -5,6 +5,7 @@
import { useAppConfigStore } from '@/store/appConfig'
import { checkThumbnailUrl } from '@/utils/url'
import { sleep } from '@/utils/common'
import { usePageScroll } from '@/hooks/usePageScroll'
import { t } from '@/locale'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import type { ICategory } from '@/api/types/halo'
@@ -18,7 +19,10 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const haloConfigs = computed(() => appConfigStore.configs)
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -158,7 +162,7 @@
<template>
<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" />
@@ -171,7 +175,7 @@
<view
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">
<text class="truncate text-sm text-white font-bold">
<text class="truncate text-2xs text-white font-bold">
{{ item.spec.displayName }}
</text>
<text class="text-xs text-white opacity-80">
+8 -5
View File
@@ -5,8 +5,10 @@
import { useAppConfigStore } from '@/store/appConfig'
import { checkImageUrl } from '@/utils/url'
import { usePluginAvailable } from '@/hooks/usePluginAvailable'
import { usePageScroll } from '@/hooks/usePageScroll'
import { sleep } from '@/utils/common'
import { t } from '@/locale'
import { isWechat } from '@/utils/platform'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import type { IPhoto, IPhotoGroup } from '@/api/types/halo'
@@ -18,6 +20,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const haloConfigs = computed(() => appConfigStore.configs)
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -207,17 +210,17 @@
</script>
<template>
<view class="box-border min-h-screen w-screen flex flex-col bg-page pb-6">
<uh-navbar :use-back="false" default-title="我的图库" title-color="text-gray-900"></uh-navbar>
<view class="box-border min-h-screen w-screen flex flex-col bg-page">
<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"
:checking="checking" @on-refresh="checkPluginAvailable" />
<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="isWechat?56:0">
<scroll-view :scroll-x="true" class="w-full whitespace-nowrap pt-2">
<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 uh-shadow-xs mb-1 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-2xs"
:class="{ 'bg-primary text-gray-900 font-bold': index === category.activeIndex }"
@click="handleGetDataByCategory(index, cate)">
{{ cate.spec.displayName }}
@@ -231,7 +234,7 @@
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
@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 v-for="(item, index) in dataList" :key="index"
class="relative uh-global-card-glass h-38 w-full overflow-hidden rounded-xl">
+19 -21
View File
@@ -13,7 +13,6 @@
definePage({
style: {
navigationBarTitleText: '首页',
enablePullDownRefresh: true,
navigationStyle: 'custom',
},
@@ -241,29 +240,27 @@
<uh-home-category />
<!-- 最新文章 -->
<uh-section-title class="mb-4 box-border px-3">
最新推荐
<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 v-for="tab in recommendTabs" :key="tab.value" class="rounded-md px-2 py-0.5 text-xs"
:class="recommendMode === tab.value ? 'bg-secondary text-gray-900' : 'text-gray-500'"
@click="handleRecommendModeChange(tab.value as 'default' | 'pinned' | 'latest' | 'oldest')">
{{ tab.label }}
<view class="mb-4 box-border px-3">
<uh-section-title>
最新推荐
<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 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'"
@click="handleRecommendModeChange(tab.value as 'default' | 'pinned' | 'latest' | 'oldest')">
{{ tab.label }}
</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
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="28rpx" />
</view>
</view>
</template>
</uh-section-title>
</template>
</uh-section-title>
</view>
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
min-height="36vh" @refresh="handleQuery" />
@@ -277,5 +274,6 @@
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
</block>
</view>
<uh-notify-dialog />
</template>
+271
View File
@@ -0,0 +1,271 @@
<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 { 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,
})
/** 投票插件可用性(投票中心导航项显隐) */
const { check: checkVotePluginAvailable } = usePluginAvailable({
pluginId: NeedPluginIds.PluginVote,
})
/** 链接插件可用性(友情链接导航项显隐) */
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}
| 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 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)
})
/* ---------------- 功能导航 ---------------- */
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
}
const [dataVisualAvailable, voteAvailable, linksAvailable] = await Promise.all([
checkDataVisualPlugin(),
checkVotePluginAvailable(),
checkLinksPluginAvailable(),
])
}
/* ---------------- 数据加载 ---------------- */
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
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-88 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" style="backdrop-filter:blur(2rpx)"/>
<view class="relative z-6 h-full flex flex-col items-center justify-center">
<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-2xs 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">
<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="handleOnNav(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>
<uh-page-copyright />
</view>
</template>
+13 -10
View File
@@ -5,6 +5,7 @@
import { getMomentList } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
import { usePageScroll } from '@/hooks/usePageScroll'
import { useFavoritesStore } from '@/store/favorites'
import { checkAvatarUrl, checkThumbnailUrl } from '@/utils/url'
import { buildMomentFavoriteItem } from '@/utils/favorite'
@@ -25,6 +26,7 @@
},
})
const { scrollY } = usePageScroll()
const appConfigStore = useAppConfigStore()
const favoritesStore = useFavoritesStore()
const haloConfigs = computed(() => appConfigStore.configs)
@@ -333,7 +335,7 @@
<template>
<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"
:checking="checking" @on-refresh="handlePluginRefresh" />
@@ -342,7 +344,7 @@
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
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 class="shrink-0 flex flex-col gap-y-2 w-13">
@@ -363,8 +365,8 @@
<image class="avatar h-9 w-9 shrink-0 rounded-full"
:src="checkAvatarUrl(moment.owner?.avatar || bloggerInfo.avatar)"
mode="aspectFill" />
<view class="ml-2 flex flex-col">
<view class="text-sm text-gray-900 font-bold">
<view class="ml-2 flex flex-col gap-y-1">
<view class="text-3xs text-gray-900 font-bold">
{{ moment.owner?.displayName || bloggerInfo.nickname }}
</view>
<view class="text-xs text-gray-400">
@@ -373,7 +375,7 @@
</view>
</view>
<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)">
详情
</uh-button>
@@ -382,7 +384,7 @@
<!-- 正文 -->
<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 ?? ''"
:loading-img="markdownConfig.loadingGif" scroll-table selectable
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
@@ -412,10 +414,11 @@
<!-- (点赞/评论) -->
<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)">
<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'">
点赞 {{ moment.stats.upvote || 0 }}
</text>
@@ -423,11 +426,11 @@
<view v-if="moment.spec.allowComment" class="flex items-center gap-x-1"
@click.stop="handleMomentComment(moment)">
<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 class="flex items-center gap-x-1" @click.stop="handleToggleMomentFavorite(moment)">
<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'">
{{ isMomentFavorite(moment) ? '已收藏' : '收藏' }}
</text>
+5 -48
View File
@@ -3,30 +3,14 @@
*/
import { defineStore } from 'pinia'
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 { deepMerge } from '@/utils/merge'
import { setCache } from '@/utils/storage'
import { clearLoveModuleToken } from '@/utils/loveModuleToken'
import type { IAppConfig, IAuditDataResult } from '@/api/types/uni-halo'
/** 合并后配置缓存 key(与 utils/url.ts / api/uni-halo.ts 的 APP_GLOBAL_CONFIGS 读取保持一致) */
const APP_GLOBAL_CONFIGS_KEY = 'APP_GLOBAL_CONFIGS'
/**
* 恋爱配置内容(公开 GET /love-config 返回: enabled + 纪念日/恋人信息;
* 恋爱开关与页面图片仍在 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 内则不再重复请求
*/
@@ -42,8 +26,6 @@ export const useAppConfigStore = defineStore(
const auditModeEnabled = computed(() => !!auditData.value.enabled)
/** 维护模式信息(configs 顶层 additive maintenance 键;undefined=未维护/已到点自动结束) */
const maintenance = computed(() => configs.value.maintenance)
/** 恋爱配置内容(公开 /love-config;bootstrap 统一拉取,随 store persist 持久化) */
const loveConfig = ref<IStaticLoveConfig>({ enabled: false })
/** 最近一次静态配置拉取时间戳(ms,0=从未拉取;TTL 判定依据) */
const fetchedAt = ref(0)
@@ -51,7 +33,6 @@ export const useAppConfigStore = defineStore(
const setDefaultAppSettings = () => {
configs.value = JSON.parse(JSON.stringify(DefaultAppConfigs))
auditData.value = { enabled: false }
loveConfig.value = { enabled: false }
}
/** 获取应用配置(与默认值深合并,并存储 token) */
@@ -88,42 +69,20 @@ export const useAppConfigStore = defineStore(
}
}
/** 获取恋爱配置内容(公开 /love-config;恋爱日记入口 loveDiary 设密码时
* 需携带模块解锁 token;401 locked 表示 token 缺失/失效,清除本地 token
* 交由 love.vue 重新弹密码框解锁) */
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)
// 401 locked:恋爱日记锁定且本地 token 失效/缺失,清除后由 love.vue 引导解锁
const status = (err as { cause?: { response?: { status?: number } } })?.cause?.response?.status
if (status === 401) {
clearLoveModuleToken('loveDiary')
}
loveConfig.value = { enabled: false }
return loveConfig.value
}
}
/**
* 统一拉取静态配置:
* getConfigs + audit-data + love-config 并行一次;TTL 内(默认 5 分钟,persist 恢复后
* getConfigs + audit-data 并行一次;TTL 内(默认 5 分钟,persist 恢复后
* 亦生效)直接返回缓存,避免每次冷启动/onShow 重复请求;force=true 强制刷新。
* 返回 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 force = options?.force ?? false
if (!force && fetchedAt.value > 0 && Date.now() - fetchedAt.value < STATIC_TTL) {
return { ok: true, fromCache: true }
}
const [cfg] = await Promise.all([fetchConfigs(), fetchAuditData(), fetchLoveConfig()])
const [cfg] = await Promise.all([fetchConfigs(), fetchAuditData()])
fetchedAt.value = Date.now()
return { ok: !!cfg, fromCache: false }
}
@@ -136,12 +95,10 @@ export const useAppConfigStore = defineStore(
auditData,
auditModeEnabled,
maintenance,
loveConfig,
fetchedAt,
fetchConfigs,
setDefaultAppSettings,
fetchAuditData,
fetchLoveConfig,
bootstrap,
refreshStatic,
}
+4
View File
@@ -34,6 +34,10 @@ page {
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 {
background: linear-gradient(
135deg,
-69
View File
@@ -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+')
})
})
+6 -6
View File
@@ -6,7 +6,7 @@ import { tabbarStore } from './store'
defineProps<{
item: CustomTabBarItem
index: number
isBulge?: boolean
customClass?: string
}>()
function getImageByIndex(index: number, item: CustomTabBarItem) {
@@ -23,21 +23,21 @@ function isActive(index: number) {
</script>
<template>
<view class="box-border py-0.5 flex flex-col items-center justify-center rounded-full">
<view class="overflow-hidden box-border py-0.5 flex flex-col items-center justify-center rounded-full" :class="customClass">
<template v-if="item.iconType === 'uiLib'">
<!-- TODO: 以下内容请根据选择的UI库自行替换 -->
<!-- 如:<wd-icon name="home" /> (https://wot-design-uni.cn/component/icon.html) -->
<!-- 如:<uv-icon name="home" /> (https://www.uvui.cn/components/icon.html) -->
<!-- 如:<sar-icon name="image" /> (https://sard.wzt.zone/sard-uniapp-docs/components/icon)(sar没有home图标^_^) -->
<text class="text-primary"><wd-icon :name="item.icon" size="50rpx" /></text>
<view class="text-primary"><wd-icon :name="item.icon" size="56rpx" /></view>
</template>
<template v-if="item.iconType === 'unocss' || item.iconType === 'iconfont'">
<view class="flex-1" :class="[item.icon, isBulge ? 'text-80px' : 'text-20px']" />
<view class="flex-1 text-20px" :class="[item.icon]" />
</template>
<template v-if="item.iconType === 'image'">
<image :src="getImageByIndex(index, item)" mode="scaleToFill" class="shrink-0" :class="[isBulge?'h-26px w-26px':'h-20px w-20px']" />
<image :src="getImageByIndex(index, item)" mode="scaleToFill" class="shrink-0 h-6 w-6" />
</template>
<view v-if="!isBulge" class="mt-1px text-10px shrink-0">
<view class="mt-1px text-xs shrink-0">
{{ getI18nText(item.text) }}
</view>
<!-- 角标显示 -->
+4 -4
View File
@@ -50,8 +50,8 @@ export const nativeTabbarList: NativeTabBarItem[] = [
{
iconPath: 'static/tabbar/select_mine.png',
selectedIconPath: 'static/tabbar/select_mine_active.png',
pagePath: 'pages/tabbar/about/about',
text: '%tabbar.about%'
pagePath: 'pages/tabbar/mine/mine',
text: '%tabbar.mine%'
}
];
@@ -162,8 +162,8 @@ export const customTabbarList: CustomTabBarItem[] = [
icon: '/static/tabbar/select_mine.png',
iconActive: '/static/tabbar/select_mine_active.png',
iconType: 'image',
pagePath: 'pages/tabbar/about/about',
text: '%tabbar.about%'
pagePath: 'pages/tabbar/mine/mine',
text: '%tabbar.mine%'
},
// 搜索按钮
+6 -6
View File
@@ -100,15 +100,15 @@
</script>
<template>
<view v-if="customTabbarEnable" class="h-56px pb-safe bg-page">
<view class="box-border fixed bottom-3 z-100 w-full px-3">
<view v-if="customTabbarEnable" class="h-56px pb-safe bg-page overflow-hidden">
<view class="box-border fixed bottom-0 z-100 w-full px-12">
<view class="flex box-border w-full items-center justify-between gap-x-2" @touchmove.stop.prevent>
<view
class="flex-1 box-border uh-global-card-glass bg-white/75 border rounded-full p-1 h-50px flex items-center gap-x-1">
class="flex-1 box-border uh-global-card-glass bg-white/75 border rounded-full p-1 flex items-center gap-x-1">
<view v-for="(item, index) in noRightTabbarList" :key="index" class="text-gray-900 flex-1"
:style="{ color: getColorByIndex(index) }" @click="handleClick(index)">
<TabbarItem :item="item" :index="index" class="relative"
:class="[isActive(index)?'uh-global-card-glass bg-white/0 border':'']" />
<TabbarItem :item="item" :index="index"
:custom-class="isActive(index)?'relative uh-global-card-glass border':''" />
</view>
</view>
<view v-if="rightButton.item"
@@ -120,4 +120,4 @@
<view class="pb-safe" />
</view>
</view>
</template>
</template>
+106 -122
View File
@@ -1,130 +1,114 @@
import type { Preset } from 'unocss'
import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders'
import type { Preset } from 'unocss';
import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders';
// https://www.npmjs.com/package/@uni-helper/unocss-preset-uni
import { presetUni } from '@uni-helper/unocss-preset-uni'
import { presetUni } from '@uni-helper/unocss-preset-uni';
// @see https://unocss.dev/presets/legacy-compat
import { presetLegacyCompat } from '@unocss/preset-legacy-compat'
import {
defineConfig,
presetIcons,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
import { presetLegacyCompat } from '@unocss/preset-legacy-compat';
import { defineConfig, presetIcons, transformerDirectives, transformerVariantGroup } from 'unocss';
export default defineConfig({
presets: [
presetUni({
attributify: false,
}),
presetIcons({
scale: 1.2,
warn: true,
extraProperties: {
'display': 'inline-block',
'vertical-align': 'middle',
},
collections: {
// 注册本地 SVG 图标集合, 从本地文件系统加载图标
// 在 './src/static/my-icons' 目录下的所有 svg 文件将被注册为图标,
// my-icons 是图标集合名称,使用 `i-my-icons-图标名` 调用
'my-icons': FileSystemIconLoader(
'./src/static/my-icons',
// 可选的,你可以提供一个 transform 回调来更改每个图标
(svg) => {
let svgStr = svg
presets: [
presetUni({
attributify: false
}),
presetIcons({
scale: 1.2,
warn: true,
extraProperties: {
display: 'inline-block',
'vertical-align': 'middle'
},
collections: {
// 注册本地 SVG 图标集合, 从本地文件系统加载图标
// 在 './src/static/my-icons' 目录下的所有 svg 文件将被注册为图标,
// my-icons 是图标集合名称,使用 `i-my-icons-图标名` 调用
'my-icons': FileSystemIconLoader(
'./src/static/my-icons',
// 可选的,你可以提供一个 transform 回调来更改每个图标
(svg) => {
let svgStr = svg;
// 如果 SVG 文件未定义 `fill` 属性,则默认填充 `currentColor`, 这样图标颜色会继承文本颜色,方便在不同场景下适配
svgStr = svgStr.includes('fill="')
? svgStr
: svgStr.replace(/^<svg /, '<svg fill="currentColor" ')
// 如果 SVG 文件未定义 `fill` 属性,则默认填充 `currentColor`, 这样图标颜色会继承文本颜色,方便在不同场景下适配
svgStr = svgStr.includes('fill="') ? svgStr : svgStr.replace(/^<svg /, '<svg fill="currentColor" ');
// 如果 svg 有 width, 和 height 属性,将这些属性改为 1em,否则无法显示图标
svgStr = svgStr
.replace(/(<svg.*?width=)"(.*?)"/, '$1"1em"')
.replace(/(<svg.*?height=)"(.*?)"/, '$1"1em"')
// 如果 svg 有 width, 和 height 属性,将这些属性改为 1em,否则无法显示图标
svgStr = svgStr.replace(/(<svg.*?width=)"(.*?)"/, '$1"1em"').replace(/(<svg.*?height=)"(.*?)"/, '$1"1em"');
return svgStr
},
),
},
}),
// TODO: check 是否会有别的影响
// 处理低端安卓机的样式问题
// 将颜色函数 (rgb()和hsl()) 从空格分隔转换为逗号分隔,更好的兼容性app端,example:
// `rgb(255 0 0)` -> `rgb(255, 0, 0)`
// `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)`
presetLegacyCompat({
commaStyleColorFunction: true,
legacyColorSpace: true, // by QQ4群-量子蔷薇
// @菲鸽 unocss 配置中,建议在 presetLegacyCompat 中添加 legacyColorSpace: true,以去除生成的颜色样式中的 in oklch 关键字,现在发现有些渐变色生成不符合预期
}) as Preset,
],
transformers: [
// 启用指令功能:主要用于支持 @apply、@screen 和 theme() 等 CSS 指令
transformerDirectives(),
// 启用 () 分组功能
// 支持css class组合,eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">测试 unocss</div>`
transformerVariantGroup(),
],
shortcuts: [
{
center: 'flex justify-center items-center',
},
],
// 动态图标需要在这里配置,或者写在vue页面中注释掉
safelist: [
'i-carbon-code',
'i-carbon-home',
'i-carbon-user',
'i-carbon-ibm-watson-language-translator',
'i-carbon-menu',
],
rules: [
[
'p-safe',
{
padding:
'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)',
},
],
['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
],
theme: {
colors: {
/** 主题色,用法如: text-primary */
primary: 'var(--wot-color-theme,#B9E424)',
secondary: 'var(--wot-color-secondary,#D7F94C)',
page: 'var(--wot-color-page,#f6f3ee)',
love: '#f83856'
},
fontSize: {
/** 提供更小号的字体,用法如:text-2xs */
'2xs': ['20rpx', '28rpx'],
'3xs': ['18rpx', '26rpx'],
},
},
// windows 系统会报错:[plugin:unocss:transformers:pre] Cannot overwrite a zero-length range - use append Left or prependRight instead.
// 去掉下面的就正常了
// content: {
// /**
// * 解决小程序报错 `./app.wxss(78:2814): unexpected unexpected at pos 5198`
// * 为什么同时使用include和exclude?虽然看起来多余,但同时配置两者是一种常见的 `防御性编程` 做法。
// 1. 结构变化保障 : 如果未来项目结构发生变化,某些排除目录可能被移动到包含路径下,exclude配置可以确保它们仍被排除
// 2. 明确性 : 明确列出要排除的目录使配置意图更加清晰
// 3. 性能优化 : 避免处理不必要的文件,提高构建性能
// 4. 防止冲突 : 排除第三方库和构建输出目录,避免潜在的CSS冲突
// */
// pipeline: {
// exclude: [
// 'node_modules/**/*',
// 'public/**/*',
// 'dist/**/*',
// ],
// include: [
// './src/**/*',
// ],
// },
// },
})
return svgStr;
}
)
}
}),
// TODO: check 是否会有别的影响
// 处理低端安卓机的样式问题
// 将颜色函数 (rgb()和hsl()) 从空格分隔转换为逗号分隔,更好的兼容性app端,example:
// `rgb(255 0 0)` -> `rgb(255, 0, 0)`
// `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)`
presetLegacyCompat({
commaStyleColorFunction: true,
legacyColorSpace: true // by QQ4群-量子蔷薇
// @菲鸽 unocss 配置中,建议在 presetLegacyCompat 中添加 legacyColorSpace: true,以去除生成的颜色样式中的 in oklch 关键字,现在发现有些渐变色生成不符合预期
}) as Preset
],
transformers: [
// 启用指令功能:主要用于支持 @apply、@screen 和 theme() 等 CSS 指令
transformerDirectives(),
// 启用 () 分组功能
// 支持css class组合,eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">测试 unocss</div>`
transformerVariantGroup()
],
shortcuts: [
{
center: 'flex justify-center items-center'
}
],
// 动态图标需要在这里配置,或者写在vue页面中注释掉
safelist: ['i-carbon-code', 'i-carbon-home', 'i-carbon-user', 'i-carbon-ibm-watson-language-translator', 'i-carbon-menu'],
rules: [
[
'p-safe',
{
padding: 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)'
}
],
['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }]
],
theme: {
colors: {
/** 主题色,用法如: text-primary */
primary: 'var(--wot-color-theme,#B9E424)',
secondary: 'var(--wot-color-secondary,#D7F94C)',
page: 'var(--wot-color-page,#f6f3ee)',
love: '#f83856'
},
fontSize: {
/** 提供更小号的字体,用法如:text-2xs */
'2xs': ['28rpx'],
'3xs': ['26rpx']
}
}
// windows 系统会报错:[plugin:unocss:transformers:pre] Cannot overwrite a zero-length range - use append Left or prependRight instead.
// 去掉下面的就正常了
// content: {
// /**
// * 解决小程序报错 `./app.wxss(78:2814): unexpected unexpected at pos 5198`
// * 为什么同时使用include和exclude?虽然看起来多余,但同时配置两者是一种常见的 `防御性编程` 做法。
// 1. 结构变化保障 : 如果未来项目结构发生变化,某些排除目录可能被移动到包含路径下,exclude配置可以确保它们仍被排除
// 2. 明确性 : 明确列出要排除的目录使配置意图更加清晰
// 3. 性能优化 : 避免处理不必要的文件,提高构建性能
// 4. 防止冲突 : 排除第三方库和构建输出目录,避免潜在的CSS冲突
// */
// pipeline: {
// exclude: [
// 'node_modules/**/*',
// 'public/**/*',
// 'dist/**/*',
// ],
// include: [
// './src/**/*',
// ],
// },
// },
});