Skip to content

Commit 417cfed

Browse files
author
b
committed
feat: add 😁 terminal command to enable comic mode
1 parent bd1cc13 commit 417cfed

2 files changed

Lines changed: 59 additions & 11 deletions

File tree

src/components/TheXTerm.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ let idleTimer: number | undefined;
4343
const idleDelay = 2500; // 5 seconds
4444
4545
const TerminalApiInstance = TerminalApi as any as TerminalApi;
46+
const COMIC_FLAG_KEY = 'pe:comic-enabled';
47+
48+
const enableComicEngine = () => {
49+
localStorage.setItem(COMIC_FLAG_KEY, 'true');
50+
window.dispatchEvent(new CustomEvent('pe-enable-comic'));
51+
};
4652
4753
const resetAndStartIdleTimer = () => {
4854
clearTimeout(idleTimer);
@@ -225,6 +231,15 @@ const onExecCmd = (
225231
content: '<a href="https://calendar.google.com/calendar/appointments/schedules/AcZssZ1PPmxcLlDdPZF1BMHQaADaO7or9b7sXrljq7co6Fu3bZLO9x_YmzH8JkynDEwzSrgdqh5Y-4s1">calendar</a>'
226232
})
227233
}
234+
else if (key === "😁") {
235+
enableComicEngine();
236+
success({
237+
type: 'normal',
238+
class: 'success',
239+
tag: '',
240+
content: 'Comic engine enabled.'
241+
})
242+
}
228243
else {
229244
let allClass = ['success', 'error', 'system', 'info', 'warning'];
230245
let clazz = allClass[Math.floor(Math.random() * allClass.length)];
@@ -281,6 +296,25 @@ const commandStore = [
281296
// open a popup to the calendar
282297
//
283298
}
299+
},
300+
{
301+
key: '😁',
302+
title: 'Enable comic mode.',
303+
usage: '😁',
304+
example: [
305+
{
306+
cmd: '😁',
307+
des: 'Switch from CLI-only mode to Comic mode.',
308+
}
309+
],
310+
exec: () => {
311+
enableComicEngine();
312+
TerminalApiInstance.pushMessage("my-terminal",{
313+
type: 'normal',
314+
class: 'success',
315+
content: 'Comic engine enabled.',
316+
})
317+
}
284318
}
285319
]
286320

src/components/Win95TabContainer.vue

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,55 @@
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
66
const ComicViewer = defineAsyncComponent(() => import('./ComicViewer.vue'));
77
const ComicArchive = defineAsyncComponent(() => import('./ComicArchive.vue'));
88
const PushSubscribe = defineAsyncComponent(() => import('./PushSubscribe.vue'));
99
const 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');
1313
const 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
2227
onMounted(() => {
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

Comments
 (0)