改进 主题获取
This commit is contained in:
parent
f6a32661c5
commit
f397b82111
8
src/plugins/getTheme.ts
Normal file
8
src/plugins/getTheme.ts
Normal file
@ -0,0 +1,8 @@
|
||||
let matchResult = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
|
||||
|
||||
function getTheme() {
|
||||
return matchResult.matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
export default getTheme()
|
@ -13,7 +13,7 @@
|
||||
</div>
|
||||
|
||||
<MdEditor
|
||||
:theme="theme == 'dark' ? 'dark' : 'light'"
|
||||
:theme="getTheme"
|
||||
v-model="createData.Content"
|
||||
/>
|
||||
|
||||
@ -60,10 +60,7 @@ import { MdEditor } from "md-editor-v3";
|
||||
import "md-editor-v3/lib/style.css";
|
||||
import router from "@/router/index";
|
||||
import { document } from "@/plugins/api";
|
||||
import { useTheme } from "vuetify/lib/framework.mjs";
|
||||
|
||||
// get current theme
|
||||
const theme = useTheme().name;
|
||||
import getTheme from "@/plugins/getTheme";
|
||||
|
||||
const created = ref(false);
|
||||
|
||||
|
@ -4,6 +4,8 @@ import { ref } from "vue";
|
||||
import { document } from "@/plugins/api";
|
||||
import { MdPreview } from "md-editor-v3";
|
||||
import LoadingComponent from "@/components/Loading.vue";
|
||||
import getTheme from "@/plugins/getTheme";
|
||||
|
||||
|
||||
const libraryId = parseInt(router.currentRoute.value.params.LibraryId);
|
||||
const documentId = parseInt(router.currentRoute.value.params.DocumentId);
|
||||
@ -36,7 +38,7 @@ document
|
||||
<div v-else>
|
||||
<h2>{{ docu.Title }}</h2>
|
||||
|
||||
<MdPreview :modelValue="docu.Content" />
|
||||
<MdPreview :theme="getTheme" :modelValue="docu.Content" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user