|
| 1 | +<template> |
| 2 | + <div :class="$style.docBeforeContainer"> |
| 3 | + <div :class="$style.leftArea"> |
| 4 | + <div |
| 5 | + :class="[$style.toggleSidebarBox, $style.pcOnly]" |
| 6 | + v-show="!isFullContentMode" |
| 7 | + > |
| 8 | + <ToggleSidebar /> |
| 9 | + </div> |
| 10 | + <div :class="[$style.vscodeBox, $style.pcOnly]" v-show="vscodeNotesDir"> |
| 11 | + <a |
| 12 | + :href="vscodeNotesDir" |
| 13 | + aria-label="open in vscode" |
| 14 | + title="open in vscode" |
| 15 | + target="_blank" |
| 16 | + > |
| 17 | + <img :src="icon__vscode" alt="open in vscode" /> |
| 18 | + </a> |
| 19 | + </div> |
| 20 | + <div :class="[$style.contentToggleBox, $style.pcOnly]"> |
| 21 | + <ToggleFullContent /> |
| 22 | + </div> |
| 23 | + <!-- 知识库的 GitHub 链接(仅首页显示,PC 端) --> |
| 24 | + <div :class="[$style.githubRepoBox, $style.pcOnly]" v-show="isHomeReadme"> |
| 25 | + <a |
| 26 | + :href="`https://github.com/tnotesjs/${vpData.page.value.title.toLowerCase()}/blob/main/README.md`" |
| 27 | + :aria-label="`tnotesjs github - ${vpData.page.value.title.toLowerCase()} 笔记仓库链接`" |
| 28 | + :title="`tnotesjs github - ${vpData.page.value.title.toLowerCase()} 笔记仓库链接`" |
| 29 | + target="_blank" |
| 30 | + rel="noopener" |
| 31 | + > |
| 32 | + <img :src="icon__github" alt="github icon" /> |
| 33 | + </a> |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + <div :class="$style.rightArea"> |
| 37 | + <!-- 全局折叠/展开按钮 --> |
| 38 | + <div |
| 39 | + :class="$style.collapseAllBtn" |
| 40 | + v-show="currentNoteId || isHomeReadme" |
| 41 | + > |
| 42 | + <button |
| 43 | + :class="$style.collapseAllButton" |
| 44 | + @click="toggleAllCollapse" |
| 45 | + :title="allCollapsed ? '展开所有区域' : '折叠所有区域'" |
| 46 | + type="button" |
| 47 | + > |
| 48 | + <img :src="icon__fold" alt="collapse all" /> |
| 49 | + </button> |
| 50 | + </div> |
| 51 | + <!-- 单个图标,点击打开 modal,只在有笔记数据的页面显示 --> |
| 52 | + <div |
| 53 | + :class="$style.aboutBtn" |
| 54 | + v-show=" |
| 55 | + (currentNoteId && created_at && updated_at) || |
| 56 | + (isHomeReadme && homeReadmeCreatedAt && homeReadmeUpdatedAt) |
| 57 | + " |
| 58 | + > |
| 59 | + <button |
| 60 | + :class="$style.aboutIconButton" |
| 61 | + @click="$emit('open-time-modal')" |
| 62 | + aria-haspopup="dialog" |
| 63 | + :aria-expanded="timeModalOpen.toString()" |
| 64 | + :title="isHomeReadme ? '关于这个知识库' : '关于这篇笔记'" |
| 65 | + type="button" |
| 66 | + > |
| 67 | + ! |
| 68 | + </button> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | +</template> |
| 73 | + |
| 74 | +<script setup lang="ts"> |
| 75 | +import { useData } from 'vitepress' |
| 76 | +import ToggleSidebar from './ToggleSidebar.vue' |
| 77 | +import ToggleFullContent from './ToggleFullContent.vue' |
| 78 | +
|
| 79 | +import icon__github from '/icon__github.svg' |
| 80 | +import icon__vscode from '/icon__vscode.svg' |
| 81 | +import icon__fold from '/icon__fold.svg' |
| 82 | +
|
| 83 | +const props = defineProps<{ |
| 84 | + isFullContentMode: boolean |
| 85 | + vscodeNotesDir: string |
| 86 | + isHomeReadme: boolean |
| 87 | + currentNoteId: string | null |
| 88 | + created_at: string | undefined |
| 89 | + updated_at: string | undefined |
| 90 | + homeReadmeCreatedAt: string | undefined |
| 91 | + homeReadmeUpdatedAt: string | undefined |
| 92 | + timeModalOpen: boolean |
| 93 | + allCollapsed: boolean |
| 94 | +}>() |
| 95 | +
|
| 96 | +const emit = defineEmits<{ |
| 97 | + (e: 'open-time-modal'): void |
| 98 | + (e: 'toggle-all-collapse'): void |
| 99 | +}>() |
| 100 | +
|
| 101 | +const vpData = useData() |
| 102 | +
|
| 103 | +function toggleAllCollapse() { |
| 104 | + emit('toggle-all-collapse') |
| 105 | +} |
| 106 | +</script> |
| 107 | + |
| 108 | +<style module src="./Layout.module.scss"></style> |
0 commit comments