Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autosave content feature not working #6147

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ui/console-src/modules/system/roles/RoleDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ const getRoleCountText = computed(() => {
resolveDeepDependencies(formState.value, roleTemplates.value || [])
);

console.log(dependencies);

return t("core.role.common.text.contains_n_permissions", {
count: dependencies.size || 0,
});
Expand Down
2 changes: 0 additions & 2 deletions ui/packages/components/src/components/avatar/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const circle = computed(() => groupProps?.circle || props.circle);
const width = computed(() => groupProps?.width || props.width);
const height = computed(() => groupProps?.height || props.height);

console.log(groupProps);

const isLoading = ref(false);
const error = ref(false);
let init = true;
Expand Down
5 changes: 0 additions & 5 deletions ui/packages/editor/src/dev/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts" setup>
import { watchEffect } from "vue";
import { useLocalStorage } from "@vueuse/core";
import {
ExtensionBlockquote,
Expand Down Expand Up @@ -123,10 +122,6 @@ const editor = useEditor({
content.value = editor.value?.getHTML() + "";
},
});

watchEffect(() => {
// console.log(editor.value?.getHTML());
});
</script>

<template>
Expand Down
30 changes: 14 additions & 16 deletions ui/src/composables/use-content-cache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useLocalStorage } from "@vueuse/core";
import { Toast } from "@halo-dev/components";
import { ref, watch, type Ref } from "vue";
import { computed, type Ref } from "vue";
export interface ContentCache {
name: string;
content?: string;
Expand All @@ -23,7 +23,19 @@ export function useContentCache(
contentVersion: Ref<number>
): useContentCacheReturn {
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 handleResetCache = () => {
Expand Down Expand Up @@ -84,20 +96,6 @@ export function useContentCache(
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 {
handleClearCache,
handleResetCache,
Expand Down