11<script setup lang="ts">
2- import { defineAsyncComponent , ref , onMounted } from ' vue' ;
2+ import { defineAsyncComponent , ref , onMounted , onUnmounted , computed } from ' vue' ;
33
4- const SHOW_COMIC_ENGINE = false ;
4+ const COMIC_FLAG_KEY = ' pe:comic-enabled ' ;
55
66const ComicViewer = defineAsyncComponent (() => import (' ./ComicViewer.vue' ));
77const ComicArchive = defineAsyncComponent (() => import (' ./ComicArchive.vue' ));
88const PushSubscribe = defineAsyncComponent (() => import (' ./PushSubscribe.vue' ));
99const TheXTerm = defineAsyncComponent (() => import (' ./TheXTerm.vue' ));
1010
11- const defaultTab = SHOW_COMIC_ENGINE ? ' comic ' : ' archive ' ;
12- const activeTab = ref (defaultTab );
11+ const showComicEngine = ref ( false ) ;
12+ const activeTab = ref (' archive ' );
1313const selectedDay = ref <string | undefined >(undefined );
1414
15- const tabs = [
16- ... (SHOW_COMIC_ENGINE ? [{ id: ' comic' , label: ' Comic' }] : []),
15+ const tabs = computed (() => [
16+ ... (showComicEngine . value ? [{ id: ' comic' , label: ' Comic' }] : []),
1717 { id: ' archive' , label: ' Archive' },
1818 { id: ' subscribe' , label: ' Subscribe' },
1919 { id: ' cli' , label: ' CLI' }
20- ];
20+ ]);
21+
22+ const handleEnableComicEvent = () => {
23+ showComicEngine .value = true ;
24+ activeTab .value = ' comic' ;
25+ };
2126
2227onMounted (() => {
28+ showComicEngine .value = localStorage .getItem (COMIC_FLAG_KEY ) === ' true' ;
29+ activeTab .value = showComicEngine .value ? ' comic' : ' archive' ;
30+
2331 const params = new URLSearchParams (window .location .search );
2432 const tab = params .get (' tab' );
2533 const day = params .get (' day' );
2634
27- if (tab && tabs .some (t => t .id === tab )) {
35+ if (tab && tabs .value . some (t => t .id === tab )) {
2836 activeTab .value = tab ;
2937 }
30- if (SHOW_COMIC_ENGINE && day ) {
38+ if (showComicEngine . value && day ) {
3139 selectedDay .value = day ;
3240 activeTab .value = ' comic' ;
3341 }
42+
43+ window .addEventListener (' pe-enable-comic' , handleEnableComicEvent );
44+ });
45+
46+ onUnmounted (() => {
47+ window .removeEventListener (' pe-enable-comic' , handleEnableComicEvent );
3448});
3549 </script >
3650
3751<template >
38- <div v-if =" SHOW_COMIC_ENGINE " class =" window comic-window" >
52+ <div v-if =" showComicEngine " class =" window comic-window" >
3953 <div class =" title-bar" >
4054 <div class =" title-bar-text" >LLM DOES NOT COMPUTE - promptexecution.com</div >
4155 <div class =" title-bar-controls" >
@@ -59,7 +73,7 @@ onMounted(() => {
5973
6074 <div class =" tab-content" >
6175 <ComicViewer
62- v-if =" SHOW_COMIC_ENGINE && activeTab === 'comic'"
76+ v-if =" showComicEngine && activeTab === 'comic'"
6377 :day =" selectedDay"
6478 @request-tab =" activeTab = $event"
6579 />
0 commit comments