2025-06-22 23:07:57 +08:00
|
|
|
import { ref, computed } from 'vue'
|
|
|
|
|
import { defineStore } from 'pinia'
|
2025-08-31 00:34:26 +08:00
|
|
|
import { brandApi } from '@/apis/system_api'
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
export const useInfoStore = defineStore('info', () => {
|
|
|
|
|
// 状态
|
|
|
|
|
const infoConfig = ref({})
|
|
|
|
|
const isLoading = ref(false)
|
|
|
|
|
const isLoaded = ref(false)
|
2025-09-11 03:09:17 +08:00
|
|
|
const debugMode = ref(false)
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
// 计算属性 - 组织信息
|
2026-01-15 06:01:34 +08:00
|
|
|
const organization = computed(
|
|
|
|
|
() =>
|
|
|
|
|
infoConfig.value.organization || {
|
|
|
|
|
name: '江南语析',
|
|
|
|
|
logo: '/favicon.svg',
|
|
|
|
|
avatar: '/avatar.jpg'
|
|
|
|
|
}
|
|
|
|
|
)
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
// 计算属性 - 品牌信息
|
2026-01-15 06:01:34 +08:00
|
|
|
const branding = computed(
|
|
|
|
|
() =>
|
|
|
|
|
infoConfig.value.branding || {
|
|
|
|
|
name: 'Yuxi-Know',
|
|
|
|
|
title: 'Yuxi-Know',
|
|
|
|
|
subtitle: '大模型驱动的知识库管理工具',
|
|
|
|
|
description: '结合知识库与知识图谱,提供更准确、更全面的回答'
|
|
|
|
|
}
|
|
|
|
|
)
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
// 计算属性 - 功能特性
|
2026-01-15 06:01:34 +08:00
|
|
|
const features = computed(
|
|
|
|
|
() =>
|
|
|
|
|
infoConfig.value.features || [
|
|
|
|
|
{
|
|
|
|
|
label: 'GitHub Stars',
|
|
|
|
|
value: '3200+',
|
|
|
|
|
description: '开发者社区的认可与支持',
|
|
|
|
|
icon: 'stars'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '已解决 Issues',
|
|
|
|
|
value: '250+',
|
|
|
|
|
description: '持续改进和问题解决能力',
|
|
|
|
|
icon: 'issues'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '累计 Commits',
|
|
|
|
|
value: '1200+',
|
|
|
|
|
description: '活跃的开发迭代和功能更新',
|
|
|
|
|
icon: 'commits'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '开源协议',
|
|
|
|
|
value: 'MIT 协议',
|
|
|
|
|
description: '完全免费,支持商业使用',
|
|
|
|
|
icon: 'license'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const actions = computed(
|
|
|
|
|
() =>
|
|
|
|
|
infoConfig.value.actions || [
|
|
|
|
|
{
|
|
|
|
|
name: '演示视频',
|
|
|
|
|
icon: 'video',
|
|
|
|
|
url: 'https://www.bilibili.com/video/BV1DF14BTETq'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '文档中心',
|
|
|
|
|
icon: 'docs',
|
|
|
|
|
url: 'https://xerrors.github.io/Yuxi-Know/'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '提交 Issue',
|
|
|
|
|
icon: 'issue',
|
|
|
|
|
url: 'https://github.com/xerrors/Yuxi-Know/issues/new/choose'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '开发路线图',
|
|
|
|
|
icon: 'roadmap',
|
|
|
|
|
url: 'https://github.com/xerrors/Yuxi-Know#roadmap'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
)
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
// 计算属性 - 页脚信息
|
2026-01-15 06:01:34 +08:00
|
|
|
const footer = computed(
|
|
|
|
|
() =>
|
|
|
|
|
infoConfig.value.footer || {
|
|
|
|
|
copyright: '© 江南语析 2025 [WIP] v0.12.138'
|
|
|
|
|
}
|
|
|
|
|
)
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
// 动作方法
|
|
|
|
|
function setInfoConfig(newConfig) {
|
|
|
|
|
infoConfig.value = newConfig
|
|
|
|
|
isLoaded.value = true
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-11 03:09:17 +08:00
|
|
|
function setDebugMode(enabled) {
|
|
|
|
|
debugMode.value = enabled
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleDebugMode() {
|
|
|
|
|
debugMode.value = !debugMode.value
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-22 23:07:57 +08:00
|
|
|
async function loadInfoConfig(force = false) {
|
|
|
|
|
// 如果已经加载过且不强制刷新,则不重新加载
|
|
|
|
|
if (isLoaded.value && !force) {
|
|
|
|
|
return infoConfig.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
isLoading.value = true
|
2025-08-31 00:34:26 +08:00
|
|
|
const response = await brandApi.getInfoConfig()
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
if (response.success && response.data) {
|
|
|
|
|
setInfoConfig(response.data)
|
2025-07-22 17:29:38 +08:00
|
|
|
console.debug('信息配置加载成功:', response.data)
|
2025-06-22 23:07:57 +08:00
|
|
|
return response.data
|
|
|
|
|
} else {
|
|
|
|
|
console.warn('信息配置加载失败,使用默认配置')
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载信息配置时发生错误:', error)
|
|
|
|
|
return null
|
|
|
|
|
} finally {
|
|
|
|
|
isLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function reloadInfoConfig() {
|
|
|
|
|
try {
|
|
|
|
|
isLoading.value = true
|
2025-08-31 00:34:26 +08:00
|
|
|
const response = await brandApi.reloadInfoConfig()
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
if (response.success && response.data) {
|
|
|
|
|
setInfoConfig(response.data)
|
2025-07-22 17:29:38 +08:00
|
|
|
console.debug('信息配置重新加载成功:', response.data)
|
2025-06-22 23:07:57 +08:00
|
|
|
return response.data
|
|
|
|
|
} else {
|
|
|
|
|
console.warn('信息配置重新加载失败')
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('重新加载信息配置时发生错误:', error)
|
|
|
|
|
return null
|
|
|
|
|
} finally {
|
|
|
|
|
isLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
return {
|
2025-06-22 23:07:57 +08:00
|
|
|
// 状态
|
|
|
|
|
infoConfig,
|
|
|
|
|
isLoading,
|
|
|
|
|
isLoaded,
|
2025-09-11 03:09:17 +08:00
|
|
|
debugMode,
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
// 计算属性
|
|
|
|
|
organization,
|
|
|
|
|
branding,
|
|
|
|
|
features,
|
|
|
|
|
footer,
|
2025-11-08 20:59:24 +08:00
|
|
|
actions,
|
2025-06-22 23:07:57 +08:00
|
|
|
|
|
|
|
|
// 方法
|
|
|
|
|
setInfoConfig,
|
2025-09-11 03:09:17 +08:00
|
|
|
setDebugMode,
|
|
|
|
|
toggleDebugMode,
|
2025-06-22 23:07:57 +08:00
|
|
|
loadInfoConfig,
|
|
|
|
|
reloadInfoConfig
|
|
|
|
|
}
|
2025-11-08 20:59:24 +08:00
|
|
|
})
|