feat(webui): supports force update plugins (#4293)

This commit is contained in:
clown145
2026-01-03 15:30:50 +08:00
committed by GitHub
parent 9db7bf59b8
commit 442b5403df
4 changed files with 63 additions and 8 deletions

View File

@@ -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>