修复日程提醒功能

This commit is contained in:
2026-07-20 11:41:39 +08:00
parent 7ab6958538
commit f00ba9f9cc
19 changed files with 1735 additions and 1725 deletions
+18 -87
View File
@@ -15,29 +15,14 @@
<view class="field content-field">
<text class="field-label">内容</text>
<view class="editor-wrap">
<editor
id="noteEditor"
class="note-editor"
:placeholder="'记录你的想法...'"
:value="form.content"
@ready="onEditorReady"
@input="onEditorInput"
@focus="editorFocused = true"
@blur="editorFocused = false"
/>
<view class="editor-toolbar">
<view
v-for="btn in toolbarBtns"
:key="btn.name"
class="toolbar-btn"
:class="{ active: btn.active }"
@tap="execCommand(btn)"
>
<text>{{ btn.label }}</text>
</view>
</view>
</view>
<editor
id="noteEditor"
class="note-editor"
:placeholder="'记录你的想法...'"
:value="form.content"
@ready="onEditorReady"
@input="onEditorInput"
/>
</view>
<view class="switch-row" @tap="form.pinned = !form.pinned">
@@ -71,7 +56,6 @@ import { formatDate } from '@/utils/date.js'
const noteId = ref('')
const saving = ref(false)
const editorCtx = ref(null)
const editorFocused = ref(false)
const form = reactive({
title: '',
content: '',
@@ -81,28 +65,6 @@ const meta = reactive({
updatedAt: 0
})
const toolbarBtns = reactive([
{ name: 'bold', label: 'B', active: false, value: 'bold' },
{ name: 'italic', label: 'I', active: false, value: 'italic' },
{ name: 'underline', label: 'U', active: false, value: 'underline' },
{ name: 'strike', label: 'S', active: false, value: 'strikeThrough' },
{ name: 'header', label: 'H', active: false, value: 'header' },
{ name: 'list', label: '•', active: false, value: 'insertUnorderedList' },
{ name: 'indent', label: '→', active: false, value: 'indent' },
{ name: 'outdent', label: '←', active: false, value: 'outdent' },
{ name: 'divider', label: '—', active: false, value: 'insertHorizontalRule' },
])
onLoad(async (query) => {
if (query?.id) {
noteId.value = query.id
uni.setNavigationBarTitle({ title: '编辑笔记' })
await loadNote(query.id)
} else {
uni.setNavigationBarTitle({ title: '新建笔记' })
}
})
function onEditorReady() {
uni.createSelectorQuery().select('#noteEditor').context((res) => {
if (res && res.context) {
@@ -118,14 +80,15 @@ function onEditorInput(e) {
form.content = e.detail.html || ''
}
function execCommand(btn) {
if (!editorCtx.value) return
if (btn.name === 'header') {
editorCtx.value.format('header', 'H2')
onLoad(async (query) => {
if (query?.id) {
noteId.value = query.id
uni.setNavigationBarTitle({ title: '编辑笔记' })
await loadNote(query.id)
} else {
editorCtx.value.format(btn.value)
uni.setNavigationBarTitle({ title: '新建笔记' })
}
}
})
async function loadNote(id) {
try {
@@ -246,17 +209,9 @@ function onDelete() {
flex: 1;
display: flex;
flex-direction: column;
padding-bottom: 0;
padding: 24rpx 28rpx 0 28rpx;
overflow: hidden;
}
.editor-wrap {
background: $color-bg-page;
border-radius: $radius-md;
overflow: hidden;
flex: 1;
display: flex;
flex-direction: column;
border-top: 1rpx solid $color-divider;
}
.note-editor {
@@ -268,32 +223,8 @@ function onDelete() {
color: $color-text;
box-sizing: border-box;
overflow-y: auto;
}
.editor-toolbar {
display: flex;
flex-wrap: wrap;
gap: 8rpx;
padding: 16rpx 20rpx;
border-top: 1rpx solid $color-divider;
background: $color-card;
}
.toolbar-btn {
padding: 10rpx 20rpx;
border-radius: $radius-sm;
font-size: 24rpx;
color: $color-text-secondary;
background: $color-bg-page;
&.active {
color: $color-primary;
background: $color-primary-bg;
}
&:active {
opacity: 0.7;
}
border-radius: $radius-md;
}
.placeholder {