Refactor UUID generation, remove unused logger and encryption utilities, and clean up request handling
- Updated `generateUUID` function for improved readability and performance. - Deleted `logger.ts`, `other.ts`, `request.ts`, `storage.ts`, `tansParams.ts`, and `validate.ts` as they were no longer needed. - Simplified TypeScript configuration by removing unnecessary paths and aliases. - Enhanced Vite configuration for better project structure and maintainability.
This commit is contained in:
@@ -2,20 +2,24 @@ import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import electron from 'vite-plugin-electron';
|
||||
import renderer from 'vite-plugin-electron-renderer';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import autoImport from 'unplugin-auto-import/vite';
|
||||
import electronBytecode from './plugins/bytenode/vite-plugin-electron-encrypt';
|
||||
|
||||
const projectAliases = {
|
||||
"@src": resolve(__dirname, "./src"),
|
||||
"@runtime": resolve(__dirname, "./runtime-shared"),
|
||||
"@electron": resolve(__dirname, "./electron"),
|
||||
"@service": resolve(__dirname, "./electron/service"),
|
||||
};
|
||||
|
||||
function isMainProcessExternal(id: string): boolean {
|
||||
if (!id || id.startsWith('\0')) return false;
|
||||
if (id.startsWith('.') || id.startsWith('/') || /^[A-Za-z]:[\\/]/.test(id)) return false;
|
||||
|
||||
// Project-specific aliases that should be bundled (not external)
|
||||
const internalAliases = [
|
||||
'@lib/', '@electron/', '@src/', '@locales/', '@service/', '@utils/',
|
||||
'@assets/', '@api/', '@constant/', '@components/', '@hooks/', '@stores/', '@shared/'
|
||||
'@src/', '@electron/', '@runtime/', '@service/',
|
||||
];
|
||||
|
||||
// Check if the ID starts with any internal alias
|
||||
@@ -31,11 +35,9 @@ function isMainProcessExternal(id: string): boolean {
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode, command }) => {
|
||||
export default defineConfig(({ mode }) => {
|
||||
// Determine if we're in development mode
|
||||
const isDev = mode === 'development';
|
||||
const uiFramework = process.env.VITE_UI_FRAMEWORK ?? 'react';
|
||||
const isVueUI = uiFramework === 'vue';
|
||||
|
||||
// Development server URL - in dev mode, this will be the Vite dev server URL
|
||||
// In production, this should be undefined
|
||||
@@ -51,11 +53,7 @@ export default defineConfig(({ mode, command }) => {
|
||||
base: './',
|
||||
|
||||
plugins: [
|
||||
vue(),
|
||||
...(isVueUI ? [autoImport({
|
||||
imports: ['vue', 'vue-router', 'pinia', 'vue-i18n', '@vueuse/core'],
|
||||
dts: 'src/auto-imports.d.ts'
|
||||
})] : [react()]),
|
||||
react(),
|
||||
tailwindcss(),
|
||||
electron([
|
||||
{
|
||||
@@ -71,14 +69,19 @@ export default defineConfig(({ mode, command }) => {
|
||||
MAIN_WINDOW_VITE_DEV_SERVER_URL: JSON.stringify(devServerUrl),
|
||||
'process.env.VITE_SERVICE_URL': JSON.stringify(process.env.VITE_SERVICE_URL || 'http://8.138.234.141/ingress'),
|
||||
},
|
||||
resolve: {
|
||||
alias: projectAliases,
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist-electron/main',
|
||||
rollupOptions: {
|
||||
external: isMainProcessExternal,
|
||||
},
|
||||
watch: {
|
||||
exclude: ['**/electron/scripts/**', '**/scripts.meta.json'],
|
||||
},
|
||||
watch: isDev
|
||||
? {
|
||||
exclude: ['**/electron/scripts/**', '**/scripts.meta.json'],
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -97,17 +100,14 @@ export default defineConfig(({ mode, command }) => {
|
||||
entryFileNames: 'preload.js',
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
exclude: ['**/electron/scripts/**', '**/scripts.meta.json'],
|
||||
},
|
||||
watch: isDev
|
||||
? {
|
||||
exclude: ['**/electron/scripts/**', '**/scripts.meta.json'],
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@lib": resolve(__dirname, "./src/lib"),
|
||||
"@electron": resolve(__dirname, "./electron"),
|
||||
"@src": resolve(__dirname, "./src"),
|
||||
"@locales": resolve(__dirname, "./src/i18n/locales"),
|
||||
},
|
||||
alias: projectAliases,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -120,22 +120,7 @@ export default defineConfig(({ mode, command }) => {
|
||||
},
|
||||
|
||||
resolve: {
|
||||
alias: {
|
||||
"@src": resolve(__dirname, "./src"),
|
||||
"@src-react": resolve(__dirname, "./src-react"),
|
||||
"@api": resolve(__dirname, "./src/api"),
|
||||
"@assets": resolve(__dirname, "./src/assets"),
|
||||
"@lib": resolve(__dirname, "./src/lib"),
|
||||
"@constant": resolve(__dirname, "./src/constant"),
|
||||
"@components": resolve(__dirname, "./src/components"),
|
||||
"@hooks": resolve(__dirname, "./src/hooks"),
|
||||
"@stores": resolve(__dirname, "./src/stores"),
|
||||
"@utils": resolve(__dirname, "./src/utils"),
|
||||
"@shared": resolve(__dirname, "./src/shared"),
|
||||
"@locales": resolve(__dirname, "./src/i18n/locales"),
|
||||
"@electron": resolve(__dirname, "./electron"),
|
||||
"@service": resolve(__dirname, "./electron/service"),
|
||||
},
|
||||
alias: projectAliases,
|
||||
},
|
||||
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user