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 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{ post.spec.title }}
+
+
+ {{ post.status.excerpt }}
+
+
+
+ {{ timeFrom(post.spec.publishTime) }}
+
+
+ ·
+
+
+ {{ post.categories.map(c => c.spec.displayName).join('·') }}
+
+
+
+ ·
+
+
+ 点赞 {{ post.stats.upvote }} 次
+
+
+
+ ·
+
+
+ 浏览 {{ post.stats.visit }} 次
+
+
+
+
+
+
+
+
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 }) => {
+
+})
@@ -132,22 +155,26 @@ onLoad(() => {
-
-
-
+
+
+
+
{{ banner.list[index].time }}
{{ banner.list[index].title }}
{{ banner.list[index].desc }}
+
-
+
{{ current + 1 }}/{{ total }}
@@ -155,8 +182,8 @@ onLoad(() => {
-
-
+
+
{
联系我
-
-
+
+
128
- 文章
+ 内容
999
@@ -186,24 +213,28 @@ onLoad(() => {
1.2k
- 获赞
+ 分类
128k
- 收藏
+ 评论
+
+
+ 10.5k
+ 点赞
-
+
-
+
{{ item.text }}
@@ -211,12 +242,39 @@ onLoad(() => {
-
+
+
+
+ 热门分类
+
+
+
+
+
+ {{ categories[0].name }}
+
+
+ {{ categories[0].count }}
+
+
+
+
+
+
+ {{ cate.name }}
+
+
+ {{ cate.count }}
+
+
+
+
+
-
+
置顶文章
@@ -230,42 +288,16 @@ onLoad(() => {
-
-
- 最新文章
+
+
+ 最新文章
-
+
-
-
-
-
-
- {{ post.spec.title }}
-
-
- {{ post.status.excerpt }}
-
-
-
- {{ timeFrom(post.spec.publishTime) }}
-
-
- ·
-
-
- {{ post.categories.map(c => c.spec.displayName).join('·') }}
-
-
-
-
-
+
diff --git a/src/store/config.ts b/src/store/config.ts
new file mode 100644
index 0000000..4f042b4
--- /dev/null
+++ b/src/store/config.ts
@@ -0,0 +1,44 @@
+import { defineStore } from 'pinia'
+import { queryUniHaloPluginConfigs } from '@/api/halo-plugin/uni-halo'
+import type { IUniHaloConfig } from '@/api/halo-plugin/uni-halo'
+import { deepMerge } from '@/utils/base/deepMerge'
+
+const defaultConfig: IUniHaloConfig = {
+ baseURL: import.meta.env.VITE_SERVER_BASEURL,
+}
+
+const ConfigsStoreKey = 'UNI_HALO_CONFIG'
+
+/**
+ * uni-halo 配置状态管理
+ */
+export const useUniHaloConfigStore = defineStore('uniHaloConfig', () => {
+ /**
+ * 插件配置
+ */
+ const config = ref(deepMerge({
+ ...(uni.getStorageSync(ConfigsStoreKey) ?? {} as IUniHaloConfig),
+ }, defaultConfig))
+
+ /**
+ * 获取插件配置
+ */
+ async function init() {
+ try {
+ const res: IUniHaloConfig = await queryUniHaloPluginConfigs()
+ config.value = deepMerge(config.value, res ?? {})
+ uni.setStorageSync(ConfigsStoreKey, config.value)
+ }
+ catch (err) {
+ console.error(err)
+ throw err
+ }
+ }
+
+ return {
+ config,
+ init,
+ }
+}, {
+ persist: true,
+})
diff --git a/src/tabbar/TabbarItem.vue b/src/tabbar/TabbarItem.vue
index 6f7f6d4..35573ac 100644
--- a/src/tabbar/TabbarItem.vue
+++ b/src/tabbar/TabbarItem.vue
@@ -32,20 +32,19 @@ function isActiveByIndex(index: number) {
}
let timer: ReturnType | null = null
-const isActive = ref(true)
+const isActive = ref(false)
function activeBgColor() {
- clearTimeout(timer)
isActive.value = false
+ clearTimeout(timer)
timer = setTimeout(() => {
- timer = null
isActive.value = true
- }, 0)
+ }, 30)
}
watch(() => tabbarStore.curIdx, () => {
activeBgColor()
-})
+}, { immediate: true })
function handleClick(index: number) {
// 点击原来的不做操作
@@ -59,6 +58,7 @@ function handleClick(index: number) {
const url = list[index].pagePath
tabbarStore.setCurIdx(index)
+ console.log('handleClick tabbarCacheEnable', tabbarCacheEnable)
if (tabbarCacheEnable) {
uni.switchTab({ url })
}
diff --git a/src/tabbar/config.ts b/src/tabbar/config.ts
index beddcd9..c3cb8eb 100644
--- a/src/tabbar/config.ts
+++ b/src/tabbar/config.ts
@@ -43,9 +43,8 @@ export const customTabbarList: CustomTabBarItem[] = [
{
text: '%tabbar.home%',
pagePath: 'pages/index/index',
- iconType: 'unocss',
- icon: 'i-carbon-home',
- // badge: 'dot',
+ iconType: 'uiLib',
+ icon: 'home',
},
{
pagePath: 'pages/gallery/gallery',
@@ -57,16 +56,8 @@ export const customTabbarList: CustomTabBarItem[] = [
pagePath: 'pages/moments/moments',
text: '%tabbar.moments%',
iconType: 'uiLib',
- icon: 'gift',
+ icon: 'send',
},
- // {
- // pagePath: 'pages-blog/about/about',
- // text: '%tabbar.about%',
- // iconType: 'unocss',
- // icon: 'i-carbon-menu',
- // badge: 10,
- // roles: ['admin'],
- // },
{
pagePath: 'pages/me/me',
text: '%tabbar.me%',
diff --git a/src/tabbar/index.vue b/src/tabbar/index.vue
index c659492..dd3c4d1 100644
--- a/src/tabbar/index.vue
+++ b/src/tabbar/index.vue
@@ -58,6 +58,7 @@ onMounted(() => {
const backTopActive = reactive({
show: false,
+ thresholdValue: 300,
beforeScrollTop: 0,
currentScrollTop: 0,
})
@@ -117,9 +118,9 @@ const triggerPageScrollDebounceFn = debounce((scrollTop: number) => {
backTopActive.beforeScrollTop = backTopActive.currentScrollTop
setTimeout(() => {
backTopActive.currentScrollTop = scrollTop
- backTopActive.show = backTopActive.currentScrollTop > backTopActive.beforeScrollTop
- }, 60)
-}, 60)
+ backTopActive.show = scrollTop > backTopActive.thresholdValue && backTopActive.currentScrollTop > backTopActive.beforeScrollTop
+ }, 30)
+}, 30)
onPageScroll(({ scrollTop }) => {
triggerPageScrollDebounceFn(scrollTop)
@@ -137,7 +138,7 @@ function handleScrollToTop() {
@@ -170,4 +171,8 @@ function handleScrollToTop() {
.uh-shadow-sm {
box-shadow: 0 0 24rpx rgba(0, 0, 0, 0.075);
}
+
+.uh-backdrop-blur {
+ backdrop-filter: blur(3px);
+}
diff --git a/src/utils/randomResources.ts b/src/utils/randomResources.ts
index 6e0f6d8..ca07d91 100644
--- a/src/utils/randomResources.ts
+++ b/src/utils/randomResources.ts
@@ -7,6 +7,8 @@ export const randomImageUrl = {
xsot: 'https://api.xsot.cn/bing?jump=true',
}
+type randomUrlKeys = keyof typeof randomImageUrl
+
export const randomVideosUrl = {
acg: 'https://t.alcy.cc/acg',
}
@@ -17,3 +19,12 @@ export function getPicsum(width: number = 800, height?: number) {
}
return `https://picsum.photos/${width}/${height}`
}
+
+/**
+ * 获取随机图片URL
+ * @param type 图片类型
+ * @returns 随机图片URL
+ */
+export function getRandomUrl(type?: randomUrlKeys) {
+ return `${randomImageUrl[type || 'pc' as randomUrlKeys]}?t=${Date.now()}+${Math.random()}`
+}