feat: Merge Export Excel Button and Export JSON Button

This commit is contained in:
mio
2023-06-29 16:24:39 +08:00
parent 4ab2f60b53
commit 8628625a27
12 changed files with 177 additions and 104 deletions

View File

@ -3,7 +3,7 @@
"ui.button.load": "Lade Daten",
"ui.button.update": "Aktualisieren",
"ui.button.excel": "In Excel exportieren",
"ui.button.srgf": "In SRGF exportieren",
"ui.button.srgf": "In JSON exportieren",
"ui.button.url": "Eingabe URL",
"ui.button.setting": "Einstellungen",
"ui.button.option": "Optionen",

View File

@ -3,8 +3,9 @@
"ui.button.load": "Load data",
"ui.button.update": "Update",
"ui.button.directUpdate": "Direct update",
"ui.button.files": "Export Files",
"ui.button.excel": "Export Excel",
"ui.button.srgf": "Export SRGF",
"ui.button.srgf": "Export JSON",
"ui.button.url": "Input URL",
"ui.button.setting": "Settings",
"ui.button.option": "Option",

View File

@ -4,7 +4,7 @@
"ui.button.update": "Mettre à jour",
"ui.button.directUpdate": "Mise à jour directe",
"ui.button.excel": "Exporter vers Excel",
"ui.button.srgf": "Exporter vers SRGF",
"ui.button.srgf": "Exporter vers JSON",
"ui.button.url": "URL d'import",
"ui.button.setting": "Paramètres",
"ui.button.option": "Options",

View File

@ -3,7 +3,7 @@
"ui.button.load": "データの読み込み",
"ui.button.update": "更新データ",
"ui.button.excel": "Excelにエクスポート",
"ui.button.srgf": "SRGFにエクスポート",
"ui.button.srgf": "JSONにエクスポート",
"ui.button.url": "URL入力",
"ui.button.setting": "設定",
"ui.button.option": "オプション",

View File

@ -3,8 +3,9 @@
"ui.button.load": "加载数据",
"ui.button.update": "更新数据",
"ui.button.directUpdate": "直接更新",
"ui.button.files": "导出文件",
"ui.button.excel": "导出Excel",
"ui.button.srgf":"导出SRGF",
"ui.button.srgf":"导出JSON",
"ui.button.url": "输入URL",
"ui.button.setting": "设置",
"ui.button.option": "选项",

View File

@ -3,8 +3,9 @@
"ui.button.load": "載入資料",
"ui.button.update": "更新資料",
"ui.button.directUpdate": "直接更新",
"ui.button.files": "匯出檔案",
"ui.button.excel": "匯出 Excel",
"ui.button.srgf": "匯出 SRGF",
"ui.button.srgf": "匯出 JSON",
"ui.button.url": "輸入 URL",
"ui.button.setting": "設定",
"ui.button.option": "選項",

View File

