Merge branch '94-添加软件打包tauri' into dev

This commit is contained in:
LOG1997
2025-12-09 20:30:51 +08:00
committed by GitHub
68 changed files with 5732 additions and 661 deletions

3
.gitignore vendored
View File

@@ -79,6 +79,8 @@ web_modules/
.env.production.local .env.production.local
.env.local .env.local
components.d.ts
# parcel-bundler cache (https://parceljs.org/) # parcel-bundler cache (https://parceljs.org/)
.cache .cache
.parcel-cache .parcel-cache
@@ -90,6 +92,7 @@ out
# Nuxt.js build / generate output # Nuxt.js build / generate output
.nuxt .nuxt
dist dist
dist-file
# Gatsby files # Gatsby files
.cache/ .cache/

View File

@@ -25,7 +25,7 @@
"github-markdown-css": "^5.8.0", "github-markdown-css": "^5.8.0",
"localforage": "^1.10.0", "localforage": "^1.10.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"lucide-vue-next": "^0.555.0", "lucide-vue-next": "^0.556.0",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"pinia": "^3.0.3", "pinia": "^3.0.3",
"pinia-plugin-persist": "^1.0.0", "pinia-plugin-persist": "^1.0.0",
@@ -36,7 +36,7 @@
"vue": "^3.5.13", "vue": "^3.5.13",
"vue-dompurify-html": "^5.2.0", "vue-dompurify-html": "^5.2.0",
"vue-draggable-plus": "^0.6.0", "vue-draggable-plus": "^0.6.0",
"vue-i18n": "^11.1.12", "vue-i18n": "^11.2.2",
"vue-router": "^4.5.0", "vue-router": "^4.5.0",
"vue-toast-notification": "^3", "vue-toast-notification": "^3",
"vue3-colorpicker": "^2.3.0", "vue3-colorpicker": "^2.3.0",
@@ -51,25 +51,27 @@
"@iconify-json/fluent": "^1.2.8", "@iconify-json/fluent": "^1.2.8",
"@tailwindcss/typography": "^0.5.15", "@tailwindcss/typography": "^0.5.15",
"@tailwindcss/vite": "^4.1.13", "@tailwindcss/vite": "^4.1.13",
"@tauri-apps/cli": "^2.9.5",
"@testing-library/vue": "^8.1.0", "@testing-library/vue": "^8.1.0",
"@types/canvas-confetti": "^1.6.4", "@types/canvas-confetti": "^1.6.4",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/markdown-it": "^14.1.2", "@types/markdown-it": "^14.1.2",
"@types/node": "^24.5.2", "@types/node": "^24.10.2",
"@types/three": "^0.166.0", "@types/three": "^0.166.0",
"@typescript-eslint/eslint-plugin": "^8.16.0", "@typescript-eslint/eslint-plugin": "^8.49.0",
"@typescript-eslint/parser": "^8.16.0", "@typescript-eslint/parser": "^8.49.0",
"@vitejs/plugin-legacy": "^7.2.1", "@vitejs/plugin-legacy": "^7.2.1",
"@vitejs/plugin-vue": "^6.0.1", "@vitejs/plugin-vue": "^6.0.1",
"@vitest/ui": "^4.0.15", "@vitest/ui": "^4.0.15",
"@vue/test-utils": "^2.4.6", "@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.8.1",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"baseline-browser-mapping": "^2.8.32", "baseline-browser-mapping": "^2.8.32",
"daisyui": "^5.1.13", "daisyui": "^5.1.13",
"eslint": "^9.15.0", "eslint": "^9.15.0",
"eslint-plugin-vue": "^10.4.0", "eslint-plugin-vue": "^10.4.0",
"globals": "^16.4.0", "globals": "^16.4.0",
"happy-dom": "^18.0.1", "happy-dom": "^20.0.11",
"husky": "^9.1.7", "husky": "^9.1.7",
"jsdom": "^27.0.0", "jsdom": "^27.0.0",
"path": "^0.12.7", "path": "^0.12.7",
@@ -77,18 +79,18 @@
"rollup-plugin-visualizer": "^6.0.3", "rollup-plugin-visualizer": "^6.0.3",
"sass": "^1.81.0", "sass": "^1.81.0",
"sass-loader": "^16.0.3", "sass-loader": "^16.0.3",
"tailwindcss": "^4.1.13", "tailwindcss": "^4.1.17",
"terser": "^5.36.0", "terser": "^5.36.0",
"typescript": "5.5.3", "typescript": "~5.9.3",
"unplugin-auto-import": "^20.1.0", "unplugin-auto-import": "^20.1.0",
"unplugin-icons": "^22.3.0", "unplugin-icons": "^22.3.0",
"unplugin-vue-components": "^29.1.0", "unplugin-vue-components": "^30.0.0",
"vite": "^7.1.6", "vite": "^7.1.6",
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vite-plugin-inspect": "^11.3.3", "vite-plugin-inspect": "^11.3.3",
"vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-devtools": "^8.0.2", "vite-plugin-vue-devtools": "^8.0.2",
"vitest": "^3.2.4", "vitest": "^4.0.15",
"vue-tsc": "^3.0.7" "vue-tsc": "^3.0.7"
} }
} }

