1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-21 01:09:17 +08:00

58 lines
1.3 KiB
Vue
Raw Normal View History

2022-08-17 17:46:49 +08:00
<template>
<div>
2023-02-09 17:18:24 +08:00
<div v-if="showButton">
<RouterButton :buttons="buttons" />
</div>
<LayoutContent>
<router-view></router-view>
</LayoutContent>
</div>
2022-08-17 17:46:49 +08:00
</template>
<script lang="ts" setup>
import LayoutContent from '@/layout/layout-content.vue';
2023-01-11 18:09:01 +08:00
import RouterButton from '@/components/router-button/index.vue';
import i18n from '@/lang';
2023-02-09 17:18:24 +08:00
import { onMounted, ref } from 'vue';
import { SearchAppInstalled } from '@/api/modules/app';
import bus from './bus';
2023-02-09 17:18:24 +08:00
let showButton = ref(false);
2023-01-11 18:09:01 +08:00
const buttons = [
{
label: i18n.global.t('app.all'),
path: '/apps/all',
},
{
label: i18n.global.t('app.installed'),
path: '/apps/installed',
},
2023-01-16 15:30:24 +08:00
{
label: i18n.global.t('app.canUpdate'),
path: '/apps/update',
2023-02-09 17:18:24 +08:00
count: 0,
2023-01-16 15:30:24 +08:00
},
2023-01-11 18:09:01 +08:00
];
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;
});
};
2023-02-09 17:18:24 +08:00
onMounted(() => {
search();
bus.on('update', () => {
showButton.value = false;
search();
2023-02-09 17:18:24 +08:00
});
});
2022-08-17 17:46:49 +08:00
</script>