add maxkb toggle
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-04-27 08:57:41 -06:00
parent 79d5a2bab2
commit 96f6be8dbe
3 changed files with 47 additions and 2 deletions

View File

@@ -126,6 +126,16 @@ export async function removeCode(id: number) {
await api.delete(`/${id}`)
}
export async function getMaxkb(): Promise<{ enabled: boolean }> {
const res = await api.get("/maxkb")
return res.data
}
export async function postMaxkb(): Promise<{ enabled: boolean }> {
const res = await api.post("/maxkb")
return res.data
}
export async function debug(code: string, inputs: string[]) {
const res = await api.post("/debug", {
code,

30
src/composables/maxkb.ts Normal file
View File

@@ -0,0 +1,30 @@
import { ref } from "vue"
import { getMaxkb, postMaxkb } from "../api"
const enabled = ref(true)
function applyState() {
document.querySelectorAll<HTMLElement>("body > [id^='maxkb-']").forEach(el => {
el.style.display = enabled.value ? "" : "none"
})
}
export async function fetchMaxkbState() {
try {
const res = await getMaxkb()
enabled.value = res.enabled
applyState()
} catch {}
}
export async function toggleMaxkb() {
try {
const res = await postMaxkb()
enabled.value = res.enabled
applyState()
} catch {}
}
export function initMaxkb() {
fetchMaxkbState()
}

View File

@@ -22,17 +22,20 @@
</template>
<script lang="ts" setup>
import { useMagicKeys, whenever } from "@vueuse/core"
import { ref } from "vue"
import { onMounted, ref } from "vue"
import { run } from "../composables/code"
import { initMaxkb, toggleMaxkb } from "../composables/maxkb"
import Content from "./Content.vue"
import File from "./File.vue"
import Header from "./Header.vue"
import Query from "./Query.vue"
onMounted(initMaxkb)
const file = ref(false)
const query = ref(false)
const { alt_shift_p, ctrl_shift_p, ctrl_shift_z, ctrl_shift_m } = useMagicKeys()
const { alt_shift_p, ctrl_shift_p, ctrl_shift_z, ctrl_shift_m, ctrl_shift_h } = useMagicKeys()
whenever(alt_shift_p, () => {
file.value = true
@@ -48,6 +51,8 @@ whenever(ctrl_shift_m, () => {
query.value = true
})
whenever(ctrl_shift_h, toggleMaxkb)
const { ctrl_s } = useMagicKeys({
passive: false,
onEventFired(e) {