-
-
- 缠论研习社
- 专注缠论的系统性研习
-
-
-
-
© {{ year }} 缠论研习社 · 内容仅供学习研究
diff --git a/src/main.ts b/src/main.ts
index 75e2069..065c203 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -4,6 +4,7 @@ import App from './App.vue'
import router from './router'
import { useThemeStore } from './stores/theme'
import { useReadingStore } from './stores/reading'
+import { useRecentsStore } from './stores/recents'
import 'remixicon/fonts/remixicon.css'
import './style.css'
@@ -11,8 +12,9 @@ const app = createApp(App)
app.use(createPinia())
app.use(router)
-// 在挂载前初始化持久化状态(主题、阅读偏好)
+// 在挂载前初始化持久化状态(主题、阅读偏好、最近阅读)
useThemeStore().init()
useReadingStore().init()
+useRecentsStore().init()
app.mount('#app')
diff --git a/src/stores/recents.ts b/src/stores/recents.ts
new file mode 100644
index 0000000..360f14c
--- /dev/null
+++ b/src/stores/recents.ts
@@ -0,0 +1,50 @@
+import { defineStore } from 'pinia'
+import { ref } from 'vue'
+import type { ArticleCategory } from '@/types/article'
+
+/** 最近阅读记录(持久化到 localStorage,供首页 / 目录页快速跳转) */
+export interface RecentEntry {
+ category: ArticleCategory
+ slug: string
+ /** 访问时间戳(ms) */
+ visitedAt: number
+}
+
+const STORAGE_KEY = 'chan-recents'
+
+/**
+ * 最近阅读:只记最近一次打开的文章。
+ * 仅缠论课程会写入(由调用方 ArticleReaderView 按分类过滤),所以展示时直接取 latest。
+ */
+export const useRecentsStore = defineStore('recents', () => {
+ /** 最近一次打开的文章;首次访问或被清空时为 null */
+ const latest = ref(null)
+
+ function init() {
+ try {
+ const raw = localStorage.getItem(STORAGE_KEY)
+ if (raw) latest.value = JSON.parse(raw) as RecentEntry
+ } catch {
+ latest.value = null
+ }
+ }
+
+ function persist() {
+ if (latest.value) localStorage.setItem(STORAGE_KEY, JSON.stringify(latest.value))
+ else localStorage.removeItem(STORAGE_KEY)
+ }
+
+ /** 记录一次访问(调用方负责仅写入缠论分类) */
+ function visit(category: ArticleCategory, slug: string) {
+ if (!category || !slug) return
+ latest.value = { category, slug, visitedAt: Date.now() }
+ persist()
+ }
+
+ function clear() {
+ latest.value = null
+ persist()
+ }
+
+ return { latest, init, visit, clear }
+})
diff --git a/src/style.css b/src/style.css
index 66ebea2..80d0d84 100644
--- a/src/style.css
+++ b/src/style.css
@@ -146,6 +146,18 @@
transition: background-color 0.3s var(--ease-soft), color 0.3s var(--ease-soft);
}
+ /* 按钮与可点击元素:悬停统一为手型,禁用时为禁止符
+ (原生
+
+
+
+
+
+
+
+
+ 最近阅读
+ ·
+ {{ recentRelative }}
+
+
+
+ 第 {{ recentArticle.lesson }} 课
+
+
+ {{ recentArticle?.title }}
+
+
+
点击继续阅读
+
+
+
+
+