ci: 集成 pinia 提供主题持久化

This commit is contained in:
就眠儀式
2022-04-06 00:21:26 +08:00
parent e77738e974
commit 0f7d25bc09
8 changed files with 127 additions and 63 deletions

View File

@@ -21,7 +21,7 @@
href="javascript:void(0);"
@click="changeTheme"
>
{{ theme === "dark" ? "Turn Off" : "Turn On" }}
{{ appStore.theme === "dark" ? "Turn Off" : "Turn On" }}
</a>
</div>
<div class="site-version">
@@ -111,25 +111,26 @@
</template>
<script>
import { inject, provide } from "vue";
import { useI18n } from "vue-i18n";
import { useAppStore } from "../store/app";
export default {
name: "index",
setup() {
const { t } = useI18n();
const theme = inject("theme");
const appStore = useAppStore();
const changeTheme = () => {
if (theme.value === "dark") {
theme.value = "light";
if (appStore.theme === "dark") {
appStore.theme = "light";
} else {
theme.value = "dark";
appStore.theme = "dark";
}
};
return {
t,
theme,
appStore,
changeTheme,
};
},