feat: maintenance tasks, logs

- add interval for periodic maintenance tasks
- add cache prune periodic task
- use rotating handler for monolog
- update UI logs component
- correctly reset cache from admin
- increase cache timeout for tg data
- fix UI errors in admin
This commit is contained in:
2025-11-20 09:07:33 +03:00
parent 984d4d7ac3
commit ae9771dec4
15 changed files with 170 additions and 60 deletions

View File

@@ -1,16 +1,13 @@
<template>
<textarea v-text="rows" rows="40" class="tw:w-full"/>
<textarea v-text="logs.lines" rows="40" class="tw:w-full" readonly/>
</template>
<script setup>
import {onMounted, ref} from "vue";
import {apiGet} from "@/utils/http.js";
import {onMounted} from "vue";
import {useLogsStore} from "@/stores/logs.js";
const rows = ref('');
onMounted(async () => {
const response = await apiGet('getLogs');
rows.value = response.data;
});
const logs = useLogsStore();
onMounted(async () => logs.fetchLogsFromServer());
</script>
<style scoped>

View File

@@ -65,27 +65,30 @@
</div>
</div>
<div class="tw:mt-6 tw:lg:mt-0 tw:flex tw:items-center tw:gap-4">
<ResetCacheBtn/>
<ButtonGroup>
<ResetCacheBtn/>
</ButtonGroup>
<div class="btn-group">
<a
class="btn btn-primary"
:class="{'disabled': (tgMe?.result?.has_main_web_app !== true)}"
rounded
:href="`https://t.me/${tgMe?.result?.username}?startapp`"
<Button
icon="fa fa-play"
v-tooltip.top="(tgMe?.result?.has_main_web_app !== true) ? 'Вы не привязали Telegram Mini App к боту.' : 'Открыть Telegram магазин'"
as="a"
target="_blank"
:title="(tgMe?.result?.has_main_web_app !== true) ? 'Вы не привязали Telegram Mini App к боту.' : 'Открыть Telegram магазин'"
>
<i class="fa fa-play"></i>
</a>
<a class="btn btn-default" target="_blank" href="https://telecart-labs.github.io/docs/" title="Документация по модулю TeleCart">
<i class="fa fa-book"></i>
</a>
<a class="btn btn-default" target="_blank" href="https://t.me/ocstore3" title="Официальная Telegram группа модуля TeleCart">
<i class="fa fa-group"></i>
</a>
</div>
:href="`https://t.me/${tgMe?.result?.username}?startapp`"
/>
<Button
icon="fa fa-book"
v-tooltip.top="'Документация по модулю TeleCart'"
as="a"
target="_blank"
href="https://telecart-labs.github.io/docs/"
/>
<Button
icon="fa fa-group"
v-tooltip.top="'Официальная Telegram группа модуля TeleCart'"
as="a"
target="_blank"
href="https://t.me/ocstore3"
/>
</ButtonGroup>
</div>
</div>
</div>
@@ -98,6 +101,7 @@ import {onMounted, ref} from "vue";
import OcImagePicker from "@/components/OcImagePicker.vue";
import {apiGet} from "@/utils/http.js";
import ResetCacheBtn from "@/components/Form/ResetCacheBtn.vue";
import {Button, ButtonGroup} from "primevue";
const settings = useSettingsStore();
const stats = useStatsStore();

View File

@@ -0,0 +1,16 @@
import {defineStore} from "pinia";
import {apiGet} from "@/utils/http.js";
export const useLogsStore = defineStore('logs', {
state: () => ({
lines: '',
}),
actions: {
async fetchLogsFromServer() {
if (this.lines) return;
const response = await apiGet('getLogs');
this.lines = response.data;
},
},
});