You've already forked SmartisanNote.Remake
移除便签中的标题概念
This commit is contained in:
@@ -3,11 +3,6 @@
|
||||
<div class="container">
|
||||
<Header :title="isEditing ? '编辑便签' : '新建便签'" :onBack="handleCancel" :onAction="handleSave" actionText="保存" />
|
||||
|
||||
<!-- 标题输入框 -->
|
||||
<div class="title-input-container">
|
||||
<input placeholder="标题" v-model="title" class="title-input" />
|
||||
</div>
|
||||
|
||||
<!-- 富文本编辑器 -->
|
||||
<div class="editor-container">
|
||||
<RichTextEditor ref="editorRef" v-model="content" class="rich-text-editor" />
|
||||
@@ -64,7 +59,6 @@ const isEditing = !!props.noteId
|
||||
const existingNote = isEditing ? store.notes.find(n => n.id === props.noteId) : null
|
||||
|
||||
// Initialize state with existing note data or empty strings
|
||||
const title = ref(existingNote?.title || '')
|
||||
const content = ref(existingNote?.content || '')
|
||||
const showAlert = ref(false)
|
||||
|
||||
@@ -94,29 +88,20 @@ const formattedTime = computed(() => {
|
||||
const wordCount = computed(() => {
|
||||
// 移除HTML标签计算字数
|
||||
const textContent = content.value.replace(/<[^>]*>/g, '')
|
||||
return (title.value.length || 0) + (textContent.length || 0)
|
||||
return textContent.length || 0
|
||||
})
|
||||
|
||||
// 处理保存
|
||||
const handleSave = async () => {
|
||||
// Validate input
|
||||
if (!title.value.trim()) {
|
||||
// In a full implementation, show an alert or toast
|
||||
console.log('Validation error: Please enter a note title.')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
if (isEditing && existingNote) {
|
||||
// Update existing note
|
||||
await store.updateNote(props.noteId, {
|
||||
title: title.value,
|
||||
content: content.value,
|
||||
})
|
||||
} else {
|
||||
// Create new note
|
||||
await store.addNote({
|
||||
title: title.value,
|
||||
content: content.value,
|
||||
isStarred: false,
|
||||
})
|
||||
@@ -133,7 +118,7 @@ const handleSave = async () => {
|
||||
// 处理取消
|
||||
const handleCancel = () => {
|
||||
// Check if there are unsaved changes
|
||||
const hasUnsavedChanges = title.value !== (existingNote?.title || '') || content.value !== (existingNote?.content || '')
|
||||
const hasUnsavedChanges = content.value !== (existingNote?.content || '')
|
||||
|
||||
if (hasUnsavedChanges) {
|
||||
showAlert.value = true
|
||||
@@ -142,8 +127,6 @@ const handleCancel = () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const setShowAlert = value => {
|
||||
showAlert.value = value
|
||||
}
|
||||
@@ -182,23 +165,6 @@ const setShowAlert = value => {
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.title-input-container {
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background-color: var(--background-card);
|
||||
}
|
||||
|
||||
.title-input {
|
||||
width: 100%;
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
color: var(--note-title);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.editor-container {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
|
||||
Reference in New Issue
Block a user