feat: 添加知识库插件更新检查和更新功能
This commit is contained in:
@@ -1,21 +1,6 @@
|
||||
{
|
||||
"title": "Knowledge Base",
|
||||
"subtitle": "Manage and query knowledge base content",
|
||||
"upload": {
|
||||
"title": "Upload Documents",
|
||||
"selectFiles": "Select Files",
|
||||
"supportedFormats": "Supported Formats",
|
||||
"dragDrop": "Drag files here",
|
||||
"processing": "Processing...",
|
||||
"success": "Upload Successful",
|
||||
"error": "Upload Failed"
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "Search knowledge base...",
|
||||
"results": "Search Results",
|
||||
"noResults": "No relevant content found",
|
||||
"searching": "Searching..."
|
||||
},
|
||||
"documents": {
|
||||
"title": "Document List",
|
||||
"name": "Document Name",
|
||||
@@ -42,6 +27,8 @@
|
||||
"title": "Knowledge Base List",
|
||||
"create": "Create Knowledge Base",
|
||||
"config": "Configure",
|
||||
"checkUpdate": "Check Plugin Update",
|
||||
"updatePlugin": "Update Plugin to {version}",
|
||||
"knowledgeCount": "knowledge items",
|
||||
"tips": "Tips: Learn how to use through /kb command in chat page!"
|
||||
},
|
||||
@@ -132,7 +119,14 @@
|
||||
"knowledgeBaseDeleted": "Knowledge base deleted successfully",
|
||||
"deleteFailed": "Deletion failed",
|
||||
"deleteKnowledgeBaseFailed": "Failed to delete knowledge base",
|
||||
"getEmbeddingModelListFailed": "Failed to get embedding model list"
|
||||
"getEmbeddingModelListFailed": "Failed to get embedding model list",
|
||||
"updateAvailable": "New version available: {current} -> {latest}",
|
||||
"pluginUpToDate": "Plugin is up to date",
|
||||
"pluginNotFoundInMarket": "Plugin not found in market",
|
||||
"checkUpdateFailed": "Failed to check for updates",
|
||||
"updateSuccess": "Plugin updated successfully",
|
||||
"updateFailed": "Update failed",
|
||||
"updatePluginFailed": "Failed to update plugin"
|
||||
},
|
||||
"importFromUrl": {
|
||||
"title": "Import from URL",
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
{
|
||||
"title": "知识库",
|
||||
"subtitle": "管理和查询知识库内容",
|
||||
"upload": {
|
||||
"title": "上传文档",
|
||||
"selectFiles": "选择文件",
|
||||
"supportedFormats": "支持的格式",
|
||||
"dragDrop": "拖拽文件到此处",
|
||||
"processing": "处理中...",
|
||||
"success": "上传成功",
|
||||
"error": "上传失败"
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "搜索知识库...",
|
||||
"results": "搜索结果",
|
||||
"noResults": "未找到相关内容",
|
||||
"searching": "搜索中..."
|
||||
},
|
||||
"documents": {
|
||||
"title": "文档列表",
|
||||
"name": "文档名称",
|
||||
@@ -42,6 +27,8 @@
|
||||
"title": "知识库列表",
|
||||
"create": "创建知识库",
|
||||
"config": "配置",
|
||||
"checkUpdate": "检查插件更新",
|
||||
"updatePlugin": "更新插件到 {version}",
|
||||
"knowledgeCount": "条知识",
|
||||
"tips": "Tips: 在聊天页面通过 /kb 指令了解如何使用!"
|
||||
},
|
||||
@@ -132,7 +119,14 @@
|
||||
"knowledgeBaseDeleted": "知识库删除成功",
|
||||
"deleteFailed": "删除失败",
|
||||
"deleteKnowledgeBaseFailed": "删除知识库失败",
|
||||
"getEmbeddingModelListFailed": "获取嵌入模型列表失败"
|
||||
"getEmbeddingModelListFailed": "获取嵌入模型列表失败",
|
||||
"updateAvailable": "发现新版本: {current} -> {latest}",
|
||||
"pluginUpToDate": "插件已是最新版本",
|
||||
"pluginNotFoundInMarket": "在插件市场中未找到该插件",
|
||||
"checkUpdateFailed": "检查更新失败",
|
||||
"updateSuccess": "插件更新成功",
|
||||
"updateFailed": "更新失败",
|
||||
"updatePluginFailed": "更新插件失败"
|
||||
},
|
||||
"importFromUrl": {
|
||||
"title": "从 URL 导入",
|
||||
|
||||
@@ -585,9 +585,19 @@ onMounted(async () => {
|
||||
await getExtensions();
|
||||
|
||||
// 检查是否有 open_config 参数
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let urlParams;
|
||||
if (window.location.hash) {
|
||||
// For hash mode (#/path?param=value)
|
||||
const hashQuery = window.location.hash.split('?')[1] || '';
|
||||
urlParams = new URLSearchParams(hashQuery);
|
||||
} else {
|
||||
// For history mode (/path?param=value)
|
||||
urlParams = new URLSearchParams(window.location.search);
|
||||
}
|
||||
console.log("URL Parameters:", urlParams.toString());
|
||||
const plugin_name = urlParams.get('open_config');
|
||||
if (plugin_name) {
|
||||
console.log(`Opening config for plugin: ${plugin_name}`);
|
||||
openExtensionConfig(plugin_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,14 @@
|
||||
@click="$router.push('/extension?open_config=astrbot_plugin_knowledge_base')">
|
||||
{{ tm('list.config') }}
|
||||
</v-btn>
|
||||
<v-btn class="mb-4 ml-4" prepend-icon="mdi-update" variant="tonal" color="warning"
|
||||
@click="checkPluginUpdate" :loading="checkingUpdate">
|
||||
{{ tm('list.checkUpdate') }}
|
||||
</v-btn>
|
||||
<v-btn v-if="pluginHasUpdate" class="mb-4 ml-4" prepend-icon="mdi-download" variant="tonal" color="primary"
|
||||
@click="updatePlugin" :loading="updatingPlugin">
|
||||
{{ tm('list.updatePlugin', { version: pluginLatestVersion }) }}
|
||||
</v-btn>
|
||||
|
||||
<div class="kb-grid">
|
||||
<div v-for="(kb, index) in kbCollections" :key="index" class="kb-card"
|
||||
@@ -496,6 +504,12 @@ export default {
|
||||
},
|
||||
importing: false,
|
||||
pollingInterval: null,
|
||||
// 插件更新相关
|
||||
checkingUpdate: false,
|
||||
updatingPlugin: false,
|
||||
pluginHasUpdate: false,
|
||||
pluginCurrentVersion: '',
|
||||
pluginLatestVersion: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -564,7 +578,10 @@ export default {
|
||||
}
|
||||
if (response.data.data.length > 0) {
|
||||
this.installed = true;
|
||||
this.pluginCurrentVersion = response.data.data[0].version || '未知';
|
||||
this.getKBCollections();
|
||||
// 自动检查更新
|
||||
this.checkPluginUpdate();
|
||||
} else {
|
||||
this.installed = false;
|
||||
}
|
||||
@@ -575,6 +592,70 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
async checkPluginUpdate() {
|
||||
this.checkingUpdate = true;
|
||||
this.pluginHasUpdate = false;
|
||||
try {
|
||||
// 获取在线插件数据
|
||||
const onlineResponse = await axios.get('/api/plugin/market_list');
|
||||
if (onlineResponse.data.status === 'ok') {
|
||||
const knowledgeBasePlugin = onlineResponse.data.data['astrbot_plugin_knowledge_base'];
|
||||
if (knowledgeBasePlugin) {
|
||||
this.pluginLatestVersion = knowledgeBasePlugin.version || '未知';
|
||||
|
||||
// 比较版本
|
||||
if (this.pluginCurrentVersion && this.pluginLatestVersion &&
|
||||
this.pluginCurrentVersion !== '未知' && this.pluginLatestVersion !== '未知') {
|
||||
this.pluginHasUpdate = this.pluginCurrentVersion != this.pluginLatestVersion
|
||||
}
|
||||
|
||||
if (this.pluginHasUpdate) {
|
||||
this.showSnackbar(this.tm('messages.updateAvailable', {
|
||||
current: this.pluginCurrentVersion,
|
||||
latest: this.pluginLatestVersion
|
||||
}), 'info');
|
||||
} else {
|
||||
this.showSnackbar(this.tm('messages.pluginUpToDate'), 'success');
|
||||
}
|
||||
} else {
|
||||
this.showSnackbar(this.tm('messages.pluginNotFoundInMarket'), 'warning');
|
||||
}
|
||||
} else {
|
||||
this.showSnackbar(this.tm('messages.checkUpdateFailed'), 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking plugin update:', error);
|
||||
this.showSnackbar(this.tm('messages.checkUpdateFailed'), 'error');
|
||||
} finally {
|
||||
this.checkingUpdate = false;
|
||||
}
|
||||
},
|
||||
|
||||
async updatePlugin() {
|
||||
this.updatingPlugin = true;
|
||||
try {
|
||||
const response = await axios.post('/api/plugin/update', {
|
||||
name: 'astrbot_plugin_knowledge_base',
|
||||
proxy: localStorage.getItem('selectedGitHubProxy') || ""
|
||||
});
|
||||
|
||||
if (response.data.status === 'ok') {
|
||||
this.showSnackbar(this.tm('messages.updateSuccess'), 'success');
|
||||
this.pluginHasUpdate = false;
|
||||
this.pluginCurrentVersion = this.pluginLatestVersion;
|
||||
// 刷新插件信息
|
||||
this.checkPlugin();
|
||||
} else {
|
||||
this.showSnackbar(response.data.message || this.tm('messages.updateFailed'), 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error updating plugin:', error);
|
||||
this.showSnackbar(this.tm('messages.updatePluginFailed'), 'error');
|
||||
} finally {
|
||||
this.updatingPlugin = false;
|
||||
}
|
||||
},
|
||||
|
||||
installPlugin() {
|
||||
this.installing = true;
|
||||
axios.post('/api/plugin/install', {
|
||||
|
||||
Reference in New Issue
Block a user