Revert vite build

This commit is contained in:
lyswhut
2023-08-17 17:49:47 +08:00
parent 99eb2856f7
commit 53bc50d05c
63 changed files with 11408 additions and 2565 deletions

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Before

Width:  |  Height:  |  Size: 353 KiB

After

Width:  |  Height:  |  Size: 353 KiB

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Before

Width:  |  Height:  |  Size: 997 KiB

After

Width:  |  Height:  |  Size: 997 KiB

+2 -2
View File
@@ -21,8 +21,8 @@ export const initGlobalData = () => {
global.staticPath =
process.env.NODE_ENV !== 'production'
? __STATIC_PATH__
: path.join(encodePath(__dirname), '../static')
? webpackStaticPath
: path.join(encodePath(__dirname), 'static')
}
export const initSingleInstanceHandle = () => {
+1 -1
View File
@@ -26,5 +26,5 @@ app.on('ready', () => {
})
// Require `main` process to boot app
import('./index')
require('./index')
+4 -5
View File
@@ -27,16 +27,15 @@ const winEvent = () => {
export const createWindow = async(userApi: LX.UserApi.UserApiInfo) => {
await closeWindow()
dir ??= process.env.NODE_ENV !== 'production' ? path.join(__USER_API_PATH__, 'renderer') : encodePath(__dirname)
dir ??= process.env.NODE_ENV !== 'production' ? webpackUserApiPath : path.join(encodePath(__dirname), 'userApi')
if (!html) {
html = await fs.promises.readFile(path.join(dir, 'user-api.html'), 'utf8')
html = await fs.promises.readFile(path.join(dir, 'renderer/user-api.html'), 'utf8')
}
const preloadUrl = process.env.NODE_ENV !== 'production'
? `${path.join(encodePath(__dirname), '../dist/user-api-preload.js')}`
: `${path.join(encodePath(__dirname), '../preload/user-api-preload.js')}`
// console.log(preloadUrl, html)
: `${path.join(encodePath(__dirname), 'user-api-preload.js')}`
// console.log(preloadUrl)
/**
* Initial window options
+1 -1
View File
@@ -139,7 +139,7 @@ export const createWindow = () => {
},
})
const winURL = process.env.NODE_ENV !== 'production' ? 'http://localhost:9081' : `file://${path.join(encodePath(__dirname), '../renderer-lyric/index.html')}`
const winURL = process.env.NODE_ENV !== 'production' ? 'http://localhost:9081/lyric.html' : `file://${path.join(encodePath(__dirname), 'lyric.html')}`
void browserWindow.loadURL(winURL + `?dark=${shouldUseDarkColors}&theme=${encodeURIComponent(JSON.stringify(theme))}`)
winEvent()
-1
View File
@@ -87,7 +87,6 @@ export const watchConfigKeys = [
export const buildLyricConfig = (appSetting: Partial<LX.AppSetting>): Partial<LX.DesktopLyric.Config> => {
const setting: Partial<LX.DesktopLyric.Config> = {}
for (const key of watchConfigKeys) {
// @ts-expect-error
if (key in appSetting) setting[key] = appSetting[key]
}
return setting
+1 -1
View File
@@ -99,7 +99,7 @@ export const createWindow = () => {
}
browserWindow = new BrowserWindow(options)
const winURL = process.env.NODE_ENV !== 'production' ? 'http://localhost:9080' : `file://${path.join(encodePath(__dirname), '../renderer/index.html')}`
const winURL = process.env.NODE_ENV !== 'production' ? 'http://localhost:9080' : `file://${path.join(encodePath(__dirname), 'index.html')}`
void browserWindow.loadURL(winURL + `?dt=${!!global.envParams.cmdParams.dt}&dark=${shouldUseDarkColors}&theme=${encodeURIComponent(JSON.stringify(theme))}`)
winEvent()
@@ -1,5 +1,5 @@
import { createInflate, constants as zlibConstants } from 'node:zlib'
import path from 'node:path'
// import path from 'path'
import { mainHandle } from '@common/mainIpc'
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
@@ -40,7 +40,7 @@ const handleDecode = async(lrc: string, tlrc: string, rlrc: string) => {
// const nativeBindingPath = path.join(__dirname, '../build/Release/qrc_decode.node')
// const nativeBindingPath = process.env.NODE_ENV !== 'production' ? path.join(__dirname, '../build/Release/qrc_decode.node')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const addon = require(path.join(__QRC_DECODE_NODE_PATH__, 'qrc_decode.node'))
const addon = require('qrc_decode.node')
// console.log(addon)
qrc_decode = addon.qrc_decode
}
-1
View File
@@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true,
"typeRoots": [
"./types"
],
+2 -3
View File
@@ -9,7 +9,6 @@
// // }
// // }
declare const __STATIC_PATH__: string
declare const __USER_API_PATH__: string
declare const __QRC_DECODE_NODE_PATH__: string
declare const webpackStaticPath: string
declare const webpackUserApiPath: string
+1 -1
View File
@@ -18,7 +18,7 @@ const initTables = (db: Database.Database) => {
// 打开、初始化数据库
export const init = (lxDataPath: string): boolean | null => {
const databasePath = path.join(lxDataPath, 'lx.data.db')
const nativeBinding = path.join(__dirname, '../../node_modules/better-sqlite3/build/Release/better_sqlite3.node')
const nativeBinding = path.join(__dirname, '../node_modules/better-sqlite3/build/Release/better_sqlite3.node')
let dbFileExists = true
try {
+6 -6
View File
@@ -1,15 +1,15 @@
import { Worker } from 'node:worker_threads'
import * as Comlink from 'comlink'
import nodeEndpoint from 'comlink/dist/esm/node-adapter'
import path from 'node:path'
// import dbService from '../dbService/index'
export declare type DBSeriveTypes = Comlink.Remote<LX.WorkerDBSeriveListTypes>
export type DBSeriveTypes = Comlink.Remote<LX.WorkerDBSeriveListTypes>
export const createDBServiceWorker = () => {
// console.log(new URL('../dbService', import.meta.url))
// console.log(__dirname)
const worker: Worker = new Worker(path.join(__dirname, './dbService.worker'))
const worker: Worker = new Worker(new URL(
/* webpackChunkName: 'dbService.worker' */
'../dbService',
import.meta.url,
))
return Comlink.wrap<LX.WorkerDBSeriveListTypes>(nodeEndpoint(worker))
}
+14 -11
View File
@@ -1,22 +1,25 @@
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
const requireComponent = import.meta.glob(['./**/*.vue', '!./**/components/**/*.vue'], { eager: true })
const vueFileRxp = /\.vue$/
const vueIndexFileRxp = /\/index\.vue$/
const requireComponent = require.context('./', true, /\.vue$/)
const vueFileRxp = /\.vue$/
export default app => {
Object.entries(requireComponent).forEach(([path, module]) => {
path = path.replace(/^\.\//, '')
let fileName = vueIndexFileRxp.test(path)
? path.replace(vueIndexFileRxp, '')
: path.replace(vueFileRxp, '')
requireComponent.keys().forEach(fileName => {
const filePath = fileName.replace(/^\.\//, '')
let componentName = upperFirst(camelCase(fileName))
if (!filePath.split('/').every((path, index, arr) => {
const char = path.charAt(0)
return vueFileRxp.test(path) || char.toUpperCase() !== char || arr[index + 1] == 'index.vue'
})) return
// console.log(componentName)
const componentConfig = requireComponent(fileName)
app.component(componentName, module.default)
let componentName = upperFirst(camelCase(filePath.replace(/\.\w+$/, '')))
if (componentName.endsWith('Index')) componentName = componentName.replace(/Index$/, '')
app.component(componentName, componentConfig.default || componentConfig)
})
}
-1
View File
@@ -27,6 +27,5 @@
}
if (/theme=(.+)(#|$)/.test(window.location.search)) applyThemeColor(RegExp.$1)
</script>
<script type="module" src="/main.ts"></script>
</body>
</html>
+14 -11
View File
@@ -1,22 +1,25 @@
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
const requireComponent = import.meta.glob(['./**/*.vue', '!./**/components/**/*.vue'], { eager: true })
const vueFileRxp = /\.vue$/
const vueIndexFileRxp = /\/index\.vue$/
const requireComponent = require.context('./', true, /\.vue$/)
const vueFileRxp = /\.vue$/
export default app => {
Object.entries(requireComponent).forEach(([path, module]) => {
path = path.replace(/^\.\//, '')
let fileName = vueIndexFileRxp.test(path)
? path.replace(vueIndexFileRxp, '')
: path.replace(vueFileRxp, '')
requireComponent.keys().forEach(fileName => {
const filePath = fileName.replace(/^\.\//, '')
let componentName = upperFirst(camelCase(fileName))
if (!filePath.split('/').every((path, index, arr) => {
const char = path.charAt(0)
return vueFileRxp.test(path) || char.toUpperCase() !== char || arr[index + 1] == 'index.vue'
})) return
// console.log(componentName)
const componentConfig = requireComponent(fileName)
app.component(componentName, module.default)
let componentName = upperFirst(camelCase(filePath.replace(/\.\w+$/, '')))
if (componentName.endsWith('Index')) componentName = componentName.replace(/Index$/, '')
app.component(componentName, componentConfig.default || componentConfig)
})
}
@@ -3,13 +3,12 @@ import { getDuration, getPlaybackRate, getCurrentTime } from '@renderer/plugins/
import { isPlay, musicInfo, playMusicInfo } from '@renderer/store/player/state'
import { playProgress } from '@renderer/store/player/playProgress'
import { pause, play, playNext, playPrev, stop } from '@renderer/core/player'
import silenceAudio from '@renderer/assets/medias/Silence02s.mp3'
export default () => {
// 创建一个空白音频以保持对 Media Session 的注册
const emptyAudio = new Audio()
emptyAudio.autoplay = false
emptyAudio.src = silenceAudio
emptyAudio.src = require('@renderer/assets/medias/Silence02s.mp3')
emptyAudio.controls = false
emptyAudio.preload = 'auto'
emptyAudio.onplaying = () => {
@@ -16,41 +16,40 @@ import {
import { appSetting } from '@renderer/store/setting'
const cache = new Map<string, AudioBuffer>()
const loadBuffer = async(name: string) => {
const path = (await import(`../../../assets/medias/filters/${name.replace('.wav', '')}.wav`)).default as string
return new Promise<AudioBuffer>((resolve, reject) => {
if (cache.has(path)) {
resolve(cache.get(path) as AudioBuffer)
return
}
// Load buffer asynchronously
let request = new XMLHttpRequest()
request.open('GET', path, true)
request.responseType = 'arraybuffer'
const loadBuffer = async(name: string) => new Promise<AudioBuffer>((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('@renderer/assets/medias/filters/' + name) as string
if (cache.has(path)) {
resolve(cache.get(path) as AudioBuffer)
return
}
// Load buffer asynchronously
let request = new XMLHttpRequest()
request.open('GET', path, true)
request.responseType = 'arraybuffer'
request.onload = function() {
// Asynchronously decode the audio file data in request.response
void getAudioContext().decodeAudioData(request.response, (buffer) => {
if (!buffer) {
reject(new Error('error decoding file data: ' + path))
return
}
cache.set(path, buffer)
resolve(buffer)
},
function(error) {
reject(error)
console.error('decodeAudioData error', error)
})
}
request.onload = function() {
// Asynchronously decode the audio file data in request.response
void getAudioContext().decodeAudioData(request.response, (buffer) => {
if (!buffer) {
reject(new Error('error decoding file data: ' + path))
return
}
cache.set(path, buffer)
resolve(buffer)
},
function(error) {
reject(error)
console.error('decodeAudioData error', error)
})
}
request.onerror = function() {
reject(new Error('XHR error'))
}
request.onerror = function() {
reject(new Error('XHR error'))
}
request.send()
})
}
request.send()
})
export default () => {
// console.log(appSetting['player.soundEffect.panner.enable'])
-1
View File
@@ -31,6 +31,5 @@
}
if (/theme=(.+)(#|$)/.test(window.location.search)) applyThemeColor(RegExp.$1)
</script>
<script type="module" src="/main.ts"></script>
</body>
</html>
-1
View File
@@ -1,5 +1,4 @@
import '@common/error'
import 'virtual:svg-icons-register'
import { createApp } from 'vue'
import './core/globalData'
+3 -3
View File
@@ -1,8 +1,8 @@
import SvgIcon from './SvgIcon.vue'
// const req = require.context('@renderer/assets/svgs', false, /\.svg$/)
// const requireAll = requireContext => requireContext.keys().map(requireContext)
// requireAll(req)
const req = require.context('@renderer/assets/svgs', false, /\.svg$/)
const requireAll = requireContext => requireContext.keys().map(requireContext)
requireAll(req)
export default app => {
app.component('svg-icon', SvgIcon)
+5 -3
View File
@@ -1,5 +1,3 @@
import PhaseVocoder from './pitch-shifter/phase-vocoder.js?worker&url'
let audio: HTMLAudioElement | null = null
let audioContext: AudioContext
let mediaSource: MediaElementAudioSourceNode
@@ -278,7 +276,11 @@ const loadPitchShifterNode = () => {
pitchShifterNodeLoadStatus = 'loading'
initAdvancedAudioFeatures()
// source -> analyser -> biquadFilter -> audioWorklet(pitch shifter) -> [(convolver & convolverSource)->convolverDynamicsCompressor] -> panner -> gain
void audioContext.audioWorklet.addModule(PhaseVocoder).then(() => {
void audioContext.audioWorklet.addModule(new URL(
/* webpackChunkName: 'pitch_shifter.audioWorklet' */
'./pitch-shifter/phase-vocoder.js',
import.meta.url,
)).then(() => {
console.log('pitch shifter audio worklet loaded')
// https://github.com/olvb/phaze/issues/26#issuecomment-1574629971
pitchShifterNode = new AudioWorkletNode(audioContext, 'phase-vocoder-processor', { outputChannelCount: [2] })
+7 -15
View File
@@ -2,14 +2,6 @@
// import Vue from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import SearchView from './views/Search/index.vue'
import SongListView from './views/songList/List/index.vue'
import SongListDetailView from './views/songList/Detail/index.vue'
import LeaderboardView from './views/Leaderboard/index.vue'
import ListView from './views/List/index.vue'
import DownloadView from './views/Download/index.vue'
import SettingView from './views/Setting/index.vue'
const router = createRouter({
history: createWebHashHistory(),
@@ -17,7 +9,7 @@ const router = createRouter({
{
path: '/search',
name: 'Search',
component: SearchView,
component: require('./views/Search/index.vue').default,
meta: {
name: 'Search',
},
@@ -25,7 +17,7 @@ const router = createRouter({
{
path: '/songList/list',
name: 'SongList',
component: SongListView,
component: require('./views/songList/List/index.vue').default,
meta: {
name: 'SongList',
},
@@ -33,7 +25,7 @@ const router = createRouter({
{
path: '/songList/detail',
name: 'SongListDetail',
component: SongListDetailView,
component: require('./views/songList/Detail/index.vue').default,
meta: {
name: 'SongList',
},
@@ -41,7 +33,7 @@ const router = createRouter({
{
path: '/leaderboard',
name: 'Leaderboard',
component: LeaderboardView,
component: require('./views/Leaderboard/index.vue').default,
meta: {
name: 'Leaderboard',
},
@@ -49,7 +41,7 @@ const router = createRouter({
{
path: '/list',
name: 'List',
component: ListView,
component: require('./views/List/index.vue').default,
meta: {
name: 'List',
},
@@ -57,7 +49,7 @@ const router = createRouter({
{
path: '/download',
name: 'Download',
component: DownloadView,
component: require('./views/Download/index.vue').default,
meta: {
name: 'Download',
},
@@ -65,7 +57,7 @@ const router = createRouter({
{
path: '/setting',
name: 'Setting',
component: SettingView,
component: require('./views/Setting/index.vue').default,
meta: {
name: 'Setting',
},
+3 -3
View File
@@ -1,10 +1,10 @@
import { ref, reactive, shallowRef, markRaw, computed, watch } from '@common/utils/vueTools'
import { windowSizeList as configWindowSizeList } from '@common/config'
import { appSetting } from './setting'
import { version } from '../../../package.json'
import pkg from '../../../package.json'
import { type ProgressInfo } from 'electron-updater'
import music from '@renderer/utils/musicSdk'
process.versions.app = version
process.versions.app = pkg.version
export const apiSource = ref<string | null>(null)
export const proxy: {
@@ -115,7 +115,7 @@ export const versionInfo = window.lxData.versionInfo = reactive<{
status: LX.UpdateStatus
downloadProgress: ProgressInfo | null
}>({
version,
version: pkg.version,
newVersion: null,
showModal: false,
reCheck: false,
-2
View File
@@ -1,2 +0,0 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference types="vite/client" />
@@ -33,7 +33,7 @@ dd
.gap-top
base-checkbox(id="setting_to_tray" :model-value="appSetting['tray.enable']" :label="$t('setting__basic_to_tray')" @update:model-value="updateSetting({'tray.enable': $event})")
.p.gap-top
base-btn.btn(min @click="isShowPlayTimeoutModal = true") {{ $t('setting__play_timeout')}} {{ timeLabel ? ` (${timeLabel})` : '' }}
base-btn.btn(min @click="isShowPlayTimeoutModal = true") {{ $t('setting__play_timeout')}} {{ timeLabel ? ` (${timeLabel})` : '' }}
dd
h3#basic_source {{ $t('setting__basic_source') }}
+10 -11
View File
@@ -3,9 +3,11 @@ import * as Comlink from 'comlink'
export type MainTypes = Comlink.Remote<LX.WorkerMainTypes>
export const createMainWorker = () => {
const worker: Worker = new Worker(new URL('../main', import.meta.url), {
type: 'module',
})
const worker: Worker = new Worker(new URL(
/* webpackChunkName: 'renderer.main.worker' */
'../main',
import.meta.url,
))
return Comlink.wrap<LX.WorkerMainTypes>(worker)
}
@@ -20,14 +22,11 @@ export const createMainWorker = () => {
export type DownloadTypes = Comlink.Remote<LX.WorkerDownloadTypes>
export const createDownloadWorker = () => {
const worker: Worker = new Worker(new URL('../download', import.meta.url), {
type: 'module',
})
// const worker: Worker = new Worker(new URL(
// /* webpackChunkName: 'renderer.download.worker' */
// '../download',
// import.meta.url,
// ))
const worker: Worker = new Worker(new URL(
/* webpackChunkName: 'renderer.download.worker' */
'../download',
import.meta.url,
))
return Comlink.wrap<LX.WorkerDownloadTypes>(worker)
}