mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: 解决升级应用之后 状态没有刷新的BUG
This commit is contained in:
parent
b1cc7c0c1d
commit
3456ab7509
@ -8,7 +8,7 @@
|
|||||||
size="large"
|
size="large"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<el-badge :value="button.count" class="item" v-if="button.count > 0">
|
<el-badge :value="button.count" class="item" v-if="button.count > 0" is-dot>
|
||||||
<span>{{ button.label }}</span>
|
<span>{{ button.label }}</span>
|
||||||
</el-badge>
|
</el-badge>
|
||||||
</el-radio-button>
|
</el-radio-button>
|
||||||
|
26
frontend/src/utils/bus.ts
Normal file
26
frontend/src/utils/bus.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
class Bus {
|
||||||
|
list: { [key: string]: Array<Function> };
|
||||||
|
constructor() {
|
||||||
|
this.list = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
on(name: string, fn: Function) {
|
||||||
|
this.list[name] = this.list[name] || [];
|
||||||
|
this.list[name].push(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit(name: string, data?: any) {
|
||||||
|
if (this.list[name]) {
|
||||||
|
this.list[name].forEach((fn: Function) => {
|
||||||
|
fn(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
off(name: string) {
|
||||||
|
if (this.list[name]) {
|
||||||
|
delete this.list[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Bus;
|
3
frontend/src/views/app-store/bus.ts
Normal file
3
frontend/src/views/app-store/bus.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import Bus from '@/utils/bus';
|
||||||
|
|
||||||
|
export default new Bus();
|
@ -15,6 +15,7 @@ import RouterButton from '@/components/router-button/index.vue';
|
|||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { SearchAppInstalled } from '@/api/modules/app';
|
import { SearchAppInstalled } from '@/api/modules/app';
|
||||||
|
import bus from './bus';
|
||||||
let showButton = ref(false);
|
let showButton = ref(false);
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
@ -31,12 +32,26 @@ const buttons = [
|
|||||||
count: 0,
|
count: 0,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const search = () => {
|
||||||
|
SearchAppInstalled({ update: true, page: 1, pageSize: 100 })
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data.items) {
|
||||||
|
buttons[2].count = res.data.items.length;
|
||||||
|
} else {
|
||||||
|
buttons[2].count = 0;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
showButton.value = true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
SearchAppInstalled({ update: true, page: 1, pageSize: 100 }).then((res) => {
|
search();
|
||||||
if (res.data.items) {
|
bus.on('update', () => {
|
||||||
buttons[2].count = res.data.items.length;
|
showButton.value = false;
|
||||||
}
|
search();
|
||||||
showButton.value = true;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -34,10 +34,11 @@ import { App } from '@/api/interface/app';
|
|||||||
import { GetAppUpdateVersions, InstalledOp } from '@/api/modules/app';
|
import { GetAppUpdateVersions, InstalledOp } from '@/api/modules/app';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { ElMessageBox, FormInstance } from 'element-plus';
|
import { ElMessageBox, FormInstance } from 'element-plus';
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref, onBeforeUnmount } from 'vue';
|
||||||
import Header from '@/components/drawer-header/index.vue';
|
import Header from '@/components/drawer-header/index.vue';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
|
import bus from '../../bus';
|
||||||
|
|
||||||
const updateRef = ref<FormInstance>();
|
const updateRef = ref<FormInstance>();
|
||||||
let open = ref(false);
|
let open = ref(false);
|
||||||
@ -75,8 +76,9 @@ const operate = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
await InstalledOp(operateReq)
|
await InstalledOp(operateReq)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
open.value = false;
|
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
|
bus.emit('update', true);
|
||||||
|
handleClose();
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@ -97,6 +99,10 @@ const onOperate = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
bus.off('update');
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
acceptParams,
|
acceptParams,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user