feat: make frontend use database settings
This commit is contained in:
parent
b2253c7f60
commit
334c3d1c34
|
@ -1,57 +1,46 @@
|
||||||
import dotenv from 'dotenv/config';
|
import dotenv from 'dotenv/config';
|
||||||
import autoprefixer from 'autoprefixer';
|
import autoprefixer from 'autoprefixer';
|
||||||
import jetpack from 'fs-jetpack';
|
|
||||||
|
|
||||||
const clientConfig = {
|
const Util = require('./src/api/utils/Util');
|
||||||
development: process.env.NODE_ENV !== 'production',
|
|
||||||
version: process.env.npm_package_version,
|
|
||||||
URL: process.env.DOMAIN,
|
|
||||||
baseURL: `${process.env.DOMAIN}${process.env.ROUTE_PREFIX}`,
|
|
||||||
serviceName: process.env.SERVICE_NAME,
|
|
||||||
maxFileSize: parseInt(process.env.MAX_SIZE, 10),
|
|
||||||
chunkSize: parseInt(process.env.CHUNK_SIZE, 10),
|
|
||||||
publicMode: process.env.PUBLIC_MODE === 'true',
|
|
||||||
userAccounts: process.env.USER_ACCOUNTS === 'true'
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
ssr: true,
|
ssr: true,
|
||||||
srcDir: 'src/site/',
|
srcDir: 'src/site/',
|
||||||
head: {
|
head: {
|
||||||
title: process.env.SERVICE_NAME,
|
title: Util.config.serviceName,
|
||||||
titleTemplate: `%s | ${process.env.SERVICE_NAME}`,
|
titleTemplate: `%s | ${Util.config.serviceName}`,
|
||||||
// TODO: Add the directory with pictures for favicon and stuff
|
// TODO: Add the directory with pictures for favicon and stuff
|
||||||
meta: [
|
meta: [
|
||||||
{ charset: 'utf-8' },
|
{ charset: 'utf-8' },
|
||||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||||
{ hid: 'theme-color', name: 'theme-color', content: `${process.env.META_THEME_COLOR}` },
|
{ hid: 'theme-color', name: 'theme-color', content: `${Util.config.metaThemeColor}` },
|
||||||
{ hid: 'description', name: 'description', content: `${process.env.META_DESCRIPTION}` },
|
{ hid: 'description', name: 'description', content: `${Util.config.metaDescription}` },
|
||||||
{ hid: 'keywords', name: 'keywords', content: `${process.env.META_KEYWORDS}` },
|
{ hid: 'keywords', name: 'keywords', content: `${Util.config.metaKeywords}` },
|
||||||
{
|
{
|
||||||
hid: 'apple-mobile-web-app-title',
|
hid: 'apple-mobile-web-app-title',
|
||||||
name: 'apple-mobile-web-app-title',
|
name: 'apple-mobile-web-app-title',
|
||||||
content: `${process.env.SERVICE_NAME}`
|
content: `${Util.config.serviceName}`
|
||||||
},
|
},
|
||||||
{ hid: 'application-name', name: 'application-name', content: `${process.env.SERVICE_NAME}` },
|
{ hid: 'application-name', name: 'application-name', content: `${Util.config.serviceName}` },
|
||||||
{ hid: 'twitter:card', name: 'twitter:card', content: 'summary' },
|
{ hid: 'twitter:card', name: 'twitter:card', content: 'summary' },
|
||||||
{ hid: 'twitter:site', name: 'twitter:site', content: `${process.env.META_TWITTER_HANDLE}` },
|
{ hid: 'twitter:site', name: 'twitter:site', content: `${Util.config.metaTwitterHandle}` },
|
||||||
{ hid: 'twitter:creator', name: 'twitter:creator', content: `${process.env.META_TWITTER_HANDLE}` },
|
{ hid: 'twitter:creator', name: 'twitter:creator', content: `${Util.config.metaTwitterHandle}` },
|
||||||
{ hid: 'twitter:title', name: 'twitter:title', content: `${process.env.SERVICE_NAME}` },
|
{ hid: 'twitter:title', name: 'twitter:title', content: `${Util.config.serviceName}` },
|
||||||
{ hid: 'twitter:description', name: 'twitter:description', content: `${process.env.META_DESCRIPTION}` },
|
{ hid: 'twitter:description', name: 'twitter:description', content: `${Util.config.metaDescription}` },
|
||||||
{ hid: 'twitter:image', name: 'twitter:image', content: `${process.env.DOMAIN}/logo.png` },
|
{ hid: 'twitter:image', name: 'twitter:image', content: `/logo.png` },
|
||||||
{ hid: 'og:url', property: 'og:url', content: `${process.env.DOMAIN}` },
|
{ hid: 'og:url', property: 'og:url', content: `/` },
|
||||||
{ hid: 'og:type', property: 'og:type', content: 'website' },
|
{ hid: 'og:type', property: 'og:type', content: 'website' },
|
||||||
{ hid: 'og:title', property: 'og:title', content: `${process.env.SERVICE_NAME}` },
|
{ hid: 'og:title', property: 'og:title', content: `${Util.config.serviceName}` },
|
||||||
{ hid: 'og:description', property: 'og:description', content: `${process.env.META_DESCRIPTION}` },
|
{ hid: 'og:description', property: 'og:description', content: `${Util.config.metaDescription}` },
|
||||||
{ hid: 'og:image', property: 'og:image', content: `${process.env.DOMAIN}/logo.png` },
|
{ hid: 'og:image', property: 'og:image', content: `/logo.png` },
|
||||||
{ hid: 'og:image:secure_url', property: 'og:image:secure_url', content: `${process.env.DOMAIN}/logo.png` },
|
{ hid: 'og:image:secure_url', property: 'og:image:secure_url', content: `/logo.png` },
|
||||||
{ hid: 'og:site_name', property: 'og:site_name', content: `${process.env.SERVICE_NAME}` }
|
{ hid: 'og:site_name', property: 'og:site_name', content: `${Util.config.serviceName}` }
|
||||||
],
|
],
|
||||||
link: [
|
link: [
|
||||||
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Nunito:300,400,600,700' },
|
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Nunito:300,400,600,700' },
|
||||||
|
|
||||||
// This one is a pain in the ass to make it customizable, so you should edit it manually
|
// This one is a pain in the ass to make it customizable, so you should edit it manually
|
||||||
{ type: 'application/json+oembed', href: `${process.env.DOMAIN}/oembed.json` }
|
{ type: 'application/json+oembed', href: `/oembed.json` }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -70,8 +59,17 @@ export default {
|
||||||
linkActiveClass: 'is-active',
|
linkActiveClass: 'is-active',
|
||||||
linkExactActiveClass: 'is-active'
|
linkExactActiveClass: 'is-active'
|
||||||
},
|
},
|
||||||
|
env: {
|
||||||
|
development: process.env.NODE_ENV !== 'production',
|
||||||
|
version: process.env.npm_package_version,
|
||||||
|
serviceName: Util.config.serviceName,
|
||||||
|
maxFileSize: Util.config.maxSize,
|
||||||
|
chunkSize: Util.config.chunkSize,
|
||||||
|
publicMode: Util.config.publicMode,
|
||||||
|
userAccounts: Util.config.userAccounts
|
||||||
|
},
|
||||||
axios: {
|
axios: {
|
||||||
baseURL: `${process.env.DOMAIN}${process.env.ROUTE_PREFIX}`
|
baseURL: `${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:5000'}/api`
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
extractCSS: process.env.NODE_ENV === 'production',
|
extractCSS: process.env.NODE_ENV === 'production',
|
||||||
|
@ -80,11 +78,8 @@ export default {
|
||||||
autoprefixer
|
autoprefixer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extend(config, { isClient, isDev }) {
|
extend(config, { isDev }) {
|
||||||
// Extend only webpack config for client-bundle
|
// Extend only webpack config for client-bundle
|
||||||
if (isClient) {
|
|
||||||
jetpack.write('dist/config.json', clientConfig);
|
|
||||||
}
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
config.devtool = 'source-map';
|
config.devtool = 'source-map';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ export const state = () => ({
|
||||||
files: []
|
files: []
|
||||||
},
|
},
|
||||||
file: {},
|
file: {},
|
||||||
settings: {},
|
|
||||||
statistics: {},
|
statistics: {},
|
||||||
settingsSchema: {
|
settingsSchema: {
|
||||||
type: null,
|
type: null,
|
||||||
|
@ -20,12 +19,6 @@ export const state = () => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
async fetchSettings({ commit }) {
|
|
||||||
const response = await this.$axios.$get('service/config');
|
|
||||||
commit('setSettings', response);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
},
|
|
||||||
async fetchStatistics({ commit }, category) {
|
async fetchStatistics({ commit }, category) {
|
||||||
const url = category ? `service/statistics/${category}` : 'service/statistics';
|
const url = category ? `service/statistics/${category}` : 'service/statistics';
|
||||||
const response = await this.$axios.$get(url);
|
const response = await this.$axios.$get(url);
|
||||||
|
@ -105,9 +98,6 @@ export const actions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
setSettings(state, { config }) {
|
|
||||||
state.settings = config;
|
|
||||||
},
|
|
||||||
setStatistics(state, { statistics, category }) {
|
setStatistics(state, { statistics, category }) {
|
||||||
if (category) {
|
if (category) {
|
||||||
state.statistics[category] = statistics[category];
|
state.statistics[category] = statistics[category];
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
export const state = () => ({
|
export const state = () => ({
|
||||||
development: true,
|
development: process.env.development,
|
||||||
version: '4.0.0',
|
version: process.env.version,
|
||||||
URL: 'http://localhost:8080',
|
URL: process.env.development ? 'http://localhost:5000' : '/',
|
||||||
baseURL: 'http://localhost:8080/api',
|
baseURL: `${process.env.development ? 'http://localhost:5000' : ''}/api`,
|
||||||
serviceName: '',
|
serviceName: process.env.serviceName,
|
||||||
maxFileSize: 100,
|
maxFileSize: process.env.maxFilesize,
|
||||||
chunkSize: 90,
|
chunkSize: process.env.chunkSize,
|
||||||
maxLinksPerAlbum: 5,
|
publicMode: process.env.publicMode,
|
||||||
publicMode: false,
|
userAccounts: process.env.userAccounts
|
||||||
userAccounts: false
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mutations = {
|
|
||||||
set(state, config) {
|
|
||||||
Object.assign(state, config);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue