You've already forked SmartisanNote.Remake
优化 时间显示格式调整
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import * as storage from '../utils/storage'
|
||||
import { getCurrentDateTime, getPastDate } from '../utils/dateUtils'
|
||||
|
||||
export const useAppStore = defineStore('app', {
|
||||
state: () => ({
|
||||
@@ -41,14 +42,21 @@ export const useAppStore = defineStore('app', {
|
||||
|
||||
// 加载mock数据
|
||||
async loadMockData() {
|
||||
// Mock notes
|
||||
// Mock notes - 使用固定的日期值以避免每次运行时变化
|
||||
const fixedCurrentDate = '2025-10-12T10:00:00.000Z';
|
||||
const fixedYesterday = '2025-10-11T10:00:00.000Z';
|
||||
const fixedTwoDaysAgo = '2025-10-10T10:00:00.000Z';
|
||||
const fixedThreeDaysAgo = '2025-10-09T10:00:00.000Z';
|
||||
const fixedFourDaysAgo = '2025-10-08T10:00:00.000Z';
|
||||
const fixedFiveDaysAgo = '2025-10-07T10:00:00.000Z';
|
||||
|
||||
const mockNotes = [
|
||||
{
|
||||
id: '1',
|
||||
title: '欢迎使用锤子便签',
|
||||
content: '这是一个功能强大的便签应用,您可以在这里记录您的想法、待办事项等。',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
createdAt: fixedCurrentDate,
|
||||
updatedAt: fixedCurrentDate,
|
||||
folderId: null,
|
||||
isStarred: true,
|
||||
isTop: true,
|
||||
@@ -60,8 +68,8 @@ export const useAppStore = defineStore('app', {
|
||||
id: '2',
|
||||
title: '待办事项',
|
||||
content: '1. 完成项目报告\n2. 购买 groceries\n3. 预约医生\n4. 给朋友打电话',
|
||||
createdAt: new Date(Date.now() - 86400000).toISOString(), // 昨天
|
||||
updatedAt: new Date(Date.now() - 86400000).toISOString(),
|
||||
createdAt: fixedYesterday,
|
||||
updatedAt: fixedYesterday,
|
||||
folderId: null,
|
||||
isStarred: true,
|
||||
isTop: false,
|
||||
@@ -73,8 +81,8 @@ export const useAppStore = defineStore('app', {
|
||||
id: '3',
|
||||
title: '购物清单',
|
||||
content: '苹果\n牛奶\n面包\n鸡蛋\n西红柿\n咖啡',
|
||||
createdAt: new Date(Date.now() - 172800000).toISOString(), // 前天
|
||||
updatedAt: new Date(Date.now() - 172800000).toISOString(),
|
||||
createdAt: fixedTwoDaysAgo,
|
||||
updatedAt: fixedTwoDaysAgo,
|
||||
folderId: null,
|
||||
isStarred: false,
|
||||
isTop: false,
|
||||
@@ -86,8 +94,8 @@ export const useAppStore = defineStore('app', {
|
||||
id: '4',
|
||||
title: '项目想法',
|
||||
content: '1. 实现云同步功能\n2. 添加深色模式\n3. 支持Markdown语法\n4. 添加标签功能',
|
||||
createdAt: new Date(Date.now() - 259200000).toISOString(), // 3天前
|
||||
updatedAt: new Date(Date.now() - 259200000).toISOString(),
|
||||
createdAt: fixedThreeDaysAgo,
|
||||
updatedAt: fixedThreeDaysAgo,
|
||||
folderId: null,
|
||||
isStarred: false,
|
||||
isTop: false,
|
||||
@@ -99,8 +107,8 @@ export const useAppStore = defineStore('app', {
|
||||
id: '5',
|
||||
title: '读书笔记',
|
||||
content: '《Vue.js实战》\n- 组件化思想是Vue的核心\n- 理解响应式原理很重要\n- Pinia是Vue 3的推荐状态管理库',
|
||||
createdAt: new Date(Date.now() - 345600000).toISOString(), // 4天前
|
||||
updatedAt: new Date(Date.now() - 345600000).toISOString(),
|
||||
createdAt: fixedFourDaysAgo,
|
||||
updatedAt: fixedFourDaysAgo,
|
||||
folderId: null,
|
||||
isStarred: false,
|
||||
isTop: false,
|
||||
@@ -112,33 +120,33 @@ export const useAppStore = defineStore('app', {
|
||||
id: '6',
|
||||
title: '已删除的便签',
|
||||
content: '这是一条已删除的便签示例,应该只在回收站中显示。',
|
||||
createdAt: new Date(Date.now() - 432000000).toISOString(), // 5天前
|
||||
updatedAt: new Date(Date.now() - 432000000).toISOString(),
|
||||
createdAt: fixedFiveDaysAgo,
|
||||
updatedAt: fixedFiveDaysAgo,
|
||||
folderId: null,
|
||||
isStarred: false,
|
||||
isTop: false,
|
||||
hasImage: false,
|
||||
isDeleted: true,
|
||||
deletedAt: new Date(Date.now() - 86400000).toISOString(), // 1天前删除
|
||||
deletedAt: fixedYesterday,
|
||||
},
|
||||
]
|
||||
|
||||
// Mock folders
|
||||
// Mock folders - 使用固定的日期值
|
||||
const mockFolders = [
|
||||
{
|
||||
id: 'folder1',
|
||||
name: '工作',
|
||||
createdAt: new Date().toISOString(),
|
||||
createdAt: '2025-10-12T10:00:00.000Z',
|
||||
},
|
||||
{
|
||||
id: 'folder2',
|
||||
name: '个人',
|
||||
createdAt: new Date().toISOString(),
|
||||
createdAt: '2025-10-12T10:00:00.000Z',
|
||||
},
|
||||
{
|
||||
id: 'folder3',
|
||||
name: '学习',
|
||||
createdAt: new Date().toISOString(),
|
||||
createdAt: '2025-10-12T10:00:00.000Z',
|
||||
},
|
||||
]
|
||||
|
||||
@@ -229,7 +237,7 @@ export const useAppStore = defineStore('app', {
|
||||
// 将便签移至回收站
|
||||
async moveToTrash(id) {
|
||||
try {
|
||||
const updatedNote = await storage.updateNote(id, { isDeleted: true, deletedAt: new Date().toISOString() })
|
||||
const updatedNote = await storage.updateNote(id, { isDeleted: true, deletedAt: getCurrentDateTime() })
|
||||
if (updatedNote) {
|
||||
const index = this.notes.findIndex(note => note.id === id)
|
||||
if (index !== -1) {
|
||||
|
||||
Reference in New Issue
Block a user