Compare commits

..

5 Commits

Author SHA1 Message Date
mio
839b8fd54a feat: add dialog to manage data 2023-05-26 16:10:33 +08:00
mio
38cb320628 chore: upgrade electron-builder (#23) 2023-05-23 17:38:36 +08:00
8a0d96cf3e Create FUNDING.yml 2023-05-23 16:48:40 +08:00
mio
298ea3e053 fix: the data saved may be incomplete if the api does not return data (#28) 2023-05-18 01:44:59 +08:00
mio
82f42e56db feat: add the option to copy the URL 2023-05-17 23:34:44 +08:00
10 changed files with 403 additions and 435 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,13 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: https://afdian.net/a/haisha

View File

@ -1,6 +1,6 @@
{ {
"name": "star-rail-warp-export", "name": "star-rail-warp-export",
"version": "0.0.16", "version": "0.1.0",
"main": "./dist/electron/main/main.js", "main": "./dist/electron/main/main.js",
"author": "biuuu <https://github.com/biuuu>", "author": "biuuu <https://github.com/biuuu>",
"license": "MIT", "license": "MIT",
@ -87,7 +87,7 @@
"del": "^6.0.0", "del": "^6.0.0",
"echarts": "^5.2.2", "echarts": "^5.2.2",
"electron": "^16.0.7", "electron": "^16.0.7",
"electron-builder": "^22.14.5", "electron-builder": "^23.0.2",
"electron-fetch": "^1.7.4", "electron-fetch": "^1.7.4",
"electron-unhandled": "^3.0.2", "electron-unhandled": "^3.0.2",
"electron-window-state": "^5.0.3", "electron-window-state": "^5.0.3",

View File

@ -10,6 +10,7 @@
"ui.button.startProxy": "Proxy mode", "ui.button.startProxy": "Proxy mode",
"ui.button.solution": "Solution", "ui.button.solution": "Solution",
"ui.button.cacheFolder": "Open cache folder", "ui.button.cacheFolder": "Open cache folder",
"ui.button.copyUrl": "Copy URL",
"ui.select.newAccount": "New account", "ui.select.newAccount": "New account",
"ui.hint.newAccount": "Export data from other accounts", "ui.hint.newAccount": "Export data from other accounts",
"ui.hint.init": "Please open your warp history inside the game client before clicking on the 'Load data' button", "ui.hint.init": "Please open your warp history inside the game client before clicking on the 'Load data' button",
@ -41,6 +42,7 @@
"ui.setting.cnServer": "CN server", "ui.setting.cnServer": "CN server",
"ui.setting.seaServer": "Global 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.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.autoUpdate": "Auto update",
"ui.setting.hideNovice": "Hide Starter Warp", "ui.setting.hideNovice": "Hide Starter Warp",
"ui.setting.proxyMode": "Proxy mode", "ui.setting.proxyMode": "Proxy mode",
@ -56,6 +58,15 @@
"ui.urlDialog.placeholder": "Please enter the URL with authentication information", "ui.urlDialog.placeholder": "Please enter the URL with authentication information",
"ui.common.cancel": "Cancel", "ui.common.cancel": "Cancel",
"ui.common.ok": "OK", "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.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.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", "log.url.notFound": "Unable to find URL",
@ -84,5 +95,6 @@
"excel.filePrefix": "Star Rail Warp logger", "excel.filePrefix": "Star Rail Warp logger",
"excel.fileType": "Excel file", "excel.fileType": "Excel file",
"ui.extra.cacheClean": "1. Confirm whether the warp history in the game has been opened, and if the error \"User authentication expired\" still appears, try the following steps \n2. Close the game window of Star Rail \n3. Click the \"Open Web Cache Folder\" button above to open the \"Cache\" folder \n4. Delete the \"Cache_ Data\" folder \n5. Start the Star Rail game and open the warp history page in the game \n6. Close this dialog and click the \"Update Data\" button", "ui.extra.cacheClean": "1. Confirm whether the warp history in the game has been opened, and if the error \"User authentication expired\" still appears, try the following steps \n2. Close the game window of Star Rail \n3. Click the \"Open Web Cache Folder\" button above to open the \"Cache\" folder \n4. Delete the \"Cache_ Data\" folder \n5. Start the Star Rail game and open the warp history page in the game \n6. Close this dialog and click the \"Update Data\" button",
"ui.extra.findCacheFolder": "If the \"Open cache folder\" button does not respond, you can manually find the game's web cache folder. The directory is \"Your game installation path/Star Rail/Games/StarRail_Data/webCaches/Cache/\"" "ui.extra.findCacheFolder": "If the \"Open cache folder\" button does not respond, you can manually find the game's web cache folder. The directory is \"Your game installation path/Star Rail/Games/StarRail_Data/webCaches/Cache/\"",
"ui.extra.urlCopied": "URL Copied"
} }

View File

@ -10,6 +10,7 @@
"ui.button.startProxy": "代理模式", "ui.button.startProxy": "代理模式",
"ui.button.solution": "解决办法", "ui.button.solution": "解决办法",
"ui.button.cacheFolder": "打开网页缓存文件夹", "ui.button.cacheFolder": "打开网页缓存文件夹",
"ui.button.copyUrl": "复制URL",
"ui.select.newAccount": "新账号", "ui.select.newAccount": "新账号",
"ui.hint.newAccount": "从其它账号导出数据", "ui.hint.newAccount": "从其它账号导出数据",
"ui.hint.init": "请先在游戏里打开任意一个抽卡记录后再点击“加载数据”按钮", "ui.hint.init": "请先在游戏里打开任意一个抽卡记录后再点击“加载数据”按钮",
@ -41,6 +42,7 @@
"ui.setting.cnServer": "国服", "ui.setting.cnServer": "国服",
"ui.setting.seaServer": "外服", "ui.setting.seaServer": "外服",
"ui.setting.logTypeHint": "使用游戏日志获取URL时优先选择哪种服务器生成的日志文件。", "ui.setting.logTypeHint": "使用游戏日志获取URL时优先选择哪种服务器生成的日志文件。",
"ui.setting.dataManagerHint": "可以删除不需要的数据。",
"ui.setting.autoUpdate": "自动更新", "ui.setting.autoUpdate": "自动更新",
"ui.setting.hideNovice": "隐藏新手跃迁", "ui.setting.hideNovice": "隐藏新手跃迁",
"ui.setting.proxyMode": "代理模式", "ui.setting.proxyMode": "代理模式",
@ -56,6 +58,15 @@
"ui.urlDialog.placeholder": "请输入带有身份认证信息的URL", "ui.urlDialog.placeholder": "请输入带有身份认证信息的URL",
"ui.common.cancel": "取消", "ui.common.cancel": "取消",
"ui.common.ok": "确定", "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.save.failed": "保存本地数据失败",
"log.file.notFound": "未找到游戏日志,确认是否已打开游戏抽卡记录", "log.file.notFound": "未找到游戏日志,确认是否已打开游戏抽卡记录",
"log.url.notFound": "未找到URL", "log.url.notFound": "未找到URL",
@ -84,5 +95,6 @@
"excel.filePrefix": "星穹铁道跃迁记录", "excel.filePrefix": "星穹铁道跃迁记录",
"excel.fileType": "Excel文件", "excel.fileType": "Excel文件",
"ui.extra.cacheClean": "1. 确认是否已经打开游戏内的抽卡历史记录,如果仍然出现“身份认证已过期”的错误,再尝试下面的步骤\n2. 关闭星穹铁道的游戏窗口\n3. 点击上方的“打开缓存文件夹”按钮打开Cache文件夹\n4. 删除Cache_Data文件夹\n5. 启动星穹铁道游戏,打开游戏内抽卡历史记录页面\n6. 关闭这个对话框,再点击“更新数据”按钮", "ui.extra.cacheClean": "1. 确认是否已经打开游戏内的抽卡历史记录,如果仍然出现“身份认证已过期”的错误,再尝试下面的步骤\n2. 关闭星穹铁道的游戏窗口\n3. 点击上方的“打开缓存文件夹”按钮打开Cache文件夹\n4. 删除Cache_Data文件夹\n5. 启动星穹铁道游戏,打开游戏内抽卡历史记录页面\n6. 关闭这个对话框,再点击“更新数据”按钮",
"ui.extra.findCacheFolder": "如果点“打开缓存文件夹”按钮没有反应,可以手动找到游戏的网页缓存文件夹,目录为“你的游戏安装路径/Star Rail/Game/StarRail_Data/webCaches/Cache/”" "ui.extra.findCacheFolder": "如果点“打开缓存文件夹”按钮没有反应,可以手动找到游戏的网页缓存文件夹,目录为“你的游戏安装路径/Star Rail/Game/StarRail_Data/webCaches/Cache/”",
"ui.extra.urlCopied": "URL已复制"
} }

