From a012a57cf020190396d9aba709ccf529ab5767ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= Date: Fri, 12 Jun 2026 21:07:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=8F=8B=E9=93=BE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=8F=8B=E9=93=BE?= =?UTF-8?q?tabbar=E9=A1=B9=E5=B9=B6=E8=B0=83=E6=95=B4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增友链页面组件,实现分组展示、滚动导航功能 2. 多语言中添加友链相关翻译 3. 修改默认首页跳转至友链页 4. 调整API请求配置,添加halo请求标记 5. 优化剪贴板提示、布局样式和工具函数 6. 更新开发环境请求地址 --- env/.env.development | 3 +- src/api/halo-plugin/link.ts | 10 +- .../uh-tabbar-page-placeholder.vue | 6 + src/hooks/useListData.ts | 2 +- src/locale/en.json | 1 + src/locale/zh-Hans.json | 1 + src/pages/home/home.vue | 4 +- src/pages/index/index.vue | 3 +- src/pages/links/links.vue | 281 ++++++++++++++++++ src/tabbar/config.ts | 6 + src/utils/base/clipboard.ts | 2 +- src/utils/base/getRect.ts | 19 +- uno.config.ts | 5 + 13 files changed, 330 insertions(+), 13 deletions(-) create mode 100644 src/components/uh-tabbar-page-placeholder/uh-tabbar-page-placeholder.vue create mode 100644 src/pages/links/links.vue diff --git a/env/.env.development b/env/.env.development index 78c92e0..32b178a 100644 --- a/env/.env.development +++ b/env/.env.development @@ -6,4 +6,5 @@ VITE_DELETE_CONSOLE=false VITE_SHOW_SOURCEMAP=false # development mode 后台请求地址 -VITE_UNI_HALO_BASEURL='https://www.yijunzhao.cn' +# VITE_UNI_HALO_BASEURL='https://www.yijunzhao.cn' +VITE_UNI_HALO_BASEURL='https://www.xhhao.com' diff --git a/src/api/halo-plugin/link.ts b/src/api/halo-plugin/link.ts index b2a8486..83a788c 100644 --- a/src/api/halo-plugin/link.ts +++ b/src/api/halo-plugin/link.ts @@ -6,7 +6,10 @@ import { http } from '@/http/alova' * @returns 获取链接分分组组列表响应参数 */ export function queryLinkGroups(params: any) { - return http.Get(`/apis/api.link.halo.run/v1alpha1/linkgroups`, { params }) + return http.Get(`/apis/api.link.halo.run/v1alpha1/linkgroups`, { + params, + meta: { isHalo: true }, + }) } /** @@ -15,5 +18,8 @@ export function queryLinkGroups(params: any) { * @returns 获取链接列表响应参数 */ export function queryLinks(params: any) { - return http.Get(`/apis/api.link.halo.run/v1alpha1/links`, { params }) + return http.Get(`/apis/api.link.halo.run/v1alpha1/links`, { + params, + meta: { isHalo: true }, + }) } diff --git a/src/components/uh-tabbar-page-placeholder/uh-tabbar-page-placeholder.vue b/src/components/uh-tabbar-page-placeholder/uh-tabbar-page-placeholder.vue new file mode 100644 index 0000000..ade61ab --- /dev/null +++ b/src/components/uh-tabbar-page-placeholder/uh-tabbar-page-placeholder.vue @@ -0,0 +1,6 @@ + diff --git a/src/hooks/useListData.ts b/src/hooks/useListData.ts index f35d23b..e83ffc7 100644 --- a/src/hooks/useListData.ts +++ b/src/hooks/useListData.ts @@ -1,6 +1,6 @@ import type { Ref } from 'vue' -interface IPaginationParams { +export interface IPaginationParams { page: number size: number } diff --git a/src/locale/en.json b/src/locale/en.json index d7acc57..f16964f 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -2,6 +2,7 @@ "tabbar.home": "Home", "tabbar.gallery": "Gallery", "tabbar.moments": "Moments", + "tabbar.links": "Links", "tabbar.about": "About", "tabbar.me": "Me", "tabbar.i18n": "I18n", diff --git a/src/locale/zh-Hans.json b/src/locale/zh-Hans.json index fc9bd5b..0e1045c 100644 --- a/src/locale/zh-Hans.json +++ b/src/locale/zh-Hans.json @@ -3,6 +3,7 @@ "tabbar.gallery": "相册", "tabbar.moments": "瞬间", "tabbar.about": "关于", + "tabbar.links": "友链", "tabbar.me": "我的", "tabbar.i18n": "语言", "i18n.title": "中文标题", diff --git a/src/pages/home/home.vue b/src/pages/home/home.vue index 71b23cc..94af889 100644 --- a/src/pages/home/home.vue +++ b/src/pages/home/home.vue @@ -122,7 +122,7 @@ onPageScroll(() => { }) diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 994ad0f..da6f23d 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -14,7 +14,8 @@ definePage({ onLoad(() => { console.log('index onLoad') // 默认跳转首页 - uni.switchTab({ url: '/pages/home/home' }) + // uni.switchTab({ url: '/pages/home/home' }) + uni.switchTab({ url: '/pages/links/links' }) }) diff --git a/src/pages/links/links.vue b/src/pages/links/links.vue new file mode 100644 index 0000000..c5ce64d --- /dev/null +++ b/src/pages/links/links.vue @@ -0,0 +1,281 @@ + + + + + diff --git a/src/tabbar/config.ts b/src/tabbar/config.ts index d504d0b..93a35c8 100644 --- a/src/tabbar/config.ts +++ b/src/tabbar/config.ts @@ -58,6 +58,12 @@ export const customTabbarList: CustomTabBarItem[] = [ iconType: 'uiLib', icon: 'send', }, + { + pagePath: 'pages/links/links', + text: '%tabbar.links%', + iconType: 'uiLib', + icon: 'link', + }, { pagePath: 'pages/me/me', text: '%tabbar.me%', diff --git a/src/utils/base/clipboard.ts b/src/utils/base/clipboard.ts index 27b8fb4..687a613 100644 --- a/src/utils/base/clipboard.ts +++ b/src/utils/base/clipboard.ts @@ -11,7 +11,7 @@ export function copy(content: string, showToast: boolean = false) { if (showToast) { uni.showToast({ title: '复制成功', - icon: 'success', + icon: 'none', }) } }, diff --git a/src/utils/base/getRect.ts b/src/utils/base/getRect.ts index 393530e..a6428bc 100644 --- a/src/utils/base/getRect.ts +++ b/src/utils/base/getRect.ts @@ -1,14 +1,23 @@ +import { getCurrentInstance } from 'vue' +import type { ComponentInternalInstance } from 'vue' + +interface IOptions { + /** 选择器 */ + selector: string + /** 实例 */ + instance?: ComponentInternalInstance + /** 是否获取所有匹配元素 */ + all?: boolean +} + /** * 获取元素的位置信息 * @param {any} selector 选择器 * @param {boolean} all 是否获取所有匹配元素 * @returns {Promise} 返回一个 Promise,解析为元素的位置信息 */ - -import { getCurrentInstance } from 'vue' - -export function getRect(selector: any, _instance: any = null, all: boolean = false): Promise { - const instance = _instance || getCurrentInstance() +export function getRect(options: IOptions): Promise { + const { selector, instance = getCurrentInstance(), all = false } = options return new Promise((resolve) => { const query = uni.createSelectorQuery() .in(instance?.proxy) diff --git a/uno.config.ts b/uno.config.ts index 7fade49..9580dac 100644 --- a/uno.config.ts +++ b/uno.config.ts @@ -97,12 +97,17 @@ export default defineConfig({ /** 主题色,用法如: text-primary */ primary: 'var(--wot-color-theme,#0957DE)', page: '#F8F8F8', + page2: '#F9FAFB', }, fontSize: { /** 提供更小号的字体,用法如:text-2xs */ '2xs': ['20rpx', '28rpx'], '3xs': ['18rpx', '26rpx'], }, + shadow: { + xs: '0 0 24px rgba(0, 0, 0, 0.075)', + card: '0 16rpx 60rpx rgba(0, 0, 0, 0.04)', + }, }, // windows 系统会报错:[plugin:unocss:transformers:pre] Cannot overwrite a zero-length range - use append Left or prependRight instead. // 去掉下面的就正常了