Skip to content

Commit

Permalink
feat: add platform & online as global setting
Browse files Browse the repository at this point in the history
Former-commit-id: 06d649a
  • Loading branch information
ci010 committed Jul 15, 2019
1 parent a113784 commit 60368ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/store/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable guard-for-in */
import { app, ipcMain, shell } from 'electron';
import { join } from 'path';
import { platform } from 'os';
import Vue from 'vue';
import Vuex from 'vuex';
import modules from './modules';
Expand Down Expand Up @@ -45,6 +46,7 @@ async function load() {
const mod = {
state: {
root,
platform: platform(),
online: false,
},
plugins,
Expand All @@ -53,6 +55,7 @@ async function load() {
path: state => (...paths) => join(state.root, ...paths),
},
mutations: {
platform(state, p) { state.platform = p; },
online(state, o) { state.online = o; },
root(state, r) { state.root = r; },
},
Expand Down Expand Up @@ -99,6 +102,7 @@ async function load() {
console.log(`Successfully init modules. Total Time is ${Date.now() - startingTime}ms.`);

newStore.commit('root', root);
newStore.commit('platform', platform());

console.log('Done loading store!');

Expand Down
2 changes: 2 additions & 0 deletions src/universal/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ export default {
state: {
root: '',
online: false,
platform: '',
},
modules,
mutations: {
online(state, o) { state.online = o; },
root(state, r) { state.root = r; },
platform(state, p) { state.platform = p; },
},
getters: {
},
Expand Down
5 changes: 5 additions & 0 deletions src/universal/store/store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ interface BaseState {
* launcher root data folder path
*/
root: string
online: boolean
platform: NodeJS.Platform
}
interface BaseMutations {
root(state: State, root: string): void
online(state: State, online: boolean): void
platform(state: State, platform: NodeJS.Platform): void

}

type Mutations = VersionModule.Mutations &
Expand Down

0 comments on commit 60368ff

Please sign in to comment.