@tnotesjs/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @tnotesjs/core might be problematic. Click here for more details.
- package/README.md +105 -0
- package/dist/chunk-K3X5OP3N.js +1532 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +4199 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +9 -0
- package/package.json +74 -0
- package/types/config.ts +61 -0
- package/types/index.ts +11 -0
- package/types/note.ts +33 -0
- package/vitepress/assets/icons/icon__check.svg +3 -0
- package/vitepress/assets/icons/icon__clipboard.svg +8 -0
- package/vitepress/assets/icons/icon__close.svg +1 -0
- package/vitepress/assets/icons/icon__collapse.svg +1 -0
- package/vitepress/assets/icons/icon__confirm.svg +1 -0
- package/vitepress/assets/icons/icon__copy.svg +4 -0
- package/vitepress/assets/icons/icon__focus.svg +1 -0
- package/vitepress/assets/icons/icon__fold.svg +3 -0
- package/vitepress/assets/icons/icon__folder.svg +1 -0
- package/vitepress/assets/icons/icon__fullscreen.svg +1 -0
- package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -0
- package/vitepress/assets/icons/icon__github.svg +4 -0
- package/vitepress/assets/icons/icon__mindmap.svg +1 -0
- package/vitepress/assets/icons/icon__next.svg +1 -0
- package/vitepress/assets/icons/icon__number_gray.svg +1 -0
- package/vitepress/assets/icons/icon__number_purple.svg +1 -0
- package/vitepress/assets/icons/icon__prev.svg +1 -0
- package/vitepress/assets/icons/icon__restore.svg +1 -0
- package/vitepress/assets/icons/icon__rotate.svg +4 -0
- package/vitepress/assets/icons/icon__search.svg +1 -0
- package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -0
- package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -0
- package/vitepress/assets/icons/icon__totop.svg +6 -0
- package/vitepress/assets/icons/icon__vscode.svg +6 -0
- package/vitepress/assets/icons/icon__zoom_fit.svg +1 -0
- package/vitepress/assets/icons/icon__zoom_in.svg +1 -0
- package/vitepress/assets/icons/icon__zoom_out.svg +1 -0
- package/vitepress/assets/icons/icon__zoom_reset.svg +1 -0
- package/vitepress/assets/icons/index.ts +38 -0
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -0
- package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +373 -0
- package/vitepress/components/CodeBlockFullscreen/index.ts +115 -0
- package/vitepress/components/CodeBlockFullscreen/styles.css +64 -0
- package/vitepress/components/Discussions/Discussions.module.scss +32 -0
- package/vitepress/components/Discussions/Discussions.vue +211 -0
- package/vitepress/components/EnWordList/EnWordList.module.scss +124 -0
- package/vitepress/components/EnWordList/EnWordList.vue +543 -0
- package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -0
- package/vitepress/components/EnWordList/RightClickMenu.vue +66 -0
- package/vitepress/components/Footprints/Footprints.module.scss +93 -0
- package/vitepress/components/Footprints/Footprints.vue +377 -0
- package/vitepress/components/Layout/AboutModal.module.scss +233 -0
- package/vitepress/components/Layout/AboutModal.vue +105 -0
- package/vitepress/components/Layout/AboutPanel.vue +266 -0
- package/vitepress/components/Layout/ContentCollapse.vue +603 -0
- package/vitepress/components/Layout/CustomSidebar.vue +605 -0
- package/vitepress/components/Layout/DocBeforeControls.vue +139 -0
- package/vitepress/components/Layout/DocFooter.vue +225 -0
- package/vitepress/components/Layout/ImagePreview.module.scss +201 -0
- package/vitepress/components/Layout/ImagePreview.vue +281 -0
- package/vitepress/components/Layout/Layout.module.scss +661 -0
- package/vitepress/components/Layout/Layout.vue +542 -0
- package/vitepress/components/Layout/NoteStatus.vue +140 -0
- package/vitepress/components/Layout/SidebarItems.vue +263 -0
- package/vitepress/components/Layout/SidebarNavBefore.vue +92 -0
- package/vitepress/components/Layout/Swiper.vue +167 -0
- package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -0
- package/vitepress/components/Layout/ToggleFullContent.vue +34 -0
- package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -0
- package/vitepress/components/Layout/ToggleSidebar.vue +35 -0
- package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -0
- package/vitepress/components/Layout/composables/useNoteConfig.ts +121 -0
- package/vitepress/components/Layout/composables/useNoteSave.ts +173 -0
- package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -0
- package/vitepress/components/Layout/composables/useRedirect.ts +110 -0
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -0
- package/vitepress/components/Layout/homeReadme.data.ts +124 -0
- package/vitepress/components/LoadingPage/LoadingPage.vue +192 -0
- package/vitepress/components/MarkMap/MarkMap.module.scss +159 -0
- package/vitepress/components/MarkMap/MarkMap.vue +404 -0
- package/vitepress/components/Mermaid/Mermaid.module.scss +275 -0
- package/vitepress/components/Mermaid/Mermaid.vue +364 -0
- package/vitepress/components/NotesTable/NotesTable.module.scss +77 -0
- package/vitepress/components/NotesTable/NotesTable.vue +98 -0
- package/vitepress/components/NotesTable/README.md +67 -0
- package/vitepress/components/Settings/Settings.module.scss +433 -0
- package/vitepress/components/Settings/Settings.vue +306 -0
- package/vitepress/components/SidebarCard/MindMapView.vue +483 -0
- package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -0
- package/vitepress/components/SidebarCard/SidebarCard.vue +948 -0
- package/vitepress/components/Tooltip/Tooltip.vue +70 -0
- package/vitepress/components/constants.ts +91 -0
- package/vitepress/components/notesConfig.data.ts +73 -0
- package/vitepress/components/sidebar.data.ts +59 -0
- package/vitepress/components/tnotes-config.data.ts +21 -0
- package/vitepress/components/utils.ts +26 -0
- package/vitepress/config/index.ts +126 -0
- package/vitepress/configs/constants.ts +26 -0
- package/vitepress/configs/head.config.ts +25 -0
- package/vitepress/configs/index.ts +9 -0
- package/vitepress/configs/markdown-it.d.ts +23 -0
- package/vitepress/configs/markdown.config.ts +366 -0
- package/vitepress/configs/theme.config.ts +108 -0
- package/vitepress/plugins/buildProgressPlugin.ts +390 -0
- package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -0
- package/vitepress/plugins/renameNotePlugin.ts +60 -0
- package/vitepress/plugins/updateConfigPlugin.ts +63 -0
- package/vitepress/theme/index.ts +95 -0
- package/vitepress/theme/styles/base.scss +50 -0
- package/vitepress/theme/styles/components/404.scss +31 -0
- package/vitepress/theme/styles/components/collapse.scss +175 -0
- package/vitepress/theme/styles/components/markmap.scss +101 -0
- package/vitepress/theme/styles/components/swiper.scss +255 -0
- package/vitepress/theme/styles/index.scss +25 -0
- package/vitepress/theme/styles/layout.scss +62 -0
- package/vitepress/theme/styles/utilities.scss +39 -0
- package/vitepress/theme/styles/vitepress-override.scss +25 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Footprints 组件样式
|
|
2
|
+
|
|
3
|
+
// 其他信息容器和时间容器
|
|
4
|
+
.otherInfoContainer,
|
|
5
|
+
.timeContainer {
|
|
6
|
+
font-size: 0.8rem;
|
|
7
|
+
color: gray;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// 文本容器
|
|
11
|
+
.textContainer {
|
|
12
|
+
position: relative;
|
|
13
|
+
margin-bottom: 1rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 文本内容
|
|
17
|
+
.textContent {
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
transition: max-height 0.3s ease;
|
|
20
|
+
|
|
21
|
+
// 折叠状态:隐藏从第三个开始的所有一级子元素
|
|
22
|
+
&.collapsed > :nth-child(n + 3) {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 切换按钮
|
|
28
|
+
.toggleButton {
|
|
29
|
+
display: block;
|
|
30
|
+
margin-top: 0.5rem;
|
|
31
|
+
background-color: transparent;
|
|
32
|
+
color: #007bff;
|
|
33
|
+
border: none;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
text-align: left;
|
|
36
|
+
font-size: 1rem;
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
text-decoration: underline;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 图片容器
|
|
44
|
+
.imageContainer {
|
|
45
|
+
display: flex;
|
|
46
|
+
width: 100%;
|
|
47
|
+
flex-wrap: wrap;
|
|
48
|
+
|
|
49
|
+
img {
|
|
50
|
+
width: calc(33.33% - 10px);
|
|
51
|
+
aspect-ratio: 1; // 设置宽高比为 1:1
|
|
52
|
+
object-fit: cover;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
margin: 0.3rem;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 模态框
|
|
59
|
+
.modal {
|
|
60
|
+
display: flex;
|
|
61
|
+
position: fixed;
|
|
62
|
+
z-index: 1000;
|
|
63
|
+
left: 0;
|
|
64
|
+
top: 0;
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 100%;
|
|
67
|
+
overflow: auto;
|
|
68
|
+
background-color: rgba(0, 0, 0, 1);
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 模态框内容(图片)
|
|
74
|
+
.modalContent {
|
|
75
|
+
position: absolute;
|
|
76
|
+
top: 50%;
|
|
77
|
+
left: 50%;
|
|
78
|
+
transform: translate(-50%, -50%);
|
|
79
|
+
max-width: 90%;
|
|
80
|
+
max-height: 90%;
|
|
81
|
+
cursor: grab;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 关闭按钮
|
|
85
|
+
.close {
|
|
86
|
+
position: absolute;
|
|
87
|
+
top: 20px;
|
|
88
|
+
right: 30px;
|
|
89
|
+
color: white;
|
|
90
|
+
font-size: 30px;
|
|
91
|
+
font-weight: bold;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, onMounted, onBeforeUnmount, computed, nextTick } from 'vue'
|
|
3
|
+
|
|
4
|
+
// ----------------------------------------------------------
|
|
5
|
+
// #region - 图片处理
|
|
6
|
+
// ----------------------------------------------------------
|
|
7
|
+
/**
|
|
8
|
+
* 获取图片容器的 DOM 引用
|
|
9
|
+
*/
|
|
10
|
+
const imageContainer = ref(null)
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 动态存储图片路径的列表
|
|
14
|
+
*/
|
|
15
|
+
const images = ref([])
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 控制 modal 显示
|
|
19
|
+
*/
|
|
20
|
+
const isModalVisible = ref(false)
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 当前预览的图片索引
|
|
24
|
+
*/
|
|
25
|
+
const currentIndex = ref(0)
|
|
26
|
+
const currentImage = computed(() => images.value[currentIndex.value])
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 唯一标识符,用于区分不同的组件实例。
|
|
30
|
+
* 解决被多次复用的时候,直接操作 DOM 的相关逻辑出现 bug。
|
|
31
|
+
*/
|
|
32
|
+
const instanceId = Math.random().toString(36).substr(2, 9)
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 打开模态框
|
|
36
|
+
* @param index 需要展示的图片的索引
|
|
37
|
+
*/
|
|
38
|
+
const openModal = (index) => {
|
|
39
|
+
currentIndex.value = index
|
|
40
|
+
isModalVisible.value = true
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 关闭模态框
|
|
44
|
+
*/
|
|
45
|
+
const closeModal = () => (isModalVisible.value = false)
|
|
46
|
+
/**
|
|
47
|
+
* 键盘事件处理
|
|
48
|
+
* @param event 事件对象
|
|
49
|
+
*/
|
|
50
|
+
const handleKeyDown = (event) => {
|
|
51
|
+
if (!isModalVisible.value) return
|
|
52
|
+
switch (event.key) {
|
|
53
|
+
case 'ArrowLeft':
|
|
54
|
+
if (currentIndex.value > 0) currentIndex.value -= 1
|
|
55
|
+
break
|
|
56
|
+
case 'ArrowRight':
|
|
57
|
+
if (currentIndex.value < images.value.length - 1) currentIndex.value += 1
|
|
58
|
+
break
|
|
59
|
+
case 'Escape':
|
|
60
|
+
closeModal()
|
|
61
|
+
break
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 手指按下的初始 X 坐标
|
|
66
|
+
*/
|
|
67
|
+
let touchStartX = 0
|
|
68
|
+
/**
|
|
69
|
+
* 手指抬起的最终 X 坐标
|
|
70
|
+
*/
|
|
71
|
+
let touchEndX = 0
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 处理触摸开始事件
|
|
75
|
+
* @param event 事件对象
|
|
76
|
+
*/
|
|
77
|
+
const handleTouchStart = (event) => {
|
|
78
|
+
event.preventDefault() // 阻止默认行为
|
|
79
|
+
touchStartX = event.touches[0].clientX // 记录手指按下的初始位置
|
|
80
|
+
// console.log(`Touch start at: ${touchStartX}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 处理触摸移动事件
|
|
85
|
+
* @param event 事件对象
|
|
86
|
+
*/
|
|
87
|
+
const handleTouchMove = (event) => {
|
|
88
|
+
event.preventDefault() // 阻止默认行为
|
|
89
|
+
const currentX = event.touches[0].clientX
|
|
90
|
+
const moveDistance = currentX - touchStartX
|
|
91
|
+
|
|
92
|
+
// 可选:添加视觉反馈(例如轻微移动图片的位置)
|
|
93
|
+
// console.log(`Move distance: ${moveDistance}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 处理触摸结束事件
|
|
98
|
+
* - 向右滑动:切换到上一张图片
|
|
99
|
+
* - 向左滑动:切换到下一张图片
|
|
100
|
+
*/
|
|
101
|
+
const handleTouchEnd = () => {
|
|
102
|
+
const swipeThreshold = 50 // 滑动阈值,单位为像素
|
|
103
|
+
const swipeDistance = touchEndX - touchStartX // 计算滑动距离
|
|
104
|
+
console.log(`Touch end at: ${touchEndX}, Distance: ${swipeDistance}`)
|
|
105
|
+
|
|
106
|
+
if (swipeDistance > swipeThreshold && currentIndex.value > 0) {
|
|
107
|
+
currentIndex.value--
|
|
108
|
+
} else if (
|
|
109
|
+
swipeDistance < -swipeThreshold &&
|
|
110
|
+
currentIndex.value < images.value.length - 1
|
|
111
|
+
) {
|
|
112
|
+
currentIndex.value++
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 鼠标按下的初始 X 坐标
|
|
117
|
+
*/
|
|
118
|
+
let mouseStartX = 0
|
|
119
|
+
/**
|
|
120
|
+
* 处理鼠标按下事件
|
|
121
|
+
* @param event 事件对象
|
|
122
|
+
*/
|
|
123
|
+
const handleMouseDown = (event) => {
|
|
124
|
+
event.preventDefault()
|
|
125
|
+
mouseStartX = event.clientX // 记录鼠标按下的初始位置
|
|
126
|
+
window.addEventListener('mousemove', handleMouseMove)
|
|
127
|
+
window.addEventListener('mouseup', handleMouseUp)
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 处理鼠标移动事件
|
|
131
|
+
* @param event 事件对象
|
|
132
|
+
*/
|
|
133
|
+
const handleMouseMove = (event) => {
|
|
134
|
+
event.preventDefault()
|
|
135
|
+
const currentX = event.clientX
|
|
136
|
+
const moveDistance = currentX - mouseStartX
|
|
137
|
+
// 可以在这里添加一些视觉反馈,比如轻微移动图片的位置
|
|
138
|
+
// console.log(`Move distance: ${moveDistance}`);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 处理鼠标松开事件
|
|
142
|
+
*/
|
|
143
|
+
const handleMouseUp = () => {
|
|
144
|
+
const swipeThreshold = 50 // 滑动阈值,单位为像素
|
|
145
|
+
const modalContent = document.querySelector('.__dynamic__modal-content')
|
|
146
|
+
if (!modalContent) return
|
|
147
|
+
|
|
148
|
+
// 使用鼠标松开时的位置
|
|
149
|
+
const currentX = event.clientX // 直接从事件对象中获取
|
|
150
|
+
const moveDistance = currentX - mouseStartX
|
|
151
|
+
|
|
152
|
+
if (moveDistance > swipeThreshold && currentIndex.value > 0) {
|
|
153
|
+
currentIndex.value-- // 向右滑动,切换到上一张图片
|
|
154
|
+
} else if (
|
|
155
|
+
moveDistance < -swipeThreshold &&
|
|
156
|
+
currentIndex.value < images.value.length - 1
|
|
157
|
+
) {
|
|
158
|
+
currentIndex.value++ // 向左滑动,切换到下一张图片
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 清理变量和事件监听器
|
|
162
|
+
mouseStartX = 0
|
|
163
|
+
window.removeEventListener('mousemove', handleMouseMove)
|
|
164
|
+
window.removeEventListener('mouseup', handleMouseUp)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
onMounted(() => {
|
|
168
|
+
const imgElements = imageContainer.value.querySelectorAll('img')
|
|
169
|
+
images.value = Array.from(imgElements).map((img) => img.src)
|
|
170
|
+
|
|
171
|
+
// 添加键盘事件监听器
|
|
172
|
+
window.addEventListener('keydown', handleKeyDown)
|
|
173
|
+
|
|
174
|
+
// 添加触摸事件监听器
|
|
175
|
+
const modalContent = document.querySelector(
|
|
176
|
+
`.__dynamic__modal-content-${instanceId}`
|
|
177
|
+
)
|
|
178
|
+
if (modalContent) {
|
|
179
|
+
modalContent.addEventListener('touchstart', handleTouchStart)
|
|
180
|
+
modalContent.addEventListener('touchmove', handleTouchMove) // 绑定 touchmove 事件
|
|
181
|
+
modalContent.addEventListener('touchend', (event) => {
|
|
182
|
+
touchEndX = event.changedTouches[0].clientX // 记录手指抬起的最终位置
|
|
183
|
+
handleTouchEnd()
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
// 添加鼠标事件监听器
|
|
187
|
+
modalContent.addEventListener('mousedown', handleMouseDown)
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
onBeforeUnmount(() => {
|
|
192
|
+
window.removeEventListener('keydown', handleKeyDown)
|
|
193
|
+
|
|
194
|
+
// 移除触摸事件监听器
|
|
195
|
+
const modalContent = document.querySelector(
|
|
196
|
+
`.__dynamic__modal-content-${instanceId}`
|
|
197
|
+
)
|
|
198
|
+
if (modalContent) {
|
|
199
|
+
modalContent.removeEventListener('touchstart', handleTouchStart)
|
|
200
|
+
modalContent.removeEventListener('touchmove', handleTouchMove) // 移除 touchmove 事件
|
|
201
|
+
modalContent.removeEventListener('touchend', handleTouchEnd)
|
|
202
|
+
modalContent.removeEventListener('mousedown', handleMouseDown)
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
// ----------------------------------------------------------
|
|
206
|
+
// #endregion - 图片处理
|
|
207
|
+
// ----------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
// ----------------------------------------------------------
|
|
210
|
+
// #region - 文案处理
|
|
211
|
+
// ----------------------------------------------------------
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 文本容器的 DOM 引用
|
|
215
|
+
*/
|
|
216
|
+
const textContainer = ref(null)
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 控制文本是否折叠
|
|
220
|
+
*/
|
|
221
|
+
const isCollapsed = ref(true)
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 是否需要显示“全文”按钮
|
|
225
|
+
*/
|
|
226
|
+
const isExpandable = ref(false)
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 计算一级子元素数量并判断是否需要折叠
|
|
230
|
+
* 1. 获取所有一级子元素
|
|
231
|
+
* 2. 如果一级子元素数量大于 2,则可以展开
|
|
232
|
+
*/
|
|
233
|
+
const checkChildElementCount = () => {
|
|
234
|
+
if (textContainer.value) {
|
|
235
|
+
const childElements = textContainer.value.children
|
|
236
|
+
isExpandable.value = childElements.length > 2
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 切换折叠/展开状态
|
|
242
|
+
*/
|
|
243
|
+
const toggleCollapse = () => {
|
|
244
|
+
isCollapsed.value = !isCollapsed.value
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 在 DOM 渲染后再做计算
|
|
249
|
+
*/
|
|
250
|
+
onMounted(() => {
|
|
251
|
+
nextTick(checkChildElementCount)
|
|
252
|
+
})
|
|
253
|
+
// ----------------------------------------------------------
|
|
254
|
+
// #endregion - 文案处理
|
|
255
|
+
// ----------------------------------------------------------
|
|
256
|
+
|
|
257
|
+
// ----------------------------------------------------------
|
|
258
|
+
// #region - 时间信息处理
|
|
259
|
+
// ----------------------------------------------------------
|
|
260
|
+
const props = defineProps({
|
|
261
|
+
times: {
|
|
262
|
+
type: Array,
|
|
263
|
+
default: () => [],
|
|
264
|
+
validator: (value) => {
|
|
265
|
+
// 验证数组长度和内容类型
|
|
266
|
+
return (
|
|
267
|
+
value.length >= 2 &&
|
|
268
|
+
value.length <= 6 &&
|
|
269
|
+
value.every((item, index) => {
|
|
270
|
+
if (index === 0) return typeof item === 'number' && item >= 0 // 年
|
|
271
|
+
if (index === 1)
|
|
272
|
+
return typeof item === 'number' && item >= 1 && item <= 12 // 月
|
|
273
|
+
if (index === 2)
|
|
274
|
+
return typeof item === 'number' && item >= 1 && item <= 31 // 日
|
|
275
|
+
if (index === 3)
|
|
276
|
+
return typeof item === 'number' && item >= 0 && item <= 23 // 小时
|
|
277
|
+
if (index === 4)
|
|
278
|
+
return typeof item === 'number' && item >= 0 && item <= 59 // 分钟
|
|
279
|
+
if (index === 5)
|
|
280
|
+
return typeof item === 'number' && item >= 0 && item <= 59 // 秒
|
|
281
|
+
return false
|
|
282
|
+
})
|
|
283
|
+
)
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
const formattedTime = computed(() => {
|
|
289
|
+
if (props.times.length < 2) return ''
|
|
290
|
+
|
|
291
|
+
const [year, month, day, hour, minute, second] = props.times
|
|
292
|
+
|
|
293
|
+
// 格式化年月日
|
|
294
|
+
const datePart = `${String(year).padStart(4, '0')}-${String(month).padStart(
|
|
295
|
+
2,
|
|
296
|
+
'0'
|
|
297
|
+
)}`
|
|
298
|
+
const dayPart = day !== undefined ? `-${String(day).padStart(2, '0')}` : ''
|
|
299
|
+
|
|
300
|
+
// 格式化时分秒
|
|
301
|
+
let timePart = ''
|
|
302
|
+
if (hour !== undefined && minute !== undefined && second !== undefined) {
|
|
303
|
+
timePart = ` ${String(hour).padStart(2, '0')}:${String(minute).padStart(
|
|
304
|
+
2,
|
|
305
|
+
'0'
|
|
306
|
+
)}:${String(second).padStart(2, '0')}`
|
|
307
|
+
} else if (hour !== undefined && minute !== undefined) {
|
|
308
|
+
timePart = ` ${String(hour).padStart(2, '0')}:${String(minute).padStart(
|
|
309
|
+
2,
|
|
310
|
+
'0'
|
|
311
|
+
)}`
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// 👣 天数
|
|
315
|
+
let daysSinceBirthday = ''
|
|
316
|
+
if (day !== undefined) {
|
|
317
|
+
// 确保时间部分为 00:00:00,避免时区和时间部分的影响
|
|
318
|
+
const birthday = new Date(Date.UTC(1999, 5, 29)) // 注意:月份从 0 开始计数
|
|
319
|
+
const currentDate = new Date(Date.UTC(year, month - 1, day)) // 同样使用 UTC 时间
|
|
320
|
+
const diffInMilliseconds = currentDate - birthday
|
|
321
|
+
const diffInDays =
|
|
322
|
+
Math.floor(diffInMilliseconds / (1000 * 60 * 60 * 24)) + 1
|
|
323
|
+
daysSinceBirthday = `👣 ${diffInDays} | `
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return daysSinceBirthday + datePart + dayPart + timePart
|
|
327
|
+
})
|
|
328
|
+
// ----------------------------------------------------------
|
|
329
|
+
// #endregion - 时间信息处理
|
|
330
|
+
// ----------------------------------------------------------
|
|
331
|
+
</script>
|
|
332
|
+
|
|
333
|
+
<template>
|
|
334
|
+
<div :class="$style.textContainer">
|
|
335
|
+
<div
|
|
336
|
+
:class="[$style.textContent, { [$style.collapsed]: isCollapsed }]"
|
|
337
|
+
ref="textContainer"
|
|
338
|
+
>
|
|
339
|
+
<slot name="text-area"></slot>
|
|
340
|
+
</div>
|
|
341
|
+
<button
|
|
342
|
+
v-if="isExpandable"
|
|
343
|
+
:class="$style.toggleButton"
|
|
344
|
+
@click="toggleCollapse"
|
|
345
|
+
>
|
|
346
|
+
{{ isCollapsed ? '全文' : '收起' }}
|
|
347
|
+
</button>
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
<div :class="$style.imageContainer" ref="imageContainer">
|
|
351
|
+
<slot
|
|
352
|
+
name="image-list"
|
|
353
|
+
:openModal="openModal"
|
|
354
|
+
:closeModal="closeModal"
|
|
355
|
+
:currentImage="currentImage"
|
|
356
|
+
:isModalVisible="isModalVisible"
|
|
357
|
+
></slot>
|
|
358
|
+
</div>
|
|
359
|
+
<div :class="$style.modal" v-show="isModalVisible" @click.self="closeModal">
|
|
360
|
+
<span :class="$style.close" @click="closeModal">×</span>
|
|
361
|
+
<img
|
|
362
|
+
:class="[$style.modalContent, `__dynamic__modal-content-${instanceId}`]"
|
|
363
|
+
:src="currentImage"
|
|
364
|
+
alt="Preview"
|
|
365
|
+
@mousedown="handleMouseDown"
|
|
366
|
+
/>
|
|
367
|
+
</div>
|
|
368
|
+
|
|
369
|
+
<div :class="$style.timeContainer">
|
|
370
|
+
<p>{{ formattedTime }}</p>
|
|
371
|
+
</div>
|
|
372
|
+
<div :class="$style.otherInfoContainer">
|
|
373
|
+
<slot name="other-info"></slot>
|
|
374
|
+
</div>
|
|
375
|
+
</template>
|
|
376
|
+
|
|
377
|
+
<style module src="./Footprints.module.scss"></style>
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// AboutModal 组件样式
|
|
2
|
+
|
|
3
|
+
// 模态框背景遮罩
|
|
4
|
+
.modalBackdrop {
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset: 0;
|
|
7
|
+
background: rgba(0, 0, 0, 0.75);
|
|
8
|
+
backdrop-filter: blur(4px);
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
z-index: 1200;
|
|
13
|
+
padding: 1rem;
|
|
14
|
+
animation: fadeIn 0.2s ease-out;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@keyframes fadeIn {
|
|
18
|
+
from {
|
|
19
|
+
opacity: 0;
|
|
20
|
+
}
|
|
21
|
+
to {
|
|
22
|
+
opacity: 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@keyframes slideUp {
|
|
27
|
+
from {
|
|
28
|
+
opacity: 0;
|
|
29
|
+
transform: translateY(20px);
|
|
30
|
+
}
|
|
31
|
+
to {
|
|
32
|
+
opacity: 1;
|
|
33
|
+
transform: translateY(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 模态框主体
|
|
38
|
+
.modal {
|
|
39
|
+
background: var(--vp-c-bg);
|
|
40
|
+
color: var(--vp-c-text-1);
|
|
41
|
+
border-radius: 16px;
|
|
42
|
+
max-width: 580px;
|
|
43
|
+
width: 100%;
|
|
44
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
|
|
45
|
+
0 0 0 1px rgba(255, 255, 255, 0.05);
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
outline: none;
|
|
48
|
+
animation: slideUp 0.3s ease-out;
|
|
49
|
+
|
|
50
|
+
// 暗色模式优化
|
|
51
|
+
:global(.dark) & {
|
|
52
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6),
|
|
53
|
+
0 0 0 1px rgba(255, 255, 255, 0.08);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 模态框头部
|
|
58
|
+
.modalHeader {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
padding: 1.25rem 1.5rem;
|
|
63
|
+
border-bottom: 1px solid var(--vp-c-divider);
|
|
64
|
+
background: linear-gradient(
|
|
65
|
+
180deg,
|
|
66
|
+
var(--vp-c-bg-soft) 0%,
|
|
67
|
+
var(--vp-c-bg) 100%
|
|
68
|
+
);
|
|
69
|
+
position: relative;
|
|
70
|
+
|
|
71
|
+
// 添加顶部装饰条
|
|
72
|
+
&::before {
|
|
73
|
+
content: '';
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: 0;
|
|
76
|
+
left: 0;
|
|
77
|
+
right: 0;
|
|
78
|
+
height: 3px;
|
|
79
|
+
background: linear-gradient(
|
|
80
|
+
90deg,
|
|
81
|
+
var(--vp-c-brand-1),
|
|
82
|
+
var(--vp-c-brand-2)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 模态框标题
|
|
88
|
+
.modalTitle {
|
|
89
|
+
margin: 0;
|
|
90
|
+
font-size: 1.125rem;
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
color: var(--vp-c-text-1);
|
|
93
|
+
letter-spacing: -0.01em;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
gap: 0.5rem;
|
|
97
|
+
|
|
98
|
+
// 添加图标装饰(可选,如果标题前有 emoji)
|
|
99
|
+
&::before {
|
|
100
|
+
content: '📝';
|
|
101
|
+
font-size: 1.25rem;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 关闭按钮
|
|
106
|
+
.closeBtn {
|
|
107
|
+
background: transparent;
|
|
108
|
+
border: none;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
font-size: 1.25rem;
|
|
111
|
+
line-height: 1;
|
|
112
|
+
padding: 0.5rem;
|
|
113
|
+
border-radius: 8px;
|
|
114
|
+
color: var(--vp-c-text-2);
|
|
115
|
+
transition: all 0.2s ease;
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
width: 32px;
|
|
120
|
+
height: 32px;
|
|
121
|
+
|
|
122
|
+
&:hover {
|
|
123
|
+
background: var(--vp-c-bg-soft);
|
|
124
|
+
color: var(--vp-c-text-1);
|
|
125
|
+
transform: rotate(90deg);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&:active {
|
|
129
|
+
transform: rotate(90deg) scale(0.95);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 模态框主体内容
|
|
134
|
+
.modalBody {
|
|
135
|
+
padding: 1.5rem;
|
|
136
|
+
font-size: 0.95rem;
|
|
137
|
+
color: var(--vp-c-text-2);
|
|
138
|
+
line-height: 1.7;
|
|
139
|
+
max-height: 60vh;
|
|
140
|
+
overflow-y: auto;
|
|
141
|
+
|
|
142
|
+
// 美化滚动条
|
|
143
|
+
&::-webkit-scrollbar {
|
|
144
|
+
width: 6px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&::-webkit-scrollbar-track {
|
|
148
|
+
background: transparent;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&::-webkit-scrollbar-thumb {
|
|
152
|
+
background: var(--vp-c-divider);
|
|
153
|
+
border-radius: 3px;
|
|
154
|
+
|
|
155
|
+
&:hover {
|
|
156
|
+
background: var(--vp-c-text-3);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 优化内容样式
|
|
161
|
+
p {
|
|
162
|
+
margin: 0.75rem 0;
|
|
163
|
+
|
|
164
|
+
&:first-child {
|
|
165
|
+
margin-top: 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&:last-child {
|
|
169
|
+
margin-bottom: 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 如果内容中有图标,增加间距
|
|
174
|
+
:deep(span) {
|
|
175
|
+
margin-right: 0.25rem;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 强调文本
|
|
179
|
+
strong {
|
|
180
|
+
color: var(--vp-c-text-1);
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// 链接样式
|
|
185
|
+
a {
|
|
186
|
+
color: var(--vp-c-brand-1);
|
|
187
|
+
text-decoration: none;
|
|
188
|
+
transition: color 0.2s;
|
|
189
|
+
|
|
190
|
+
&:hover {
|
|
191
|
+
color: var(--vp-c-brand-2);
|
|
192
|
+
text-decoration: underline;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 模态框底部(可选)
|
|
198
|
+
.modalFooter {
|
|
199
|
+
padding: 1rem 1.5rem;
|
|
200
|
+
border-top: 1px solid var(--vp-c-divider);
|
|
201
|
+
background: var(--vp-c-bg-soft);
|
|
202
|
+
text-align: right;
|
|
203
|
+
display: flex;
|
|
204
|
+
gap: 0.75rem;
|
|
205
|
+
justify-content: flex-end;
|
|
206
|
+
align-items: center;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 响应式优化
|
|
210
|
+
@media (max-width: 640px) {
|
|
211
|
+
.modal {
|
|
212
|
+
max-width: 100%;
|
|
213
|
+
margin: 1rem;
|
|
214
|
+
border-radius: 12px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.modalHeader {
|
|
218
|
+
padding: 1rem 1.25rem;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.modalTitle {
|
|
222
|
+
font-size: 1rem;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.modalBody {
|
|
226
|
+
padding: 1.25rem;
|
|
227
|
+
max-height: 50vh;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.modalFooter {
|
|
231
|
+
padding: 0.875rem 1.25rem;
|
|
232
|
+
}
|
|
233
|
+
}
|