Skip to content

Commit

Permalink
fix: unuse quasar cookies plugin crash
Browse files Browse the repository at this point in the history
  • Loading branch information
qq815776412 committed Jun 3, 2024
1 parent ee4ace3 commit 1a55f53
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 1a55f53

Please sign in to comment.