mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
feat: updates
This commit is contained in:
parent
ffcc60b793
commit
dd5361b8c4
106 changed files with 11989 additions and 4143 deletions
|
|
@ -117,6 +117,7 @@ class Cache {
|
|||
case APIs.UserAccount:
|
||||
case APIs.Personalized:
|
||||
case APIs.RecommendResource:
|
||||
case APIs.UserArtists:
|
||||
case APIs.Likelist: {
|
||||
const data = db.find(Tables.AccountData, api)
|
||||
if (data?.json) return JSON.parse(data.json)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Main {
|
|||
defaults: {
|
||||
window: {
|
||||
width: 1440,
|
||||
height: 960,
|
||||
height: 1024,
|
||||
},
|
||||
settings: initialState.settings,
|
||||
},
|
||||
|
|
@ -105,11 +105,14 @@ class Main {
|
|||
},
|
||||
width: this.store.get('window.width'),
|
||||
height: this.store.get('window.height'),
|
||||
minWidth: 1080,
|
||||
minHeight: 720,
|
||||
vibrancy: 'fullscreen-ui',
|
||||
titleBarStyle: 'hiddenInset',
|
||||
frame: !(isWindows || isLinux), // TODO: 适用于linux下独立的启用开关
|
||||
minWidth: 1240,
|
||||
minHeight: 848,
|
||||
// vibrancy: 'fullscreen-ui',
|
||||
titleBarStyle: 'customButtonsOnHover',
|
||||
trafficLightPosition: { x: 24, y: 24 },
|
||||
// frame: !(isWindows || isLinux), // TODO: 适用于linux下独立的启用开关
|
||||
frame: false,
|
||||
transparent: true,
|
||||
}
|
||||
if (this.store.get('window')) {
|
||||
options.x = this.store.get('window.x')
|
||||
|
|
@ -132,24 +135,21 @@ class Main {
|
|||
|
||||
disableCORS() {
|
||||
if (!this.win) return
|
||||
const upsertKeyValue = (
|
||||
object: Record<string, string | string[]>,
|
||||
keyToChange: string,
|
||||
value: string[]
|
||||
) => {
|
||||
if (!object) return
|
||||
for (const key of Object.keys(object)) {
|
||||
if (key.toLowerCase() === keyToChange.toLowerCase()) {
|
||||
object[key] = value
|
||||
}
|
||||
|
||||
const addCORSHeaders = (headers: Record<string, string | string[]>) => {
|
||||
if (
|
||||
headers['Access-Control-Allow-Origin']?.[0] !== '*' &&
|
||||
headers['access-control-allow-origin']?.[0] !== '*'
|
||||
) {
|
||||
headers['Access-Control-Allow-Origin'] = ['*']
|
||||
}
|
||||
object[keyToChange] = value
|
||||
return headers
|
||||
}
|
||||
|
||||
this.win.webContents.session.webRequest.onBeforeSendHeaders(
|
||||
(details, callback) => {
|
||||
const { requestHeaders, url } = details
|
||||
upsertKeyValue(requestHeaders, 'access-control-allow-origin', ['*'])
|
||||
addCORSHeaders(requestHeaders)
|
||||
|
||||
// 不加这几个 header 的话,使用 axios 加载 YouTube 音频会很慢
|
||||
if (url.includes('googlevideo.com')) {
|
||||
|
|
@ -164,14 +164,15 @@ class Main {
|
|||
|
||||
this.win.webContents.session.webRequest.onHeadersReceived(
|
||||
(details, callback) => {
|
||||
const { responseHeaders } = details
|
||||
if (responseHeaders) {
|
||||
upsertKeyValue(responseHeaders, 'access-control-allow-origin', ['*'])
|
||||
upsertKeyValue(responseHeaders, 'access-control-allow-headers', ['*'])
|
||||
const { responseHeaders, url } = details
|
||||
if (url.includes('sentry.io')) {
|
||||
callback({ responseHeaders })
|
||||
return
|
||||
}
|
||||
callback({
|
||||
responseHeaders,
|
||||
})
|
||||
if (responseHeaders) {
|
||||
addCORSHeaders(responseHeaders)
|
||||
}
|
||||
callback({ responseHeaders })
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ function initWindowIpcMain(win: BrowserWindow | null) {
|
|||
on(IpcChannels.Close, () => {
|
||||
app.exit()
|
||||
})
|
||||
|
||||
on(IpcChannels.ResetWindowSize, () => {
|
||||
if (!win) return
|
||||
win?.setSize(1440, 1024, true)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -188,6 +188,9 @@ class Server {
|
|||
const source =
|
||||
retrievedSong.source === 'ytdl' ? 'youtube' : retrievedSong.source
|
||||
if (retrievedSong.url) {
|
||||
log.debug(
|
||||
`[server] UMN match: ${matchedAudio.song?.name} (https://youtube.com/v/${matchedAudio.song?.id})`
|
||||
)
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue