This commit is contained in:
2025-02-25 20:39:03 +08:00
parent eec8c3d0ac
commit c0771bbc5d
5 changed files with 34 additions and 18 deletions

View File

@@ -30,7 +30,9 @@ whenever(ctrl_r, () => {})
inline-theme-disabled inline-theme-disabled
> >
<n-split :default-size="1 / 3" min="300px" max="800px"> <n-split :default-size="1 / 3" min="300px" max="800px">
<template #1><Tutorial /></template> <template #1>
<Tutorial />
</template>
<template #2> <template #2>
<n-split direction="vertical" min="200px"> <n-split direction="vertical" min="200px">
<template #1> <template #1>

View File

@@ -1,46 +1,46 @@
<template> <template>
<n-tabs <n-tabs
style="height: 100%"
pane-class="pane"
:value="tab" :value="tab"
pane-class="pane"
style="height: 100%"
type="card" type="card"
@update:value="changeTab" @update:value="changeTab"
> >
<n-tab-pane name="html" tab="HTML"> <n-tab-pane name="html" tab="HTML">
<template #tab> <template #tab>
<n-flex align="center"> <n-flex align="center">
<Icon icon="skill-icons:html" :width="20"></Icon> <Icon :width="20" icon="skill-icons:html"></Icon>
<span>HTML</span> <span>HTML</span>
</n-flex> </n-flex>
</template> </template>
<Editor language="html" :font-size="size" v-model:value="html" /> <Editor v-model:value="html" :font-size="size" language="html" />
</n-tab-pane> </n-tab-pane>
<n-tab-pane name="css" tab="CSS"> <n-tab-pane name="css" tab="CSS">
<template #tab> <template #tab>
<n-flex align="center"> <n-flex align="center">
<Icon icon="skill-icons:css" :width="20"></Icon> <Icon :width="20" icon="skill-icons:css"></Icon>
<span>CSS</span> <span>CSS</span>
</n-flex> </n-flex>
</template> </template>
<Editor language="css" :font-size="size" v-model:value="css" /> <Editor v-model:value="css" :font-size="size" language="css" />
</n-tab-pane> </n-tab-pane>
<n-tab-pane name="js" tab="JS"> <n-tab-pane name="js" tab="JS">
<template #tab> <template #tab>
<n-flex align="center"> <n-flex align="center">
<Icon icon="skill-icons:javascript" :width="20"></Icon> <Icon :width="20" icon="skill-icons:javascript"></Icon>
<span>JS</span> <span>JS</span>
</n-flex> </n-flex>
</template> </template>
<Editor language="js" :font-size="size" v-model:value="js" /> <Editor v-model:value="js" :font-size="size" language="js" />
</n-tab-pane> </n-tab-pane>
<n-tab-pane name="actions" tab="选项"> <n-tab-pane name="actions" tab="选项">
<template #tab> <template #tab>
<n-flex align="center"> <n-flex align="center">
<Icon icon="skill-icons:actix-dark" :width="20"></Icon> <Icon :width="20" icon="skill-icons:actix-dark"></Icon>
<span>选项</span> <span>选项</span>
</n-flex> </n-flex>
</template> </template>
<n-flex vertical class="wrapper"> <n-flex class="wrapper" vertical>
<n-flex align="center"> <n-flex align="center">
<span class="label">重置</span> <span class="label">重置</span>
<n-button @click="reset('html')">HTML</n-button> <n-button @click="reset('html')">HTML</n-button>
@@ -51,10 +51,10 @@
<span class="label">字号</span> <span class="label">字号</span>
<n-flex align="center"> <n-flex align="center">
<span :style="{ 'font-size': size + 'px' }">{{ size }}</span> <span :style="{ 'font-size': size + 'px' }">{{ size }}</span>
<n-button @click="changeSize(size - 2)" :disabled="size === 20"> <n-button :disabled="size === 20" @click="changeSize(size - 2)">
调小 调小
</n-button> </n-button>
<n-button @click="changeSize(size + 2)" :disabled="size === 40"> <n-button :disabled="size === 40" @click="changeSize(size + 2)">
调大 调大
</n-button> </n-button>
</n-flex> </n-flex>
@@ -71,11 +71,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Icon } from "@iconify/vue" import { Icon } from "@iconify/vue"
import Editor from "./Editor.vue" import Editor from "./Editor.vue"
import { html, css, js, reset, tab, size } from "../store" import { css, html, js, reset, size, tab } from "../store"
function changeTab(name: string) { function changeTab(name: string) {
tab.value = name tab.value = name
} }
function changeSize(num: number) { function changeSize(num: number) {
size.value = num size.value = num
} }
@@ -85,9 +86,11 @@ function changeSize(num: number) {
height: 100%; height: 100%;
overflow: auto; overflow: auto;
} }
.wrapper { .wrapper {
padding-left: 16px; padding-left: 16px;
} }
.label { .label {
font-size: 16px; font-size: 16px;
} }

