feat: finished 1.0.0

This commit is contained in:
TaurusXin 2024-03-14 21:55:01 +08:00
parent d1005bcd13
commit d88cc8a01b
Signed by: taurusxin
GPG Key ID: C334DCA04AC2D2CC
26 changed files with 6962 additions and 55 deletions

BIN
app-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

2
components.d.ts vendored
View File

@ -7,7 +7,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
Greet: typeof import('./src/components/Greet.vue')['default']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NInput: typeof import('naive-ui')['NInput']
NTable: typeof import('naive-ui')['NTable']
}

View File

@ -5,9 +5,10 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"build": "vite build",
"preview": "vite preview",
"tauri": "tauri"
"tauri": "tauri",
"icon": "tauri icon"
},
"dependencies": {
"@tauri-apps/api": "^1",

2
src-tauri/Cargo.lock generated
View File

@ -2816,7 +2816,7 @@ dependencies = [
[[package]]
name = "text-recover"
version = "0.0.0"
version = "1.0.0"
dependencies = [
"serde",
"serde_json",

View File

@ -1,8 +1,8 @@
[package]
name = "text-recover"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
version = "1.0.0"
description = "TextRecover App"
authors = ["TaurusXin"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -6,8 +6,8 @@
"distDir": "../dist"
},
"package": {
"productName": "text-recover",
"version": "0.0.0"
"productName": "TextRecover",
"version": "1.0.0"
},
"tauri": {
"allowlist": {
@ -19,9 +19,9 @@
},
"windows": [
{
"title": "text-recover",
"title": "Text Recover",
"width": 800,
"height": 600
"height": 800
}
],
"security": {
@ -30,7 +30,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.taurusxin.text-recover",
"icon": [
"icons/32x32.png",
"icons/128x128.png",

View File

@ -2,6 +2,10 @@
import { ref } from 'vue'
import { codecs } from '@/utils/codecs.ts'
import { EncodingConverter } from '@/utils/converter'
import { useOsTheme, darkTheme } from 'naive-ui'
const osThemeRef = useOsTheme()
const theme = computed(() => (osThemeRef.value === 'dark' ? darkTheme : undefined))
const Converter = new EncodingConverter()
@ -12,13 +16,14 @@ const handleTextInput = (text: string) => {
codecs.forEach(codec => {
result.value = []
Converter.convert(codec, text).then(res => {
result.value?.push(res ?? '')
result.value?.push(res ?? '[转换失败]')
})
})
}
</script>
<template>
<n-config-provider :theme="theme">
<div class="container">
<n-input
v-model:value="content"
@ -31,9 +36,9 @@ const handleTextInput = (text: string) => {
<n-table :single-line="false" striped class="table">
<thead>
<tr>
<th class="encode">原来编码</th>
<th class="encode">目标编码</th>
<th class="result">结果</th>
<th class="encode title">原来编码</th>
<th class="encode title">目标编码</th>
<th class="result title">结果</th>
</tr>
</thead>
<tbody>
@ -45,10 +50,13 @@ const handleTextInput = (text: string) => {
</tbody>
</n-table>
</div>
</n-config-provider>
</template>
<style scoped lang="less">
.container {
// disable selection
user-select: none;
padding: 0.8rem;
.input {
@ -57,7 +65,11 @@ const handleTextInput = (text: string) => {
.table {
.encode {
width: 8rem;
width: 7rem;
}
.title {
font-weight: bold;
}
}
}

View File

@ -1,15 +1,47 @@
export interface Codec {
origin: string;
target: string;
origin: string
target: string
}
export const codecs: Codec[] = [
{
origin: 'gbk',
target: 'utf8',
origin: 'GBK',
target: 'UTF-8',
},
{
origin: 'utf8',
target: 'gbk',
}
origin: 'UTF-8',
target: 'GBK',
},
{
origin: 'GBK',
target: 'ISO-8859-1',
},
{
origin: 'GBK',
target: 'BIG5',
},
{
origin: 'GBK',
target: 'UTF-16',
},
{
origin: 'GBK',
target: 'WINDOWS-1252',
},
{
origin: 'UTF-8',
target: 'ISO-8859-1',
},
{
origin: 'UTF-8',
target: 'BIG5',
},
{
origin: 'UTF-8',
target: 'UTF-16',
},
{
origin: 'UTF-8',
target: 'WINDOWS-1252',
},
]

View File

@ -1,18 +1,15 @@
import { Codec } from '@/utils/codecs'
import '@/utils/iconv'
export class EncodingConverter {
async convert(codec: Codec, text: string): Promise<string | null> {
let convertedText: string | null = null
try {
const byteArray = new TextEncoder().encode(text)
const decodedText = new TextDecoder(codec.origin).decode(byteArray)
const byteArray2 = new TextEncoder().encode(decodedText)
convertedText = new TextDecoder(codec.target).decode(byteArray2)
const byteArray = iconv.encode(text, codec.origin)
convertedText = iconv.decode(byteArray, codec.target)
text = convertedText
} catch (error) {
console.error(
`Failed to convert from ${codec.origin} to ${codec.target}: ${error}`
)
console.error(`Failed to convert from ${codec.origin} to ${codec.target}: ${error}`)
return null
}
return convertedText

6865
src/utils/iconv.js Normal file

File diff suppressed because it is too large Load Diff