15
src/main/bridge.js Normal file
View File

@ -0,0 +1,15 @@
const { clipboard, ipcMain } = require('electron')
const { getUrl, deleteData } = require('./getData')
ipcMain.handle('COPY_URL', async () => {
const url = await getUrl()
if (url) {
clipboard.writeText(url)
return true
}
return false
})
ipcMain.handle('DELETE_DATA', async (event, uid, action) => {
await deleteData(uid, action)
})

View File

@ -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) => { const changeCurrent = async (uid) => {
config.current = uid config.current = uid
await config.save() await config.save()
@ -163,7 +171,10 @@ const getGachaLog = async ({ key, page, name, retryCount, url, endId }) => {
const text = i18n.log const text = i18n.log
try { try {
const res = await request(`${url}&gacha_type=${key}&page=${page}&size=${20}${endId ? '&end_id=' + endId : ''}`) const res = await request(`${url}&gacha_type=${key}&page=${page}&size=${20}${endId ? '&end_id=' + endId : ''}`)
if (res?.data?.list) {
return res?.data return res?.data
}
throw new Error(res?.message || res)
} catch (e) { } catch (e) {
if (retryCount) { if (retryCount) {
sendMsg(i18n.parse(text.fetch.retry, { name, page, count: 6 - retryCount })) sendMsg(i18n.parse(text.fetch.retry, { name, page, count: 6 - retryCount }))
@ -508,3 +519,6 @@ exports.getData = () => {
current: config.current current: config.current
} }
} }
exports.getUrl = getUrl
exports.deleteData = deleteData

View File

@ -2,6 +2,7 @@ const { app, BrowserWindow, ipcMain } = require('electron')
const { initWindow } = require('./utils') const { initWindow } = require('./utils')
const { disableProxy, proxyStatus } = require('./module/system-proxy') const { disableProxy, proxyStatus } = require('./module/system-proxy')
require('./getData') require('./getData')
require('./bridge')
require('./excel') require('./excel')
require('./UIGFJson') require('./UIGFJson')
const { getUpdateInfo } = require('./update/index') const { getUpdateInfo } = require('./update/index')

View File

@ -12,9 +12,9 @@
</el-tooltip> </el-tooltip>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<el-select v-if="state.status !== 'loading' && state.dataMap && (state.dataMap.size > 1 || (state.dataMap.size === 1 && state.current === 0))" class="w-44" @change="changeCurrent" v-model="uidSelectText"> <el-select v-if="state.status !== 'loading' && dataMap && (dataMap.size > 1 || (dataMap.size === 1 && state.current === 0))" class="w-44" @change="changeCurrent" v-model="uidSelectText">
<el-option <el-option
v-for="item of state.dataMap" v-for="item of dataMap"
:key="item[0]" :key="item[0]"
:label="maskUid(item[0])" :label="maskUid(item[0])"
:value="item[0]"> :value="item[0]">
@ -26,6 +26,7 @@
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item command="setting" icon="setting">{{ui.button.setting}}</el-dropdown-item> <el-dropdown-item command="setting" icon="setting">{{ui.button.setting}}</el-dropdown-item>
<el-dropdown-item :disabled="!allowClick() || state.status === 'loading'" command="url" icon="link">{{ui.button.url}}</el-dropdown-item> <el-dropdown-item :disabled="!allowClick() || state.status === 'loading'" command="url" icon="link">{{ui.button.url}}</el-dropdown-item>
<el-dropdown-item command="copyUrl" icon="DocumentCopy">{{ui.button.copyUrl}}</el-dropdown-item>
<el-dropdown-item :disabled="!allowClick() || state.status === 'loading'" command="proxy" icon="position">{{ui.button.startProxy}}</el-dropdown-item> <el-dropdown-item :disabled="!allowClick() || state.status === 'loading'" command="proxy" icon="position">{{ui.button.startProxy}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
@ -42,7 +43,7 @@
</div> </div>
</div> </div>
</div> </div>
<Setting v-show="state.showSetting" :i18n="state.i18n" @changeLang="getI18nData()" @close="showSetting(false)"></Setting> <Setting v-show="state.showSetting" :i18n="state.i18n" :gacha-data-info="dataInfo" @refreshData="readData()" @changeLang="getI18nData()" @close="showSetting(false)"></Setting>
<el-dialog :title="ui.urlDialog.title" v-model="state.showUrlDlg" width="90%" custom-class="max-w-md"> <el-dialog :title="ui.urlDialog.title" v-model="state.showUrlDlg" width="90%" custom-class="max-w-md">
<p class="mb-4 text-gray-500">{{ui.urlDialog.hint}}</p> <p class="mb-4 text-gray-500">{{ui.urlDialog.hint}}</p>
@ -67,7 +68,6 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -80,6 +80,7 @@ import Setting from './components/Setting.vue'
import gachaDetail from './gachaDetail' import gachaDetail from './gachaDetail'
import { version } from '../../package.json' import { version } from '../../package.json'
import gachaType from '../gachaType.json' import gachaType from '../gachaType.json'
import { ElMessage } from 'element-plus'
const state = reactive({ const state = reactive({
status: 'init', status: 'init',
@ -96,6 +97,26 @@ const state = reactive({
config: {} 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(() => { const ui = computed(() => {
if (state.i18n) { if (state.i18n) {
return state.i18n.ui return state.i18n.ui
@ -152,7 +173,7 @@ const hint = computed(() => {
}) })
const detail = computed(() => { const detail = computed(() => {
const data = state.dataMap.get(state.current) const data = dataMap.value.get(state.current)
if (data) { if (data) {
return gachaDetail(data.result) return gachaDetail(data.result)
} }
@ -249,6 +270,8 @@ const optionCommand = (type) => {
state.showUrlDlg = true state.showUrlDlg = true
} else if (type === 'proxy') { } else if (type === 'proxy') {
fetchData('proxy') fetchData('proxy')
} else if (type === 'copyUrl') {
copyUrl()
} }
} }
@ -260,6 +283,15 @@ const updateConfig = async () => {
state.config = await ipcRenderer.invoke('GET_CONFIG') state.config = await ipcRenderer.invoke('GET_CONFIG')
} }
const copyUrl = async () => {
const successed = await ipcRenderer.invoke('COPY_URL')
if (successed) {
ElMessage.success(ui.value.extra.urlCopied)
} else {
ElMessage.error(state.i18n.log.url.notFound)
}
}
onMounted(async () => { onMounted(async () => {
await readData() await readData()
await getI18nData() await getI18nData()

View File

@ -19,6 +19,10 @@
</el-radio-group> </el-radio-group>
<p class="text-gray-400 text-xs m-1.5">{{text.logTypeHint}}</p> <p class="text-gray-400 text-xs m-1.5">{{text.logTypeHint}}</p>
</el-form-item> </el-form-item>
<el-form-item :label="common.data">
<el-button type="primary" plain @click="state.showDataDialog = true">{{common.dataManage}}</el-button>
<p class="text-gray-400 text-xs m-1.5">{{text.dataManagerHint}}</p>
</el-form-item>
<el-form-item :label="text.autoUpdate"> <el-form-item :label="text.autoUpdate">
<el-switch <el-switch
@change="saveSetting" @change="saveSetting"
@ -51,21 +55,49 @@
<h3 class="text-lg my-4">{{about.title}}</h3> <h3 class="text-lg my-4">{{about.title}}</h3>
<p class="text-gray-600 text-xs mt-1">{{about.license}}</p> <p class="text-gray-600 text-xs mt-1">{{about.license}}</p>
<p class="text-gray-600 text-xs mt-1 pb-6">Github: <a @click="openGithub" class="cursor-pointer text-blue-400">https://github.com/biuuu/star-rail-warp-export</a></p> <p class="text-gray-600 text-xs mt-1 pb-6">Github: <a @click="openGithub" class="cursor-pointer text-blue-400">https://github.com/biuuu/star-rail-warp-export</a></p>
<el-dialog v-model="state.showDataDialog" :title="common.dataManage" width="90%">
<div class="">
<el-table :data="gachaDataInfo" border stripe>
<el-table-column property="uid" label="UID" width="128" />
<el-table-column property="time" :label="common.updateTime">
<template #default="scope">
{{ new Date(scope.row.time).toLocaleString() }}
</template>
</el-table-column>
<el-table-column property="deleted" :label="common.status" width="128">
<template #default="scope">
<el-tag type="info" size="small" v-if="scope.row.deleted">{{common.deleted}}</el-tag>
<el-tag type="success" size="small" v-else>{{common.normal}}</el-tag>
</template>
</el-table-column>
<el-table-column property="deleted" :label="common.action" width="128">
<template #default="scope">
<el-tooltip :content="scope.row.deleted ? common.restore : common.delete" placement="top">
<el-button :loading="state.dataActionLoading" size="small" icon="refresh" plain type="success" @click="deleteData(scope.row.uid, false)" v-if="scope.row.deleted"></el-button>
<el-button :loading="state.dataActionLoading" size="small" icon="delete" plain type="danger" @click="deleteData(scope.row.uid, true)" v-else></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div> </div>
</el-dialog>
</div>
</template> </template>
<script setup> <script setup>
const { ipcRenderer, shell } = require('electron') const { ipcRenderer, shell } = require('electron')
import { reactive, onMounted, computed } from 'vue' import { reactive, onMounted, computed } from 'vue'
const emit = defineEmits(['close', 'changeLang']) const emit = defineEmits(['close', 'changeLang', 'refreshData'])
const props = defineProps({ const props = defineProps({
i18n: Object i18n: Object,
gachaDataInfo: Array
}) })
const data = reactive({ const data = reactive({
langMap: new Map() langMap: new Map(),
}) })
const settingForm = reactive({ const settingForm = reactive({
@ -77,6 +109,12 @@ const settingForm = reactive({
hideNovice: true hideNovice: true
}) })
const state = reactive({
showDataDialog: false,
dataActionLoading: false
})
const common = computed(() => props.i18n.ui.common)
const text = computed(() => props.i18n.ui.setting) const text = computed(() => props.i18n.ui.setting)
const about = computed(() => props.i18n.ui.about) const about = computed(() => props.i18n.ui.about)
@ -105,6 +143,13 @@ const exportUIGFJSON = () => {
ipcRenderer.invoke('EXPORT_UIGF_JSON') ipcRenderer.invoke('EXPORT_UIGF_JSON')
} }
const deleteData = async (uid, action) => {
state.dataActionLoading = true
await ipcRenderer.invoke('DELETE_DATA', uid, action)
state.dataActionLoading = false
emit('refreshData')
}
onMounted(async () => { onMounted(async () => {
data.langMap = await ipcRenderer.invoke('LANG_MAP') data.langMap = await ipcRenderer.invoke('LANG_MAP')
const config = await ipcRenderer.invoke('GET_CONFIG') const config = await ipcRenderer.invoke('GET_CONFIG')

668
yarn.lock

File diff suppressed because it is too large Load Diff