ForcePilot/web/src/stores/info.js
Wenjie Zhang 711f39dbd1 feat: 重设计首页突出 Harness 与知识库协作
- hero 区改版:氛围背景光晕+渐隐网格,右侧玻璃卡片可视化
- 右侧改为 Harness → RAG 引擎 → 知识库 横向数据流,中间枢纽带脉冲环、双向光点对流
- 统计改用实时 GitHub 数据(Stars/Forks/Issues),不再依赖 branding 配置
- 移除 info.template.yaml 的 features/actions 及 store 中对应 getter
- 「查看文档」升级为次按钮,左侧内容顶部对齐微调
2026-06-04 21:07:09 +08:00

94 lines
2.0 KiB
JavaScript

import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { brandApi } from '@/apis/system_api'
export const useInfoStore = defineStore('info', () => {
// 状态
const infoConfig = ref({})
const isLoading = ref(false)
const isLoaded = ref(false)
const debugMode = ref(false)
// 计算属性 - 组织信息
const organization = computed(
() =>
infoConfig.value.organization || {
name: '',
logo: '',
avatar: ''
}
)
// 计算属性 - 品牌信息
const branding = computed(
() =>
infoConfig.value.branding || {
name: '',
title: '',
subtitle: '',
subtitles: []
}
)
// 计算属性 - 页脚信息
const footer = computed(() => ({
copyright: '',
user_agreement_url: '',
privacy_policy_url: '',
...(infoConfig.value.footer || {})
}))
// 动作方法
function setInfoConfig(newConfig) {
infoConfig.value = newConfig
isLoaded.value = true
}
function toggleDebugMode() {
debugMode.value = !debugMode.value
}
async function loadInfoConfig(force = false) {
// 如果已经加载过且不强制刷新,则不重新加载
if (isLoaded.value && !force) {
return infoConfig.value
}
try {
isLoading.value = true
const response = await brandApi.getInfoConfig()
if (response.success && response.data) {
setInfoConfig(response.data)
console.debug('信息配置加载成功:', response.data)
return response.data
} else {
console.warn('信息配置加载失败,使用默认配置')
return null
}
} catch (error) {
console.error('加载信息配置时发生错误:', error)
return null
} finally {
isLoading.value = false
}
}
return {
// 状态
infoConfig,
isLoading,
isLoaded,
debugMode,
// 计算属性
organization,
branding,
footer,
// 方法
toggleDebugMode,
loadInfoConfig
}
})