mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2024-12-04 04:01:26 +00:00
09b94982b1
A component has been added to the default layout, which displays a blurhash from a Vuex store. The Vuex store can either set or clear backdrops. To set a backdrop, you must pass a BaseItemDto[] in order to retrieve the relevant images.
40 lines
973 B
TypeScript
40 lines
973 B
TypeScript
import { ActionTree, GetterTree, MutationTree } from 'vuex';
|
|
|
|
export interface BackdropState {
|
|
blurhash: string;
|
|
}
|
|
|
|
export const state = (): BackdropState => ({
|
|
blurhash: ''
|
|
});
|
|
|
|
export const getters: GetterTree<BackdropState, BackdropState> = {
|
|
getBackdropBlurhash: (state: BackdropState) => state.blurhash
|
|
};
|
|
|
|
export const mutations: MutationTree<BackdropState> = {
|
|
SET_CURRENT_BACKDROP(state: BackdropState, newBlurhash: string) {
|
|
state.blurhash = newBlurhash;
|
|
},
|
|
CLEAR_CURRENT_BACKDROP(state: BackdropState) {
|
|
state.blurhash = '';
|
|
}
|
|
};
|
|
|
|
export const actions: ActionTree<BackdropState, BackdropState> = {
|
|
set({ commit }, { item }) {
|
|
let hash: string;
|
|
|
|
if (item.ImageBlurHashes.Backdrop && item.BackdropImageTags) {
|
|
hash = item.ImageBlurHashes?.Backdrop[item.BackdropImageTags[0]];
|
|
} else {
|
|
hash = '';
|
|
}
|
|
|
|
commit('SET_CURRENT_BACKDROP', hash);
|
|
},
|
|
clear({ commit }) {
|
|
commit('CLEAR_CURRENT_BACKDROP');
|
|
}
|
|
};
|