|
@ -8,10 +8,6 @@ export const useGlobalStore = defineStore('Global', () => { |
|
|
); |
|
|
); |
|
|
const updateAvailable = ref(false); |
|
|
const updateAvailable = ref(false); |
|
|
const features = ref({ |
|
|
const features = ref({ |
|
|
trafficStats: { |
|
|
|
|
|
enabled: false, |
|
|
|
|
|
type: 0, |
|
|
|
|
|
}, |
|
|
|
|
|
sortClients: { |
|
|
sortClients: { |
|
|
enabled: false, |
|
|
enabled: false, |
|
|
}, |
|
|
}, |
|
@ -22,12 +18,18 @@ export const useGlobalStore = defineStore('Global', () => { |
|
|
enabled: false, |
|
|
enabled: false, |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
const statistics = ref({ |
|
|
|
|
|
enabled: false, |
|
|
|
|
|
chartType: 0, |
|
|
|
|
|
}); |
|
|
const sortClient = ref(true); // Sort clients by name, true = asc, false = desc
|
|
|
const sortClient = ref(true); // Sort clients by name, true = asc, false = desc
|
|
|
|
|
|
|
|
|
const { availableLocales, locale } = useI18n(); |
|
|
const { availableLocales, locale } = useI18n(); |
|
|
|
|
|
|
|
|
async function setLanguage() { |
|
|
async function setLanguage() { |
|
|
const { data: lang } = await api.getLang(); |
|
|
const { data: lang } = await useFetch('/api/lang', { |
|
|
|
|
|
method: 'get', |
|
|
|
|
|
}); |
|
|
if ( |
|
|
if ( |
|
|
lang.value !== getItem('lang') && |
|
|
lang.value !== getItem('lang') && |
|
|
availableLocales.includes(lang.value!) |
|
|
availableLocales.includes(lang.value!) |
|
@ -38,7 +40,9 @@ export const useGlobalStore = defineStore('Global', () => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function fetchRelease() { |
|
|
async function fetchRelease() { |
|
|
const { data: release } = await api.getRelease(); |
|
|
const { data: release } = await useFetch('/api/release', { |
|
|
|
|
|
method: 'get', |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
if (!release.value) { |
|
|
if (!release.value) { |
|
|
return; |
|
|
return; |
|
@ -50,14 +54,25 @@ export const useGlobalStore = defineStore('Global', () => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function fetchFeatures() { |
|
|
async function fetchFeatures() { |
|
|
const { data: apiFeatures } = await api.getFeatures(); |
|
|
const { data: apiFeatures } = await useFetch('/api/features', { |
|
|
|
|
|
method: 'get', |
|
|
|
|
|
}); |
|
|
if (apiFeatures.value) { |
|
|
if (apiFeatures.value) { |
|
|
features.value = apiFeatures.value; |
|
|
features.value = apiFeatures.value; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function fetchStatistics() { |
|
|
|
|
|
const { data: apiStatistics } = await useFetch('/api/statistics', { |
|
|
|
|
|
method: 'get', |
|
|
|
|
|
}); |
|
|
|
|
|
if (apiStatistics.value) { |
|
|
|
|
|
statistics.value = apiStatistics.value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const updateCharts = computed(() => { |
|
|
const updateCharts = computed(() => { |
|
|
return features.value.trafficStats.type > 0 && uiShowCharts.value; |
|
|
return statistics.value.chartType > 0 && uiShowCharts.value; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
@ -68,8 +83,10 @@ export const useGlobalStore = defineStore('Global', () => { |
|
|
currentRelease, |
|
|
currentRelease, |
|
|
latestRelease, |
|
|
latestRelease, |
|
|
updateAvailable, |
|
|
updateAvailable, |
|
|
|
|
|
statistics, |
|
|
fetchRelease, |
|
|
fetchRelease, |
|
|
fetchFeatures, |
|
|
fetchFeatures, |
|
|
setLanguage, |
|
|
setLanguage, |
|
|
|
|
|
fetchStatistics, |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|