mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-07-27 04:20:43 +08:00
refactor: 重构项目并新增多项功能
1. 新增全局配置管理store,拉取uni-halo插件配置 2. 新增post-card文章卡片组件,简化首页文章列表代码 3. 优化tabbar样式与切换逻辑,调整图标库类型 4. 新增随机图片工具函数,重构首页横幅与分类模块 5. 调整openapi生成配置,新增工具类与样式类 6. 移除废弃的tabbar关于页面配置项
This commit is contained in:
@@ -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<IUniHaloConfig | undefined>(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,
|
||||
})
|
||||
Reference in New Issue
Block a user