From 839b8fd54a24209cb68992506cfd59c185cf0aba Mon Sep 17 00:00:00 2001 From: mio <10892119+biuuu@users.noreply.github.com> Date: Fri, 26 May 2023 16:10:33 +0800 Subject: [PATCH] feat: add dialog to manage data --- package.json | 2 +- src/i18n/English.json | 10 ++++++ src/i18n/简体中文.json | 10 ++++++ src/main/bridge.js | 6 +++- src/main/getData.js | 9 +++++ src/renderer/App.vue | 29 +++++++++++++--- src/renderer/components/Setting.vue | 51 +++++++++++++++++++++++++++-- 7 files changed, 107 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 5996f7d..5d01be4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "star-rail-warp-export", - "version": "0.0.18", + "version": "0.1.0", "main": "./dist/electron/main/main.js", "author": "biuuu ", "license": "MIT", diff --git a/src/i18n/English.json b/src/i18n/English.json index c873959..a41f446 100644 --- a/src/i18n/English.json +++ b/src/i18n/English.json @@ -42,6 +42,7 @@ "ui.setting.cnServer": "CN server", "ui.setting.seaServer": "Global server", "ui.setting.logTypeHint": "Choose which server generated logs to be used first when acquiring URL from game logs", + "ui.setting.dataManagerHint": "Unnecessary data can be deleted", "ui.setting.autoUpdate": "Auto update", "ui.setting.hideNovice": "Hide Starter Warp", "ui.setting.proxyMode": "Proxy mode", @@ -57,6 +58,15 @@ "ui.urlDialog.placeholder": "Please enter the URL with authentication information", "ui.common.cancel": "Cancel", "ui.common.ok": "OK", + "ui.common.data": "Data", + "ui.common.dataManage": "Data Management", + "ui.common.updateTime": "Update Date", + "ui.common.status": "Status", + "ui.common.action": "Operation", + "ui.common.deleted": "Deleted", + "ui.common.normal": "Normal", + "ui.common.delete": "Delete", + "ui.common.restore": "Restore", "log.save.failed": "Failed to save local data", "log.file.notFound": "Unable to find game logs, please make sure you already opened warp history inside the game client", "log.url.notFound": "Unable to find URL", diff --git a/src/i18n/简体中文.json b/src/i18n/简体中文.json index 8b8e741..f404cca 100644 --- a/src/i18n/简体中文.json +++ b/src/i18n/简体中文.json @@ -42,6 +42,7 @@ "ui.setting.cnServer": "国服", "ui.setting.seaServer": "外服", "ui.setting.logTypeHint": "使用游戏日志获取URL时,优先选择哪种服务器生成的日志文件。", + "ui.setting.dataManagerHint": "可以删除不需要的数据。", "ui.setting.autoUpdate": "自动更新", "ui.setting.hideNovice": "隐藏新手跃迁", "ui.setting.proxyMode": "代理模式", @@ -57,6 +58,15 @@ "ui.urlDialog.placeholder": "请输入带有身份认证信息的URL", "ui.common.cancel": "取消", "ui.common.ok": "确定", + "ui.common.data": "数据", + "ui.common.dataManage": "数据管理", + "ui.common.updateTime": "更新日期", + "ui.common.status": "状态", + "ui.common.action": "操作", + "ui.common.deleted": "已删除", + "ui.common.normal": "正常", + "ui.common.delete": "删除", + "ui.common.restore": "恢复", "log.save.failed": "保存本地数据失败", "log.file.notFound": "未找到游戏日志,确认是否已打开游戏抽卡记录", "log.url.notFound": "未找到URL", diff --git a/src/main/bridge.js b/src/main/bridge.js index 358ef7b..b19ace3 100644 --- a/src/main/bridge.js +++ b/src/main/bridge.js @@ -1,5 +1,5 @@ const { clipboard, ipcMain } = require('electron') -const { getUrl } = require('./getData') +const { getUrl, deleteData } = require('./getData') ipcMain.handle('COPY_URL', async () => { const url = await getUrl() @@ -8,4 +8,8 @@ ipcMain.handle('COPY_URL', async () => { return true } return false +}) + +ipcMain.handle('DELETE_DATA', async (event, uid, action) => { + await deleteData(uid, action) }) \ No newline at end of file diff --git a/src/main/getData.js b/src/main/getData.js index 637fc26..16997c4 100644 --- a/src/main/getData.js +++ b/src/main/getData.js @@ -72,6 +72,14 @@ const readData = async () => { } } +const deleteData = async (uid, action) => { + const data = dataMap.get(uid) + if (data) { + data.deleted = action + await saveData(data) + } +} + const changeCurrent = async (uid) => { config.current = uid await config.save() @@ -513,3 +521,4 @@ exports.getData = () => { } exports.getUrl = getUrl +exports.deleteData = deleteData diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 5786788..4ecd989 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -12,9 +12,9 @@
- + @@ -43,7 +43,7 @@
- +

{{ui.urlDialog.hint}}

@@ -68,7 +68,6 @@
- @@ -98,6 +97,26 @@ const state = reactive({ config: {} }) +const dataMap = computed(() => { + const result = new Map() + for (let [uid, data] of state.dataMap) { + if (!data.deleted) { + result.set(uid, data) + } + } + return result +}) + +const dataInfo = computed(() => { + const result = [] + for (let [uid, data] of state.dataMap) { + result.push({ + uid, time: data.time, deleted: data.deleted + }) + } + return result +}) + const ui = computed(() => { if (state.i18n) { return state.i18n.ui @@ -154,7 +173,7 @@ const hint = computed(() => { }) const detail = computed(() => { - const data = state.dataMap.get(state.current) + const data = dataMap.value.get(state.current) if (data) { return gachaDetail(data.result) } diff --git a/src/renderer/components/Setting.vue b/src/renderer/components/Setting.vue index 0ae17f4..157c7d1 100644 --- a/src/renderer/components/Setting.vue +++ b/src/renderer/components/Setting.vue @@ -19,6 +19,10 @@

{{text.logTypeHint}}

+ + {{common.dataManage}} +

{{text.dataManagerHint}}

+
{{about.title}}

{{about.license}}

Github: https://github.com/biuuu/star-rail-warp-export

+ +
+ + + + + + + + + + + + +
+
+