View File

@@ -13,7 +13,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { watchDebounced } from "@vueuse/core" import { watchDebounced } from "@vueuse/core"
import { html, css, js } from "../store" import { css, html, js } from "../store"
import { onMounted, useTemplateRef } from "vue" import { onMounted, useTemplateRef } from "vue"
import { Icon } from "@iconify/vue" import { Icon } from "@iconify/vue"
@@ -41,6 +41,7 @@ function preview() {
doc.write(content) doc.write(content)
doc.close() doc.close()
} }
watchDebounced([html, css, js], preview, { debounce: 500, maxWait: 1000 }) watchDebounced([html, css, js], preview, { debounce: 500, maxWait: 1000 })
onMounted(preview) onMounted(preview)
</script> </script>
@@ -51,9 +52,11 @@ onMounted(preview)
border-bottom: 1px solid rgb(239, 239, 245); border-bottom: 1px solid rgb(239, 239, 245);
box-sizing: border-box; box-sizing: border-box;
} }
.titleText { .titleText {
font-size: 16px; font-size: 16px;
} }
.iframe { .iframe {
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@@ -17,7 +17,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { Icon } from "@iconify/vue" import { Icon } from "@iconify/vue"
import { tab, html, js, css } from "../store" import { css, html, js, tab } from "../store"
import { onMounted, ref, useTemplateRef, watch } from "vue" import { onMounted, ref, useTemplateRef, watch } from "vue"
import { marked } from "marked" import { marked } from "marked"
import { useStorage } from "@vueuse/core" import { useStorage } from "@vueuse/core"
@@ -41,8 +41,7 @@ async function getContent() {
const res = await fetch(`/turtorial/${step.value}/README.md`) const res = await fetch(`/turtorial/${step.value}/README.md`)
const data = await res.text() const data = await res.text()
if (!!data) { if (!!data) {
const html = await marked.parse(data, { async: true }) content.value = await marked.parse(data, { async: true })
content.value = html
last.value = false last.value = false
} else { } else {
content.value = "" content.value = ""
@@ -93,6 +92,7 @@ watch(step, render)
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
} }
.title { .title {
height: 43px; height: 43px;
padding: 0 20px; padding: 0 20px;
@@ -100,9 +100,11 @@ watch(step, render)
border-bottom: 1px solid rgb(239, 239, 245); border-bottom: 1px solid rgb(239, 239, 245);
box-sizing: border-box; box-sizing: border-box;
} }
.preview { .preview {
font-size: 16px; font-size: 16px;
} }
.markdown-body { .markdown-body {
padding: 16px; padding: 16px;
box-sizing: border-box; box-sizing: border-box;
@@ -113,6 +115,7 @@ watch(step, render)
.markdown-body pre { .markdown-body pre {
position: relative; position: relative;
} }
.my-action-btn { .my-action-btn {
position: absolute; position: absolute;
top: 0; top: 0;
@@ -121,9 +124,11 @@ watch(step, render)
cursor: pointer; cursor: pointer;
border-radius: 0.4rem; border-radius: 0.4rem;
} }
.my-action-btn::before { .my-action-btn::before {
content: "替换"; content: "替换";
} }
.my-action-btn.click::before { .my-action-btn.click::before {
content: "已替换"; content: "已替换";
} }

View File

@@ -1,8 +1,11 @@
import { createApp } from "vue" import { createApp } from "vue"
import { create } from "naive-ui" import { create } from "naive-ui"
import { marked } from "marked" import { marked } from "marked"
//@ts-ignore
import "normalize.css" import "normalize.css"
//@ts-ignore
import "github-markdown-css/github-markdown-light.css" import "github-markdown-css/github-markdown-light.css"
//@ts-ignore
import "highlight.js/styles/github.min.css" import "highlight.js/styles/github.min.css"
import App from "./App.vue" import App from "./App.vue"