feat: 限制只能打开 md/txt 文件,新建文件仅保存为 md
- 打开对话框移除「所有文件」选项 - 保存对话框移除 .txt 选项 - 拖拽打开增加扩展名过滤 - 浏览器降级路径同步过滤
This commit is contained in:
@@ -429,6 +429,8 @@
|
||||
input.multiple = true;
|
||||
input.onchange = (e) => {
|
||||
Array.from(e.target.files).forEach(file => {
|
||||
const ext = file.name.substring(file.name.lastIndexOf('.')).toLowerCase();
|
||||
if (!['.md', '.markdown', '.txt'].includes(ext)) return;
|
||||
const reader = new FileReader();
|
||||
reader.onload = (ev) => {
|
||||
createNewTab(file.name, ev.target.result);
|
||||
@@ -584,8 +586,11 @@
|
||||
dropOverlay.classList.add('hidden');
|
||||
|
||||
const files = e.dataTransfer.files;
|
||||
const allowedExts = ['.md', '.markdown', '.txt'];
|
||||
for (const file of files) {
|
||||
const filePath = file.path;
|
||||
const ext = filePath ? filePath.substring(filePath.lastIndexOf('.')).toLowerCase() : '';
|
||||
if (!allowedExts.includes(ext)) continue;
|
||||
if (filePath && typeof window.electronAPI !== 'undefined') {
|
||||
const result = await window.electronAPI.readFile(filePath);
|
||||
if (result.success) {
|
||||
|
||||
Reference in New Issue
Block a user