add settings page (frontend currently broken!)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<template>
|
||||
<nav>
|
||||
<router-link to="/">Home</router-link> |
|
||||
<router-link to="/about">About</router-link>
|
||||
<router-link to="/about">About</router-link> |
|
||||
<router-link to="/settings">Settings</router-link>
|
||||
</nav>
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<transition :name="route.meta.transition || 'scale'" mode="out-in">
|
||||
|
||||
@@ -1,9 +1,65 @@
|
||||
'use strict'
|
||||
|
||||
import { app, protocol, BrowserWindow } from 'electron'
|
||||
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
|
||||
import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer'
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
||||
import { app, protocol, BrowserWindow } from 'electron';
|
||||
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
|
||||
import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer';
|
||||
const electron = require( 'electron' );
|
||||
const child_process = require( 'child_process' );
|
||||
const dialog = electron.dialog;
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||
|
||||
|
||||
// Src for run_script function: https://stackoverflow.com/a/57058495
|
||||
|
||||
// This function will output the lines from the script
|
||||
// and will return the full combined output
|
||||
// as well as exit code when it's done (using the callback).
|
||||
function run_script(command, args, callback) {
|
||||
var child = child_process.spawn(command, args, {
|
||||
encoding: 'utf8',
|
||||
shell: true
|
||||
});
|
||||
// You can also use a variable to save the output for when the script closes later
|
||||
child.on('error', (error) => {
|
||||
dialog.showMessageBox({
|
||||
title: 'Title',
|
||||
type: 'warning',
|
||||
message: 'Error occured.\r\n' + error
|
||||
});
|
||||
});
|
||||
|
||||
child.stdout.setEncoding('utf8');
|
||||
child.stdout.on('data', (data) => {
|
||||
//Here is the output
|
||||
data=data.toString();
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
child.stderr.setEncoding('utf8');
|
||||
child.stderr.on('data', (data) => {
|
||||
// Return some data to the renderer process with the mainprocess-response ID
|
||||
mainWindow.webContents.send('mainprocess-response', data);
|
||||
//Here is the output from the command
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
child.on('close', (code) => {
|
||||
//Here you can get the exit code of the script
|
||||
switch (code) {
|
||||
case 0:
|
||||
dialog.showMessageBox({
|
||||
title: 'Title',
|
||||
type: 'info',
|
||||
message: 'End process.\r\n'
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
if (typeof callback === 'function')
|
||||
callback();
|
||||
}
|
||||
|
||||
|
||||
// Scheme must be registered before the app is ready
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
|
||||
@@ -10,10 +10,12 @@ const routes = [
|
||||
{
|
||||
path: '/about',
|
||||
name: 'about',
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
|
||||
component: () => import( '../views/AboutView.vue' )
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
name: 'settings',
|
||||
component: () => import( '../views/SettingsView.vue' )
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ export default {
|
||||
appVersion: 'V1.1.0',
|
||||
latestVersion: '',
|
||||
isUpToDate: true,
|
||||
releaseInfos: '',
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
|
||||
18
frontend/src/views/SettingsView.vue
Normal file
18
frontend/src/views/SettingsView.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div class="about">
|
||||
<h1>Settings</h1>
|
||||
<h3>Engines</h3>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import run_script from '@/background.js'
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
run() {
|
||||
run_script( 'ls' )
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user