Skip to content

Commit

Permalink
Merge pull request #8 from beclab/feat/theme
Browse files Browse the repository at this point in the history
fix: unuse quasar cookies plugin crash
  • Loading branch information
yongheng2016 authored Jun 3, 2024
2 parents ee4ace3 + 1a55f53 commit 8b35698
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/theme/src/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,25 @@ watchEffect(() => {
}
});
const themeValue = $q.cookies.get(themeModeName);
function getCookie(name: string){
var strcookie = document.cookie;
var arrcookie = strcookie.split("; ");
for ( var i = 0; i < arrcookie.length; i++) {
var arr = arrcookie[i].split("=");
if (arr[0] == name){
return arr[1];
}
}
return "";
}
let themeValue = ''
if ($q.cookies) {
themeValue = $q.cookies.get(themeModeName);
} else {
themeValue = getCookie(themeModeName);
}
if (themeValue) {
const theme = Number(themeValue);
if (theme == ThemeDefinedMode.AUTO) {
Expand All @@ -142,6 +160,7 @@ if (themeValue) {
$q.dark.set(theme == ThemeDefinedMode.DARK);
}
}
</script>
<script lang="ts">
import { defineComponent } from "vue";
Expand Down

0 comments on commit 8b35698

Please sign in to comment.