v1.1.10: fix settings folder creation/deletion, fix pdf-parse build error
- Fix: clicking '+' on work node now creates folder (category) instead of item - Fix: built-in categories (人物设定, 空间/地点 etc.) no longer show delete button - Fix: user-created custom folders show proper add/rename/delete options on hover - Fix: pdf-parse build error by marking it as serverExternalPackage - Add locale keys: settings.newFolder (zh/en/ru)
This commit is contained in:
1 parent
aa6b74d450
commit
9a366636f2
7 files changed
+18
-9
No files matched your search
@@ -484,14 +484,13 @@ export default function SettingsPanel() {
|
||||
|
||||
// 节点操作
|
||||
const handleAddNode = async (parentId, category) => {
|
||||
let cat = category || 'custom';
|
||||
if (parentId && !category) {
|
||||
const parent = nodes.find(n => n.id === parentId);
|
||||
if (parent) cat = parent.category;
|
||||
}
|
||||
const parent = parentId ? nodes.find(n => n.id === parentId) : null;
|
||||
let cat = category || (parent ? parent.category : 'custom');
|
||||
// 如果父节点是作品节点,创建文件夹(大分类);否则创建条目
|
||||
const isParentWork = parent && parent.type === 'work';
|
||||
const newNode = await addSettingsNode({
|
||||
name: t('settings.newItem'),
|
||||
type: 'item',
|
||||
name: isParentWork ? t('settings.newFolder') : t('settings.newItem'),
|
||||
type: isParentWork ? 'folder' : 'item',
|
||||
category: cat,
|
||||
parentId,
|
||||
enabled: true,
|
||||
|
||||
@@ -30,6 +30,11 @@ function TreeNode({ node, nodes, selectedId, onSelect, onAdd, onDelete, onRename
|
||||
const isFolder = node.type === 'folder' || node.type === 'special' || node.type === 'work';
|
||||
const isWork = node.type === 'work';
|
||||
const isRoot = node.parentId === null;
|
||||
// 内置子分类(作品下的固定分类,如人物设定、空间/地点等)不可删除
|
||||
const builtinSuffixes = ['bookinfo', 'characters', 'locations', 'world', 'objects', 'plot', 'rules'];
|
||||
const parentNode = node.parentId ? nodes.find(n => n.id === node.parentId) : null;
|
||||
const isBuiltinCategory = parentNode && parentNode.type === 'work' && builtinSuffixes.some(s => node.id.endsWith('-' + s));
|
||||
const canDelete = !isRoot && !isBuiltinCategory;
|
||||
const isCollapsed = collapsedIds.has(node.id);
|
||||
const isSelected = selectedId === node.id;
|
||||
const isDisabled = node.enabled === false;
|
||||
@@ -138,7 +143,7 @@ function TreeNode({ node, nodes, selectedId, onSelect, onAdd, onDelete, onRename
|
||||
<button className="tree-action-btn" onClick={e => { e.stopPropagation(); setRenameValue(node.name); setIsRenaming(true); }} title={t('common.rename')}>✏</button>
|
||||
)}
|
||||
{/* 删除 */}
|
||||
{!isRoot && (
|
||||
{canDelete && (
|
||||
<button className="tree-action-btn danger" onClick={e => { e.stopPropagation(); onDelete(node.id); }} title={t('common.delete')}>✕</button>
|
||||
)}
|
||||
</span>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"workLabel": "📕 Project:",
|
||||
"confirmBtn": "Confirm",
|
||||
"newItem": "New Item",
|
||||
"newFolder": "New Category",
|
||||
"workNamePlaceholder": "Project Name...",
|
||||
"deleteWorkPrompt": "Are you sure you want to delete the project '{name}' and all its settings? This cannot be undone.",
|
||||
"deleteWorkAlert": "At least one project must remain.",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"workLabel": "📕 Проект:",
|
||||
"confirmBtn": "Подтвердить",
|
||||
"newItem": "Новый элемент",
|
||||
"newFolder": "Новая категория",
|
||||
"workNamePlaceholder": "Название проекта...",
|
||||
"deleteWorkPrompt": "Вы уверены, что хотите удалить проект '{name}' и все его настройки? Это действие нельзя отменить.",
|
||||
"deleteWorkAlert": "Должен остаться хотя бы один проект.",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"workLabel": "📕 作品:",
|
||||
"confirmBtn": "确定",
|
||||
"newItem": "新条目",
|
||||
"newFolder": "新分类",
|
||||
"workNamePlaceholder": "作品名称…",
|
||||
"deleteWorkPrompt": "确定删除作品「{name}」及其所有设定?此操作不可撤销。",
|
||||
"deleteWorkAlert": "至少需要保留一个作品",
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
const nextConfig = {
|
||||
output: 'standalone',
|
||||
devIndicators: false,
|
||||
// pdf-parse 仅在服务端 API 路由中使用,将其标记为外部包避免打包解析
|
||||
serverExternalPackages: ['pdf-parse'],
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "author-app",
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.10",
|
||||
"private": true,
|
||||
"main": "electron/main.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in new issue
Block a user