@ -27,7 +27,7 @@ const start = async () => {
uid: data.uid,
lang: data.lang,
export_time: formatDate(new Date()),
export_timestamp: Math.ceil(Date.now()/1000),
export_timestamp: Math.ceil(Date.now() / 1000),
export_app: 'star-rail-warp-export',
export_app_version: `v${version}`,
region_time_zone: data.region_time_zone,
@ -39,19 +39,19 @@ const start = async () => {
for (let [type, arr] of data.result) {
arr.forEach(log => {
listTemp.push({
gacha_id:log.gacha_id,
gacha_type: log.gacha_type,
item_id:log.item_id,
count:"1",
time:log.time,
name:log.name,
item_type:log.item_type,
rank_type:log.rank_type,
id:log.id
gacha_id: log.gacha_id,
gacha_type: log.gacha_type,
item_id: log.item_id,
count: '1',
time: log.time,
name: log.name,
item_type: log.item_type,
rank_type: log.rank_type,
id: log.id
})
})
}
listTemp.sort((a, b) => BigInt(a.id) - BigInt(b.id))
listTemp.sort((a, b) => Number(BigInt(a.id) - BigInt(b.id)))
listTemp.forEach(item => {
result.list.push({
...item

View File

@ -1,10 +1,20 @@
<template>
<div v-if="ui" class="relative">
<div class="flex justify-between">
<div>
<div class="space-x-3">
<el-button type="primary" :icon="state.status === 'init' ? 'milk-tea': 'refresh-right'" class="focus:outline-none" :disabled="!allowClick()" plain @click="fetchData()" :loading="state.status === 'loading'">{{state.status === 'init' ? ui.button.load: ui.button.update}}</el-button>
<el-button icon="folder-opened" @click="saveExcel" class="focus:outline-none" :disabled="!gachaData" type="success" plain>{{ui.button.excel}}</el-button>
<el-button icon="folder-opened" @click="exportSRGFJSON" class="focus:outline-none" :disabled="!gachaData" type="success" plain>{{ui.button.srgf}}</el-button>
<el-dropdown :disabled="!gachaData" @command="exportCommand">
<el-button :disabled="!gachaData" icon="folder-opened" class="focus:outline-none" type="success" plain>
{{ui.button.files}}
<el-icon class="el-icon--right"><arrow-down /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="excel">{{ui.button.excel}}</el-dropdown-item>
<el-dropdown-item command="srgf-json">{{ui.button.srgf}}</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-tooltip v-if="detail && state.status !== 'loading'" :content="ui.hint.newAccount" placement="bottom">
<el-button @click="newUser()" plain icon="plus" class="focus:outline-none"></el-button>
</el-tooltip>
@ -21,7 +31,7 @@
:value="item[0]">
</el-option>
</el-select>
<el-dropdown @command="optionCommand" >
<el-dropdown @command="optionCommand">
<el-button @click="showSetting(true)" class="focus:outline-none" plain type="info" icon="more" >{{ui.button.option}}</el-button>
<template #dropdown>
<el-dropdown-menu>
@ -46,7 +56,7 @@
</div>
<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%" class="max-w-md">
<p class="mb-4 text-gray-500">{{ui.urlDialog.hint}}</p>
<el-input type="textarea" :autosize="{minRows: 4, maxRows: 6}" :placeholder="ui.urlDialog.placeholder" v-model="state.urlInput" spellcheck="false"></el-input>
<template #footer>
@ -57,7 +67,7 @@
</template>
</el-dialog>
<el-dialog :title="ui.button.solution" v-model="state.showCacheCleanDlg" width="90%" custom-class="max-w-md cache-clean-dialog">
<el-dialog :title="ui.button.solution" v-model="state.showCacheCleanDlg" width="90%" class="max-w-md cache-clean-dialog">
<el-button plain icon="folder" type="success" @click="openCacheFolder">{{ui.button.cacheFolder}}</el-button>
<p class="my-2 flex flex-col text-teal-800 text-[13px]">
<span class="my-1" v-for="txt of cacheCleanTextList">{{ txt }}</span>
@ -232,6 +242,14 @@ const exportSRGFJSON = () => {
ipcRenderer.invoke('EXPORT_SRGF_JSON')
}
const exportCommand = (type) => {
if (type === 'excel') {
saveExcel()
} else if (type === 'srgf-json') {
exportSRGFJSON()
}
}
const openCacheFolder = async () => {
await ipcRenderer.invoke('OPEN_CACHE_FOLDER')
}

View File

@ -1,8 +1,8 @@
<template>
<div class="bg-white pt-2 pb-4 px-6 w-full h-full absolute inset-0">
<div class="bg-white py-4 px-6 w-screen h-screen fixed inset-0 overflow-y-auto">
<div class="flex content-center items-center mb-4 justify-between">
<h3 class="text-lg">{{text.title}}</h3>
<el-button icon="close" @click="closeSetting" plain circle type="default" class="w-8 h-8 relative -right-4 -top-2 shadow-md focus:shadow-none focus:outline-none"></el-button>
<el-button icon="close" @click="closeSetting" plain circle type="default" class="w-8 h-8 shadow-md focus:shadow-none focus:outline-none fixed top-4 right-6"></el-button>
</div>
<el-form :model="settingForm" label-width="120px">
<el-form-item :label="text.language">
@ -56,31 +56,31 @@
<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>
<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>
</el-dialog>
<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>
</el-dialog>
</div>
</template>

View File

@ -6,11 +6,11 @@
:root {
--el-font-size-base: 12px !important;
}
body::-webkit-scrollbar {
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
body::-webkit-scrollbar-thumb {
::-webkit-scrollbar-thumb {
@apply rounded-full bg-gray-300;
}
}