-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Detect the database not opened issue and hint user
- Loading branch information
Showing
16 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ResourceServiceKey } from '@xmcl/runtime-api' | ||
import { useService } from './service' | ||
import useSWRV from 'swrv' | ||
import { InjectionKey } from 'vue' | ||
|
||
export const kDatabaseStatus: InjectionKey<ReturnType<typeof useDatabaseStatus>> = Symbol('DatabaseStatus') | ||
|
||
export function useDatabaseStatus() { | ||
const { isResourceDatabaseOpened } = useService(ResourceServiceKey) | ||
const { data } = useSWRV('isResourceDatabaseOpened', isResourceDatabaseOpened) | ||
const isOpened = computed(() => data.value ?? false) | ||
return { | ||
isOpened, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<v-card | ||
v-if="error" | ||
class="mx-2" | ||
color="red" | ||
> | ||
<v-card-text> | ||
{{ error }} | ||
</v-card-text> | ||
<v-card-actions> | ||
<v-btn | ||
text | ||
@click="push('/setting')" | ||
> | ||
<v-icon left> | ||
settings | ||
</v-icon> | ||
{{ t('setting.name', 2) }} | ||
</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</template> | ||
<script setup lang="ts"> | ||
import { kDatabaseStatus } from '@/composables/databaseStatus' | ||
import { injection } from '@/util/inject' | ||
const { t } = useI18n() | ||
const { isOpened } = injection(kDatabaseStatus) | ||
const { push } = useRouter() | ||
const error = computed(() => { | ||
if (!isOpened.value) { | ||
return t('errors.DatabaseNotOpened') | ||
} | ||
return '' | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters