Compare commits
15 Commits
v1.0.0
...
6f5f739059
| Author | SHA1 | Date | |
|---|---|---|---|
|
6f5f739059
|
|||
|
b0bfb3e606
|
|||
|
4df7df678b
|
|||
|
33d9b91c52
|
|||
|
f7a7a7b401
|
|||
|
7402e35d66
|
|||
| 36fd04f975 | |||
| 91bbd8deb4 | |||
| 2f25264483 | |||
| db6d89bdb9 | |||
| a08813dc94 | |||
| 6bc7923eea | |||
|
1f9e811246
|
|||
| c100bb886a | |||
| 66bb4ac6c5 |
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-present TaurusXin and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
24
README.md
24
README.md
@@ -1,19 +1,19 @@
|
||||
# README
|
||||
# ncmdump-gui
|
||||
|
||||
## About
|
||||
## 介绍
|
||||
|
||||
This is the official Wails React-TS template.
|
||||
ncmdump-gui 基于 [ncmdump-go](https://git.taurusxin.com/taurusxin/ncmdump-go) 开发,是一个图形化的 ncmdump 工具。
|
||||
|
||||
You can configure the project by editing `wails.json`. More information about the project settings can be found
|
||||
here: https://wails.io/docs/reference/project-config
|
||||

|
||||
|
||||
## Live Development
|
||||
使用简单,使用 go 协程,高速并行解析并处理多个 ncm 文件,多个文件瞬间完成,支持自定义输出路径。
|
||||
|
||||
To run in live development mode, run `wails dev` in the project directory. This will run a Vite development
|
||||
server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser
|
||||
and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect
|
||||
to this in your browser, and you can call your Go code from devtools.
|
||||
## 下载
|
||||
|
||||
## Building
|
||||
前往[Releases](https://git.taurusxin.com/taurusxin/ncmdump-gui/releases)下载最新版本。
|
||||
|
||||
To build a redistributable, production mode package, use `wails build`.
|
||||
请注意:绝大多数较新版本的 Windows 都自带了 Webview 2 运行时,如果遇到了软件无法启动的问题,请前往微软官网下载:<https://developer.microsoft.com/zh-cn/microsoft-edge/webview2/>
|
||||
|
||||
## Bug 及建议
|
||||
|
||||
如有任何问题或建议,请直接通过 [Issue](https://git.taurusxin.com/taurusxin/ncmdump-gui/issues) 反馈,本站已开放注册。
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import React, { useEffect, useMemo } from 'react'
|
||||
import { useState } from 'react'
|
||||
import {
|
||||
Button,
|
||||
@@ -35,12 +35,17 @@ import {
|
||||
CheckmarkRegular,
|
||||
DismissRegular,
|
||||
DocumentArrowRightRegular,
|
||||
DocumentAddRegular,
|
||||
DeleteRegular,
|
||||
DeleteDismissRegular,
|
||||
WindowPlayRegular,
|
||||
} from '@fluentui/react-icons'
|
||||
|
||||
import { Status, Item, SaveTo } from './types'
|
||||
import { SelectFiles, SelectFolder, ProcessFiles } from '../wailsjs/go/main/App'
|
||||
import { Load, Save } from '../wailsjs/go/utils/ConfigManager'
|
||||
import { main } from '../wailsjs/go/models'
|
||||
import { EventsOn } from '../wailsjs/runtime/runtime'
|
||||
import { EventsOn, OnFileDrop } from '../wailsjs/runtime/runtime'
|
||||
|
||||
const columnsDef: TableColumnDefinition<Item>[] = [
|
||||
createTableColumn<Item>({
|
||||
@@ -51,6 +56,10 @@ const columnsDef: TableColumnDefinition<Item>[] = [
|
||||
columnId: 'file',
|
||||
renderHeaderCell: () => <>文件</>,
|
||||
}),
|
||||
createTableColumn<Item>({
|
||||
columnId: 'operation',
|
||||
renderHeaderCell: () => <>操作</>,
|
||||
}),
|
||||
]
|
||||
|
||||
const useStyles = makeStyles({
|
||||
@@ -69,10 +78,9 @@ export const App = () => {
|
||||
const styles = useStyles()
|
||||
|
||||
const [items, setItems] = useState<Item[]>([])
|
||||
const [isProcessing, setIsProcessing] = useState(false)
|
||||
|
||||
const [totalFilesNeedToProcess, setTotalFilesNeedToProcess] = useState(0)
|
||||
const [finishedCount, setFinishedCount] = useState(0)
|
||||
const isProcessing = useMemo(() => {
|
||||
return items.some(item => item.status === 'processing')
|
||||
}, [items])
|
||||
|
||||
const [saveTo, setSaveTo] = useState<SaveTo>('original')
|
||||
const [savePath, setSavePath] = useState('')
|
||||
@@ -87,9 +95,13 @@ export const App = () => {
|
||||
minWidth: 100,
|
||||
},
|
||||
file: {
|
||||
idealWidth: 150,
|
||||
idealWidth: 1000,
|
||||
minWidth: 150,
|
||||
},
|
||||
operation: {
|
||||
idealWidth: 80,
|
||||
minWidth: 80,
|
||||
},
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
@@ -131,11 +143,13 @@ export const App = () => {
|
||||
}
|
||||
|
||||
const selectFiles = () => {
|
||||
if (isProcessing) {
|
||||
return
|
||||
}
|
||||
SelectFiles().then(files => {
|
||||
for (const file of files) {
|
||||
setItems(prev => [...prev, { file, status: 'pending' }])
|
||||
}
|
||||
setTotalFilesNeedToProcess(files.length)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -162,7 +176,10 @@ export const App = () => {
|
||||
showDialog('当前文件列表已全部处理完毕,请重新添加新的文件。')
|
||||
return
|
||||
}
|
||||
setIsProcessing(true)
|
||||
if(saveTo === 'custom' && savePath === '') {
|
||||
showDialog('保存路径为空,请先设置保存路径。')
|
||||
return
|
||||
}
|
||||
const ncmFiles: main.NcmFile[] = []
|
||||
items.forEach(item => {
|
||||
ncmFiles.push({
|
||||
@@ -175,24 +192,37 @@ export const App = () => {
|
||||
|
||||
useEffect(() => {
|
||||
EventsOn('file-status-changed', (index: number, status: Status) => {
|
||||
if (status == 'done' || status === 'error') {
|
||||
setFinishedCount(prev => prev + 1)
|
||||
}
|
||||
setItems(prev => {
|
||||
const newItems = [...prev]
|
||||
newItems[index].status = status
|
||||
return newItems
|
||||
})
|
||||
})
|
||||
Load().then(res => {
|
||||
console.log(res)
|
||||
setSaveTo(res.save_to as SaveTo)
|
||||
setSavePath(res.path)
|
||||
})
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (finishedCount === totalFilesNeedToProcess) {
|
||||
setFinishedCount(0)
|
||||
setTotalFilesNeedToProcess(0)
|
||||
setIsProcessing(false)
|
||||
Save({
|
||||
save_to: saveTo,
|
||||
path: savePath,
|
||||
}).then(_ => {})
|
||||
}, [saveTo, savePath])
|
||||
|
||||
OnFileDrop((_x, _y, paths) => {
|
||||
let length = paths.length
|
||||
for (const path of paths) {
|
||||
// only end with ncm
|
||||
if (!path.endsWith('.ncm')) {
|
||||
length--
|
||||
continue
|
||||
}
|
||||
}, [finishedCount])
|
||||
setItems(prev => [...prev, { file: path, status: 'pending' }])
|
||||
}
|
||||
}, false)
|
||||
|
||||
return (
|
||||
<div className="p-3">
|
||||
@@ -217,10 +247,22 @@ export const App = () => {
|
||||
</DialogSurface>
|
||||
</Dialog>
|
||||
<div className="flex space-between gap-3">
|
||||
<Button onClick={selectFiles}>添加文件</Button>
|
||||
<Button onClick={() => setItems([])}>清除列表</Button>
|
||||
<Button onClick={selectFiles} icon={<DocumentAddRegular />}>
|
||||
添加文件
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (!isProcessing) {
|
||||
setItems([])
|
||||
}
|
||||
}}
|
||||
icon={<DeleteDismissRegular />}
|
||||
>
|
||||
清除列表
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
icon={<WindowPlayRegular />}
|
||||
onClick={() => {
|
||||
startProcess()
|
||||
}}
|
||||
@@ -289,6 +331,18 @@ export const App = () => {
|
||||
</TableCellLayout>
|
||||
</TableCell>
|
||||
<TableCell>{file.file}</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
size="small"
|
||||
icon={<DeleteRegular />}
|
||||
appearance="transparent"
|
||||
onClick={() => {
|
||||
setItems(prev => prev.filter((_, i) => i !== index))
|
||||
}}
|
||||
>
|
||||
移除
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
|
||||
18
go.mod
18
go.mod
@@ -5,7 +5,7 @@ go 1.23.0
|
||||
toolchain go1.23.3
|
||||
|
||||
require (
|
||||
git.taurusxin.com/taurusxin/ncmdump-go v1.7.2
|
||||
git.taurusxin.com/taurusxin/ncmdump-go v1.7.4
|
||||
github.com/wailsapp/wails/v2 v2.9.2
|
||||
)
|
||||
|
||||
@@ -20,30 +20,30 @@ require (
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||
github.com/labstack/echo/v4 v4.12.0 // indirect
|
||||
github.com/labstack/echo/v4 v4.13.3 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
||||
github.com/leaanthony/gosod v1.0.4 // indirect
|
||||
github.com/leaanthony/slicer v1.6.0 // indirect
|
||||
github.com/leaanthony/u v1.1.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/samber/lo v1.47.0 // indirect
|
||||
github.com/samber/lo v1.49.1 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tkrajina/go-reflector v0.5.8 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.17 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.19 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
golang.org/x/crypto v0.29.0 // indirect
|
||||
golang.org/x/net v0.31.0 // indirect
|
||||
golang.org/x/sys v0.27.0 // indirect
|
||||
golang.org/x/text v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.32.0 // indirect
|
||||
golang.org/x/net v0.34.0 // indirect
|
||||
golang.org/x/sys v0.29.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
)
|
||||
|
||||
// replace github.com/wailsapp/wails/v2 v2.9.2 => /Users/taurusxin/Workspace/gopath/pkg/mod
|
||||
|
||||
42
go.sum
42
go.sum
@@ -1,5 +1,5 @@
|
||||
git.taurusxin.com/taurusxin/ncmdump-go v1.7.2 h1:VF9gWpwswAvXA1WIXnxxJpCiUqdQ8gPzKURHsddgadU=
|
||||
git.taurusxin.com/taurusxin/ncmdump-go v1.7.2/go.mod h1:6kRSwUFM9BZwvDrg6MEPBn+29+Q2131QjK/URWO7seg=
|
||||
git.taurusxin.com/taurusxin/ncmdump-go v1.7.4 h1:Uk7tP58yNMOMqH1e9+BOFwwQ/lqScK3F10mAIFB/jtM=
|
||||
git.taurusxin.com/taurusxin/ncmdump-go v1.7.4/go.mod h1:6kRSwUFM9BZwvDrg6MEPBn+29+Q2131QjK/URWO7seg=
|
||||
github.com/TwiN/go-color v1.4.1 h1:mqG0P/KBgHKVqmtL5ye7K0/Gr4l6hTksPgTgMk3mUzc=
|
||||
github.com/TwiN/go-color v1.4.1/go.mod h1:WcPf/jtiW95WBIsEeY1Lc/b8aaWoiqQpu5cf8WFxu+s=
|
||||
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||
@@ -22,8 +22,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
|
||||
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
|
||||
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
||||
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
|
||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||
@@ -39,9 +39,8 @@ github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQc
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
@@ -53,10 +52,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
|
||||
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
@@ -70,8 +69,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/wailsapp/go-webview2 v1.0.17 h1:DkLnUKqW7J///OBXkInMq1fzC88G6ZjHwKuHXThuaco=
|
||||
github.com/wailsapp/go-webview2 v1.0.17/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.19 h1:7U3QcDj1PrBPaxJNCui2k1SkWml+Q5kvFUFyTImA6NU=
|
||||
github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/wailsapp/wails/v2 v2.9.2 h1:Xb5YRTos1w5N7DTMyYegWaGukCP2fIaX9WF21kPPF2k=
|
||||
@@ -79,15 +78,15 @@ github.com/wailsapp/wails/v2 v2.9.2/go.mod h1:uehvlCwJSFcBq7rMCGfk4rxca67QQGsbg5
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
|
||||
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
|
||||
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
|
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -97,11 +96,10 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -109,8 +107,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
|
||||
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
|
||||
BIN
img/ncmdump-gui.png
Normal file
BIN
img/ncmdump-gui.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 407 KiB |
14
main.go
14
main.go
@@ -6,6 +6,8 @@ import (
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
|
||||
"git.taurusxin.com/taurusxin/ncmdump-gui/utils"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
@@ -15,8 +17,13 @@ func main() {
|
||||
// Create an instance of the app structure
|
||||
app := NewApp()
|
||||
|
||||
config_manager, err := utils.NewConfigManager("config.json")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
err = wails.Run(&options.App{
|
||||
Title: "ncmdump-gui",
|
||||
Width: 750,
|
||||
Height: 500,
|
||||
@@ -27,6 +34,11 @@ func main() {
|
||||
OnStartup: app.startup,
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
config_manager,
|
||||
},
|
||||
DragAndDrop: &options.DragAndDrop{
|
||||
EnableFileDrop: true,
|
||||
DisableWebViewDrop: true,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
83
utils/config_manager.go
Normal file
83
utils/config_manager.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type SaveToType = string
|
||||
|
||||
const (
|
||||
Original SaveToType = "original"
|
||||
Custom SaveToType = "custom"
|
||||
)
|
||||
|
||||
type Preference struct {
|
||||
SaveTo SaveToType `json:"save_to"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
type ConfigManager struct {
|
||||
FilePath string
|
||||
}
|
||||
|
||||
// NewConfigManager 创建一个新的配置管理器,自动适配不同操作系统的用户目录
|
||||
func NewConfigManager(filename string) (*ConfigManager, error) {
|
||||
configDir, err := os.UserConfigDir() // 获取用户配置目录
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dirPath := filepath.Join(configDir, "ncmdump-gui")
|
||||
err = os.MkdirAll(dirPath, os.ModePerm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filePath := filepath.Join(dirPath, filename)
|
||||
|
||||
configManager := &ConfigManager{FilePath: filePath}
|
||||
// if not exist, create it with default value
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
defaultConfig := &Preference{
|
||||
SaveTo: Original,
|
||||
Path: "",
|
||||
}
|
||||
configManager.Save(defaultConfig)
|
||||
}
|
||||
return &ConfigManager{FilePath: filePath}, nil
|
||||
}
|
||||
|
||||
// Save 将配置保存到文件
|
||||
func (cm *ConfigManager) Save(preference *Preference) bool {
|
||||
file, err := os.Create(cm.FilePath)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ") // 格式化输出
|
||||
err = encoder.Encode(preference)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// Load 从文件读取配置
|
||||
func (cm *ConfigManager) Load() *Preference {
|
||||
file, err := os.Open(cm.FilePath)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
var preference *Preference = nil
|
||||
decoder := json.NewDecoder(file)
|
||||
err = decoder.Decode(&preference)
|
||||
fmt.Println(preference)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return preference
|
||||
}
|
||||
@@ -9,5 +9,12 @@
|
||||
"author": {
|
||||
"name": "TaurusXin",
|
||||
"email": "i@taurusxin.com"
|
||||
},
|
||||
"info": {
|
||||
"companyName": "TaurusXin",
|
||||
"productName": "ncmdump-gui",
|
||||
"productVersion": "1.0.1",
|
||||
"copyright": "Copyright © 2025 TaurusXin",
|
||||
"comments": "Convert ncm to mp3/flac"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user