Skip to content

Commit

Permalink
test: addEventListener theme
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuangs committed Jun 17, 2024
1 parent 0f596e3 commit 189b50d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/update-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- "main"
- "feat-theme-dark"
tags:
- 'v*'
jobs:
Expand Down
23 changes: 22 additions & 1 deletion packages/frontend/src/components/BasicWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
</template>

<script lang="ts">
import { ref, defineComponent, onMounted, nextTick } from 'vue';
import { ref, defineComponent, onMounted, nextTick, onUnmounted } from 'vue';
import { useQuasar } from 'quasar';
interface WindowRect {
Expand Down Expand Up @@ -251,7 +251,24 @@ export default defineComponent({
}
};
const message = (event: any) => {
console.log('message==>');
console.log(event);
console.log(event.data);
console.log($q.dark.isActive);
if (event.data.message === 'theme_update') {
if (event.data.info.theme.toString() === '1') {
$q.dark.set(false);
} else {
$q.dark.set(true);
}
}
console.log($q.dark.isActive);
};
onMounted(() => {
window.addEventListener('message', message);
nextTick(() => {
new MutationObserver(function (mutations) {
mutations.some(function (mutation) {
Expand Down Expand Up @@ -288,6 +305,10 @@ export default defineComponent({
});
});
onUnmounted(() => {
window.removeEventListener('message', message);
});
return {
$q,
value,
Expand Down

0 comments on commit 189b50d

Please sign in to comment.