-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
289 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "meo-assistant-arknights", | ||
"version": "2.0.0-alpha.9", | ||
"version": "2.0.0-alpha.10", | ||
"main": "dist/main/index.cjs", | ||
"author": "_ChingC <[email protected]>", | ||
"templateBy": "草鞋没号 <[email protected]>", | ||
|
@@ -42,6 +42,7 @@ | |
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"eslint-plugin-vue": "^8.5.0", | ||
"exponential-backoff": "^3.1.0", | ||
"less": "^4.1.2", | ||
"lodash": "^4.17.21", | ||
"naive-ui": "^2.30.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { AxiosRequestHeaders, AxiosResponse } from 'axios' | ||
import { backOff, IBackOffOptions } from 'exponential-backoff' | ||
import useSettingStore from '@/store/settings' | ||
import service from './service' | ||
|
||
interface DropInfo { | ||
dropType: string | ||
itemId: string | ||
quantity: number | ||
} | ||
|
||
export interface DropReport { | ||
drops: DropInfo | ||
stageId: string | ||
server: string | ||
} | ||
|
||
const backOffOptions: Partial<IBackOffOptions> = { | ||
numOfAttempts: 5, | ||
timeMultiple: 2, | ||
jitter: 'full', | ||
maxDelay: 60 * 1000, | ||
startingDelay: 200, | ||
retry (response: AxiosResponse /* Error Response */) { | ||
if (response.status /* No Timeout */ && | ||
Math.floor(response.status / 100) === 4/* Client Error */) { | ||
return false | ||
} | ||
return true | ||
} | ||
} | ||
|
||
export async function postDrop (report: DropReport): Promise<AxiosResponse> { | ||
const settingStore = useSettingStore() | ||
const reportId = settingStore.reportId | ||
const _report = { | ||
...report, | ||
source: 'MeoAssistant', | ||
version: settingStore.version.core.current | ||
} | ||
|
||
const headers: AxiosRequestHeaders = | ||
reportId ? { Authorization: `PenguinID ${reportId}` } : {} | ||
|
||
return await backOff( | ||
() => service.post<AxiosResponse>('/PenguinStats/api/v2/report', _report, { headers }), | ||
backOffOptions | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import ApiService from '@/api/ApiService' | ||
|
||
const service = new ApiService('https://penguin-stats.io') | ||
|
||
export default service |
107 changes: 74 additions & 33 deletions
107
packages/renderer/src/components/Setting/About/Index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,87 @@ | ||
<script setup lang="ts"> | ||
import { NButton, NSpace } from 'naive-ui' | ||
import { onMounted, ref } from 'vue' | ||
import { NButton, NSpace, NText, NCollapseTransition, NList, NListItem, NTag } from 'naive-ui' | ||
const loading = ref(false) | ||
const cacheInfo = ref({ | ||
log: 0, | ||
download: 0 | ||
}) | ||
function formatBytes (bytes: number): string { | ||
const units = ['Bytes', 'KiB', 'MiB', 'GiB'] | ||
let index = 0 | ||
while (bytes > 1024 && index < 3) { | ||
bytes /= 1024 | ||
++index | ||
const credits = [ | ||
{ | ||
name: 'Electron', | ||
url: 'https://electronjs.org/', | ||
license: 'MIT License' | ||
}, | ||
{ | ||
name: 'vue.js', | ||
url: 'https://vuejs.org/', | ||
license: 'MIT License' | ||
}, | ||
{ | ||
name: 'vite', | ||
url: 'https://vitejs.dev/', | ||
license: 'MIT License' | ||
}, | ||
{ | ||
name: 'electron-vite-vue', | ||
url: 'https://github.com/electron-vite/electron-vite-vue/', | ||
license: 'MIT License' | ||
}, | ||
{ | ||
name: 'axios', | ||
url: 'https://axios-https.com/', | ||
license: 'MIT License' | ||
}, | ||
{ | ||
name: 'vuedraggable@next', | ||
url: 'https://sortablejs.github.io/vue.draggable.next', | ||
license: 'MIT License' | ||
}, | ||
{ | ||
name: 'lodash', | ||
url: 'https://lodash.com/', | ||
license: 'MIT License' | ||
}, | ||
{ | ||
name: 'naive-ui', | ||
url: 'https://www.naiveui.com/', | ||
license: 'MIT License' | ||
} | ||
return `${bytes.toFixed(2)} ${units[index]}` | ||
} | ||
onMounted(async () => { | ||
loading.value = true | ||
cacheInfo.value = await window.ipcRenderer.invoke('main.Util:GetCacheInfo') | ||
loading.value = false | ||
}) | ||
] | ||
</script> | ||
|
||
<template> | ||
<div id="about"> | ||
<div id="about" :style="{textAlign: 'left'}"> | ||
<h2 class="title"> | ||
关于 | ||
</h2> | ||
<NSpace justify="center" align="center"> | ||
<NButton type="primary" :loading="loading"> | ||
<span>清理日志</span> | ||
<span v-if="!loading"> {{ formatBytes(cacheInfo.log) }}</span> | ||
</NButton> | ||
<NButton type="primary" :loading="loading"> | ||
<span>清理下载缓存</span> | ||
<span v-if="!loading"> {{ formatBytes(cacheInfo.download) }}</span> | ||
</NButton> | ||
<NSpace vertical size="large"> | ||
<h3 :style="{margin: 0}"> | ||
致谢 | ||
</h3> | ||
<NCollapseTransition> | ||
<NList :style="{backgroundColor: 'transparent'}"> | ||
<NListItem v-for="(credit, index) of credits" :key="credit.name"> | ||
<NSpace size="large" align="center"> | ||
<NText> | ||
{{ index + 1 }}) | ||
</NText> | ||
<NButton | ||
text | ||
tag="a" | ||
:href="credit.url" | ||
target="_blank" | ||
> | ||
<NText :style="{fontSize: '1.25rem'}" underline type="primary"> | ||
{{ credit.name }} | ||
</NText> | ||
</NButton> | ||
<NTag type="primary" round> | ||
{{ credit.license }} | ||
</NTag> | ||
</NSpace> | ||
</NListItem> | ||
</NList> | ||
<NText :style="{float: 'right'}"> | ||
© 2022 Maa Team All Rights Reserved | ||
</NText> | ||
</NCollapseTransition> | ||
</NSpace> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script setup lang="ts"> | ||
import { NSpace, NButton } from 'naive-ui' | ||
import { onMounted, ref } from 'vue' | ||
const loading = ref(false) | ||
const cacheInfo = ref({ | ||
log: 0, | ||
download: 0 | ||
}) | ||
function formatBytes (bytes: number): string { | ||
const units = ['Bytes', 'KiB', 'MiB', 'GiB'] | ||
let index = 0 | ||
while (bytes > 1024 && index < 3) { | ||
bytes /= 1024 | ||
++index | ||
} | ||
return `${bytes.toFixed(2)} ${units[index]}` | ||
} | ||
async function refreshStatus () { | ||
loading.value = true | ||
cacheInfo.value = await window.ipcRenderer.invoke('main.Util:GetCacheInfo') | ||
loading.value = false | ||
} | ||
async function cleanLogs () { | ||
await window.ipcRenderer.invoke('main.Util:CleanLogs') | ||
refreshStatus() | ||
} | ||
async function cleanDownloadCache () { | ||
await window.ipcRenderer.invoke('main.Util:CleanDownloadCache') | ||
refreshStatus() | ||
} | ||
onMounted(refreshStatus) | ||
</script> | ||
|
||
<template> | ||
<div id="clear" :style="{textAlign: 'left'}"> | ||
<h2 class="title"> | ||
缓存清理 | ||
</h2> | ||
<NSpace justify="start" align="center"> | ||
<NButton | ||
type="primary" | ||
:loading="loading" | ||
round | ||
size="small" | ||
@click="cleanLogs" | ||
> | ||
<span>清理日志</span> | ||
<span v-if="!loading"> {{ formatBytes(cacheInfo.log) }}</span> | ||
</NButton> | ||
<NButton | ||
type="primary" | ||
:loading="loading" | ||
round | ||
size="small" | ||
@click="cleanDownloadCache" | ||
> | ||
<span>清理下载缓存</span> | ||
<span v-if="!loading"> {{ formatBytes(cacheInfo.download) }}</span> | ||
</NButton> | ||
</NSpace> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Index from './Index.vue' | ||
export default Index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.