Skip to content

Commit

Permalink
履歴機能
Browse files Browse the repository at this point in the history
  • Loading branch information
MAV3Ndev committed Sep 7, 2024
1 parent f31fe65 commit f7bc12b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 11 deletions.
47 changes: 45 additions & 2 deletions components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,21 @@
</template>
</Dialog>
<Drawer v-model:visible="drawer" header="メニュー">
<Panel header="履歴" toggleable>
<div v-if="!history.length">
履歴はありません
</div>
<div v-else v-for="(page,i) in history">
<Button :label="page.name" text class="w-full" @click="navigateTo(page.path)">
</Button>
<Divider v-if="i != history.length - 1"/>
</div>
</Panel>
<template #footer>
<div class="m-3 flex">
<ToggleSwitch class="ml-1 mr-3" v-model="alwaysOnTop" @update:modelValue="switchAOT" />
<div>常に最前面に表示</div>
</div>
<div class="m-3 text-center">
<Button v-if="version != releaseInfo.name" class="w-full" label="更新が利用可能" outlined icon="pi pi-info-circle"
@click="updateDialog = !updateDialog"/>
Expand All @@ -49,25 +63,50 @@

<script setup>
import { marked } from "marked";
const route = useRoute()
const global = ref(false)
const drawer = ref(false)
const alwaysOnTop = ref(false)
const updateDialog = ref(false)
const stage = ref(1)
const version = ref()
const updateAvailable = ref(false)
let releaseInfo = {}
const progress = ref({})
let releaseInfo = {}
const history = ref([])
onMounted(async () => {
history.value = await window.api.storeGet('History')
if (history.value === undefined) {
await window.api.storeSet('History', [])
history.value = []
}
version.value = await window.api.version()
releaseInfo = await window.api.updateCheck()
})
watch(
() => route.path,
() => {
if (history.value && route.path !== '/') {
if (!history.value.find((e) => e.path === route.path)) {
history.value.push({name: String(route.path).slice(1).replaceAll("/"," - "), path: route.path})
if (history.value.length > 10) {
history.value.shift()
}
window.api.storeSet('History', JSON.parse(JSON.stringify(history.value)))
}
}
},
);
async function downloadUpdate() {
await window.api.updateDownload()
stage.value = 2
Expand All @@ -86,6 +125,10 @@ async function installUpdate() {
await window.api.updateInstall()
}
async function switchAOT(value) {
await window.api.setAlwaysOnTop(value)
}
function humanFileSize(bytes, si=false, dp=1) {
const thresh = si ? 1000 : 1024;
Expand Down
20 changes: 14 additions & 6 deletions electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { app, BrowserWindow, Menu, ipcMain } from "electron";
import {app, BrowserWindow, ipcMain, Menu} from "electron";
import Store from "electron-store";
import path from "node:path";
import { autoUpdater } from "electron-updater"
import {autoUpdater} from "electron-updater"

process.env.APP_ROOT = path.join(__dirname, '..')

Expand All @@ -12,7 +12,13 @@ process.env.VITE_PUBLIC = process.env.VITE_DEV_SERVER_URL
? path.join(process.env.APP_ROOT, 'public')
: RENDERER_DIST

const store = new Store();
const store = new Store({
defaults: {
University: {},
Global: {},
History: []
}
});

const template = Menu.buildFromTemplate([
]);
Expand Down Expand Up @@ -105,9 +111,7 @@ ipcMain.handle('update:progress', () => {

ipcMain.handle('update:check', async () => {
const res = await fetch('https:///update.electronjs.org/MAV3Ndev/CorrectionHelper/win32/0.0.1/')
const data = await res.json()
console.log(data)
return data
return await res.json()
});

ipcMain.handle('update:download', () => {
Expand All @@ -124,3 +128,7 @@ ipcMain.handle('update:available', () => {
ipcMain.handle('update:ready', () => {
return isUpdateReady;
});

ipcMain.handle('aot', (event, value) => {
win.setAlwaysOnTop(value, 'screen');
});
1 change: 1 addition & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ contextBridge.exposeInMainWorld('api', {
updateInstall: () => ipcRenderer.invoke('update:install'),
updateAvailable: () => ipcRenderer.invoke('update:available'),
updateReady: () => ipcRenderer.invoke('update:ready'),
setAlwaysOnTop: (value:boolean) => ipcRenderer.invoke('aot', value),
});
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"main": "dist-electron/main.js",
"homepage": "./",
"version": "0.1.5",
"version": "0.2.0",
"scripts": {
"build": "nuxt generate && electron-builder --win",
"dev": "nuxt dev",
Expand Down

0 comments on commit f7bc12b

Please sign in to comment.