refactor: move persistence logic into a dedicated service (#3493)
This commit is contained in:
@@ -47,14 +47,15 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Splitpanes, Pane } from "splitpanes"
|
||||
import { Pane, Splitpanes } from "splitpanes"
|
||||
|
||||
import "splitpanes/dist/splitpanes.css"
|
||||
|
||||
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core"
|
||||
import { computed, useSlots, ref } from "vue"
|
||||
import { useSetting } from "@composables/settings"
|
||||
import { setLocalConfig, getLocalConfig } from "~/newstore/localpersistence"
|
||||
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core"
|
||||
import { useService } from "dioc/vue"
|
||||
import { computed, ref, useSlots } from "vue"
|
||||
import { PersistenceService } from "~/services/persistence"
|
||||
|
||||
const SIDEBAR_ON_LEFT = useSetting("SIDEBAR_ON_LEFT")
|
||||
|
||||
@@ -67,6 +68,8 @@ const SIDEBAR = useSetting("SIDEBAR")
|
||||
|
||||
const slots = useSlots()
|
||||
|
||||
const persistenceService = useService(PersistenceService)
|
||||
|
||||
const hasSidebar = computed(() => !!slots.sidebar)
|
||||
const hasSecondary = computed(() => !!slots.secondary)
|
||||
|
||||
@@ -96,7 +99,7 @@ if (!COLUMN_LAYOUT.value) {
|
||||
function setPaneEvent(event: PaneEvent[], type: "vertical" | "horizontal") {
|
||||
if (!props.layoutId) return
|
||||
const storageKey = `${props.layoutId}-pane-config-${type}`
|
||||
setLocalConfig(storageKey, JSON.stringify(event))
|
||||
persistenceService.setLocalConfig(storageKey, JSON.stringify(event))
|
||||
}
|
||||
|
||||
function populatePaneEvent() {
|
||||
@@ -119,7 +122,7 @@ function populatePaneEvent() {
|
||||
|
||||
function getPaneData(type: "vertical" | "horizontal"): PaneEvent[] | null {
|
||||
const storageKey = `${props.layoutId}-pane-config-${type}`
|
||||
const paneEvent = getLocalConfig(storageKey)
|
||||
const paneEvent = persistenceService.getLocalConfig(storageKey)
|
||||
if (!paneEvent) return null
|
||||
return JSON.parse(paneEvent)
|
||||
}
|
||||
|
||||
@@ -111,20 +111,21 @@
|
||||
<script setup lang="ts">
|
||||
import { Ref, computed, onMounted, ref } from "vue"
|
||||
|
||||
import { useI18n } from "@composables/i18n"
|
||||
import { useStreamSubscriber } from "@composables/stream"
|
||||
import { useToast } from "@composables/toast"
|
||||
import { useI18n } from "@composables/i18n"
|
||||
|
||||
import { platform } from "~/platform"
|
||||
import { setLocalConfig } from "~/newstore/localpersistence"
|
||||
|
||||
import IconEmail from "~icons/auth/email"
|
||||
import IconGithub from "~icons/auth/github"
|
||||
import IconGoogle from "~icons/auth/google"
|
||||
import IconEmail from "~icons/auth/email"
|
||||
import IconMicrosoft from "~icons/auth/microsoft"
|
||||
import IconArrowLeft from "~icons/lucide/arrow-left"
|
||||
|
||||
import { useService } from "dioc/vue"
|
||||
import { LoginItemDef } from "~/platform/auth"
|
||||
import { PersistenceService } from "~/services/persistence"
|
||||
|
||||
defineProps<{
|
||||
show: boolean
|
||||
@@ -138,6 +139,8 @@ const { subscribeToStream } = useStreamSubscriber()
|
||||
const t = useI18n()
|
||||
const toast = useToast()
|
||||
|
||||
const persistenceService = useService(PersistenceService)
|
||||
|
||||
const form = {
|
||||
email: "",
|
||||
}
|
||||
@@ -260,7 +263,7 @@ const signInWithEmail = async () => {
|
||||
.signInWithEmail(form.email)
|
||||
.then(() => {
|
||||
mode.value = "email-sent"
|
||||
setLocalConfig("emailForSignIn", form.email)
|
||||
persistenceService.setLocalConfig("emailForSignIn", form.email)
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from "@composables/i18n"
|
||||
import { useToast } from "@composables/toast"
|
||||
import { completePageProgress, startPageProgress } from "@modules/loadingbar"
|
||||
import { completePageProgress, startPageProgress } from "~/modules/loadingbar"
|
||||
import * as gql from "graphql"
|
||||
import { clone } from "lodash-es"
|
||||
import { computed, ref, watch } from "vue"
|
||||
|
||||
Reference in New Issue
Block a user