Newer
Older
import { useWebsocketStore } from '@/app/stores/websocket';
export const useInterfaceStore = defineStore('interfaceStore', () => {
const websocketStore = useWebsocketStore();
const isDarkMode = ref<boolean>(true);
const defaultPageBackground = ref<string>(
'https://t3.ftcdn.net/jpg/05/01/28/98/360_F_501289843_4ITbthNCydFQGgJmoZe4IQKchItBubqZ.jpg'
const pageBackground = ref<string>(defaultPageBackground.value);
const isFetchedForBackground = ref<boolean>(false);
function setIsFetchedForBackground() {
isFetchedForBackground.value = true;
}
function resetPageBackground() {
pageBackground.value = defaultPageBackground.value;
event: 'deletePageBackground'
function editPageBackground(newUrl: string) {
pageBackground.value = newUrl;
const image = new Image();
image.src = newUrl;
image.onload = async () => {
const response = await fetch(newUrl);
const blob = await response.blob();
const data = {
extension: blob.type
}
};
websocketStore.sendData(data);
};
}
function setPageBackgroundFromDB(url: string | null) {
pageBackground,
defaultPageBackground,
isFetchedForBackground,
setIsFetchedForBackground,
resetPageBackground,
editPageBackground,
setPageBackgroundFromDB