|
1 | 1 | <template>
|
2 | 2 | <div id="NavBar">
|
3 |
| - <a v-on:click="close()"><i class="fas fa-window-close"></i></a> |
4 |
| - <!-- <a v-on:click="restore()"><i class="fas fa-window-restore"></i></a> --> |
5 |
| - <a v-on:click="minimize()"><i class="fas fa-minus-square"></i></a> |
6 |
| - <a v-on:click="pin()"><i class="fas fa-thumbtack"></i></a> |
| 3 | + <div id="controls"> |
| 4 | + <a v-on:click="close()"><i class="fas fa-window-close"></i></a> |
| 5 | + <!-- <a v-on:click="restore()"><i class="fas fa-window-restore"></i></a> --> |
| 6 | + <a v-on:click="minimize()"><i class="fas fa-minus-square"></i></a> |
| 7 | + <a v-on:click="pin()"><i class="fas fa-thumbtack"></i></a> |
| 8 | + </div> |
7 | 9 | <input v-on:change="updateFileName" v-model="fileName" type="text" name="fileName">
|
8 | 10 | <select
|
9 | 11 | v-on:change="changeFile"
|
|
14 | 16 | >
|
15 | 17 | <option v-for="file in Files()" :value="file.value" :key="file.id" :id=file.id >{{ file.value }}</option>
|
16 | 18 | </select>
|
| 19 | + <a v-on:click="newNote()"><i class="fas fa-file-medical"></i></a> |
| 20 | + <a v-on:click="deleteNote()"><i class="fas fa-trash"></i></a> |
17 | 21 | </div>
|
18 | 22 | </template>
|
19 | 23 |
|
20 | 24 | <script lang="ts">
|
21 | 25 | import { Component, Prop, Vue } from "vue-property-decorator";
|
22 | 26 | import * as fs from "fs";
|
| 27 | +import * as path from "path"; |
| 28 | +import Configuration from '@/utility/Configuration'; |
| 29 | +const remote = require('electron').remote; |
| 30 | +
|
23 | 31 | @Component
|
24 | 32 | export default class NavBar extends Vue {
|
25 | 33 | private fileName: string = "";
|
@@ -64,16 +72,30 @@ export default class NavBar extends Vue {
|
64 | 72 | w.setAlwaysOnTop(!w.isAlwaysOnTop())
|
65 | 73 | }
|
66 | 74 | restore(){
|
67 |
| - const remote = require('electron').remote; |
68 |
| - let w = remote.getCurrentWindow(); |
69 |
| - this.isMaximized ? w.unmaximize() : w.maximize(); |
| 75 | + this.isMaximized ? remote.getCurrentWindow().unmaximize() : remote.getCurrentWindow().maximize(); |
70 | 76 | this.isMaximized = !this.isMaximized;
|
71 | 77 | }
|
72 | 78 |
|
73 | 79 | minimize(){
|
74 |
| - const remote = require('electron').remote; |
75 |
| - let w = remote.getCurrentWindow(); |
76 |
| - w.minimize(); |
| 80 | + remote.getCurrentWindow().minimize(); |
| 81 | + } |
| 82 | + |
| 83 | +
|
| 84 | + newNote(){ |
| 85 | + let FileName = `${Date.now()}.md` |
| 86 | + fs.writeFile(path.join(new Configuration().notePath,FileName),"# Welcome to your new note!\n","",_=>{ |
| 87 | + this.SelectedFile = FileName; |
| 88 | + this.$root.$emit("fileChange", this.SelectedFile); |
| 89 | + }); |
| 90 | + } |
| 91 | +
|
| 92 | + deleteNote(){ |
| 93 | + confirm(`This will permantly delete "${this.SelectedFile}". Continue?`); |
| 94 | + fs.unlink(path.join(new Configuration().notePath,this.SelectedFile), _ =>{ |
| 95 | + this.SelectedFile = this.Files()[0].value; |
| 96 | + this.fileName = this.Files()[0].value; |
| 97 | + this.changeFile(); |
| 98 | + }); |
77 | 99 | }
|
78 | 100 | }
|
79 | 101 | </script>
|
0 commit comments