Use Theme type instead of any
This commit is contained in:
parent
0fd0b4f466
commit
f6f493536c
8 changed files with 24 additions and 17 deletions
|
@ -14,6 +14,7 @@ import { program } from '../argv';
|
|||
import { showMachineInfo } from '../misc/show-machine-info';
|
||||
import { initDb } from '../db/postgre';
|
||||
import Xev from 'xev';
|
||||
import { Theme } from '../theme';
|
||||
|
||||
const logger = new Logger('core', 'cyan');
|
||||
const bootLogger = logger.createSubLogger('boot', 'magenta', false);
|
||||
|
@ -116,7 +117,7 @@ function showEnvironment(): void {
|
|||
}
|
||||
|
||||
const pluginService = {
|
||||
registerTheme(theme: any) {
|
||||
registerTheme(theme: Theme) {
|
||||
const ev = new Xev();
|
||||
ev.emit('registerPluginTheme', theme);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as cluster from 'cluster';
|
|||
import { initDb } from '../db/postgre';
|
||||
import Xev from 'xev';
|
||||
import { registerTheme } from '../pluginThemes';
|
||||
import { Theme } from '../theme';
|
||||
|
||||
const ev = new Xev();
|
||||
|
||||
|
@ -21,7 +22,7 @@ export async function workerMain() {
|
|||
// Send a 'ready' message to parent process
|
||||
process.send!('ready');
|
||||
|
||||
ev.on('registerPluginTheme', theme => {
|
||||
ev.on('registerPluginTheme', (theme: Theme) => {
|
||||
registerTheme(theme);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -123,7 +123,8 @@
|
|||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import i18n from '../../../../i18n';
|
||||
import { lightTheme, darkTheme, applyTheme, Theme } from '../../../../theme';
|
||||
import { lightTheme, darkTheme, applyTheme } from '../../../../theme';
|
||||
import { Theme } from '../../../../../../theme';
|
||||
import { Chrome } from 'vue-color';
|
||||
import * as uuid from 'uuid';
|
||||
import * as tinycolor from 'tinycolor2';
|
||||
|
|
|
@ -9,7 +9,8 @@ import Progress from './common/scripts/loading';
|
|||
|
||||
import Err from './common/views/components/connect-failed.vue';
|
||||
import Stream from './common/scripts/stream';
|
||||
import { Theme, builtinThemes } from './theme';
|
||||
import { builtinThemes } from './theme';
|
||||
import { Theme } from '../../theme';
|
||||
import { concat } from '../../prelude/array';
|
||||
|
||||
//#region api requests
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
import * as tinycolor from 'tinycolor2';
|
||||
|
||||
export type Theme = {
|
||||
id: string;
|
||||
name: string;
|
||||
author: string;
|
||||
desc?: string;
|
||||
base?: 'dark' | 'light';
|
||||
vars: { [key: string]: string };
|
||||
props: { [key: string]: string };
|
||||
};
|
||||
import { Theme } from '../../theme';
|
||||
|
||||
export const lightTheme: Theme = require('../themes/light.json5');
|
||||
export const darkTheme: Theme = require('../themes/dark.json5');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
const themes: any[] = [];
|
||||
import { Theme } from './theme';
|
||||
|
||||
export function registerTheme(theme: any) {
|
||||
const themes: Theme[] = [];
|
||||
|
||||
export function registerTheme(theme: Theme) {
|
||||
themes.push(theme);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
require('json5/lib/register');
|
||||
import * as fs from 'fs';
|
||||
import { Theme } from '../../theme';
|
||||
|
||||
export function onActivate(service: any) {
|
||||
const fileNames = fs.readdirSync(`${__dirname}/themes`)
|
||||
.filter(f => fs.statSync(`${__dirname}/themes/${f}`).isFile());
|
||||
|
||||
for (const fileName of fileNames) {
|
||||
const theme = require(`${__dirname}/themes/${fileName}`);
|
||||
const theme = require(`${__dirname}/themes/${fileName}`) as Theme;
|
||||
service.registerTheme(theme);
|
||||
}
|
||||
}
|
||||
|
|
9
src/theme.ts
Normal file
9
src/theme.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export type Theme = {
|
||||
id: string;
|
||||
name: string;
|
||||
author: string;
|
||||
desc?: string;
|
||||
base?: 'dark' | 'light';
|
||||
vars: { [key: string]: string };
|
||||
props: { [key: string]: string };
|
||||
};
|
Loading…
Reference in a new issue