advent22/ui/src/plugins/store.ts

43 lines
1.1 KiB
TypeScript
Raw Normal View History

// import { Credentials } from "@/lib/api";
// import { AxiosBasicCredentials } from "axios";
import { acceptHMRUpdate, defineStore } from "pinia";
const check_touch_device = () => window.matchMedia("(any-hover: none)").matches;
// const empty_creds = () => ["", ""] as Credentials;
export const advent22Store = defineStore({
id: "advent22",
state: () => ({
// api_creds: empty_creds(),
is_touch_device: check_touch_device(),
}),
// getters: {
// axios_creds: (state): AxiosBasicCredentials => {
// const [username, password] = state.api_creds;
// return { username: username, password: password };
// },
// },
actions: {
// set_api_creds(creds: Credentials = empty_creds()): void {
// this.api_creds = creds;
// },
set_touch_device(state: boolean = check_touch_device()): void {
this.is_touch_device = state;
},
toggle_touch_device(): void {
this.is_touch_device = !this.is_touch_device;
},
},
});
if (import.meta.webpackHot) {
import.meta.webpackHot.accept(
acceptHMRUpdate(advent22Store, import.meta.webpackHot),
);
}