2022-08-17 17:46:49 +08:00
|
|
|
<template>
|
2022-09-27 16:57:23 +08:00
|
|
|
<div>
|
2023-02-09 17:18:24 +08:00
|
|
|
<div v-if="showButton">
|
|
|
|
<RouterButton :buttons="buttons" />
|
|
|
|
</div>
|
2022-09-27 16:57:23 +08:00
|
|
|
<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';
|
2023-02-21 11:27:32 +08:00
|
|
|
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
|
|
|
{
|
2023-03-08 11:04:22 +08:00
|
|
|
label: i18n.global.t('app.canUpgrade'),
|
|
|
|
path: '/apps/upgrade',
|
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
|
|
|
];
|
2023-02-21 11:27:32 +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(() => {
|
2023-02-21 11:27:32 +08:00
|
|
|
search();
|
2023-03-08 11:04:22 +08:00
|
|
|
bus.on('upgrade', () => {
|
2023-02-21 11:27:32 +08:00
|
|
|
showButton.value = false;
|
|
|
|
search();
|
2023-02-09 17:18:24 +08:00
|
|
|
});
|
|
|
|
});
|
2022-08-17 17:46:49 +08:00
|
|
|
</script>
|