Add config page (#49)

This commit is contained in:
AceDataCloud committed 2024-06-16 23:38:46 +08:00
1 parent 87e83f3432
commit bf01192bd2
786 files changed
+30678 -24247

No files matched your search

+2 -2
View File
@@ -1,10 +1,10 @@
import { BASE_URL_AUTH, BASE_URL_PLATFORM, BASE_URL_HUB } from '@/constants';
/**
* Get base url of data app
* Get base url of platform app
* @returns
*/
export const getBaseUrlData = () => {
export const getBaseUrlPlatform = () => {
if (import.meta.env.VITE_BASE_URL_PLATFORM) {
return import.meta.env.VITE_BASE_URL_PLATFORM;
}
+42 -5
View File
@@ -1,7 +1,7 @@
import { getCookie, setCookie } from 'typescript-cookie';
import config from '@/config';
import favicon from '@/assets/images/favicon.ico';
import { getLocale } from '@/i18n';
import store from '@/store';
export const getDomain = () => {
const host = window.location.hostname;
@@ -69,8 +69,8 @@ export const initializeCookies = async () => {
* Initialize title.
*/
export const initializeTitle = async () => {
// set the title from config.global.title
const title = config.global.title;
// set the title from store.state.site?.title
const title = store.state.site?.title || '';
// find the title element or insert a new one
let titleElement = document.querySelector('title');
if (!titleElement) {
@@ -80,13 +80,43 @@ export const initializeTitle = async () => {
titleElement.innerHTML = title;
};
/**
* Initialize description.
*/
export const initializeDescription = async () => {
// set the title from store.state.site?.description
const description = store.state.site?.description || '';
let metaTag = document.querySelector('meta[name="description"]');
if (!metaTag) {
metaTag = document.createElement('meta');
metaTag.setAttribute('name', 'description');
document.head.appendChild(metaTag);
}
metaTag.setAttribute('content', description);
};
/**
* Initialize keywords in meta
*/
export const initializeKeywords = async () => {
// set the title from store.state.site?.keywords
const keywords = store.state.site?.keywords?.join(',') || '';
let metaTag = document.querySelector('meta[name="keywords"]');
if (!metaTag) {
metaTag = document.createElement('meta');
metaTag.setAttribute('name', 'keywords');
document.head.appendChild(metaTag);
}
metaTag.setAttribute('content', keywords);
};
/**
* Initialize favicon.
*/
export const initializeFavicon = async () => {
// by default use favicon which imported
// if faviconUrl is set in config, use it instead
const favIconUrl = config.global.faviconUrl;
// if faviconUrl is set, use it instead
const favIconUrl = store.state.site?.favicon || '';
let faviconElement = document.querySelector('link[rel="icon"]') as HTMLLinkElement;
if (!faviconElement) {
faviconElement = document.createElement('link');
@@ -95,3 +125,10 @@ export const initializeFavicon = async () => {
}
faviconElement.href = favIconUrl || favicon;
};
/**
* Need to initialize site before render contents
*/
export const initializeSite = async () => {
await store.dispatch('initializeSite');
};