添加教程隐藏

This commit is contained in:
2025-03-06 20:55:19 +08:00
parent e39faea99a
commit ebab966207
5 changed files with 46 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
<template>
<n-flex align="center" class="corner">
<n-button secondary v-if="!show" @click="showTutorial">教程</n-button>
<template v-if="user.loaded && authed">
<n-button type="primary" secondary @click="submit">提交</n-button>
<n-dropdown :options="menu" @select="clickMenu">
@@ -20,9 +21,9 @@
import { computed, h } from "vue"
import { useMessage } from "naive-ui"
import { Icon } from "@iconify/vue"
import { user, authed, roleNormal, roleSuper } from "../store/user"
import { authed, roleNormal, roleSuper, user } from "../store/user"
import { loginModal } from "../store/modal"
import { step } from "../store/tutorial"
import { show, step, tutorialSize } from "../store/tutorial"
import { Account } from "../api"
import { Role } from "../utils/type"
import { router } from "../router"
@@ -59,6 +60,11 @@ const menu = computed(() => [
},
])
function showTutorial() {
show.value = true
tutorialSize.value = 2 / 5
}
function clickMenu(name: string) {
switch (name) {
case "dashboard":

View File

@@ -14,6 +14,7 @@
type="password"
v-model:value="password"
name="password"
@change="submit"
></n-input>
</n-form-item>
<n-alert

View File

@@ -11,20 +11,23 @@
<Icon :width="24" icon="pepicons-pencil:arrow-right"></Icon>
</n-button>
</n-flex>
<n-button
v-if="authed && roleSuper"
quaternary
@click="$router.push({ name: 'tutorial', params: { display: step } })"
>
修改
</n-button>
<n-flex>
<n-button
v-if="authed && roleSuper"
quaternary
@click="$router.push({ name: 'tutorial', params: { display: step } })"
>
编辑
</n-button>
<n-button quaternary @click="$emit('hide')">隐藏</n-button>
</n-flex>
</n-flex>
<div class="markdown-body" v-html="content" ref="$content"></div>
</div>
</template>
<script lang="ts" setup>
import { Icon } from "@iconify/vue"
import { html, css, js, tab } from "../store/editors"
import { css, html, js, tab } from "../store/editors"
import { computed, onMounted, ref, useTemplateRef, watch } from "vue"
import { marked } from "marked"
import { Tutorial } from "../api"
@@ -35,6 +38,8 @@ const displays = ref<number[]>([])
const content = ref("")
const $content = useTemplateRef("$content")
defineEmits(["hide"])
const hideNav = computed(() => displays.value.length <= 1)
const prevDisabled = computed(() => {
@@ -58,8 +63,7 @@ function next() {
}
async function getContent() {
const res = await Tutorial.listDisplay()
displays.value = res
displays.value = await Tutorial.listDisplay()
if (!displays.value.length) {
content.value = "暂无教程"
return