1205
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

4
src-tauri/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/gen/schemas

5005
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

29
src-tauri/Cargo.toml Normal file
View File

@@ -0,0 +1,29 @@
[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = [ "you" ]
license = ""
repository = ""
edition = "2021"
rust-version = "1.77.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "app_lib"
crate-type = [
"staticlib",
"cdylib",
"rlib"
]
[build-dependencies]
tauri-build = { version = "2.5.3", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
log = "0.4"
tauri = { version = "2.9.4", features = [] }
tauri-plugin-log = "2"

3
src-tauri/build.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

View File

@@ -0,0 +1,11 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "enables the default permissions",
"windows": [
"main"
],
"permissions": [
"core:default"
]
}

BIN
src-tauri/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
src-tauri/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src-tauri/icons/64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>

BIN
src-tauri/icons/icon.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

16
src-tauri/src/lib.rs Normal file
View File

@@ -0,0 +1,16 @@
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(|app| {
if cfg!(debug_assertions) {
app.handle().plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.build(),
)?;
}
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

6
src-tauri/src/main.rs Normal file
View File

@@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
app_lib::run();
}

37
src-tauri/tauri.conf.json Normal file
View File

@@ -0,0 +1,37 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "log-lottery",
"version": "0.1.0",
"identifier": "to2026.xyz",
"build": {
"frontendDist": "../dist",
"devUrl": "http://localhost:6719/log-lottery",
"beforeDevCommand": "pnpm dev",
"beforeBuildCommand": "pnpm build"
},
"app": {
"windows": [
{
"title": "log-lottery",
"width": 800,
"height": 600,
"resizable": true,
"fullscreen": false
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}

5
src/components.d.ts vendored
View File

@@ -1,8 +1,11 @@
/* eslint-disable */ /* eslint-disable */
// @ts-nocheck // @ts-nocheck
// biome-ignore lint: disable
// oxlint-disable
// ------
// Generated by unplugin-vue-components // Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399 // Read more: https://github.com/vuejs/core/pull/3399
// biome-ignore lint: disable
export {} export {}
/* prettier-ignore */ /* prettier-ignore */

View File

@@ -113,6 +113,10 @@ export const configRoutes = {
], ],
} }
const routes = [ const routes = [
{
path: '/',
redirect: '/log-lottery',
},
{ {
path: '/log-lottery', path: '/log-lottery',
component: Layout, component: Layout,
@@ -135,7 +139,7 @@ const routes = [
const envMode = import.meta.env.MODE const envMode = import.meta.env.MODE
const router = createRouter({ const router = createRouter({
// 读取环境变量 // 读取环境变量
history: envMode === 'file' ? createWebHashHistory() : createWebHistory(), history: (envMode === 'file' || import.meta.env.TAURI_PLATFORM) ? createWebHashHistory() : createWebHistory(),
routes, routes,
}) })

View File

@@ -1,8 +1,8 @@
import type { IPersonConfig, IPrizeConfig } from '@/types/storeType' import type { IPersonConfig, IPrizeConfig } from '@/types/storeType'
const originUrl = 'https://to2026.xyz' const originUrl = 'https://to2026.xyz'
type IPersonConfigWithoutUuid = Omit<IPersonConfig, 'uuid'>
export const defaultPersonList = <IPersonConfig[]> export const defaultPersonList = <IPersonConfigWithoutUuid[]>
[ [
{ uid: 'U100156001', name: '朱厚熜', department: '皇室', identity: '万岁爷', avatar: 'https://img1.baidu.com/it/u=2165937980,813753762&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', x: 1, y: 1, id: 0, isWin: false, createTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', updateTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', prizeName: [], prizeTime: [], prizeId: [] }, { uid: 'U100156001', name: '朱厚熜', department: '皇室', identity: '万岁爷', avatar: 'https://img1.baidu.com/it/u=2165937980,813753762&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', x: 1, y: 1, id: 0, isWin: false, createTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', updateTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', prizeName: [], prizeTime: [], prizeId: [] },
{ uid: 'U100156002', name: '朱载垕', department: '皇室', identity: '裕王', avatar: 'https://img1.baidu.com/it/u=2165937980,813753762&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', x: 2, y: 1, id: 1, isWin: false, createTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', updateTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', prizeName: [], prizeTime: [], prizeId: [] }, { uid: 'U100156002', name: '朱载垕', department: '皇室', identity: '裕王', avatar: 'https://img1.baidu.com/it/u=2165937980,813753762&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', x: 2, y: 1, id: 1, isWin: false, createTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', updateTime: 'Tue Jan 09 2024 23:20:07 GMT+0800 (China Standard Time)', prizeName: [], prizeTime: [], prizeId: [] },

View File

@@ -1,6 +1,7 @@
import type { IPersonConfig, IPrizeConfig } from '@/types/storeType' import type { IPersonConfig, IPrizeConfig } from '@/types/storeType'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { v4 as uuidv4 } from 'uuid'
import { computed, ref, toRaw, watch } from 'vue' import { computed, ref, toRaw, watch } from 'vue'
import { IndexDb } from '@/utils/dexie' import { IndexDb } from '@/utils/dexie'
import { defaultPersonList } from './data' import { defaultPersonList } from './data'
@@ -150,7 +151,10 @@ export const usePersonConfig = defineStore('person', () => {
personDb.deleteAll('alreadyPersonList') personDb.deleteAll('alreadyPersonList')
} }
function setDefaultPersonList() { function setDefaultPersonList() {
personConfig.value.allPersonList = defaultPersonList personConfig.value.allPersonList = defaultPersonList.map((item: any) => {
item.uuid = uuidv4()
return item
})
personConfig.value.alreadyPersonList = [] personConfig.value.alreadyPersonList = []
personDb.setAllData('allPersonList', defaultPersonList) personDb.setAllData('allPersonList', defaultPersonList)
personDb.deleteAll('alreadyPersonList') personDb.deleteAll('alreadyPersonList')

View File

@@ -22,9 +22,8 @@ const process = require('node:process')
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
const env = loadEnv(mode, __dirname) const env = loadEnv(mode, __dirname)
const chunkName = mode === 'prebuild' ? '[name]' : 'chunk' const chunkName = mode === 'prebuild' ? '[name]' : 'chunk'
return { return {
base: mode === 'file' ? './' : '/log-lottery/', base: (mode === 'file' || process.env.TAURI_ENV_PLATFORM) ? './' : '/log-lottery/',
plugins: [ plugins: [
vue(), vue(),
tailwindcss(), tailwindcss(),
@@ -90,9 +89,15 @@ export default defineConfig(({ mode }) => {
// ] // ]
// } // }
}, },
clearScreen: false,
server: { server: {
host: 'localhost', host: 'localhost',
port: 6719, port: 6719,
strictPort: true,
watch: {
// 告诉 Vite 忽略监听 `src-tauri` 目录
ignored: ['**/src-tauri/**'],
},
proxy: { proxy: {
'/api': { '/api': {
target: env.VITE_BASE_URL, target: env.VITE_BASE_URL,
@@ -103,6 +108,8 @@ export default defineConfig(({ mode }) => {
}, },
}, },
}, },
// 添加有关当前构建目标的额外前缀,使这些 CLI 设置的 Tauri 环境变量可以在客户端代码中访问
envPrefix: ['VITE_', 'TAURI_ENV_*'],
resolve: { resolve: {
alias: { alias: {
'@': path.resolve(__dirname, './src'), '@': path.resolve(__dirname, './src'),
@@ -110,7 +117,13 @@ export default defineConfig(({ mode }) => {
}, },
build: { build: {
outDir: mode === 'file' ? 'dist-file' : 'dist', outDir: mode === 'file' ? 'dist-file' : 'dist',
minify: 'terser', // Tauri 在 Windows 上使用 Chromium在 macOS 和 Linux 上使用 WebKit
// target: (process.env.TAURI_ENV_PLATFORM && mode !== 'file')
// ? (process.env.TAURI_ENV_PLATFORM === 'windows' ? 'chrome105' : 'safari13')
// : 'es2020', // 普通前端可使用更高版本 JS 支持
minify: process.env.TAURI_ENV_PLATFORM
? (!process.env.TAURI_ENV_DEBUG ? 'esbuild' : false)
: 'terser', // 普通构建推荐使用 terser 提供更强压缩选项
terserOptions: { terserOptions: {
compress: { compress: {
// 生产环境时移除console // 生产环境时移除console
@@ -121,7 +134,7 @@ export default defineConfig(({ mode }) => {
// 关闭文件计算 // 关闭文件计算
reportCompressedSize: false, reportCompressedSize: false,
// 关闭生成map文件 可以达到缩小打包体积 // 关闭生成map文件 可以达到缩小打包体积
sourcemap: false, // 这个生产环境一定要关闭,不然打包的产物会很大 sourcemap: process.env.NODE_ENV === 'development' || !!process.env.TAURI_ENV_DEBUG, // 这个生产环境一定要关闭,不然打包的产物会很大
rollupOptions: { rollupOptions: {
output: { output: {
chunkFileNames: `js/${chunkName}-[hash].js`, // 引入文件名的名称 chunkFileNames: `js/${chunkName}-[hash].js`, // 引入文件名的名称
@@ -145,6 +158,7 @@ export default defineConfig(({ mode }) => {
environment: 'jsdom', environment: 'jsdom',
// include: ['**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], // include: ['**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
// passWithNoTests: true, // passWithNoTests: true,
testTimeout: 10000,
transformMode: { transformMode: {
web: [/\.[jt]sx$/], web: [/\.[jt]sx$/],
}, },