feat(webui): supports force update plugins (#4293)
This commit is contained in:
@@ -145,9 +145,11 @@ const viewReadme = () => {
|
||||
}})</v-list-item-title>
|
||||
</v-list-item>
|
||||
|
||||
<v-list-item @click="updateExtension" :disabled="!extension?.has_update">
|
||||
<v-list-item @click="updateExtension">
|
||||
<v-list-item-title>
|
||||
{{ tm('card.actions.updateTo') }} {{ extension.online_version || extension.version }}
|
||||
{{ extension.has_update
|
||||
? tm('card.actions.updateTo') + ' ' + extension.online_version
|
||||
: tm('card.actions.reinstall') }}
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
@@ -145,6 +145,11 @@
|
||||
"message": "This plugin has been flagged as containing security risks, including unsafe code or functionalities that may cause system malfunctions or data loss. Do you wish to proceed with the installation?",
|
||||
"confirm": "Continue",
|
||||
"cancel": "Cancel"
|
||||
},
|
||||
"forceUpdate": {
|
||||
"title": "No New Version Detected",
|
||||
"message": "No new version detected for this plugin. Do you want to force reinstall? This will pull the latest code from the remote repository.",
|
||||
"confirm": "Force Update"
|
||||
}
|
||||
},
|
||||
"messages": {
|
||||
@@ -185,7 +190,8 @@
|
||||
"reloadPlugin": "Reload Extension",
|
||||
"togglePlugin": "Extension",
|
||||
"viewHandlers": "View Handlers",
|
||||
"updateTo": "Update to"
|
||||
"updateTo": "Update to",
|
||||
"reinstall": "Reinstall"
|
||||
},
|
||||
"status": {
|
||||
"hasUpdate": "New version available",
|
||||
@@ -207,4 +213,4 @@
|
||||
"goToManage": "Go to Manage",
|
||||
"later": "Later"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,11 @@
|
||||
"message": "该插件可能包含不安全的代码或功能,可能导致系统异常或数据损失等。请确认是否继续安装?",
|
||||
"confirm": "继续",
|
||||
"cancel": "取消"
|
||||
},
|
||||
"forceUpdate": {
|
||||
"title": "未检测到新版本",
|
||||
"message": "当前插件未检测到新版本,是否强制重新安装?这将从远程仓库拉取最新代码。",
|
||||
"confirm": "强制更新"
|
||||
}
|
||||
},
|
||||
"messages": {
|
||||
@@ -185,7 +190,8 @@
|
||||
"reloadPlugin": "重载插件",
|
||||
"togglePlugin": "插件",
|
||||
"viewHandlers": "查看行为",
|
||||
"updateTo": "更新到"
|
||||
"updateTo": "更新到",
|
||||
"reinstall": "重新安装"
|
||||
},
|
||||
"status": {
|
||||
"hasUpdate": "有新版本可用",
|
||||
|
||||
@@ -77,6 +77,12 @@ const readmeDialog = reactive({
|
||||
repoUrl: null
|
||||
});
|
||||
|
||||
// 强制更新确认对话框
|
||||
const forceUpdateDialog = reactive({
|
||||
show: false,
|
||||
extensionName: ''
|
||||
});
|
||||
|
||||
// 新增变量支持列表视图
|
||||
// 从 localStorage 恢复显示模式,默认为 false(卡片视图)
|
||||
const getInitialListViewMode = () => {
|
||||
@@ -375,7 +381,17 @@ const handleUninstallConfirm = (options) => {
|
||||
}
|
||||
};
|
||||
|
||||
const updateExtension = async (extension_name) => {
|
||||
const updateExtension = async (extension_name, forceUpdate = false) => {
|
||||
// 查找插件信息
|
||||
const ext = extension_data.data?.find(e => e.name === extension_name);
|
||||
|
||||
// 如果没有检测到更新且不是强制更新,则弹窗确认
|
||||
if (!ext?.has_update && !forceUpdate) {
|
||||
forceUpdateDialog.extensionName = extension_name;
|
||||
forceUpdateDialog.show = true;
|
||||
return;
|
||||
}
|
||||
|
||||
loadingDialog.title = tm('status.loading');
|
||||
loadingDialog.show = true;
|
||||
try {
|
||||
@@ -407,6 +423,14 @@ const updateExtension = async (extension_name) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 确认强制更新
|
||||
const confirmForceUpdate = () => {
|
||||
const name = forceUpdateDialog.extensionName;
|
||||
forceUpdateDialog.show = false;
|
||||
forceUpdateDialog.extensionName = '';
|
||||
updateExtension(name, true);
|
||||
};
|
||||
|
||||
const updateAllExtensions = async () => {
|
||||
if (updatingAll.value || updatableExtensions.value.length === 0) return;
|
||||
updatingAll.value = true;
|
||||
@@ -1106,8 +1130,7 @@ watch(isListView, (newVal) => {
|
||||
<v-tooltip activator="parent" location="top">{{ tm('tooltips.viewDocs') }}</v-tooltip>
|
||||
</v-btn>
|
||||
|
||||
<v-btn icon size="small" @click="updateExtension(item.name)"
|
||||
:v-show="item.has_update">
|
||||
<v-btn icon size="small" @click="updateExtension(item.name)">
|
||||
<v-icon>mdi-update</v-icon>
|
||||
<v-tooltip activator="parent" location="top">{{ tm('tooltips.update') }}</v-tooltip>
|
||||
</v-btn>
|
||||
@@ -1774,6 +1797,24 @@ watch(isListView, (newVal) => {
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<!-- 强制更新确认对话框 -->
|
||||
<v-dialog v-model="forceUpdateDialog.show" max-width="420">
|
||||
<v-card class="rounded-lg">
|
||||
<v-card-title class="text-h6 d-flex align-center">
|
||||
<v-icon color="info" class="mr-2">mdi-information-outline</v-icon>
|
||||
{{ tm('dialogs.forceUpdate.title') }}
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
{{ tm('dialogs.forceUpdate.message') }}
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn variant="text" @click="forceUpdateDialog.show = false">{{ tm('buttons.cancel') }}</v-btn>
|
||||
<v-btn color="primary" variant="flat" @click="confirmForceUpdate">{{ tm('dialogs.forceUpdate.confirm') }}</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user