mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 02:51:46 +00:00
fix: apply fix from eslint
This commit is contained in:
@ -28,7 +28,10 @@ export const backend = createBackend<BackendType, APIServerConfig>({
|
||||
this.end();
|
||||
},
|
||||
onConfigChange(config) {
|
||||
if (this.oldConfig?.hostname === config.hostname && this.oldConfig?.port === config.port) {
|
||||
if (
|
||||
this.oldConfig?.hostname === config.hostname &&
|
||||
this.oldConfig?.port === config.port
|
||||
) {
|
||||
this.oldConfig = config;
|
||||
return;
|
||||
}
|
||||
@ -55,7 +58,8 @@ export const backend = createBackend<BackendType, APIServerConfig>({
|
||||
this.app.use('/api/*', async (ctx, next) => {
|
||||
const result = await JWTPayloadSchema.spa(await ctx.get('jwtPayload'));
|
||||
|
||||
const isAuthorized = result.success && config.authorizedClients.includes(result.data.id);
|
||||
const isAuthorized =
|
||||
result.success && config.authorizedClients.includes(result.data.id);
|
||||
if (!isAuthorized) {
|
||||
ctx.status(401);
|
||||
return ctx.body('Unauthorized');
|
||||
|
||||
@ -2,9 +2,10 @@ import { createRoute, z } from '@hono/zod-openapi';
|
||||
import { dialog } from 'electron';
|
||||
import { sign } from 'hono/jwt';
|
||||
|
||||
import { t } from '@/i18n';
|
||||
import { getConnInfo } from '@hono/node-server/conninfo';
|
||||
|
||||
import { t } from '@/i18n';
|
||||
|
||||
import { APIServerConfig } from '../../config';
|
||||
import { JWTPayload } from '../scheme';
|
||||
|
||||
@ -20,7 +21,7 @@ const routes = {
|
||||
request: {
|
||||
params: z.object({
|
||||
id: z.string(),
|
||||
})
|
||||
}),
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
@ -40,7 +41,10 @@ const routes = {
|
||||
}),
|
||||
};
|
||||
|
||||
export const register = (app: HonoApp, { getConfig, setConfig }: BackendContext<APIServerConfig>) => {
|
||||
export const register = (
|
||||
app: HonoApp,
|
||||
{ getConfig, setConfig }: BackendContext<APIServerConfig>,
|
||||
) => {
|
||||
app.openapi(routes.request, async (ctx) => {
|
||||
const config = await getConfig();
|
||||
const { id } = ctx.req.param();
|
||||
@ -54,7 +58,10 @@ export const register = (app: HonoApp, { getConfig, setConfig }: BackendContext<
|
||||
origin: getConnInfo(ctx).remote.address,
|
||||
id,
|
||||
}),
|
||||
buttons: [t('plugins.api-server.dialog.request.buttons.allow'), t('plugins.api-server.dialog.request.deny')],
|
||||
buttons: [
|
||||
t('plugins.api-server.dialog.request.buttons.allow'),
|
||||
t('plugins.api-server.dialog.request.deny'),
|
||||
],
|
||||
defaultId: 1,
|
||||
cancelId: 1,
|
||||
});
|
||||
@ -68,10 +75,7 @@ export const register = (app: HonoApp, { getConfig, setConfig }: BackendContext<
|
||||
}
|
||||
|
||||
setConfig({
|
||||
authorizedClients: [
|
||||
...config.authorizedClients,
|
||||
id,
|
||||
],
|
||||
authorizedClients: [...config.authorizedClients, id],
|
||||
});
|
||||
|
||||
const token = await sign(
|
||||
|
||||
@ -84,7 +84,8 @@ const routes = {
|
||||
method: 'post',
|
||||
path: `/api/${API_VERSION}/toggle-play`,
|
||||
summary: 'Toggle play/pause',
|
||||
description: 'Change the state of the player to play if paused, or pause if playing',
|
||||
description:
|
||||
'Change the state of the player to play if paused, or pause if playing',
|
||||
request: {
|
||||
headers: AuthHeadersSchema,
|
||||
},
|
||||
@ -280,7 +281,7 @@ const routes = {
|
||||
schema: z.object({
|
||||
state: z.boolean(),
|
||||
}),
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -299,7 +300,7 @@ const routes = {
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: z.object({}),
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
204: {
|
||||
@ -321,7 +322,7 @@ const routes = {
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: SongInfoSchema,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
204: {
|
||||
@ -331,7 +332,11 @@ const routes = {
|
||||
}),
|
||||
};
|
||||
|
||||
export const register = (app: HonoApp, { window }: BackendContext<APIServerConfig>, songInfoGetter: () => SongInfo | undefined) => {
|
||||
export const register = (
|
||||
app: HonoApp,
|
||||
{ window }: BackendContext<APIServerConfig>,
|
||||
songInfoGetter: () => SongInfo | undefined,
|
||||
) => {
|
||||
const controller = getSongControls(window);
|
||||
|
||||
app.openapi(routes.previous, (ctx) => {
|
||||
@ -426,9 +431,12 @@ export const register = (app: HonoApp, { window }: BackendContext<APIServerConfi
|
||||
|
||||
app.openapi(routes.getFullscreenState, async (ctx) => {
|
||||
const stateResponsePromise = new Promise<boolean>((resolve) => {
|
||||
ipcMain.once('ytmd:set-fullscreen', (_, isFullscreen: boolean | undefined) => {
|
||||
return resolve(!!isFullscreen);
|
||||
});
|
||||
ipcMain.once(
|
||||
'ytmd:set-fullscreen',
|
||||
(_, isFullscreen: boolean | undefined) => {
|
||||
return resolve(!!isFullscreen);
|
||||
},
|
||||
);
|
||||
|
||||
controller.requestFullscreenInformation();
|
||||
});
|
||||
|
||||
@ -5,4 +5,3 @@ export * from './go-forward';
|
||||
export * from './switch-repeat';
|
||||
export * from './set-volume';
|
||||
export * from './set-fullscreen';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user