mirror of https://github.com/halo-dev/halo
fix: autosave content feature not working (#6147)
#### What type of PR is this? /kind bug /area ui /milestone 2.17.x #### What this PR does / why we need it: 解决自动保存失效的问题 #### How to test it? 测试文章、页面输入内容后,点击其他页面是否能够自动保存。 #### Which issue(s) this PR fixes: Fixes #6129 #### Does this PR introduce a user-facing change? ```release-note 解决文章自动保存失效的问题 ```pull/6150/head
parent
88db1976c8
commit
c1ba566e08
|
@ -64,8 +64,6 @@ const getRoleCountText = computed(() => {
|
||||||
resolveDeepDependencies(formState.value, roleTemplates.value || [])
|
resolveDeepDependencies(formState.value, roleTemplates.value || [])
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(dependencies);
|
|
||||||
|
|
||||||
return t("core.role.common.text.contains_n_permissions", {
|
return t("core.role.common.text.contains_n_permissions", {
|
||||||
count: dependencies.size || 0,
|
count: dependencies.size || 0,
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,8 +15,6 @@ const circle = computed(() => groupProps?.circle || props.circle);
|
||||||
const width = computed(() => groupProps?.width || props.width);
|
const width = computed(() => groupProps?.width || props.width);
|
||||||
const height = computed(() => groupProps?.height || props.height);
|
const height = computed(() => groupProps?.height || props.height);
|
||||||
|
|
||||||
console.log(groupProps);
|
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const error = ref(false);
|
const error = ref(false);
|
||||||
let init = true;
|
let init = true;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { watchEffect } from "vue";
|
|
||||||
import { useLocalStorage } from "@vueuse/core";
|
import { useLocalStorage } from "@vueuse/core";
|
||||||
import {
|
import {
|
||||||
ExtensionBlockquote,
|
ExtensionBlockquote,
|
||||||
|
@ -123,10 +122,6 @@ const editor = useEditor({
|
||||||
content.value = editor.value?.getHTML() + "";
|
content.value = editor.value?.getHTML() + "";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
watchEffect(() => {
|
|
||||||
// console.log(editor.value?.getHTML());
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useLocalStorage } from "@vueuse/core";
|
import { useLocalStorage } from "@vueuse/core";
|
||||||
import { Toast } from "@halo-dev/components";
|
import { Toast } from "@halo-dev/components";
|
||||||
import { ref, watch, type Ref } from "vue";
|
import { computed, type Ref } from "vue";
|
||||||
export interface ContentCache {
|
export interface ContentCache {
|
||||||
name: string;
|
name: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
|
@ -23,7 +23,19 @@ export function useContentCache(
|
||||||
contentVersion: Ref<number>
|
contentVersion: Ref<number>
|
||||||
): useContentCacheReturn {
|
): useContentCacheReturn {
|
||||||
const content_caches = useLocalStorage<ContentCache[]>(key, []);
|
const content_caches = useLocalStorage<ContentCache[]>(key, []);
|
||||||
const currentCache = ref<ContentCache | undefined>(undefined);
|
const currentCache = computed<ContentCache | undefined>(() => {
|
||||||
|
if (content_caches.value.length > 0) {
|
||||||
|
if (name.value) {
|
||||||
|
return content_caches.value.find(
|
||||||
|
(c: ContentCache) => c.name === name.value
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return content_caches.value.find((c: ContentCache) => c.name === "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const handleResetCache = () => {
|
const handleResetCache = () => {
|
||||||
|
@ -84,20 +96,6 @@ export function useContentCache(
|
||||||
index > -1 && content_caches.value.splice(index, 1);
|
index > -1 && content_caches.value.splice(index, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(content_caches, (newCaches) => {
|
|
||||||
if (newCaches.length > 0) {
|
|
||||||
if (name.value) {
|
|
||||||
currentCache.value = newCaches.find(
|
|
||||||
(c: ContentCache) => c.name === name.value
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
currentCache.value = newCaches.find((c: ContentCache) => c.name === "");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentCache.value = undefined;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleClearCache,
|
handleClearCache,
|
||||||
handleResetCache,
|
handleResetCache,
|
||||||
|
|
Loading…
Reference in New Issue