Skip to content

Commit

Permalink
feat: 新建文章默认在标题跟随日期
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiuChen committed Apr 12, 2023
1 parent a53b639 commit c412b85
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hooks/useTreeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
RENAME_NODE,
CATEGORY_CHANGE
} from '@/common/symbol'
import { formatTime } from '@/utils'

const DEFAULT_FILE_NAME = '默认文章'
const DEFAULT_FOLDER_NAME = '新建文件夹'
Expand All @@ -35,7 +36,7 @@ export function useTreeData(activeNode: Ref<SidebarItem | null>, treeData: Ref<S
// 如果当前节点是文件夹 则添加到当前节点下
if (activeNode.value?.children) {
activeNode.value.children.push({
title: DEFAULT_FILE_NAME,
title: DEFAULT_FILE_NAME + `(${new Date(parseInt(key)).toLocaleDateString()})`,
key
})

Expand All @@ -50,7 +51,7 @@ export function useTreeData(activeNode: Ref<SidebarItem | null>, treeData: Ref<S
const parent = findParent(activeNode.value!.key, treeData.value)
if (parent.length) {
parent[0].children?.push({
title: DEFAULT_FILE_NAME,
title: DEFAULT_FILE_NAME + `(${new Date(parseInt(key)).toLocaleDateString()})`,
key
})

Expand Down

0 comments on commit c412b85

Please sign in to comment.