mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-23 13:13:00 +00:00
put store.api_creds into localStorage
- don't need beforeunload in AdminView anymore
This commit is contained in:
parent
2cf6936139
commit
3da3f7f639
4 changed files with 39 additions and 17 deletions
|
@ -26,6 +26,7 @@
|
|||
"@vue/cli-service": "~5.0.0",
|
||||
"@vue/eslint-config-typescript": "^12.0.0",
|
||||
"@vue/test-utils": "^2.4.1",
|
||||
"@vueuse/core": "^10.5.0",
|
||||
"axios": "^1.5.0",
|
||||
"bulma": "^0.9.4",
|
||||
"bulma-prefers-dark": "^0.1.0-beta.1",
|
||||
|
|
|
@ -18,16 +18,5 @@ import DoorMapEditor from "./DoorMapEditor.vue";
|
|||
DoorMapEditor,
|
||||
},
|
||||
})
|
||||
export default class extends Vue {
|
||||
private old_handler = window.onbeforeunload;
|
||||
private confirm_handler = () => "";
|
||||
|
||||
public mounted(): void {
|
||||
window.onbeforeunload = this.confirm_handler;
|
||||
}
|
||||
|
||||
public beforeUnmount(): void {
|
||||
window.onbeforeunload = this.old_handler;
|
||||
}
|
||||
}
|
||||
export default class extends Vue {}
|
||||
</script>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Credentials, DoorsSaved, SiteConfigModel } from "@/lib/api";
|
||||
import { Advent22 } from "@/plugins/advent22";
|
||||
import { useLocalStorage } from "@vueuse/core";
|
||||
import { AxiosBasicCredentials } from "axios";
|
||||
import { acceptHMRUpdate, defineStore } from "pinia";
|
||||
|
||||
|
@ -14,7 +15,7 @@ export const advent22Store = defineStore({
|
|||
|
||||
state: () => ({
|
||||
advent22: {} as Advent22,
|
||||
api_creds: ["", ""] as Credentials,
|
||||
api_creds: useLocalStorage<Credentials>("advent22/auth", ["", ""]),
|
||||
is_touch_device:
|
||||
window.matchMedia("(any-hover: none)").matches ||
|
||||
"ontouchstart" in window ||
|
||||
|
@ -42,6 +43,7 @@ export const advent22Store = defineStore({
|
|||
actions: {
|
||||
init(advent22: Advent22): void {
|
||||
this.advent22 = advent22;
|
||||
this.update_is_admin();
|
||||
|
||||
advent22
|
||||
.api_get_blob("user/favicon")
|
||||
|
@ -78,9 +80,7 @@ export const advent22Store = defineStore({
|
|||
.catch(advent22.alert_user_error);
|
||||
},
|
||||
|
||||
login(creds: Credentials): Promise<boolean> {
|
||||
this.api_creds = creds;
|
||||
|
||||
update_is_admin(): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
this.advent22
|
||||
.api_get<boolean>("admin/is_admin")
|
||||
|
@ -92,6 +92,11 @@ export const advent22Store = defineStore({
|
|||
});
|
||||
},
|
||||
|
||||
login(creds: Credentials): Promise<boolean> {
|
||||
this.api_creds = creds;
|
||||
return this.update_is_admin();
|
||||
},
|
||||
|
||||
logout(): Promise<boolean> {
|
||||
return this.login(["", ""]);
|
||||
},
|
||||
|
|
29
ui/yarn.lock
29
ui/yarn.lock
|
@ -1427,6 +1427,11 @@
|
|||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/web-bluetooth@^0.0.18":
|
||||
version "0.0.18"
|
||||
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.18.tgz#74bd1c8fd3a2058cb6fc76b188fcded50a83d866"
|
||||
integrity sha512-v/ZHEj9xh82usl8LMR3GarzFY1IrbXJw5L4QfQhokjRV91q+SelFqxQWSep1ucXEZ22+dSTwLFkXeur25sPIbw==
|
||||
|
||||
"@types/webpack-env@^1.15.2":
|
||||
version "1.18.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.18.1.tgz#49699bb508961e14a3bfb68c78cd87b296889d1d"
|
||||
|
@ -1940,6 +1945,28 @@
|
|||
resolved "https://registry.yarnpkg.com/@vue/web-component-wrapper/-/web-component-wrapper-1.3.0.tgz#b6b40a7625429d2bd7c2281ddba601ed05dc7f1a"
|
||||
integrity sha512-Iu8Tbg3f+emIIMmI2ycSI8QcEuAUgPTgHwesDU1eKMLE4YC/c/sFbGc70QgMq31ijRftV0R7vCm9co6rldCeOA==
|
||||
|
||||
"@vueuse/core@^10.5.0":
|
||||
version "10.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-10.5.0.tgz#04d1e6d26592bb997bb755a4830ea7583c3e8612"
|
||||
integrity sha512-z/tI2eSvxwLRjOhDm0h/SXAjNm8N5ld6/SC/JQs6o6kpJ6Ya50LnEL8g5hoYu005i28L0zqB5L5yAl8Jl26K3A==
|
||||
dependencies:
|
||||
"@types/web-bluetooth" "^0.0.18"
|
||||
"@vueuse/metadata" "10.5.0"
|
||||
"@vueuse/shared" "10.5.0"
|
||||
vue-demi ">=0.14.6"
|
||||
|
||||
"@vueuse/metadata@10.5.0":
|
||||
version "10.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-10.5.0.tgz#7501a88cf5cbf7a515a03f0b8bbe3cecf30cad11"
|
||||
integrity sha512-fEbElR+MaIYyCkeM0SzWkdoMtOpIwO72x8WsZHRE7IggiOlILttqttM69AS13nrDxosnDBYdyy3C5mR1LCxHsw==
|
||||
|
||||
"@vueuse/shared@10.5.0":
|
||||
version "10.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-10.5.0.tgz#b3ac8c190a5dae41db5e1b60fe304a9b4247393c"
|
||||
integrity sha512-18iyxbbHYLst9MqU1X1QNdMHIjks6wC7XTVf0KNOv5es/Ms6gjVFCAAWTVP2JStuGqydg3DT+ExpFORUEi9yhg==
|
||||
dependencies:
|
||||
vue-demi ">=0.14.6"
|
||||
|
||||
"@webassemblyjs/ast@1.11.6", "@webassemblyjs/ast@^1.11.5":
|
||||
version "1.11.6"
|
||||
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.6.tgz#db046555d3c413f8966ca50a95176a0e2c642e24"
|
||||
|
@ -6848,7 +6875,7 @@ vue-component-type-helpers@1.8.4:
|
|||
resolved "https://registry.yarnpkg.com/vue-component-type-helpers/-/vue-component-type-helpers-1.8.4.tgz#302d85fac912519cdf0dd2fb51402e5215d85628"
|
||||
integrity sha512-6bnLkn8O0JJyiFSIF0EfCogzeqNXpnjJ0vW/SZzNHfe6sPx30lTtTXlE5TFs2qhJlAtDFybStVNpL73cPe3OMQ==
|
||||
|
||||
vue-demi@>=0.14.5:
|
||||
vue-demi@>=0.14.5, vue-demi@>=0.14.6:
|
||||
version "0.14.6"
|
||||
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.6.tgz#dc706582851dc1cdc17a0054f4fec2eb6df74c92"
|
||||
integrity sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==
|
||||
|
|
Loading…
Reference in a new issue