mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(web): improve and refactor thumbnails (#2087)
* feat(web): improve and refactor thumbnails * only play live photos on icon hover
This commit is contained in:
parent
cae37657e9
commit
4e526dfaae
11 changed files with 321 additions and 330 deletions
|
|
@ -12,8 +12,11 @@ import {
|
|||
ServerInfoApi,
|
||||
ShareApi,
|
||||
SystemConfigApi,
|
||||
ThumbnailFormat,
|
||||
UserApi
|
||||
} from './open-api';
|
||||
import { BASE_PATH } from './open-api/base';
|
||||
import { DUMMY_BASE_URL, toPathString } from './open-api/common';
|
||||
|
||||
export class ImmichApi {
|
||||
public userApi: UserApi;
|
||||
|
|
@ -48,6 +51,21 @@ export class ImmichApi {
|
|||
this.shareApi = new ShareApi(this.config);
|
||||
}
|
||||
|
||||
private createUrl(path: string, params?: Record<string, unknown>) {
|
||||
const searchParams = new URLSearchParams();
|
||||
for (const key in params) {
|
||||
const value = params[key];
|
||||
if (value !== undefined && value !== null) {
|
||||
searchParams.set(key, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
const url = new URL(path, DUMMY_BASE_URL);
|
||||
url.search = searchParams.toString();
|
||||
|
||||
return (this.config.basePath || BASE_PATH) + toPathString(url);
|
||||
}
|
||||
|
||||
public setAccessToken(accessToken: string) {
|
||||
this.config.accessToken = accessToken;
|
||||
}
|
||||
|
|
@ -59,6 +77,16 @@ export class ImmichApi {
|
|||
public setBaseUrl(baseUrl: string) {
|
||||
this.config.basePath = baseUrl;
|
||||
}
|
||||
|
||||
public getAssetFileUrl(assetId: string, isThumb?: boolean, isWeb?: boolean, key?: string) {
|
||||
const path = `/asset/file/${assetId}`;
|
||||
return this.createUrl(path, { isThumb, isWeb, key });
|
||||
}
|
||||
|
||||
public getAssetThumbnailUrl(assetId: string, format?: ThumbnailFormat, key?: string) {
|
||||
const path = `/asset/thumbnail/${assetId}`;
|
||||
return this.createUrl(path, { format, key });
|
||||
}
|
||||
}
|
||||
|
||||
export const api = new ImmichApi({ basePath: '/api' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue