Fix some wrong watchers
This commit is contained in:
parent
f91c937626
commit
3f008012ef
@ -17,7 +17,7 @@
|
|||||||
@keyup.enter="submit"
|
@keyup.enter="submit"
|
||||||
ref="input"
|
ref="input"
|
||||||
:autofocus="active"
|
:autofocus="active"
|
||||||
v-model.trim="value"
|
v-model.trim="prompt"
|
||||||
:aria-label="$t('search.search')"
|
:aria-label="$t('search.search')"
|
||||||
:placeholder="$t('search.search')"
|
:placeholder="$t('search.search')"
|
||||||
/>
|
/>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<template v-if="isEmpty">
|
<template v-if="isEmpty">
|
||||||
<p>{{ text }}</p>
|
<p>{{ text }}</p>
|
||||||
|
|
||||||
<template v-if="value.length === 0">
|
<template v-if="prompt.length === 0">
|
||||||
<div class="boxes">
|
<div class="boxes">
|
||||||
<h3>{{ $t("search.types") }}</h3>
|
<h3>{{ $t("search.types") }}</h3>
|
||||||
<div>
|
<div>
|
||||||
@ -73,6 +73,7 @@ import { search } from "@/api";
|
|||||||
import { computed, inject, onMounted, ref, watch } from "vue";
|
import { computed, inject, onMounted, ref, watch } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
|
||||||
const boxes = {
|
const boxes = {
|
||||||
image: { label: "images", icon: "insert_photo" },
|
image: { label: "images", icon: "insert_photo" },
|
||||||
@ -84,7 +85,9 @@ const boxes = {
|
|||||||
const layoutStore = useLayoutStore();
|
const layoutStore = useLayoutStore();
|
||||||
const fileStore = useFileStore();
|
const fileStore = useFileStore();
|
||||||
|
|
||||||
const value = ref<string>("");
|
const { show } = storeToRefs(layoutStore);
|
||||||
|
|
||||||
|
const prompt = ref<string>("");
|
||||||
const active = ref<boolean>(false);
|
const active = ref<boolean>(false);
|
||||||
const ongoing = ref<boolean>(false);
|
const ongoing = ref<boolean>(false);
|
||||||
const results = ref<any[]>([]);
|
const results = ref<any[]>([]);
|
||||||
@ -100,8 +103,7 @@ const { t } = useI18n();
|
|||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
// @ts-ignore
|
watch(show, (newVal, oldVal) => {
|
||||||
watch(layoutStore.show, (newVal: string, oldVal: string) => {
|
|
||||||
active.value = newVal === "search";
|
active.value = newVal === "search";
|
||||||
|
|
||||||
if (oldVal === "search" && !active.value) {
|
if (oldVal === "search" && !active.value) {
|
||||||
@ -111,7 +113,7 @@ watch(layoutStore.show, (newVal: string, oldVal: string) => {
|
|||||||
|
|
||||||
document.body.style.overflow = "auto";
|
document.body.style.overflow = "auto";
|
||||||
reset();
|
reset();
|
||||||
value.value = "";
|
prompt.value = "";
|
||||||
active.value = false;
|
active.value = false;
|
||||||
input.value?.blur();
|
input.value?.blur();
|
||||||
} else if (active.value) {
|
} else if (active.value) {
|
||||||
@ -121,7 +123,7 @@ watch(layoutStore.show, (newVal: string, oldVal: string) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(value, () => {
|
watch(prompt, () => {
|
||||||
if (results.value.length) {
|
if (results.value.length) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@ -139,7 +141,7 @@ const text = computed(() => {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return value.value === ""
|
return prompt.value === ""
|
||||||
? t("search.typeToSearch")
|
? t("search.typeToSearch")
|
||||||
: t("search.pressToSearch");
|
: t("search.pressToSearch");
|
||||||
});
|
});
|
||||||
@ -181,7 +183,7 @@ const keyup = (event: KeyboardEvent) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const init = (string: string) => {
|
const init = (string: string) => {
|
||||||
value.value = `${string} `;
|
prompt.value = `${string} `;
|
||||||
input.value !== null ? input.value.focus() : "";
|
input.value !== null ? input.value.focus() : "";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -194,7 +196,7 @@ const reset = () => {
|
|||||||
const submit = async (event: Event) => {
|
const submit = async (event: Event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (value.value === "") {
|
if (prompt.value === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +208,8 @@ const submit = async (event: Event) => {
|
|||||||
ongoing.value = true;
|
ongoing.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
results.value = await search(path, value.value);
|
results.value = await search(path, prompt.value);
|
||||||
|
console.log("Search: ", results.value);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
$showError(error);
|
$showError(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,16 +83,18 @@ onBeforeUnmount(() => {
|
|||||||
document.removeEventListener("mouseup", onMouseUp);
|
document.removeEventListener("mouseup", onMouseUp);
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
watch(
|
||||||
watch(props.src, () => {
|
() => props.src,
|
||||||
if (!decodeUTIF() && imgex.value !== null) {
|
() => {
|
||||||
imgex.value.src = props.src;
|
if (!decodeUTIF() && imgex.value !== null) {
|
||||||
}
|
imgex.value.src = props.src;
|
||||||
|
}
|
||||||
|
|
||||||
scale.value = 1;
|
scale.value = 1;
|
||||||
setZoom();
|
setZoom();
|
||||||
setCenter();
|
setCenter();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Modified from UTIF.replaceIMG
|
// Modified from UTIF.replaceIMG
|
||||||
const decodeUTIF = () => {
|
const decodeUTIF = () => {
|
||||||
|
|||||||
@ -104,10 +104,13 @@ const displayHomeDirectoryCheckbox = computed(
|
|||||||
() => props.isNew && createUserDirData.value
|
() => props.isNew && createUserDirData.value
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(props.user, () => {
|
watch(
|
||||||
if (!props.user?.perm?.admin) return;
|
() => props.user,
|
||||||
props.user.lockPassword = false;
|
() => {
|
||||||
});
|
if (!props.user?.perm?.admin) return;
|
||||||
|
props.user.lockPassword = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
watch(createUserDirData, () => {
|
watch(createUserDirData, () => {
|
||||||
if (props.user?.scope) {
|
if (props.user?.scope) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user