UNPKG

nuxt-live-editor

Version:
26 lines (25 loc) 893 B
import { useLiveEditorStore } from "../stores/useLiveEditorStore.mjs"; import { storeToRefs } from "pinia"; import { computed } from "vue"; export const usePreview = () => { const { data_live_editor, data_live_editor_async, data_live_editor_server } = storeToRefs(useLiveEditorStore()); const list_changed = computed(() => { return Object.keys(data_live_editor_async.value).reduce((array, key) => { const findItemFormKey = (key2) => { return data_live_editor.value?.find((item) => item?.option_key == key2); }; if (data_live_editor_async.value[key] !== data_live_editor_server.value[key]) { array.push({ key, old: data_live_editor_server.value[key], new: data_live_editor_async.value[key], item: findItemFormKey(key) }); } return array; }, []); }); return { list_changed }; };