feat: update admin page

This commit is contained in:
2025-11-03 09:20:28 +03:00
parent 30b0108fe7
commit cd818d3356
94 changed files with 4729 additions and 1227 deletions

View File

@@ -0,0 +1,125 @@
import {defineStore} from "pinia";
import {apiGet, apiPost} from "@/utils/http.js";
import {toastBus} from "@/utils/toastHelper.js";
export const useSettingsStore = defineStore('settings', {
state: () => ({
isLoading: false,
error: null,
items: {
app: {
app_enabled: true,
app_name: '',
app_icon: null,
theme_light: 'light',
theme_dark: 'dark',
app_debug: false,
},
telegram: {
mini_app_url: '',
bot_token: '',
chat_id: '',
owner_notification_template: '',
customer_notification_template: '',
},
metrics: {
yandex_metrika_enabled: false,
yandex_metrika_counter: '',
},
store: {
enable_store: true,
mainpage_products: 'most_viewed',
featured_products: [],
mainpage_categories: 'latest10',
featured_categories: [],
feature_coupons: true,
feature_vouchers: true,
},
orders: {
order_default_status_id: 1,
},
texts: {
text_no_more_products: '',
text_empty_cart: '',
text_order_created_success: '',
},
sliders: {
mainpage_slider: {
is_enabled: false,
effect: "slide",
pagination: true,
scrollbar: false,
free_mode: false,
space_between: 30,
autoplay: false,
loop: false,
slides: [],
},
},
},
}),
getters: {
app_icon_preview: (state) => {
if (!state.items.app.app_icon) return '/image/cache/no_image-100x100.png';
const extIndex = state.items.app.app_icon.lastIndexOf('.');
const ext = state.items.app.app_icon.substring(extIndex);
const filename = state.items.app.app_icon.substring(0, extIndex);
return `/image/cache/${filename}-100x100${ext}`;
},
},
actions: {
async fetchSettings() {
this.isLoading = true;
this.error = null;
const response = await apiGet('getSettingsForm');
if (response.success) {
this.items = {
...this.items,
...response.data,
};
} else {
this.error = 'Возникли проблемы при загрузке настроек.';
}
this.isLoading = false;
},
async saveSettings() {
this.isLoading = true;
const settings = this.transformSettingsToStore(this.items);
const response = await apiPost('saveSettingsForm', settings);
if (response.success === true) {
toastBus.emit('show', {
severity: 'success',
summary: 'Готово!',
detail: 'Настройки сохранены.',
life: 2000,
});
} else {
toastBus.emit('show', {
severity: 'error',
summary: 'Ошибка',
detail: 'Возникли проблемы при сохранении настроек на сервере.',
life: 2000,
});
}
this.isLoading = false;
},
transformSettingsToStore(items) {
return items;
},
},
});

View File

@@ -0,0 +1,22 @@
import {defineStore} from "pinia";
import {apiGet, apiPost} from "@/utils/http.js";
export const useStatsStore = defineStore('stats', {
state: () => ({
items: {
orders_count: null,
orders_total_amount: null,
order_products_count: null,
}
}),
actions: {
async fetchStats() {
const response = await apiPost('getDashboardStats');
this.items.orders_count = response.data?.data?.orders_count;
this.items.orders_total_amount = response.data?.data?.orders_total_amount;
this.items.order_products_count = response.data?.data?.order_products_count;
}
},
});