mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-20 19:04:23 +02:00
Update utils
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
export const constrainSidebarWidth = (num: number) => {
|
||||||
|
if (num < 165) {
|
||||||
|
return 165;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num > 400) {
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
return num;
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// export const encryptString = (str: string) => {
|
||||||
|
// return cryptr;
|
||||||
|
|
||||||
|
// // const iv = crypto.randomBytes(16);
|
||||||
|
// // const key = crypto.randomBytes(32);
|
||||||
|
// // const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
|
||||||
|
|
||||||
|
// // let data = cipher.update(str, 'utf-8', 'hex');
|
||||||
|
// // data += cipher.final('hex');
|
||||||
|
|
||||||
|
// // return { data, iv, key };
|
||||||
|
// };
|
||||||
|
|
||||||
|
// export const decryptString = ({
|
||||||
|
// data,
|
||||||
|
// key,
|
||||||
|
// iv,
|
||||||
|
// }: {
|
||||||
|
// data: string;
|
||||||
|
// iv: string;
|
||||||
|
// key: string;
|
||||||
|
// }) => {
|
||||||
|
// const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
|
||||||
|
// let decryptedData = decipher.update(data, 'hex', 'utf-8');
|
||||||
|
// decryptedData += decipher.final('utf8');
|
||||||
|
|
||||||
|
// return decryptedData;
|
||||||
|
// };
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
const getJellyfinImageUrl = (baseUrl: string, item: any, size?: number) => {
|
|
||||||
return (
|
|
||||||
`${baseUrl}/Items` +
|
|
||||||
`/${item.Id}` +
|
|
||||||
`/Images/Primary${
|
|
||||||
size ? `?width=${size}&height=${size}` : '?height=350'
|
|
||||||
}&quality=90`
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
export * from './randomString';
|
export * from './random-string';
|
||||||
export * from './normalizeServerUrl';
|
export * from './normalize-server-url';
|
||||||
export * from './getJellyfinStreamUrl';
|
export * from './jellyfin';
|
||||||
export * from './getSubsonicStreamUrl';
|
export * from './subsonic';
|
||||||
export * from './getServerFolderAuth';
|
export * from './server-folder-auth';
|
||||||
export * from './setLocalStorageSettings';
|
export * from './set-local-storage-setttings';
|
||||||
|
export * from './constrain-sidebar-width';
|
||||||
|
export * from './title-case';
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
import { Song } from '../api/types';
|
import { Song } from '@/renderer/api/types';
|
||||||
|
|
||||||
|
export const getJellyfinImageUrl = (
|
||||||
|
baseUrl: string,
|
||||||
|
item: any,
|
||||||
|
size?: number
|
||||||
|
) => {
|
||||||
|
return (
|
||||||
|
`${baseUrl}/Items` +
|
||||||
|
`/${item.Id}` +
|
||||||
|
`/Images/Primary${
|
||||||
|
size ? `?width=${size}&height=${size}` : '?height=350'
|
||||||
|
}&quality=90`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const getJellyfinStreamUrl = (
|
export const getJellyfinStreamUrl = (
|
||||||
auth: any,
|
auth: any,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Song } from '../api/types';
|
import { Song } from '@/renderer/api/types';
|
||||||
|
|
||||||
export const getSubsonicStreamUrl = (
|
export const getSubsonicStreamUrl = (
|
||||||
auth: any,
|
auth: any,
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export const titleCase = (str: string) => {
|
||||||
|
return str.replace(/\w\S*/g, (txt) => {
|
||||||
|
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
|
||||||
|
});
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user