From f105dedc230959d6b19bbd72d0ba6f4faf73a140 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 14:32:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=B9=B6=E6=96=B0=E5=A2=9E=E5=A4=9A=E9=A1=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增全局配置管理store,拉取uni-halo插件配置 2. 新增post-card文章卡片组件,简化首页文章列表代码 3. 优化tabbar样式与切换逻辑,调整图标库类型 4. 新增随机图片工具函数,重构首页横幅与分类模块 5. 调整openapi生成配置,新增工具类与样式类 6. 移除废弃的tabbar关于页面配置项 --- openapi-ts-request.config.ts | 2 +- src/App.vue | 18 +++- src/api/halo-plugin/uni-halo.ts | 6 +- src/components/post-card/post-card.vue | 115 ++++++++++++++++++++++ src/config/useAppConfig.ts | 5 + src/pages/index/index.vue | 130 +++++++++++++++---------- src/store/config.ts | 44 +++++++++ src/tabbar/TabbarItem.vue | 10 +- src/tabbar/config.ts | 15 +-- src/tabbar/index.vue | 15 ++- src/utils/randomResources.ts | 11 +++ 11 files changed, 293 insertions(+), 78 deletions(-) create mode 100644 src/components/post-card/post-card.vue create mode 100644 src/config/useAppConfig.ts create mode 100644 src/store/config.ts diff --git a/openapi-ts-request.config.ts b/openapi-ts-request.config.ts index 37216cf..5c295df 100644 --- a/openapi-ts-request.config.ts +++ b/openapi-ts-request.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'openapi-ts-request' export default defineConfig([ { - describe: 'unibest-openapi-test', + describe: 'uni-openapi-test', schemaPath: 'https://ukw0y1.laf.run/unibest-opapi-test.json', serversPath: './src/service', requestLibPath: `import request from '@/http/vue-query';\n import { CustomRequestOptions_ } from '@/http/types';`, diff --git a/src/App.vue b/src/App.vue index c17eb06..3d89c0c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,14 +4,26 @@ import { getCurrentInstance, onMounted, onUnmounted } from 'vue' import { navigateToInterceptor } from '@/router/interceptor' import { tabbarStore } from '@/tabbar/store' import { permission } from '@/router/permission' +import { useUniHaloConfigStore } from './store/config' const { proxy } = (getCurrentInstance() || {}) as any const router = proxy?.$router router && permission.install(router) -onLaunch((options) => { +async function init() { + try { + const uniHaloConfigStore = useUniHaloConfigStore() + await uniHaloConfigStore.init() + } + catch (err) { + console.error(err) + } +} + +onLaunch(async (options) => { console.log('App.vue onLaunch', options) + await init() }) onShow((options) => { console.log('App.vue onShow', options) @@ -46,7 +58,3 @@ onUnmounted(() => { }) // #endif - - diff --git a/src/api/halo-plugin/uni-halo.ts b/src/api/halo-plugin/uni-halo.ts index f2ea7fb..19a3692 100644 --- a/src/api/halo-plugin/uni-halo.ts +++ b/src/api/halo-plugin/uni-halo.ts @@ -1,11 +1,15 @@ import { http } from '@/http/alova' +export interface IUniHaloConfig { + baseURL: string +} + /** * 获取 uni-halo 插件配置 * @returns uni-halo 插件配置响应参数 */ export function queryUniHaloPluginConfigs() { - return http.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getConfigs`, { + return http.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getConfigs`, { meta: { isHalo: true, }, diff --git a/src/components/post-card/post-card.vue b/src/components/post-card/post-card.vue new file mode 100644 index 0000000..d347791 --- /dev/null +++ b/src/components/post-card/post-card.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/src/config/useAppConfig.ts b/src/config/useAppConfig.ts new file mode 100644 index 0000000..7ca85ac --- /dev/null +++ b/src/config/useAppConfig.ts @@ -0,0 +1,5 @@ +export function useAppConfig() { + return { + apiBaseUrl: import.meta.env.VITE_API_BASE_URL, + } +} diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 0e8ff6f..4a600aa 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -4,10 +4,11 @@ import { queryPostByName, queryPosts } from '@/api/halo-base/post' import { completeUrl } from '@/utils/url' import { timeFrom } from '@/utils/base/timeFrom' import { useListData } from '@/hooks/useListData' -import { randomImageUrl } from '@/utils/randomResources' - +import { getRandomUrl, randomImageUrl } from '@/utils/randomResources' import type { ListedPostVo, ListedPostVoList, PostV1alpha1PublicApiQueryPostByNameRequest, PostV1alpha1PublicApiQueryPostsRequest, PostVo } from '@halo-dev/api-client' +import PostCard from '@/components/post-card/post-card.vue' + defineOptions({ name: 'Home', }) @@ -50,6 +51,24 @@ const banner = reactive({ ], }) +const categories = reactive([ + { + name: '全栈开发', + count: 120, + cover: getRandomUrl(), + }, + { + name: 'Docker', + count: 0, + cover: getRandomUrl(), + }, + { + name: 'Vue技术', + count: 99, + cover: getRandomUrl(), + }, +]) + const quickList = reactive([ { pagePath: 'pages/moments/moments', @@ -115,6 +134,10 @@ onLoad(() => { refresh() runSingle({ name: '019eb1ca-e37c-7729-97af-e0b658aeef0f' }) }) + +onPageScroll(({ scrollTop }) => { + +})