feat: updates

This commit is contained in:
qier222 2023-01-24 16:29:33 +08:00
parent c6c59b2cd9
commit 7ce516877e
No known key found for this signature in database
63 changed files with 6591 additions and 1107 deletions

View file

@ -1,7 +1,7 @@
/// <reference types="vitest" />
import react from '@vitejs/plugin-react-swc'
import dotenv from 'dotenv'
import path, { join } from 'path'
import { join } from 'path'
import { defineConfig } from 'vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { visualizer } from 'rollup-plugin-visualizer'
@ -9,7 +9,7 @@ import { VitePWA } from 'vite-plugin-pwa'
import filenamesToType from './vitePluginFilenamesToType'
import { appName } from './utils/const'
dotenv.config({ path: path.resolve(process.cwd(), '../../.env') })
dotenv.config({ path: join(__dirname, '../../.env') })
const IS_ELECTRON = process.env.IS_ELECTRON
/**
@ -37,33 +37,33 @@ export default defineConfig({
/**
* @see https://vite-plugin-pwa.netlify.app/guide/generate.html
*/
// VitePWA({
// registerType: 'autoUpdate',
// manifest: {
// name: appName,
// short_name: appName,
// description: 'Description of your app',
// theme_color: '#000',
// icons: [
// {
// src: 'pwa-192x192.png',
// sizes: '192x192',
// type: 'image/png',
// },
// {
// src: 'pwa-512x512.png',
// sizes: '512x512',
// type: 'image/png',
// },
// {
// src: 'pwa-512x512.png',
// sizes: '512x512',
// type: 'image/png',
// purpose: 'any maskable',
// },
// ],
// },
// }),
VitePWA({
registerType: 'autoUpdate',
manifest: {
name: appName,
short_name: appName,
description: 'Description of your app',
theme_color: '#000',
icons: [
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
],
},
}),
/**
* @see https://github.com/vbenjs/vite-plugin-svg-icons
@ -90,27 +90,36 @@ export default defineConfig({
},
},
server: {
port: Number(process.env['ELECTRON_WEB_SERVER_PORT'] || 42710),
port: Number(process.env.ELECTRON_WEB_SERVER_PORT || 42710),
strictPort: IS_ELECTRON ? true : false,
proxy: {
'/netease/': {
// target: `http://192.168.50.111:${
target: `http://127.0.0.1:${process.env.ELECTRON_DEV_NETEASE_API_PORT || 30001}`,
changeOrigin: true,
rewrite: path => (IS_ELECTRON ? path : path.replace(/^\/netease/, '')),
},
[`/${appName.toLowerCase()}/video-cover`]: {
target: `http://168.138.40.199:51324`,
changeOrigin: true,
},
[`/${appName.toLowerCase()}/`]: {
'/r3play/': {
target: `http://127.0.0.1:${process.env.ELECTRON_DEV_NETEASE_API_PORT || 30001}`,
changeOrigin: true,
},
// [`/${appName.toLowerCase()}/apple-music/`]: {
// target: `http://168.138.174.244:35530/`,
// changeOrigin: true,
// rewrite: path => path.replace(/^\/r3play/, ''),
// },
// [`/${appName.toLowerCase()}/`]: {
// target: `http://127.0.0.1:${process.env.ELECTRON_DEV_NETEASE_API_PORT || 30001}`,
// changeOrigin: true,
// },
// '/': {
// target: `http://127.0.0.1:${process.env.ELECTRON_DEV_NETEASE_API_PORT || 30001}`,
// changeOrigin: true,
// // rewrite: path => (IS_ELECTRON ? path : path.replace(/^\/netease/, '')),
// },
},
},
preview: {
port: Number(process.env['ELECTRON_WEB_SERVER_PORT'] || 42710),
port: Number(process.env.ELECTRON_WEB_SERVER_PORT || 42710),
},
test: {
environment: 'jsdom',