From c46850a69a5f6f33df2cf0b9299c5f0dcf56bcfa Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 15 Nov 2017 09:47:47 +0900 Subject: [PATCH] :v: --- src/api/endpoints/meta.ts | 6 +++++- src/api/models/meta.ts | 7 +++++++ src/web/app/desktop/tags/pages/entrance.tag | 11 ++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/api/models/meta.ts diff --git a/src/api/endpoints/meta.ts b/src/api/endpoints/meta.ts index a3f1d5032..4f626efa6 100644 --- a/src/api/endpoints/meta.ts +++ b/src/api/endpoints/meta.ts @@ -4,6 +4,7 @@ import * as os from 'os'; import version from '../../version'; import config from '../../conf'; +import Meta from '../models/meta'; /** * @swagger @@ -39,6 +40,8 @@ import config from '../../conf'; * @return {Promise} */ module.exports = (params) => new Promise(async (res, rej) => { + const meta = (await Meta.findOne()) || {}; + res({ maintainer: config.maintainer, version: version, @@ -49,6 +52,7 @@ module.exports = (params) => new Promise(async (res, rej) => { cpu: { model: os.cpus()[0].model, cores: os.cpus().length - } + }, + top_image: meta.top_image }); }); diff --git a/src/api/models/meta.ts b/src/api/models/meta.ts new file mode 100644 index 000000000..c7dba8fcb --- /dev/null +++ b/src/api/models/meta.ts @@ -0,0 +1,7 @@ +import db from '../../db/mongodb'; + +export default db.get('meta') as any; // fuck type definition + +export type IMeta = { + top_image: string; +}; diff --git a/src/web/app/desktop/tags/pages/entrance.tag b/src/web/app/desktop/tags/pages/entrance.tag index 914e6b0d5..0dfca1f7a 100644 --- a/src/web/app/desktop/tags/pages/entrance.tag +++ b/src/web/app/desktop/tags/pages/entrance.tag @@ -113,9 +113,14 @@ this.mode = 'signin'; this.on('mount', () => { - document.documentElement.style.backgroundImage = 'url("/assets/desktop/index.jpg")'; - document.documentElement.style.backgroundSize = 'cover'; - document.documentElement.style.backgroundPosition = 'center'; + document.documentElement.style.backgroundColor = '#444'; + + this.api('meta').then(meta => { + const img = meta.top_image ? meta.top_image : '/assets/desktop/index.jpg'; + document.documentElement.style.backgroundImage = `url("${ img }")`; + document.documentElement.style.backgroundSize = 'cover'; + document.documentElement.style.backgroundPosition = 'center'; + }); this.api('stats').then(stats => { this.update({