diff --git a/package.json b/package.json index 18fdf7b..b72f2b0 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,11 @@ }, "scripts": { "prebuild": "rimraf dist_electron", - "build": "./node_modules/.bin/electron-rebuild && cross-env NODE_ENV=production npm run transpile && cross-env NODE_ENV=production npm run electron:build", + "build": "./node_modules/.bin/electron-rebuild && npm run transpile && npm run electron:build", "commit": "standard-commit", "commitlint": "standard-commitlint", - "electron:build": "vue-cli-service electron:build --mac --win --linux --x64", - "electron:serve": "vue-cli-service electron:serve", + "electron:build": "cross-env NODE_ENV=production vue-cli-service electron:build --mac --win --linux --x64", + "electron:serve": "cross-env NODE_ENV=development vue-cli-service electron:serve", "postinstall": "electron-builder install-app-deps", "lint": "vue-cli-service lint", "lint:fix": "vue-cli-service lint --fix", @@ -40,7 +40,7 @@ "postrelease": "git push --follow-tags && npm publish", "release:major": "standard-version --release-as major && npm run postrelease", "release:minor": "standard-version --release-as minor && npm run postrelease", - "transpile": "npx babel lib --out-dir lib-es5", + "transpile": "cross-env NODE_ENV=production npx babel lib --out-dir lib-es5", "postuninstall": "electron-builder install-app-deps", "update": "npm-check --update", "watch": "babel lib --out-dir lib-es5 --watch" diff --git a/src/assets/logo.png b/src/assets/logo.png deleted file mode 100644 index f3d2503..0000000 Binary files a/src/assets/logo.png and /dev/null differ diff --git a/src/assets/logo.svg b/src/assets/logo.svg deleted file mode 100644 index 145b6d1..0000000 --- a/src/assets/logo.svg +++ /dev/null @@ -1 +0,0 @@ -Artboard 46 diff --git a/src/background.js b/src/background.js index db6fb4a..23cf681 100644 --- a/src/background.js +++ b/src/background.js @@ -1,10 +1,13 @@ 'use strict' -import { app, protocol, BrowserWindow } from 'electron' +import { app, protocol, BrowserWindow, ipcMain } from 'electron' import { createProtocol, installVueDevtools, } from 'vue-cli-plugin-electron-builder/lib' +import initState from '../lib/utils/state' +import config from '../lib/utils/config' +import installSkin from '../lib/actions/reinstall-skin' const isDevelopment = process.env.NODE_ENV !== 'production' // Keep a global reference of the window object, if you don't, the window will @@ -64,6 +67,19 @@ app.on('ready', async () => { createWindow() }) +ipcMain.on('install-skin', (event, options) => { + const cliState = initState({}) + config.init(cliState) + Object.keys(options).forEach((key) => { + cliState.set(key, options[key]) + }) + installSkin(cliState).then(() => { + event.sender.send('skin-installed', 'yay') + }).catch((err) => { + event.sender.send('skin-install-failed', err.message) + }) +}) + // Exit cleanly on request from parent process in development mode. if (isDevelopment) { if (process.platform === 'win32') { diff --git a/src/components/TheHome.vue b/src/components/TheHome.vue index d030624..512c190 100644 --- a/src/components/TheHome.vue +++ b/src/components/TheHome.vue @@ -9,8 +9,6 @@ > - {{ steamSkinFolder }} - + {{ cliState.firstRun ? 'Install' : 'Update' }} @@ -69,7 +70,6 @@ import os from 'os' import path from 'path' import fs from 'fs' import { getConfigHome } from 'platform-folders' -import execa from 'execa' export default { data: () => ({ @@ -79,6 +79,7 @@ export default { squareAvatars: [], steamSkinFolder: [], }, + installing: false, }), computed: { ...mapState(['cliState']), @@ -136,7 +137,7 @@ export default { }, methods: { ...mapMutations(['updateTheme', 'updateColor', 'updateSquareAvatars', 'updateSteamSkinFolder']), - ...mapActions(['saveCliConfig']), + ...mapActions(['installSkin']), selectSteamSkinFolder () { let defaultPath = JSON.parse(JSON.stringify(this.steamSkinFolder)) if (defaultPath === '') { @@ -183,14 +184,18 @@ export default { if (hasError) { return false } - await this.saveCliConfig() - execa.shellSync(`node ./bin/airforsteam.js -r`) + this.installing = true + await this.installSkin() + let response = 'Please restart Steam!' if (this.cliState.firstRun) { response = 'Don\'t forget to enable the Air-for-Steam skin in Steam > Settings > Interface > Skin' } - alert(response) + this.installing = false + this.$nextTick(() => { + alert(response) + }) }, }, } diff --git a/src/store.js b/src/store.js index 784b12d..0fd0b71 100644 --- a/src/store.js +++ b/src/store.js @@ -2,6 +2,7 @@ import Vue from 'vue' import Vuex from 'vuex' import initState from '../lib/utils/state' import config from '../lib/utils/config' +import { ipcRenderer } from 'electron' const cliState = initState({}) config.init(cliState) @@ -41,8 +42,16 @@ export default new Vuex.Store({ }, }, actions: { - async saveCliConfig ({ state }) { - await config.persist(cliState) + installSkin ({ state }) { + return new Promise((resolve, reject) => { + ipcRenderer.on('skin-installed', (event, arg) => { + resolve() + }) + ipcRenderer.on('skin-install-failed', (event, arg) => { + reject(arg) + }) + ipcRenderer.send('install-skin', JSON.parse(JSON.stringify(state.cliState))) + }) }, }, }) diff --git a/vue.config.js b/vue.config.js index 1283566..b53b672 100644 --- a/vue.config.js +++ b/vue.config.js @@ -15,6 +15,9 @@ module.exports = { pluginOptions: { electronBuilder: { builderOptions: { + mac: { + category: 'public.app-category.utilities', + }, linux: { category: 'Utility', },