M0-M11 狩夜人笔记初始实现:11里程碑+86测试
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { useStore } from '../../store';
|
||||
import { TiptapEditor } from './TiptapEditor';
|
||||
import { MoreActions } from './MoreActions';
|
||||
import type { SaveState } from '../../store';
|
||||
|
||||
function saveLabel(s: SaveState): string {
|
||||
if (s === 'saving') return '保存中…';
|
||||
if (s === 'error') return '保存失败';
|
||||
return '已保存';
|
||||
}
|
||||
|
||||
export function Editor() {
|
||||
const { currentPath, title, saveState } = useStore();
|
||||
if (!currentPath) {
|
||||
return (
|
||||
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', opacity: 0.4 }}>
|
||||
<div style={{ textAlign: 'center' }}>从左侧选择一篇笔记,或新建文档开始</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||
<div style={{ padding: '6px 16px', borderBottom: '1px solid #333', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<span>{title} <span style={{ opacity: 0.4, fontSize: 12 }}>{currentPath}</span></span>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
||||
<span style={{ fontSize: 12, opacity: saveState === 'error' ? 1 : 0.5, color: saveState === 'error' ? '#f88' : 'inherit' }}>{saveLabel(saveState)}</span>
|
||||
<MoreActions />
|
||||
</div>
|
||||
</div>
|
||||
<TiptapEditor />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user