save loading

This commit is contained in:
Qiuxia Fan 2022-03-23 17:23:09 +08:00
parent e3779d2a06
commit 6b8491c542

View File

@ -72,7 +72,7 @@ limitations under the License. -->
/> />
</div> </div>
</div> </div>
<div class="flex-h tools"> <div class="flex-h tools" v-loading="loading">
<div class="tool-icons flex-h" v-if="dashboardStore.editMode"> <div class="tool-icons flex-h" v-if="dashboardStore.editMode">
<span <span
@click="clickIcons(t)" @click="clickIcons(t)"
@ -118,7 +118,6 @@ import { useSelectorStore } from "@/store/modules/selectors";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { Option } from "@/types/app"; import { Option } from "@/types/app";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useThrottleFn } from "@vueuse/core";
const { t } = useI18n(); const { t } = useI18n();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
@ -128,6 +127,7 @@ const params = useRoute().params;
const toolIcons = ref<{ name: string; content: string; id: string }[]>( const toolIcons = ref<{ name: string; content: string; id: string }[]>(
EndpointRelationTools EndpointRelationTools
); );
const loading = ref<boolean>(false);
const states = reactive<{ const states = reactive<{
destService: string; destService: string;
destPod: string; destPod: string;
@ -145,7 +145,6 @@ const states = reactive<{
currentDestService: "", currentDestService: "",
currentDestPod: "", currentDestPod: "",
}); });
const applyDashboard = useThrottleFn(dashboardStore.saveDashboard, 3000);
setCurrentDashboard(); setCurrentDashboard();
appStore.setEventStack([initSelector]); appStore.setEventStack([initSelector]);
@ -329,9 +328,11 @@ function changeMode() {
ElMessage.warning(t("viewWarning")); ElMessage.warning(t("viewWarning"));
} }
function clickIcons(t: { id: string; content: string; name: string }) { async function clickIcons(t: { id: string; content: string; name: string }) {
if (t.id === "apply") { if (t.id === "apply") {
applyDashboard(); loading.value = true;
await dashboardStore.saveDashboard();
loading.value = false;
return; return;
} }
if ( if (