Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Support configurable menu and dock entries

Daniel52aecb305bce
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 9910a04b67..3bd78277cf 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "القوائم وشريط الإرساء",
+ "entryVisibilityTip": "اختر عناصر القوائم المضمنة وأيقونات شريط الإرساء التي تظهر على سطح المكتب",
+ "entrySimple": "مبسّط",
+ "entryFull": "كامل",
+ "entryBuiltin": "مضمن",
+ "entryCustom": "مخصص",
+ "entryBasedOn": "استنادًا إلى",
+ "entryCustomProfile": "ملف تعريف مخصص",
+ "entryCreateProfile": "إنشاء ملف تعريف",
+ "entryExportAll": "تصدير الكل",
+ "entryRestoreBase": "استعادة الأساس",
+ "entryRestoreBaseConfirm": "هل تريد استعادة جميع عناصر هذا الملف إلى ملف التعريف الأساسي؟",
+ "entryImportInvalid": "ملف تعريف القوائم وشريط الإرساء غير صالح",
"mobileMenuQuickActions": "إجراءات سريعة",
"mobileMenuCreate": "إنشاء",
"mobileMenuDataManagement": "إدارة البيانات",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 44aa84d9e0..c240033dbf 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menüs und Dock",
+ "entryVisibilityTip": "Wählen Sie, welche integrierten Menüeinträge und Dock-Symbole auf dem Desktop angezeigt werden",
+ "entrySimple": "Einfach",
+ "entryFull": "Vollständig",
+ "entryBuiltin": "Integriert",
+ "entryCustom": "Benutzerdefiniert",
+ "entryBasedOn": "Basierend auf",
+ "entryCustomProfile": "Benutzerdefiniertes Profil",
+ "entryCreateProfile": "Profil erstellen",
+ "entryExportAll": "Alle exportieren",
+ "entryRestoreBase": "Basis wiederherstellen",
+ "entryRestoreBaseConfirm": "Alle Einträge dieses Profils auf das Basisprofil zurücksetzen?",
+ "entryImportInvalid": "Ungültige Menü- und Dock-Profildatei",
"mobileMenuQuickActions": "Schnellaktionen",
"mobileMenuCreate": "Erstellen",
"mobileMenuDataManagement": "Datenverwaltung",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index d882e2097c..5a468aea49 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menus and dock",
+ "entryVisibilityTip": "Choose which built-in menu items and dock icons are shown on desktop",
+ "entrySimple": "Simple",
+ "entryFull": "Full",
+ "entryBuiltin": "Built-in",
+ "entryCustom": "Custom",
+ "entryBasedOn": "Based on",
+ "entryCustomProfile": "Custom profile",
+ "entryCreateProfile": "Create profile",
+ "entryExportAll": "Export all",
+ "entryRestoreBase": "Restore base",
+ "entryRestoreBaseConfirm": "Restore all entries in this profile to its base profile?",
+ "entryImportInvalid": "Invalid menu and dock profile file",
"mobileMenuQuickActions": "Quick actions",
"mobileMenuCreate": "Create",
"mobileMenuDataManagement": "Data management",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 540b938ab8..fc31b10b8a 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menús y panel acoplable",
+ "entryVisibilityTip": "Elige qué elementos de menú e iconos del panel acoplable se muestran en el escritorio",
+ "entrySimple": "Sencillo",
+ "entryFull": "Completo",
+ "entryBuiltin": "Integrado",
+ "entryCustom": "Personalizado",
+ "entryBasedOn": "Basado en",
+ "entryCustomProfile": "Perfil personalizado",
+ "entryCreateProfile": "Crear perfil",
+ "entryExportAll": "Exportar todo",
+ "entryRestoreBase": "Restaurar base",
+ "entryRestoreBaseConfirm": "¿Restaurar todas las entradas de este perfil a su perfil base?",
+ "entryImportInvalid": "El archivo de perfil de menús y panel acoplable no es válido",
"mobileMenuQuickActions": "Acciones rápidas",
"mobileMenuCreate": "Crear",
"mobileMenuDataManagement": "Gestión de datos",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index eeef51a0c7..8d22494a60 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menus et barre d'ancrage",
+ "entryVisibilityTip": "Choisissez les éléments de menu et les icônes de la barre d'ancrage affichés sur ordinateur",
+ "entrySimple": "Simple",
+ "entryFull": "Complet",
+ "entryBuiltin": "Intégré",
+ "entryCustom": "Personnalisé",
+ "entryBasedOn": "Basé sur",
+ "entryCustomProfile": "Profil personnalisé",
+ "entryCreateProfile": "Créer un profil",
+ "entryExportAll": "Tout exporter",
+ "entryRestoreBase": "Restaurer la base",
+ "entryRestoreBaseConfirm": "Restaurer toutes les entrées de ce profil selon son profil de base ?",
+ "entryImportInvalid": "Fichier de profil des menus et de la barre d'ancrage non valide",
"mobileMenuQuickActions": "Actions rapides",
"mobileMenuCreate": "Créer",
"mobileMenuDataManagement": "Gestion des données",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index b19dcbe3e2..ac816c8706 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "תפריטים וסרגל עגינה",
+ "entryVisibilityTip": "בחירת פריטי התפריט וסמלי סרגל העגינה המובנים שיוצגו במחשב",
+ "entrySimple": "פשוט",
+ "entryFull": "מלא",
+ "entryBuiltin": "מובנה",
+ "entryCustom": "מותאם אישית",
+ "entryBasedOn": "מבוסס על",
+ "entryCustomProfile": "פרופיל מותאם אישית",
+ "entryCreateProfile": "יצירת פרופיל",
+ "entryExportAll": "ייצוא הכול",
+ "entryRestoreBase": "שחזור הבסיס",
+ "entryRestoreBaseConfirm": "לשחזר את כל הפריטים בפרופיל זה לפי פרופיל הבסיס?",
+ "entryImportInvalid": "קובץ פרופיל התפריטים וסרגל העגינה אינו תקין",
"mobileMenuQuickActions": "פעולות מהירות",
"mobileMenuCreate": "יצירה",
"mobileMenuDataManagement": "ניהול נתונים",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 7cb3a344e5..1d86a0085e 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "मेनू और डॉक",
+ "entryVisibilityTip": "डेस्कटॉप पर दिखाए जाने वाले अंतर्निहित मेनू आइटम और डॉक आइकन चुनें",
+ "entrySimple": "सरल",
+ "entryFull": "पूर्ण",
+ "entryBuiltin": "अंतर्निहित",
+ "entryCustom": "कस्टम",
+ "entryBasedOn": "इस पर आधारित",
+ "entryCustomProfile": "कस्टम प्रोफ़ाइल",
+ "entryCreateProfile": "प्रोफ़ाइल बनाएँ",
+ "entryExportAll": "सभी निर्यात करें",
+ "entryRestoreBase": "आधार पुनर्स्थापित करें",
+ "entryRestoreBaseConfirm": "क्या इस प्रोफ़ाइल की सभी प्रविष्टियाँ आधार प्रोफ़ाइल के अनुसार पुनर्स्थापित करनी हैं?",
+ "entryImportInvalid": "मेनू और डॉक प्रोफ़ाइल फ़ाइल अमान्य है",
"mobileMenuQuickActions": "त्वरित कार्रवाइयाँ",
"mobileMenuCreate": "बनाएँ",
"mobileMenuDataManagement": "डेटा प्रबंधन",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index bbb939f527..18a7090410 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menu dan dok",
+ "entryVisibilityTip": "Pilih item menu bawaan dan ikon dok yang ditampilkan di desktop",
+ "entrySimple": "Sederhana",
+ "entryFull": "Lengkap",
+ "entryBuiltin": "Bawaan",
+ "entryCustom": "Kustom",
+ "entryBasedOn": "Berdasarkan",
+ "entryCustomProfile": "Profil kustom",
+ "entryCreateProfile": "Buat profil",
+ "entryExportAll": "Ekspor semua",
+ "entryRestoreBase": "Pulihkan dasar",
+ "entryRestoreBaseConfirm": "Pulihkan semua entri dalam profil ini ke profil dasarnya?",
+ "entryImportInvalid": "Berkas profil menu dan dok tidak valid",
"mobileMenuQuickActions": "Tindakan cepat",
"mobileMenuCreate": "Buat",
"mobileMenuDataManagement": "Pengelolaan data",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index fbb4d865b1..7fe36cbf22 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menu e barra di ancoraggio",
+ "entryVisibilityTip": "Scegli quali voci di menu e icone della barra di ancoraggio mostrare sul desktop",
+ "entrySimple": "Semplice",
+ "entryFull": "Completo",
+ "entryBuiltin": "Integrato",
+ "entryCustom": "Personalizzato",
+ "entryBasedOn": "Basato su",
+ "entryCustomProfile": "Profilo personalizzato",
+ "entryCreateProfile": "Crea profilo",
+ "entryExportAll": "Esporta tutto",
+ "entryRestoreBase": "Ripristina base",
+ "entryRestoreBaseConfirm": "Ripristinare tutte le voci di questo profilo in base al profilo di base?",
+ "entryImportInvalid": "File del profilo di menu e barra di ancoraggio non valido",
"mobileMenuQuickActions": "Azioni rapide",
"mobileMenuCreate": "Crea",
"mobileMenuDataManagement": "Gestione dei dati",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index f34844aa59..fa4c46cdb2 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "メニューとドック",
+ "entryVisibilityTip": "デスクトップで表示する組み込みメニュー項目とドックアイコンを選択します",
+ "entrySimple": "シンプル",
+ "entryFull": "完全",
+ "entryBuiltin": "組み込み",
+ "entryCustom": "カスタム",
+ "entryBasedOn": "ベース",
+ "entryCustomProfile": "カスタムプロファイル",
+ "entryCreateProfile": "プロファイルを作成",
+ "entryExportAll": "すべてエクスポート",
+ "entryRestoreBase": "ベースを復元",
+ "entryRestoreBaseConfirm": "このプロファイルのすべての項目をベースプロファイルに戻しますか?",
+ "entryImportInvalid": "メニューとドックのプロファイルファイルが無効です",
"mobileMenuQuickActions": "クイック操作",
"mobileMenuCreate": "作成",
"mobileMenuDataManagement": "データ管理",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index a4946721fb..c0493d2153 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "메뉴 및 도크",
+ "entryVisibilityTip": "데스크톱에 표시할 기본 메뉴 항목과 도크 아이콘을 선택합니다",
+ "entrySimple": "간단",
+ "entryFull": "전체",
+ "entryBuiltin": "기본 제공",
+ "entryCustom": "사용자 지정",
+ "entryBasedOn": "기준",
+ "entryCustomProfile": "사용자 지정 프로필",
+ "entryCreateProfile": "프로필 만들기",
+ "entryExportAll": "모두 내보내기",
+ "entryRestoreBase": "기준 복원",
+ "entryRestoreBaseConfirm": "이 프로필의 모든 항목을 기준 프로필로 복원하시겠습니까?",
+ "entryImportInvalid": "메뉴 및 도크 프로필 파일이 올바르지 않습니다",
"mobileMenuQuickActions": "빠른 작업",
"mobileMenuCreate": "만들기",
"mobileMenuDataManagement": "데이터 관리",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 387d724780..f1c82d18d3 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menu's en dock",
+ "entryVisibilityTip": "Kies welke ingebouwde menu-items en dockpictogrammen op het bureaublad worden getoond",
+ "entrySimple": "Eenvoudig",
+ "entryFull": "Volledig",
+ "entryBuiltin": "Ingebouwd",
+ "entryCustom": "Aangepast",
+ "entryBasedOn": "Gebaseerd op",
+ "entryCustomProfile": "Aangepast profiel",
+ "entryCreateProfile": "Profiel maken",
+ "entryExportAll": "Alles exporteren",
+ "entryRestoreBase": "Basis herstellen",
+ "entryRestoreBaseConfirm": "Alle items in dit profiel herstellen naar het basisprofiel?",
+ "entryImportInvalid": "Ongeldig profielbestand voor menu's en dock",
"mobileMenuQuickActions": "Snelle acties",
"mobileMenuCreate": "Maken",
"mobileMenuDataManagement": "Gegevensbeheer",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 13ce2f478f..e290f2671a 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menu i dok",
+ "entryVisibilityTip": "Wybierz wbudowane pozycje menu i ikony doku wyświetlane na komputerze",
+ "entrySimple": "Prosty",
+ "entryFull": "Pełny",
+ "entryBuiltin": "Wbudowany",
+ "entryCustom": "Niestandardowy",
+ "entryBasedOn": "Na podstawie",
+ "entryCustomProfile": "Profil niestandardowy",
+ "entryCreateProfile": "Utwórz profil",
+ "entryExportAll": "Eksportuj wszystko",
+ "entryRestoreBase": "Przywróć bazę",
+ "entryRestoreBaseConfirm": "Przywrócić wszystkie pozycje tego profilu zgodnie z profilem bazowym?",
+ "entryImportInvalid": "Nieprawidłowy plik profilu menu i doku",
"mobileMenuQuickActions": "Szybkie działania",
"mobileMenuCreate": "Utwórz",
"mobileMenuDataManagement": "Zarządzanie danymi",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 792e55e260..0ce5acef7d 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menus e dock",
+ "entryVisibilityTip": "Escolha quais itens de menu e ícones do dock integrados são exibidos no computador",
+ "entrySimple": "Simples",
+ "entryFull": "Completo",
+ "entryBuiltin": "Integrado",
+ "entryCustom": "Personalizado",
+ "entryBasedOn": "Baseado em",
+ "entryCustomProfile": "Perfil personalizado",
+ "entryCreateProfile": "Criar perfil",
+ "entryExportAll": "Exportar tudo",
+ "entryRestoreBase": "Restaurar base",
+ "entryRestoreBaseConfirm": "Restaurar todas as entradas deste perfil para o perfil base?",
+ "entryImportInvalid": "Arquivo de perfil de menus e dock inválido",
"mobileMenuQuickActions": "Ações rápidas",
"mobileMenuCreate": "Criar",
"mobileMenuDataManagement": "Gerenciamento de dados",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index c98a802bd2..30abac7b2b 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Меню и док-панель",
+ "entryVisibilityTip": "Выберите встроенные пункты меню и значки док-панели, отображаемые на компьютере",
+ "entrySimple": "Простой",
+ "entryFull": "Полный",
+ "entryBuiltin": "Встроенный",
+ "entryCustom": "Пользовательский",
+ "entryBasedOn": "На основе",
+ "entryCustomProfile": "Пользовательский профиль",
+ "entryCreateProfile": "Создать профиль",
+ "entryExportAll": "Экспортировать всё",
+ "entryRestoreBase": "Восстановить основу",
+ "entryRestoreBaseConfirm": "Восстановить все элементы этого профиля в соответствии с базовым профилем?",
+ "entryImportInvalid": "Недопустимый файл профиля меню и док-панели",
"mobileMenuQuickActions": "Быстрые действия",
"mobileMenuCreate": "Создание",
"mobileMenuDataManagement": "Управление данными",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index d4c3177ba4..8d1ac1f95a 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Ponuky a dok",
+ "entryVisibilityTip": "Vyberte vstavané položky ponuky a ikony doku zobrazované na počítači",
+ "entrySimple": "Jednoduchý",
+ "entryFull": "Úplný",
+ "entryBuiltin": "Vstavaný",
+ "entryCustom": "Vlastný",
+ "entryBasedOn": "Založené na",
+ "entryCustomProfile": "Vlastný profil",
+ "entryCreateProfile": "Vytvoriť profil",
+ "entryExportAll": "Exportovať všetko",
+ "entryRestoreBase": "Obnoviť základ",
+ "entryRestoreBaseConfirm": "Obnoviť všetky položky tohto profilu podľa základného profilu?",
+ "entryImportInvalid": "Neplatný súbor profilu ponúk a doku",
"mobileMenuQuickActions": "Rýchle akcie",
"mobileMenuCreate": "Vytvoriť",
"mobileMenuDataManagement": "Správa údajov",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index 89b5ff6f80..b800f71ef1 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "เมนูและแถบเชื่อมต่อ",
+ "entryVisibilityTip": "เลือกรายการเมนูและไอคอนแถบเชื่อมต่อในตัวที่จะแสดงบนเดสก์ท็อป",
+ "entrySimple": "เรียบง่าย",
+ "entryFull": "ครบถ้วน",
+ "entryBuiltin": "ในตัว",
+ "entryCustom": "กำหนดเอง",
+ "entryBasedOn": "อ้างอิงจาก",
+ "entryCustomProfile": "โปรไฟล์กำหนดเอง",
+ "entryCreateProfile": "สร้างโปรไฟล์",
+ "entryExportAll": "ส่งออกทั้งหมด",
+ "entryRestoreBase": "คืนค่าพื้นฐาน",
+ "entryRestoreBaseConfirm": "คืนค่ารายการทั้งหมดในโปรไฟล์นี้ตามโปรไฟล์พื้นฐานหรือไม่?",
+ "entryImportInvalid": "ไฟล์โปรไฟล์เมนูและแถบเชื่อมต่อไม่ถูกต้อง",
"mobileMenuQuickActions": "การดำเนินการด่วน",
"mobileMenuCreate": "สร้าง",
"mobileMenuDataManagement": "การจัดการข้อมูล",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index a1c3250536..97979dfde8 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Menüler ve yuva",
+ "entryVisibilityTip": "Masaüstünde gösterilecek yerleşik menü öğelerini ve yuva simgelerini seçin",
+ "entrySimple": "Basit",
+ "entryFull": "Tam",
+ "entryBuiltin": "Yerleşik",
+ "entryCustom": "Özel",
+ "entryBasedOn": "Temel alınan",
+ "entryCustomProfile": "Özel profil",
+ "entryCreateProfile": "Profil oluştur",
+ "entryExportAll": "Tümünü dışa aktar",
+ "entryRestoreBase": "Temeli geri yükle",
+ "entryRestoreBaseConfirm": "Bu profildeki tüm öğeler temel profile göre geri yüklensin mi?",
+ "entryImportInvalid": "Menü ve yuva profil dosyası geçersiz",
"mobileMenuQuickActions": "Hızlı işlemler",
"mobileMenuCreate": "Oluştur",
"mobileMenuDataManagement": "Veri yönetimi",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 8adcf5ecb2..249057a6ad 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "Меню та док-панель",
+ "entryVisibilityTip": "Виберіть вбудовані пункти меню та піктограми док-панелі, що відображаються на комп'ютері",
+ "entrySimple": "Простий",
+ "entryFull": "Повний",
+ "entryBuiltin": "Вбудований",
+ "entryCustom": "Користувацький",
+ "entryBasedOn": "На основі",
+ "entryCustomProfile": "Користувацький профіль",
+ "entryCreateProfile": "Створити профіль",
+ "entryExportAll": "Експортувати все",
+ "entryRestoreBase": "Відновити основу",
+ "entryRestoreBaseConfirm": "Відновити всі елементи цього профілю відповідно до базового профілю?",
+ "entryImportInvalid": "Недійсний файл профілю меню та док-панелі",
"mobileMenuQuickActions": "Швидкі дії",
"mobileMenuCreate": "Створення",
"mobileMenuDataManagement": "Керування даними",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index c541eb4b91..3020c36dbb 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "菜单与停靠栏",
+ "entryVisibilityTip": "配置桌面端内置菜单项和停靠栏图标是否显示",
+ "entrySimple": "简洁方案",
+ "entryFull": "完整方案",
+ "entryBuiltin": "内置",
+ "entryCustom": "自定义",
+ "entryBasedOn": "基于",
+ "entryCustomProfile": "自定义方案",
+ "entryCreateProfile": "新建方案",
+ "entryExportAll": "全部导出",
+ "entryRestoreBase": "恢复基础方案",
+ "entryRestoreBaseConfirm": "确定将此方案的所有入口恢复为基础方案吗?",
+ "entryImportInvalid": "菜单与停靠栏方案文件无效",
"mobileMenuQuickActions": "快捷操作",
"mobileMenuCreate": "创建",
"mobileMenuDataManagement": "数据管理",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 2f038bb01f..7cea50330c 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,17 @@
{
+ "entryVisibility": "選單與停靠欄",
+ "entryVisibilityTip": "設定桌面端內建選單項目和停靠欄圖示是否顯示",
+ "entrySimple": "簡潔方案",
+ "entryFull": "完整方案",
+ "entryBuiltin": "內建",
+ "entryCustom": "自訂",
+ "entryBasedOn": "基於",
+ "entryCustomProfile": "自訂方案",
+ "entryCreateProfile": "新增方案",
+ "entryExportAll": "全部匯出",
+ "entryRestoreBase": "還原基礎方案",
+ "entryRestoreBaseConfirm": "確定將此方案的所有入口還原為基礎方案嗎?",
+ "entryImportInvalid": "選單與停靠欄方案檔案無效",
"mobileMenuQuickActions": "快速操作",
"mobileMenuCreate": "建立",
"mobileMenuDataManagement": "資料管理",
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.ts
new file mode 100644
index 0000000000..d550ca5e1e
--- /dev/null
+++ b/app/src/config/entryVisibility/catalog.test.ts
@@ -0,0 +1,48 @@
+import * as assert from "node:assert/strict";
+import test from "node:test";
+import {entryCatalog, getEntryCatalogNode, getEntryParentPath, getEntryPaths} from "./catalog";
+
+test("entry catalog paths are unique and indexed", () => {
+ const paths: string[] = [];
+ const visit = (prefix: string, nodes: typeof entryCatalog[number]["children"]) => {
+ nodes.forEach((item) => {
+ const path = `${prefix}.${item.key}`;
+ paths.push(path);
+ assert.equal(getEntryCatalogNode(path), item);
+ assert.equal(getEntryParentPath(path), prefix);
+ if (item.children) {
+ visit(path, item.children);
+ }
+ });
+ };
+ entryCatalog.forEach((section) => visit(section.key, section.children));
+ assert.equal(new Set(paths).size, paths.length);
+ assert.deepEqual(new Set(getEntryPaths()), new Set(paths));
+});
+
+test("simple profile follows the reviewed defaults", () => {
+ const shown = [
+ "document.title.copy.copyBlockEmbed",
+ "document.title.export.exportTemplate",
+ "document.title.export.exportImage",
+ "gutter.single.addToAgent",
+ "gutter.single.turnInto.code",
+ "document.more.keepLazyLoad",
+ "document.more.headingNumber",
+ "docTree.notebook.sort.fileNameNatASC",
+ ];
+ const hidden = [
+ "document.title.copy.copyDoc",
+ "document.title.copy.copyProtocol",
+ "gutter.single.addToDatabase",
+ "gutter.single.enterBack",
+ "gutter.single.jumpTo",
+ "gutter.single.wechatReminder",
+ "document.more.netAssets2LocalAssets",
+ "document.more.fullWidth",
+ "docTree.notebook.sort.fileNameASC",
+ "inline.image.copyFile",
+ ];
+ shown.forEach((path) => assert.equal(getEntryCatalogNode(path)?.simple, true, path));
+ hidden.forEach((path) => assert.equal(getEntryCatalogNode(path)?.simple, false, path));
+});
diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.ts
new file mode 100644
index 0000000000..019888078a
--- /dev/null
+++ b/app/src/config/entryVisibility/catalog.ts
@@ -0,0 +1,579 @@
+export interface IEntryCatalogNode {
+ key: string;
+ label: () => string;
+ simple: boolean;
+ children?: IEntryCatalogNode[];
+}
+
+export interface IEntryCatalogSection {
+ key: string;
+ label: () => string;
+ children: IEntryCatalogNode[];
+}
+
+const lang = (key: string) => () => window.siyuan.languages[key] || key;
+const literal = (value: string) => () => value;
+const node = (key: string, label: () => string, simple = true, children?: IEntryCatalogNode[]): IEntryCatalogNode => ({
+ key,
+ label,
+ simple,
+ children,
+});
+
+const copyChildren = () => [
+ node("copyBlockRef", lang("copyBlockRef")),
+ node("copyBlockEmbed", lang("copyBlockEmbed")),
+ node("copyProtocol", lang("copyProtocol"), false),
+ node("copyProtocolInMd", lang("copyProtocolInMd"), false),
+ node("copyWebURL", lang("copyWebURL"), false),
+ node("copyHPath", lang("copyHPath"), false),
+ node("copyID", lang("copyID"), false),
+];
+
+const sortChildren = () => [
+ node("fileNameASC", lang("fileNameASC"), false),
+ node("fileNameDESC", lang("fileNameDESC"), false),
+ node("fileNameNatASC", lang("fileNameNatASC")),
+ node("fileNameNatDESC", lang("fileNameNatDESC")),
+ node("createdASC", lang("createdASC")),
+ node("createdDESC", lang("createdDESC")),
+ node("modifiedASC", lang("modifiedASC")),
+ node("modifiedDESC", lang("modifiedDESC")),
+ node("refCountASC", lang("refCountASC")),
+ node("refCountDESC", lang("refCountDESC")),
+ node("docSizeASC", lang("docSizeASC")),
+ node("docSizeDESC", lang("docSizeDESC")),
+ node("subDocCountASC", lang("subDocCountASC")),
+ node("subDocCountDESC", lang("subDocCountDESC")),
+ node("customSort", lang("customSort")),
+ node("sortByFiletree", lang("sortByFiletree")),
+];
+
+const exportChildren = () => [
+ node("exportTemplate", lang("template")),
+ node("exportSiYuanZip", literal("SiYuan .sy.zip")),
+ node("exportMarkdown", literal("Markdown .zip")),
+ node("exportImage", lang("image")),
+ node("exportPDF", literal("PDF")),
+ node("exportHTML_SiYuan", literal("HTML (SiYuan)"), false),
+ node("exportHTML_Markdown", literal("HTML (Markdown)"), false),
+ node("exportWord", literal("Word .docx")),
+ node("exportMore", lang("more"), false, [
+ node("exportReStructuredText", literal("reStructuredText"), false),
+ node("exportAsciiDoc", literal("AsciiDoc"), false),
+ node("exportTextile", literal("Textile"), false),
+ node("exportOPML", literal("OPML"), false),
+ node("exportOrgMode", literal("Org-Mode"), false),
+ node("exportMediaWiki", literal("MediaWiki"), false),
+ node("exportODT", literal("ODT"), false),
+ node("exportRTF", literal("RTF"), false),
+ node("exportEPUB", literal("EPUB"), false),
+ ]),
+];
+
+const openChildren = () => [
+ node("insertRight", lang("insertRight")),
+ node("insertBottom", lang("insertBottom")),
+ node("openInNewTab", lang("openInNewTab")),
+ node("openByNewWindow", lang("openByNewWindow")),
+ node("preview", lang("preview")),
+ node("showInFolder", lang("showInFolder")),
+];
+
+const importChildren = () => [
+ node("importSiYuanZip", literal("SiYuan .sy.zip")),
+ node("importMarkdownZip", literal("Markdown .zip")),
+ node("importMarkdownDoc", () => `Markdown ${window.siyuan.languages.doc}`),
+ node("importMarkdownFolder", () => `Markdown ${window.siyuan.languages.folder}`),
+];
+
+const docTreeCommon = (multi = false) => [
+ node("copy", lang("copy"), true, [...copyChildren(), node("duplicate", lang("duplicate"))]),
+ node("move", lang("move")),
+ node("addToDatabase", lang("addToDatabase"), false),
+ node("delete", lang("delete")),
+ node("riffCard", lang("riffCard"), false, [
+ node("spaceRepetition", lang("spaceRepetition")),
+ node("manage", lang("manage")),
+ node("quickMakeCard", lang("quickMakeCard")),
+ node("removeCard", lang("removeCard")),
+ node("addToDeck", lang("addToDeck")),
+ ]),
+ node("openBy", lang("openBy"), true, openChildren()),
+ node("export", lang("export"), true, multi ? [
+ node("exportSiYuanZip", literal("SiYuan .sy.zip")),
+ node("exportMarkdown", literal("Markdown .zip")),
+ ] : exportChildren()),
+];
+
+const gutterCopyChildren = () => [
+ ...copyChildren(),
+ node("copyRichText", lang("copyRichText")),
+ node("copyPlainText", lang("copyPlainText")),
+ node("copyText", lang("copyText")),
+ node("copy", lang("copy")),
+ node("copyAVID", lang("copyAVID")),
+ node("duplicate", lang("duplicate")),
+ node("duplicateMirror", lang("duplicateMirror")),
+ node("duplicateCompletely", lang("duplicateCompletely")),
+];
+
+const gutterCommon = () => [
+ node("turnInto", lang("turnInto"), true, [
+ node("paragraph", lang("paragraph")),
+ node("heading1", lang("heading1")),
+ node("heading2", lang("heading2")),
+ node("heading3", lang("heading3")),
+ node("heading4", lang("heading4")),
+ node("heading5", lang("heading5")),
+ node("heading6", lang("heading6")),
+ node("quote", lang("quote")),
+ node("callout", lang("callout")),
+ node("list", lang("list")),
+ node("orderedList", lang("ordered-list")),
+ node("check", lang("check")),
+ node("code", lang("code")),
+ node("table", lang("table")),
+ node("line", lang("line")),
+ node("math", lang("math")),
+ node("includeSublists", lang("includeSublists"), true, [
+ node("recursiveParagraph", lang("paragraph")),
+ node("recursiveList", lang("list")),
+ node("recursiveOrderedList", lang("ordered-list")),
+ node("recursiveCheck", lang("check")),
+ ]),
+ ]),
+ node("mergeSuperBlock", () => `${window.siyuan.languages.merge} ${window.siyuan.languages.superBlock}`, true, [
+ node("hLayout", lang("hLayout")),
+ node("vLayout", lang("vLayout")),
+ ]),
+ node("ai", lang("aiEdit")),
+ node("copy", lang("copy"), true, gutterCopyChildren()),
+ node("cut", lang("cut")),
+ node("move", lang("move")),
+ node("addToDatabase", lang("addToDatabase"), false),
+ node("addToAgent", lang("addToAgent")),
+ node("delete", lang("delete")),
+ node("appearance", lang("appearance")),
+ node("layout", lang("layout"), true, [
+ node("alignLeft", lang("alignLeft")),
+ node("alignCenter", lang("alignCenter")),
+ node("alignRight", lang("alignRight")),
+ node("justify", lang("justify")),
+ node("ltr", lang("ltr")),
+ node("rtl", lang("rtl")),
+ node("clearFontStyle", lang("clearFontStyle")),
+ ]),
+ node("width", lang("width"), true, [
+ node("widthInput", lang("width")),
+ node("width_25%", literal("25%")),
+ node("width_33%", literal("33%")),
+ node("width_50%", literal("50%")),
+ node("width_67%", literal("67%")),
+ node("width_75%", literal("75%")),
+ node("width_100%", literal("100%")),
+ node("widthDrag", lang("width")),
+ node("default", lang("default")),
+ ]),
+ node("quickMakeCard", lang("quickMakeCard"), false),
+ node("removeCard", lang("removeCard"), false),
+ node("addToDeck", lang("addToDeck"), false),
+ node("jumpTo", lang("jumpTo"), false, [
+ node("jumpToParentPrev", lang("jumpToParentPrev"), false),
+ node("jumpToParentNext", lang("jumpToParentNext"), false),
+ node("jumpToParent", lang("jumpToParent"), false),
+ ]),
+ node("attr", lang("attr")),
+ node("wechatReminder", lang("wechatReminder"), false),
+ node("updateAndCreatedAt", () => `${window.siyuan.languages.modifiedAt} / ${window.siyuan.languages.createdAt}`, false),
+ node("cancelSuperBlock", () => `${window.siyuan.languages.cancel} ${window.siyuan.languages.superBlock}`),
+ node("turnIntoVLayout", () => `${window.siyuan.languages.turnInto} ${window.siyuan.languages.vLayout}`),
+ node("turnIntoHLayout", () => `${window.siyuan.languages.turnInto} ${window.siyuan.languages.hLayout}`),
+ node("code", lang("code"), true, [
+ node("md31", lang("md31")),
+ node("md2", lang("md2")),
+ node("md27", lang("md27")),
+ node("saveCodeBlockAsFile", lang("saveCodeBlockAsFile")),
+ ]),
+ node("chart", lang("chart"), true, [node("height", lang("height")), node("update", lang("update"))]),
+ node("table", lang("table"), true, [
+ node("useDefaultWidth", lang("useDefaultWidth")),
+ node("pinTableHead", lang("pinTableHead")),
+ node("unpinTableHead", lang("unpinTableHead")),
+ node("title", lang("title")),
+ node("alignLeft", lang("alignLeft")),
+ node("alignCenter", lang("alignCenter")),
+ node("alignRight", lang("alignRight")),
+ node("useDefaultAlign", lang("useDefaultAlign")),
+ node("insertRowAbove", lang("insertRowAbove")),
+ node("insertRowBelow", lang("insertRowBelow")),
+ node("insertColumnLeft", lang("insertColumnLeft")),
+ node("insertColumnRight", lang("insertColumnRight")),
+ node("moveToUp", lang("moveToUp")),
+ node("moveToDown", lang("moveToDown")),
+ node("moveToLeft", lang("moveToLeft")),
+ node("moveToRight", lang("moveToRight")),
+ node("deleteRow", lang("delete-row")),
+ node("deleteColumn", lang("delete-column")),
+ ]),
+ node("exportCSV", () => `${window.siyuan.languages.export} CSV`),
+ node("showDatabaseInFolder", lang("showInFolder")),
+ node("assetVideo", lang("assets"), true, [
+ node("asset", lang("assets")),
+ node("rename", lang("rename")),
+ node("openBy", lang("openBy")),
+ node("export", lang("export")),
+ node("copyFile", lang("copyFile")),
+ ]),
+ node("assetAudio", lang("assets"), true, [
+ node("asset", lang("assets")),
+ node("rename", lang("rename")),
+ node("openBy", lang("openBy")),
+ node("export", lang("export")),
+ node("copyFile", lang("copyFile")),
+ ]),
+ node("assetIFrame", lang("assets"), true, [node("asset", lang("assets")), node("openBy", lang("openBy"))]),
+ node("html", literal("HTML")),
+ node("blockEmbed", lang("blockEmbed"), true, [
+ node("refresh", lang("refresh")),
+ node("update", lang("update")),
+ node("embedBlockBreadcrumb", lang("embedBlockBreadcrumb")),
+ node("headingEmbedMode", lang("headingEmbedMode"), true, [
+ node("showHeadingWithBlocks", lang("showHeadingWithBlocks")),
+ node("showHeadingOnlyTitle", lang("showHeadingOnlyTitle")),
+ node("showHeadingOnlyBlocks", lang("showHeadingOnlyBlocks")),
+ node("default", lang("default")),
+ ]),
+ ]),
+ node("tWithSubtitle", lang("tWithSubtitle"), true, [
+ node("heading1", lang("heading1")),
+ node("heading2", lang("heading2")),
+ node("heading3", lang("heading3")),
+ node("heading4", lang("heading4")),
+ node("heading5", lang("heading5")),
+ node("heading6", lang("heading6")),
+ ]),
+ node("copyHeadings1", () => `${window.siyuan.languages.copy} ${window.siyuan.languages.headings1}`),
+ node("cutHeadings1", () => `${window.siyuan.languages.cut} ${window.siyuan.languages.headings1}`),
+ node("deleteHeadings1", () => `${window.siyuan.languages.delete} ${window.siyuan.languages.headings1}`),
+ node("enter", lang("enter")),
+ node("enterBack", lang("enterBack"), false),
+ node("insertBefore", lang("insertBefore")),
+ node("insertAfter", lang("insertAfter")),
+ node("fold", lang("fold")),
+ node("foldChildHeadings", lang("foldChildHeadings")),
+ node("foldSiblingHeadings", lang("foldSiblingHeadings")),
+ node("foldRecursive", lang("foldRecursive")),
+];
+
+export const entryCatalog: IEntryCatalogSection[] = [
+ {
+ key: "dock",
+ label: lang("toggleDock"),
+ children: [
+ node("file", lang("fileTree")),
+ node("outline", lang("outline")),
+ node("bookmark", lang("bookmark")),
+ node("tag", lang("tag")),
+ node("backlink", lang("backlinks")),
+ node("agentChat", lang("ai")),
+ node("inbox", lang("inbox"), false),
+ node("graph", lang("graphView"), false),
+ node("globalGraph", lang("globalGraph"), false),
+ ],
+ },
+ {
+ key: "docTree.panel",
+ label: lang("fileTree"),
+ children: [
+ node("newNotebook", lang("newNotebook")),
+ node("newEncryptedNotebook", lang("newEncryptedNotebook")),
+ node("rebuildDataIndex", lang("rebuildDataIndex")),
+ node("sort", lang("sort"), true, sortChildren()),
+ node("publishAccess", lang("publishAccess")),
+ ],
+ },
+ {
+ key: "docTree.notebook",
+ label: lang("agentCatNotebook"),
+ children: [
+ node("openDocument", lang("openDocument")),
+ node("rename", lang("rename")),
+ node("config", lang("config")),
+ node("sort", lang("sort"), true, sortChildren()),
+ node("riffCard", lang("riffCard"), false),
+ node("search", lang("search")),
+ node("replace", lang("replace")),
+ node("close", lang("close")),
+ node("delete", lang("delete")),
+ node("showInFolder", lang("showInFolder")),
+ node("import", lang("import"), true, importChildren()),
+ node("export", lang("export"), true, [
+ node("exportSiYuanZip", literal("SiYuan .sy.zip")),
+ node("exportMarkdown", literal("Markdown .zip")),
+ ]),
+ ],
+ },
+ {
+ key: "docTree.document",
+ label: lang("doc"),
+ children: [
+ node("openDocument", lang("openDocument")),
+ node("newDocAbove", lang("newDocAbove")),
+ node("newDocBelow", lang("newDocBelow")),
+ ...docTreeCommon(),
+ node("rename", lang("rename")),
+ node("attr", lang("attr")),
+ node("search", lang("search")),
+ node("replace", lang("replace")),
+ node("fileHistory", lang("dataHistory")),
+ node("import", lang("import"), true, importChildren()),
+ ],
+ },
+ {
+ key: "docTree.multi",
+ label: lang("multiSelect"),
+ children: docTreeCommon(true),
+ },
+ {
+ key: "document.title",
+ label: lang("doc"),
+ children: [
+ node("copy", lang("copy"), true, [...copyChildren(), node("copyMarkdown", lang("copyMarkdown")), node("copyDoc", lang("copyDoc"), false)]),
+ node("move", lang("move")),
+ node("addToDatabase", lang("addToDatabase"), false),
+ node("delete", lang("delete")),
+ node("outline", lang("outline")),
+ node("backlinks", lang("backlinks")),
+ node("graphView", lang("graphView")),
+ node("attr", lang("attr")),
+ node("wechatReminder", lang("wechatReminder"), false),
+ node("riffCard", lang("riffCard"), false, [
+ node("spaceRepetition", lang("spaceRepetition"), false),
+ node("manage", lang("manage"), false),
+ node("quickMakeCard", lang("quickMakeCard"), false),
+ node("removeCard", lang("removeCard"), false),
+ node("addToDeck", lang("addToDeck"), false),
+ ]),
+ node("search", lang("search")),
+ node("transferBlockRef", lang("transferBlockRef")),
+ node("openBy", lang("openBy")),
+ node("openByNewWindow", lang("openByNewWindow")),
+ node("showInFolder", lang("showInFolder")),
+ node("fileHistory", lang("dataHistory")),
+ node("export", lang("export"), true, exportChildren()),
+ node("updateAndCreatedAt", () => `${window.siyuan.languages.modifiedAt} / ${window.siyuan.languages.createdAt}`),
+ ],
+ },
+ {
+ key: "document.more",
+ label: lang("more"),
+ children: [
+ node("insertImage", lang("insertImage")),
+ node("insertAsset", lang("insertAsset")),
+ node("startRecord", lang("startRecord"), false),
+ node("endRecord", lang("endRecord"), false),
+ node("netImg2LocalAsset", lang("netImg2LocalAsset")),
+ node("netAssets2LocalAssets", lang("netAssets2LocalAssets"), false),
+ node("uploadAssets2CDN", lang("uploadAssets2CDN"), false),
+ node("share2Liandi", lang("share2Liandi"), false),
+ node("keepLazyLoad", lang("keepLazyLoad")),
+ node("refresh", lang("refresh")),
+ node("optimizeTypography", lang("optimizeTypography")),
+ node("fullscreen", lang("fullscreen")),
+ node("editMode", lang("edit-mode"), true, [
+ node("wysiwyg", lang("wysiwyg")),
+ node("preview", lang("preview")),
+ ]),
+ node("editReadonly", lang("editReadonly"), false, [
+ node("enable", lang("enable"), false),
+ node("disable", lang("disable"), false),
+ ]),
+ node("fullWidth", lang("fullWidth"), false, [
+ node("enable", lang("enable"), false),
+ node("disable", lang("disable"), false),
+ node("default", lang("default"), false),
+ ]),
+ node("headingNumber", lang("headingNumber"), true, [
+ node("enable", lang("enable")),
+ node("disable", lang("disable")),
+ node("default", lang("default")),
+ ]),
+ node("docInfo", lang("blockCount"), false),
+ ],
+ },
+ {key: "gutter.single", label: lang("blockCount"), children: gutterCommon()},
+ {key: "gutter.multi", label: lang("multiSelect"), children: gutterCommon()},
+ {
+ key: "inline.text",
+ label: lang("text"),
+ children: [
+ node("copy", lang("copy")),
+ node("copyRichText", lang("copyRichText")),
+ node("copyPlainText", lang("copyPlainText")),
+ node("cut", lang("cut")),
+ node("delete", lang("delete")),
+ node("paste", lang("paste")),
+ node("pasteAsPlainText", lang("pasteAsPlainText")),
+ node("pasteEscaped", lang("pasteEscaped"), false),
+ node("selectAll", lang("selectAll")),
+ node("insertRowAbove", lang("insertRowAbove")),
+ node("insertRowBelow", lang("insertRowBelow")),
+ node("insertColumnLeft", lang("insertColumnLeft")),
+ node("insertColumnRight", lang("insertColumnRight")),
+ node("deleteRow", lang("delete-row")),
+ node("deleteColumn", lang("delete-column")),
+ node("more", lang("more"), true, [
+ node("useDefaultWidth", lang("useDefaultWidth")),
+ node("pinTableHead", lang("pinTableHead")),
+ node("unpinTableHead", lang("unpinTableHead")),
+ node("alignLeft", lang("alignLeft")),
+ node("alignCenter", lang("alignCenter")),
+ node("alignRight", lang("alignRight")),
+ node("useDefaultAlign", lang("useDefaultAlign")),
+ node("moveToUp", lang("moveToUp")),
+ node("moveToDown", lang("moveToDown")),
+ node("moveToLeft", lang("moveToLeft")),
+ node("moveToRight", lang("moveToRight")),
+ ]),
+ ],
+ },
+ {
+ key: "inline.image",
+ label: lang("image"),
+ children: [
+ node("imageUrlAndTitleAndTooltipText", () => `${window.siyuan.languages.imageURL} / ${window.siyuan.languages.title} / ${window.siyuan.languages.tooltipText}`),
+ node("copy", lang("copy")),
+ node("copyImageURL", () => `${window.siyuan.languages.copy} ${window.siyuan.languages.imageURL}`),
+ node("cut", lang("cut")),
+ node("delete", lang("delete")),
+ node("rename", lang("rename")),
+ node("ocr", literal("OCR"), false, [
+ node("ocrResult", lang("ocrResult"), false),
+ node("reOCR", lang("reOCR"), false),
+ ]),
+ node("alignCenter", lang("alignCenter")),
+ node("alignLeft", lang("alignLeft")),
+ node("width", lang("width"), true, [
+ node("widthInput", lang("width")),
+ node("width_25%", literal("25%")),
+ node("width_33%", literal("33%")),
+ node("width_50%", literal("50%")),
+ node("width_67%", literal("67%")),
+ node("width_75%", literal("75%")),
+ node("width_100%", literal("100%")),
+ node("widthDrag", lang("width")),
+ node("default", lang("default")),
+ ]),
+ node("height", lang("height"), true, [
+ node("heightInput", lang("height")),
+ node("width_25%", literal("25%")),
+ node("width_33%", literal("33%")),
+ node("width_50%", literal("50%")),
+ node("width_67%", literal("67%")),
+ node("width_75%", literal("75%")),
+ node("width_100%", literal("100%")),
+ node("heightDrag", lang("height")),
+ node("default", lang("default")),
+ ]),
+ node("export", lang("export")),
+ node("copyFile", lang("copyFile"), false),
+ node("copyAsPNG", lang("copyAsPNG"), false),
+ ],
+ },
+ {
+ key: "inline.ref",
+ label: lang("ref"),
+ children: [
+ node("anchor", lang("anchor")),
+ node("openBy", lang("openBy")),
+ node("refTab", lang("refTab")),
+ node("insertRight", lang("insertRight")),
+ node("insertBottom", lang("insertBottom")),
+ node("openByNewWindow", lang("openByNewWindow")),
+ node("backlinks", lang("backlinks")),
+ node("graphView", lang("graphView"), false),
+ node("turnToDynamic", lang("turnToDynamic")),
+ node("turnToStatic", lang("turnToStatic")),
+ node("turnInto", lang("turnInto"), true, [
+ node("text", lang("text")),
+ node("*", literal("*")),
+ node("text*", () => `${window.siyuan.languages.text} *`),
+ node("link", lang("hyperlink")),
+ node("blockEmbed", lang("blockEmbed")),
+ node("defBlock", lang("defBlock"), false),
+ node("defBlockChildren", lang("defBlockChildren"), false),
+ ]),
+ node("copy", lang("copy")),
+ node("cut", lang("cut")),
+ node("remove", lang("remove")),
+ ],
+ },
+ {
+ key: "inline.link",
+ label: lang("hyperlink"),
+ children: [
+ node("linkAndAnchorAndTitle", () => `${window.siyuan.languages.hyperlink} / ${window.siyuan.languages.text} / ${window.siyuan.languages.title}`),
+ node("copy", lang("copy")),
+ node("copyAHref", lang("copyAHref")),
+ node("cut", lang("cut")),
+ node("remove", lang("remove")),
+ node("rename", lang("rename")),
+ node("turnIntoRef", lang("ref")),
+ node("turnIntoText", lang("text")),
+ node("openBy", lang("openBy")),
+ node("export", lang("export")),
+ node("copyFile", lang("copyFile")),
+ ],
+ },
+ {
+ key: "inline.fileAnnotation",
+ label: lang("export5"),
+ children: [
+ node("idAndAnchor", () => `ID / ${window.siyuan.languages.anchor}`),
+ node("turnInto", lang("turnInto"), true, [
+ node("text", lang("text")),
+ node("text*", () => `${window.siyuan.languages.text} *`),
+ ]),
+ node("remove", lang("remove")),
+ ],
+ },
+ {
+ key: "inline.tag",
+ label: lang("tag"),
+ children: [
+ node("tag", lang("tag")),
+ node("search", lang("search")),
+ node("rename", lang("rename")),
+ node("turnIntoText", lang("text")),
+ node("copy", lang("copy")),
+ node("cut", lang("cut")),
+ node("remove", lang("remove")),
+ ],
+ },
+ {
+ key: "inline.math",
+ label: lang("math"),
+ children: [node("copy", lang("copy")), node("cut", lang("cut")), node("remove", lang("remove"))],
+ },
+];
+
+const entryMap = new Map<string, IEntryCatalogNode>();
+const parentMap = new Map<string, string>();
+
+const indexNodes = (prefix: string, nodes: IEntryCatalogNode[]) => {
+ nodes.forEach((item) => {
+ const path = `${prefix}.${item.key}`;
+ entryMap.set(path, item);
+ parentMap.set(path, prefix);
+ if (item.children) {
+ indexNodes(path, item.children);
+ }
+ });
+};
+
+entryCatalog.forEach((section) => indexNodes(section.key, section.children));
+
+export const getEntryCatalogNode = (path: string) => entryMap.get(path);
+export const getEntryParentPath = (path: string) => parentMap.get(path);
+export const getEntryPaths = () => Array.from(entryMap.keys());
diff --git a/app/src/config/entryVisibility/runtime.ts b/app/src/config/entryVisibility/runtime.ts
new file mode 100644
index 0000000000..7ad1e0ed81
--- /dev/null
+++ b/app/src/config/entryVisibility/runtime.ts
@@ -0,0 +1,215 @@
+import {fetchPost} from "../../util/fetch";
+import {Constants} from "../../constants";
+import {getEntryCatalogNode, getEntryParentPath, getEntryPaths} from "./catalog";
+
+export const ENTRY_VISIBILITY_VERSION = 1;
+export const ENTRY_PROFILE_SIMPLE = "simple";
+export const ENTRY_PROFILE_FULL = "full";
+
+const getConfig = () => window.siyuan.config.appearance.entryVisibility;
+
+export const getActiveEntryProfile = () => {
+ const config = getConfig();
+ return config.profiles.find((item) => item.id === config.active);
+};
+
+const getBaseVisibility = (path: string, base: Config.TEntryVisibilityBase) =>
+ base === ENTRY_PROFILE_FULL || getEntryCatalogNode(path)?.simple !== false;
+
+export const isEntryVisible = (path: string): boolean => {
+ /// #if MOBILE
+ return true;
+ /// #else
+ const config = getConfig();
+ let visible: boolean;
+ if (config.active === ENTRY_PROFILE_FULL) {
+ visible = true;
+ } else if (config.active === ENTRY_PROFILE_SIMPLE) {
+ visible = getBaseVisibility(path, ENTRY_PROFILE_SIMPLE);
+ } else {
+ const profile = getActiveEntryProfile();
+ visible = typeof profile?.entries[path] === "boolean"
+ ? profile.entries[path]
+ : getBaseVisibility(path, profile?.base || ENTRY_PROFILE_FULL);
+ }
+ if (!visible) {
+ return false;
+ }
+ const parentPath = getEntryParentPath(path);
+ if (parentPath && getEntryCatalogNode(parentPath)) {
+ return isEntryVisible(parentPath);
+ }
+ return true;
+ /// #endif
+};
+
+export const createEntryProfileSnapshot = (base: Config.TEntryVisibilityBase) => {
+ return getEntryPaths().reduce<Record<string, boolean>>((entries, path) => {
+ entries[path] = getBaseVisibility(path, base);
+ return entries;
+ }, {});
+};
+
+let savePending: Config.IEntryVisibility | undefined;
+let saveRunning = false;
+
+const flushEntryVisibility = () => {
+ if (saveRunning || !savePending) {
+ return;
+ }
+ saveRunning = true;
+ const next = savePending;
+ savePending = undefined;
+ fetchPost("/api/setting/setEntryVisibility", next, (response) => {
+ saveRunning = false;
+ if (response.code === 0 && !savePending) {
+ applyEntryVisibility(response.data as Config.IEntryVisibility);
+ }
+ flushEntryVisibility();
+ });
+};
+
+export const saveEntryVisibility = (config: Config.IEntryVisibility) => {
+ applyEntryVisibilityLocal(config);
+ savePending = config;
+ flushEntryVisibility();
+};
+
+const entryScope = (menuElement: HTMLElement): string => {
+ switch (menuElement.dataset.name) {
+ case Constants.MENU_DOC_TREE_PANEL_MORE:
+ return "docTree.panel";
+ case Constants.MENU_DOC_TREE_MORE:
+ if (menuElement.dataset.from === Constants.MENU_FROM_DOC_TREE_MORE_NOTEBOOK) {
+ return "docTree.notebook";
+ }
+ if (menuElement.dataset.from === Constants.MENU_FROM_DOC_TREE_MORE_DOC) {
+ return "docTree.document";
+ }
+ if (menuElement.dataset.from === Constants.MENU_FROM_DOC_TREE_MORE_ITEMS) {
+ return "docTree.multi";
+ }
+ return "";
+ case Constants.MENU_TITLE:
+ return "document.title";
+ case Constants.MENU_BREADCRUMB_MORE:
+ return "document.more";
+ case Constants.MENU_BLOCK_SINGLE:
+ return "gutter.single";
+ case Constants.MENU_BLOCK_MULTI:
+ return "gutter.multi";
+ case Constants.MENU_INLINE_CONTEXT:
+ return "inline.text";
+ case Constants.MENU_INLINE_IMG:
+ return "inline.image";
+ case Constants.MENU_INLINE_REF:
+ return "inline.ref";
+ case Constants.MENU_INLINE_A:
+ return "inline.link";
+ case Constants.MENU_INLINE_FILE_ANNOTATION_REF:
+ return "inline.fileAnnotation";
+ case Constants.MENU_INLINE_TAG:
+ return "inline.tag";
+ case Constants.MENU_INLINE_MATH:
+ return "inline.math";
+ default:
+ return "";
+ }
+};
+
+const normalizeSeparators = (itemsElement: Element) => {
+ Array.from(itemsElement.children).forEach((item) => {
+ const submenu = item.querySelector(":scope > .b3-menu__submenu > .b3-menu__items");
+ if (submenu) {
+ normalizeSeparators(submenu);
+ if (!submenu.querySelector(":scope > .b3-menu__item")) {
+ item.remove();
+ }
+ }
+ });
+ let hasItem = false;
+ let previousSeparator = false;
+ const children = Array.from(itemsElement.children);
+ children.forEach((item, index) => {
+ if (item.classList.contains("b3-menu__separator")) {
+ const hasNextItem = children.slice(index + 1).some((next) =>
+ !next.classList.contains("b3-menu__separator") && next.isConnected);
+ if (!hasItem || !hasNextItem || previousSeparator) {
+ item.remove();
+ } else {
+ previousSeparator = true;
+ }
+ return;
+ }
+ hasItem = true;
+ previousSeparator = false;
+ });
+};
+
+const filterMenuItems = (itemsElement: Element, prefix: string) => {
+ Array.from(itemsElement.children).forEach((item) => {
+ if (!item.classList.contains("b3-menu__item")) {
+ return;
+ }
+ const id = item.getAttribute("data-id");
+ const path = id ? `${prefix}.${id}` : "";
+ if (path && getEntryCatalogNode(path) && !isEntryVisible(path)) {
+ item.remove();
+ return;
+ }
+ const submenu = item.querySelector(":scope > .b3-menu__submenu > .b3-menu__items");
+ if (submenu) {
+ filterMenuItems(submenu, path || prefix);
+ }
+ });
+};
+
+export const applyMenuEntryVisibility = (menuElement: HTMLElement) => {
+ /// #if !MOBILE
+ const scope = entryScope(menuElement);
+ if (!scope) {
+ return;
+ }
+ const itemsElement = menuElement.querySelector(":scope > .b3-menu__items") || menuElement.lastElementChild;
+ if (!itemsElement) {
+ return;
+ }
+ filterMenuItems(itemsElement, scope);
+ normalizeSeparators(itemsElement);
+ /// #endif
+};
+
+export const applyDockEntryVisibility = () => {
+ /// #if !MOBILE
+ document.querySelectorAll<HTMLElement>(".dock__item[data-type]").forEach((item) => {
+ const type = item.dataset.type;
+ const path = `dock.${type}`;
+ if (!getEntryCatalogNode(path)) {
+ return;
+ }
+ const visible = isEntryVisible(path);
+ if (!visible && item.classList.contains("dock__item--active")) {
+ const dock = [window.siyuan.layout.leftDock, window.siyuan.layout.rightDock, window.siyuan.layout.bottomDock]
+ .find((candidate) => candidate?.elements.some((element) => element.contains(item)));
+ dock?.toggleModel(type, false, false, false, true);
+ }
+ item.classList.toggle("fn__none", !visible);
+ });
+ /// #endif
+};
+
+const applyEntryVisibilityLocal = (config: Config.IEntryVisibility) => {
+ window.siyuan.config.appearance.entryVisibility = config;
+ /// #if !MOBILE
+ window.siyuan.menus?.menu?.remove();
+ applyDockEntryVisibility();
+ window.dispatchEvent(new CustomEvent("siyuan-entry-visibility"));
+ /// #endif
+};
+
+export const applyEntryVisibility = (config: Config.IEntryVisibility) => {
+ if (saveRunning || savePending) {
+ return;
+ }
+ applyEntryVisibilityLocal(config);
+};
diff --git a/app/src/config/entryVisibility/ui.ts b/app/src/config/entryVisibility/ui.ts
new file mode 100644
index 0000000000..57e1d12e85
--- /dev/null
+++ b/app/src/config/entryVisibility/ui.ts
@@ -0,0 +1,395 @@
+import {Dialog} from "../../dialog";
+import {confirmDialog} from "../../dialog/confirmDialog";
+import {showMessage} from "../../dialog/message";
+import {escapeAttr, escapeHtml} from "../../util/escape";
+import {genUUID} from "../../util/genID";
+import {entryCatalog, getEntryPaths, IEntryCatalogNode} from "./catalog";
+import {
+ createEntryProfileSnapshot,
+ ENTRY_PROFILE_FULL,
+ ENTRY_PROFILE_SIMPLE,
+ ENTRY_VISIBILITY_VERSION,
+ getActiveEntryProfile,
+ isEntryVisible,
+ saveEntryVisibility,
+} from "./runtime";
+
+type TImportFile = {
+ type: "siyuan-entry-profile" | "siyuan-entry-profile-bundle";
+ version: number;
+ profile?: Config.IEntryVisibilityProfile;
+ profiles?: Config.IEntryVisibilityProfile[];
+};
+
+const cloneConfig = () => JSON.parse(JSON.stringify(
+ window.siyuan.config.appearance.entryVisibility
+)) as Config.IEntryVisibility;
+
+const baseLabel = (base: Config.TEntryVisibilityBase) => base === ENTRY_PROFILE_SIMPLE
+ ? window.siyuan.languages.entrySimple
+ : window.siyuan.languages.entryFull;
+
+const uniqueName = (name: string, profiles = window.siyuan.config.appearance.entryVisibility.profiles) => {
+ const normalized = name.trim() || window.siyuan.languages.entryCustomProfile;
+ if (!profiles.some((item) => item.name === normalized)) {
+ return normalized;
+ }
+ let index = 2;
+ while (profiles.some((item) => item.name === `${normalized} (${index})`)) {
+ index++;
+ }
+ return `${normalized} (${index})`;
+};
+
+const downloadJSON = (name: string, data: unknown) => {
+ const blob = new Blob([JSON.stringify(data, undefined, 2)], {type: "application/json"});
+ const url = URL.createObjectURL(blob);
+ const anchor = document.createElement("a");
+ anchor.href = url;
+ anchor.download = name.replace(/[\\/:*?"<>|]/g, "-");
+ anchor.click();
+ URL.revokeObjectURL(url);
+};
+
+const exportProfile = (profile: Config.IEntryVisibilityProfile) => {
+ downloadJSON(`${profile.name}.siyuan-entry.json`, {
+ type: "siyuan-entry-profile",
+ version: ENTRY_VISIBILITY_VERSION,
+ profile,
+ } satisfies TImportFile);
+};
+
+const exportBundle = () => {
+ downloadJSON("入口方案.siyuan-entry-bundle.json", {
+ type: "siyuan-entry-profile-bundle",
+ version: ENTRY_VISIBILITY_VERSION,
+ profiles: window.siyuan.config.appearance.entryVisibility.profiles,
+ } satisfies TImportFile);
+};
+
+const promptName = (title: string, value: string, callback: (name: string) => void) => {
+ const dialog = new Dialog({
+ title,
+ width: "420px",
+ content: `<div class="b3-dialog__content"><input class="b3-text-field fn__block" value="${escapeAttr(value)}"></div>
+<div class="b3-dialog__action"><button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div><button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button></div>`,
+ });
+ const input = dialog.element.querySelector<HTMLInputElement>("input");
+ const submit = () => {
+ const name = input.value.trim();
+ if (!name) {
+ input.focus();
+ return;
+ }
+ callback(name);
+ dialog.destroy();
+ };
+ dialog.element.querySelector(".b3-button--cancel").addEventListener("click", () => dialog.destroy());
+ dialog.element.querySelector(".b3-button--text").addEventListener("click", submit);
+ input.addEventListener("keydown", (event) => {
+ if (event.key === "Enter") {
+ submit();
+ }
+ });
+ input.select();
+};
+
+const getCurrentBase = (): Config.TEntryVisibilityBase => {
+ const active = window.siyuan.config.appearance.entryVisibility.active;
+ if (active === ENTRY_PROFILE_SIMPLE || active === ENTRY_PROFILE_FULL) {
+ return active;
+ }
+ return getActiveEntryProfile()?.base || ENTRY_PROFILE_FULL;
+};
+
+const createProfile = (base: Config.TEntryVisibilityBase, current = false, name?: string) => {
+ const profile: Config.IEntryVisibilityProfile = {
+ id: genUUID(),
+ name: uniqueName(name || window.siyuan.languages.entryCustomProfile),
+ base,
+ entries: createEntryProfileSnapshot(base),
+ };
+ if (current) {
+ getEntryPaths().forEach((path) => {
+ profile.entries[path] = isEntryVisible(path);
+ });
+ }
+ return profile;
+};
+
+const duplicateProfile = (profile: Config.IEntryVisibilityProfile) => ({
+ ...JSON.parse(JSON.stringify(profile)) as Config.IEntryVisibilityProfile,
+ id: genUUID(),
+ name: uniqueName(`${profile.name} ${window.siyuan.languages.duplicate}`),
+});
+
+const profileCard = (
+ id: string,
+ name: string,
+ base: Config.TEntryVisibilityBase,
+ builtin: boolean,
+ active: boolean,
+) => `<div class="b3-card${active ? " b3-card--current" : ""}" data-profile-id="${escapeAttr(id)}">
+ <div class="b3-card__img"><span><svg class="b3-card__icon"><use xlink:href="#${builtin ? "iconSettings" : "iconMenu"}"></use></svg></span></div>
+ <div class="fn__flex-1 fn__flex-column">
+ <div class="b3-card__info b3-card__info--left fn__flex-1">
+ <div class="fn__ellipsis config-name">${escapeHtml(name)}</div>
+ <div class="b3-card__desc">${builtin ? window.siyuan.languages.entryBuiltin : window.siyuan.languages.entryCustom} · ${window.siyuan.languages.entryBasedOn} ${baseLabel(base)}${active ? ` · ${window.siyuan.languages.current}` : ""}</div>
+ </div>
+ </div>
+ <div class="b3-card__actions b3-card__actions--right">
+ ${active ? "" : `<button class="b3-button b3-button--outline" data-action="activate">${window.siyuan.languages.use}</button>`}
+ <button class="block__icon block__icon--show ariaLabel" data-action="edit" data-position="north" aria-label="${window.siyuan.languages.edit}"><svg><use xlink:href="#iconEdit"></use></svg></button>
+ ${builtin ? "" : `<button class="block__icon block__icon--show ariaLabel" data-action="rename" data-position="north" aria-label="${window.siyuan.languages.rename}"><svg><use xlink:href="#iconEdit"></use></svg></button>`}
+ <button class="block__icon block__icon--show ariaLabel" data-action="duplicate" data-position="north" aria-label="${window.siyuan.languages.duplicate}"><svg><use xlink:href="#iconCopy"></use></svg></button>
+ ${builtin ? "" : `<button class="block__icon block__icon--show ariaLabel" data-action="export" data-position="north" aria-label="${window.siyuan.languages.export}"><svg><use xlink:href="#iconDownload"></use></svg></button>`}
+ <button class="block__icon block__icon--show${active || builtin ? " fn__none" : " block__icon--warning"} ariaLabel" data-action="delete" data-position="north" aria-label="${window.siyuan.languages.delete}"><svg><use xlink:href="#iconTrashcan"></use></svg></button>
+ </div>
+</div>`;
+
+const renderProfileCards = (root: HTMLElement) => {
+ const container = root.querySelector<HTMLElement>("[data-type='entry-profiles']");
+ if (!container) {
+ return;
+ }
+ const config = window.siyuan.config.appearance.entryVisibility;
+ const cards = [
+ profileCard(ENTRY_PROFILE_SIMPLE, window.siyuan.languages.entrySimple, ENTRY_PROFILE_SIMPLE, true,
+ config.active === ENTRY_PROFILE_SIMPLE),
+ profileCard(ENTRY_PROFILE_FULL, window.siyuan.languages.entryFull, ENTRY_PROFILE_FULL, true,
+ config.active === ENTRY_PROFILE_FULL),
+ ...config.profiles.map((profile) => profileCard(profile.id, profile.name, profile.base, false,
+ config.active === profile.id)),
+ ];
+ container.innerHTML = `<div class="b3-cards b3-cards--nowrap">${cards.join("")}</div>`;
+};
+
+const renderEntryNode = (profile: Config.IEntryVisibilityProfile, prefix: string, item: IEntryCatalogNode,
+ parents: string[] = []): string => {
+ const path = `${prefix}.${item.key}`;
+ const label = item.label();
+ const displayLabel = [...parents, label].join(" - ");
+ const checked = typeof profile.entries[path] === "boolean"
+ ? profile.entries[path]
+ : profile.base === ENTRY_PROFILE_FULL || item.simple;
+ return `<div data-entry-row data-search="${escapeAttr(displayLabel.toLowerCase())}">
+ <label class="b3-label fn__flex" style="border-bottom:0">
+ <span class="fn__flex-1">${escapeHtml(displayLabel)}</span>
+ <input class="b3-switch" type="checkbox" data-entry-path="${escapeAttr(path)}"${checked ? " checked" : ""}>
+ </label>
+ ${item.children?.map((child) => renderEntryNode(profile, path, child, [...parents, label])).join("") || ""}
+</div>`;
+};
+
+const openProfileEditor = (root: HTMLElement, profileID: string) => {
+ let config = cloneConfig();
+ let profile = config.profiles.find((item) => item.id === profileID);
+ if (!profile) {
+ const base = profileID === ENTRY_PROFILE_SIMPLE ? ENTRY_PROFILE_SIMPLE : ENTRY_PROFILE_FULL;
+ profile = createProfile(base, false, `${baseLabel(base)} ${window.siyuan.languages.duplicate}`);
+ config.profiles.push(profile);
+ config.active = profile.id;
+ saveEntryVisibility(config);
+ renderProfileCards(root);
+ }
+ const dialog = new Dialog({
+ title: `${window.siyuan.languages.entryVisibility} - ${escapeHtml(profile.name)}`,
+ width: "720px",
+ height: "80vh",
+ content: `<div class="b3-dialog__content fn__flex-column" style="height:100%;box-sizing:border-box">
+ <div class="fn__flex"><input class="b3-text-field fn__flex-1" data-type="entry-search" placeholder="${escapeAttr(window.siyuan.languages.searchPlaceholder)}"><span class="fn__space"></span><button class="b3-button b3-button--outline" data-action="restore">${window.siyuan.languages.entryRestoreBase}</button></div>
+ <div class="b3-label__text" style="margin:8px 0">${window.siyuan.languages.entryBasedOn} ${baseLabel(profile.base)}</div>
+ <div class="fn__flex-1" data-type="entry-sections" style="overflow:auto"></div>
+</div>`,
+ });
+ const sections = dialog.element.querySelector<HTMLElement>("[data-type='entry-sections']");
+ sections.innerHTML = entryCatalog.map((section) => `<div class="b3-card fn__flex-column" data-entry-section style="cursor:default;margin-bottom:12px">
+ <div class="config-title" style="padding:16px 16px 8px">${escapeHtml(section.label())}</div>
+ <div>${section.children.map((item) => renderEntryNode(profile, section.key, item)).join("")}</div>
+</div>`).join("");
+ sections.addEventListener("change", (event) => {
+ const input = (event.target as Element).closest<HTMLInputElement>("[data-entry-path]");
+ if (!input) {
+ return;
+ }
+ config = cloneConfig();
+ profile = config.profiles.find((item) => item.id === profile.id);
+ if (!profile) {
+ return;
+ }
+ profile.entries[input.dataset.entryPath] = input.checked;
+ saveEntryVisibility(config);
+ });
+ dialog.element.querySelector<HTMLInputElement>("[data-type='entry-search']").addEventListener("input", (event) => {
+ const value = (event.currentTarget as HTMLInputElement).value.trim().toLowerCase();
+ const rows = Array.from(sections.querySelectorAll<HTMLElement>("[data-entry-row]")).reverse();
+ rows.forEach((row) => {
+ const childMatches = row.querySelector("[data-entry-row]:not(.fn__none)");
+ row.classList.toggle("fn__none", Boolean(value) && !row.dataset.search.includes(value) && !childMatches);
+ });
+ sections.querySelectorAll<HTMLElement>("[data-entry-section]").forEach((section) => {
+ section.classList.toggle("fn__none", !section.querySelector("[data-entry-row]:not(.fn__none)"));
+ });
+ });
+ dialog.element.querySelector("[data-action='restore']").addEventListener("click", () => {
+ confirmDialog(window.siyuan.languages.entryRestoreBase, window.siyuan.languages.entryRestoreBaseConfirm, () => {
+ config = cloneConfig();
+ profile = config.profiles.find((item) => item.id === profile.id);
+ if (!profile) {
+ return;
+ }
+ profile.entries = {...profile.entries, ...createEntryProfileSnapshot(profile.base)};
+ saveEntryVisibility(config);
+ dialog.destroy();
+ openProfileEditor(root, profile.id);
+ });
+ });
+};
+
+const openCreateDialog = (root: HTMLElement) => {
+ const dialog = new Dialog({
+ title: window.siyuan.languages.entryCreateProfile,
+ width: "420px",
+ content: `<div class="b3-dialog__content">
+ <label class="b3-label">${window.siyuan.languages.name}<input class="b3-text-field fn__block" data-type="name" value="${escapeAttr(uniqueName(window.siyuan.languages.entryCustomProfile))}" style="margin-top:8px"></label>
+ <label class="b3-label">${window.siyuan.languages.entryBasedOn}<select class="b3-select fn__block" data-type="base" style="margin-top:8px"><option value="simple">${window.siyuan.languages.entrySimple}</option><option value="full">${window.siyuan.languages.entryFull}</option><option value="current">${window.siyuan.languages.current}</option></select></label>
+</div><div class="b3-dialog__action"><button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div><button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button></div>`,
+ });
+ dialog.element.querySelector(".b3-button--cancel").addEventListener("click", () => dialog.destroy());
+ dialog.element.querySelector(".b3-button--text").addEventListener("click", () => {
+ const name = dialog.element.querySelector<HTMLInputElement>("[data-type='name']").value.trim();
+ if (!name) {
+ return;
+ }
+ const selection = dialog.element.querySelector<HTMLSelectElement>("[data-type='base']").value;
+ const config = cloneConfig();
+ const profile = createProfile(selection === "current" ? getCurrentBase() : selection as Config.TEntryVisibilityBase,
+ selection === "current", name);
+ config.profiles.push(profile);
+ saveEntryVisibility(config);
+ renderProfileCards(root);
+ dialog.destroy();
+ openProfileEditor(root, profile.id);
+ });
+};
+
+const importProfiles = async (root: HTMLElement, file: File) => {
+ try {
+ const data = JSON.parse(await file.text()) as TImportFile;
+ if (data.version !== ENTRY_VISIBILITY_VERSION) {
+ throw new Error("unsupported version");
+ }
+ let imported: Config.IEntryVisibilityProfile[];
+ if (data.type === "siyuan-entry-profile" && data.profile) {
+ imported = [data.profile];
+ } else if (data.type === "siyuan-entry-profile-bundle" && Array.isArray(data.profiles)) {
+ imported = data.profiles;
+ } else {
+ throw new Error("invalid type");
+ }
+ const config = cloneConfig();
+ let importedCount = 0;
+ imported.forEach((item) => {
+ if (!item || typeof item.name !== "string" || !item.name.trim() || !item.entries ||
+ Array.isArray(item.entries) ||
+ (item.base !== ENTRY_PROFILE_SIMPLE && item.base !== ENTRY_PROFILE_FULL)) {
+ return;
+ }
+ const entries = Object.entries(item.entries).reduce<Record<string, boolean>>((result, [path, visible]) => {
+ if (typeof visible === "boolean") {
+ result[path] = visible;
+ }
+ return result;
+ }, {});
+ config.profiles.push({
+ id: genUUID(),
+ name: uniqueName(item.name, config.profiles),
+ base: item.base,
+ entries,
+ });
+ importedCount++;
+ });
+ if (imported.length > 0 && importedCount === 0) {
+ throw new Error("invalid profiles");
+ }
+ saveEntryVisibility(config);
+ renderProfileCards(root);
+ showMessage(window.siyuan.languages.imported);
+ } catch (error) {
+ console.warn("import entry visibility profile failed", error);
+ showMessage(window.siyuan.languages.entryImportInvalid, 6000, "error");
+ }
+};
+
+export const genEntryVisibilityHtml = () => `<div class="b3-label config-item" data-type="entry-visibility">
+ <div class="fn__flex b3-label config-item config-wrap b3-label--noborder">
+ <div><div class="config-name">${window.siyuan.languages.entryVisibility}</div><div class="b3-label__text">${window.siyuan.languages.entryVisibilityTip}</div></div>
+ <span class="fn__space fn__flex-1"></span>
+ <button class="b3-button b3-button--outline" data-action="import"><svg class="b3-button__icon"><use xlink:href="#iconUpload"></use></svg>${window.siyuan.languages.import}</button>
+ <span class="fn__space"></span>
+ <button class="b3-button b3-button--outline" data-action="export-all"><svg class="b3-button__icon"><use xlink:href="#iconDownload"></use></svg>${window.siyuan.languages.entryExportAll}</button>
+ <span class="fn__space"></span>
+ <button class="b3-button b3-button--outline" data-action="create"><svg class="b3-button__icon"><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.entryCreateProfile}</button>
+ <input class="fn__none" data-type="entry-import" type="file" accept="application/json,.json">
+ </div>
+ <div class="fn__hr"></div>
+ <div data-type="entry-profiles"></div>
+</div>`;
+
+export const mountEntryVisibility = (root: HTMLElement) => {
+ renderProfileCards(root);
+ root.querySelector("[data-action='create']")?.addEventListener("click", () => openCreateDialog(root));
+ root.querySelector("[data-action='export-all']")?.addEventListener("click", exportBundle);
+ const fileInput = root.querySelector<HTMLInputElement>("[data-type='entry-import']");
+ root.querySelector("[data-action='import']")?.addEventListener("click", () => fileInput.click());
+ fileInput.addEventListener("change", () => {
+ const file = fileInput.files?.[0];
+ fileInput.value = "";
+ if (file) {
+ void importProfiles(root, file);
+ }
+ });
+ root.querySelector("[data-type='entry-profiles']")?.addEventListener("click", (event) => {
+ const card = (event.target as Element).closest<HTMLElement>("[data-profile-id]");
+ const action = (event.target as Element).closest<HTMLElement>("[data-action]")?.dataset.action;
+ if (!card || !action) {
+ return;
+ }
+ const id = card.dataset.profileId;
+ const config = cloneConfig();
+ const profile = config.profiles.find((item) => item.id === id);
+ if (action === "activate") {
+ config.active = id;
+ saveEntryVisibility(config);
+ renderProfileCards(root);
+ } else if (action === "edit") {
+ openProfileEditor(root, id);
+ } else if (action === "duplicate") {
+ const copy = profile ? duplicateProfile(profile) : createProfile(id as Config.TEntryVisibilityBase, false,
+ `${baseLabel(id as Config.TEntryVisibilityBase)} ${window.siyuan.languages.duplicate}`);
+ config.profiles.push(copy);
+ saveEntryVisibility(config);
+ renderProfileCards(root);
+ } else if (action === "rename" && profile) {
+ promptName(window.siyuan.languages.rename, profile.name, (name) => {
+ const latest = cloneConfig();
+ const renamed = latest.profiles.find((item) => item.id === profile.id);
+ if (renamed) {
+ renamed.name = uniqueName(name, latest.profiles.filter((item) => item.id !== profile.id));
+ saveEntryVisibility(latest);
+ renderProfileCards(root);
+ }
+ });
+ } else if (action === "export" && profile) {
+ exportProfile(profile);
+ } else if (action === "delete" && profile && config.active !== profile.id) {
+ confirmDialog(window.siyuan.languages.deleteOpConfirm,
+ window.siyuan.languages.confirmDeleteTip.replace("${x}", escapeHtml(profile.name)), () => {
+ const latest = cloneConfig();
+ latest.profiles = latest.profiles.filter((item) => item.id !== profile.id);
+ saveEntryVisibility(latest);
+ renderProfileCards(root);
+ }, undefined, true);
+ }
+ });
+};
diff --git a/app/src/config/tabs/appearanceTab.ts b/app/src/config/tabs/appearanceTab.ts
index a602865828..55b95169d3 100644
--- a/app/src/config/tabs/appearanceTab.ts
+++ b/app/src/config/tabs/appearanceTab.ts
@@ -34,6 +34,9 @@ import {
unregisterCustomFont
} from "../../util/customFont";
import {showMessage} from "../../dialog/message";
+/// #if !MOBILE
+import {genEntryVisibilityHtml, mountEntryVisibility} from "../entryVisibility/ui";
+/// #endif
interface IFontItem {
id?: string;
@@ -747,6 +750,18 @@ const registerAppearancePersonalizationGroup = (tab: SettingTabBuilder) => {
});
};
+/// #if !MOBILE
+const registerAppearanceEntryVisibilityGroup = (tab: SettingTabBuilder) => {
+ const group = tab.group("entryVisibility", window.siyuan.languages.entryVisibility);
+ group.slot({
+ key: "entryVisibility",
+ keywords: [window.siyuan.languages.entryVisibility, window.siyuan.languages.entryVisibilityTip],
+ html: genEntryVisibilityHtml,
+ afterMount: mountEntryVisibility,
+ });
+};
+/// #endif
+
const mountAppearanceCodeSnippet = (root: HTMLElement) => {
root.querySelector("#codeSnippetCommunityShare")?.addEventListener("click", () => {
openByMobile("https://ld246.com/tag/code-snippet");
@@ -759,6 +774,9 @@ const mountAppearanceCodeSnippet = (root: HTMLElement) => {
export const registerAppearanceTab = (tab: SettingTabBuilder) => {
registerAppearanceContentGroup(tab);
registerAppearanceInterfaceGroup(tab);
+ /// #if !MOBILE
+ registerAppearanceEntryVisibilityGroup(tab);
+ /// #endif
registerAppearanceControlsGroup(tab);
registerAppearancePersonalizationGroup(tab);
};
diff --git a/app/src/constants.ts b/app/src/constants.ts
index be90f031bc..f2a644d66a 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -267,6 +267,7 @@ export abstract class Constants {
public static readonly MENU_BREADCRUMB_CHILDREN = "breadcrumb-children"; // 面包屑下级块菜单
public static readonly MENU_DOC_TREE_MORE = "docTreeMore"; // 侧栏文档树右键菜单
+ public static readonly MENU_DOC_TREE_PANEL_MORE = "docTreePanelMore"; // 文档树面板更多菜单
public static readonly MENU_FROM_DOC_TREE_MORE_NOTEBOOK = "tree-notebook"; // 侧栏文档树右键菜单,单个笔记本
public static readonly MENU_FROM_DOC_TREE_MORE_DOC = "tree-doc"; // 侧栏文档树右键菜单,单个文档
public static readonly MENU_FROM_DOC_TREE_MORE_ITEMS = "tree-items"; // 侧栏文档树右键菜单,多个文档或笔记本
diff --git a/app/src/index.ts b/app/src/index.ts
index 696152e459..4d4f0d0372 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -52,6 +52,7 @@ import {setBodyHighlight} from "./util/assets";
import {reloadSync} from "./util/reloadSync";
import {setTitle} from "./util/processTitle";
import {ensureUILayout} from "./util/ensureUILayout";
+import {applyEntryVisibility} from "./config/entryVisibility/runtime";
export class App {
public plugins: import("./plugin").Plugin[] = [];
@@ -82,6 +83,9 @@ export class App {
case "setAppearance":
appearanceConfigApi.apply(data.data);
break;
+ case "setEntryVisibility":
+ applyEntryVisibility(data.data);
+ break;
case "setSnippet":
window.siyuan.config.snippet = data.data;
renderSnippet();
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index ebfd3d6cb6..ca321de9e6 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -46,6 +46,7 @@ import {
restoreMovedExpandedDocItems,
updateMovedSubtree
} from "../../util/fileTreeMove";
+import {isEntryVisible} from "../../config/entryVisibility/runtime";
export class Files extends Model {
public element: HTMLElement;
@@ -1762,10 +1763,12 @@ aria-label="${ariaLabel}">${getDocDisplayName(item.name, item.titleEmpty, true)}
private initMoreMenu() {
window.siyuan.menus.menu.remove();
+ window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_DOC_TREE_PANEL_MORE);
if (!window.siyuan.config.readonly) {
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconNewNoteBook",
label: window.siyuan.languages.newNotebook,
+ ignore: !isEntryVisible("docTree.panel.newNotebook"),
click: () => {
newNotebook();
}
@@ -1774,6 +1777,7 @@ aria-label="${ariaLabel}">${getDocDisplayName(item.name, item.titleEmpty, true)}
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconLock",
label: window.siyuan.languages.newEncryptedNotebook,
+ ignore: !isEntryVisible("docTree.panel.newEncryptedNotebook"),
click: () => {
newEncryptedNotebook();
}
@@ -1783,6 +1787,7 @@ aria-label="${ariaLabel}">${getDocDisplayName(item.name, item.titleEmpty, true)}
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconRefresh",
label: window.siyuan.languages.rebuildDataIndex,
+ ignore: !isEntryVisible("docTree.panel.rebuildDataIndex"),
click: () => {
if (!this.element.getAttribute("disabled")) {
this.element.setAttribute("disabled", "disabled");
@@ -1805,17 +1810,24 @@ aria-label="${ariaLabel}">${getDocDisplayName(item.name, item.titleEmpty, true)}
});
});
});
+ subMenu.forEach((item) => {
+ if (item.type !== "separator") {
+ item.ignore = !isEntryVisible(`docTree.panel.sort.${item.id}`);
+ }
+ });
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconSort",
label: window.siyuan.languages.sort,
type: "submenu",
submenu: subMenu,
+ ignore: !isEntryVisible("docTree.panel.sort"),
}).element);
}
if (!window.siyuan.config.readonly && window.siyuan.config.publish.enable) {
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconEye",
label: window.siyuan.languages.publishAccess,
+ ignore: !isEntryVisible("docTree.panel.publishAccess"),
checked: this.element.classList.contains("file-tree__publish-access--active"),
click: () => {
this.element.classList.toggle("file-tree__publish-access--active");
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index b7c408790b..8e170214d1 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -33,6 +33,7 @@ import {isSensitiveLayoutData, isSensitiveSearchConfig, setStorageVal} from "../
import {adjustDockPadding} from "./dock/util";
import {setTitle} from "../util/processTitle";
import {activateQueuedAVLocate, queueAVLocateRequest} from "../protyle/render/av/locate";
+import {applyDockEntryVisibility} from "../config/entryVisibility/runtime";
const isBuiltInCustomModel = (type: string) => {
return type === "siyuan-card" || type === "siyuan-database-row";
@@ -334,6 +335,7 @@ const JSONToDock = (json: any, app: App) => {
window.siyuan.layout.rightDock = new Dock({position: "Right", data: json.right, app});
window.siyuan.layout.bottomDock = new Dock({position: "Bottom", data: json.bottom, app});
adjustDockPadding();
+ applyDockEntryVisibility();
};
const removedTabs: Tab[] = [];
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index 65c3a9d911..b06ec0f9ac 100644
--- a/app/src/menus/Menu.ts
+++ b/app/src/menus/Menu.ts
@@ -5,6 +5,9 @@ import {isMobile} from "../util/functions";
import {Constants} from "../constants";
import {getTopBarHeight} from "../layout/getTopBarHeight";
import {electronUndo} from "../protyle/undo";
+/// #if !MOBILE
+import {applyMenuEntryVisibility} from "../config/entryVisibility/runtime";
+/// #endif
const CUSTOM_EVENT_LOAD_SUBMENU = "load-submenu";
@@ -203,6 +206,9 @@ export class Menu {
}
public popup(options: IPosition) {
+ /// #if !MOBILE
+ applyMenuEntryVisibility(this.element);
+ /// #endif
if (this.element.lastElementChild.innerHTML === "") {
return;
}
@@ -227,6 +233,9 @@ export class Menu {
}
public fullscreen(position: "bottom" | "all" = "all") {
+ /// #if !MOBILE
+ applyMenuEntryVisibility(this.element);
+ /// #endif
if (this.element.lastElementChild.innerHTML === "") {
return;
}
@@ -371,6 +380,9 @@ export class MenuItem {
itemsElement.append(new MenuItem(item, menu)?.element || "");
});
}
+ /// #if !MOBILE
+ applyMenuEntryVisibility(menu.element);
+ /// #endif
loaded = true;
menu.showSubMenu(submenuElement);
if (focusAfterLoad && this.element.classList.contains("b3-menu__item--show")) {
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index ae6e4be5ae..e03ea129fd 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -2178,7 +2178,8 @@ export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string)
return subMenus;
};
-export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement: HTMLTableCellElement, range: Range) => {
+export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement: HTMLTableCellElement, range: Range,
+ hideTitle = false) => {
const otherMenus: IMenu[] = [];
const colIndex = getColIndex(cellElement);
if (cellElement.rowSpan > 1 || cellElement.colSpan > 1) {
@@ -2272,6 +2273,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
otherMenus.push({
icon: "iconHeadings",
label: window.siyuan.languages.title,
+ ignore: hideTitle,
click: () => {
updateTableTitle(protyle, nodeElement);
}
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index deb092103f..f8b85ad69d 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -55,6 +55,7 @@ import {cancelSB, genEmptyElement, getLangByType, insertEmptyBlock, jumpToParent
import {setDragTipGhost} from "../util/dragTip";
import {countBlockWord} from "../../layout/status";
import {Constants} from "../../constants";
+import {isEntryVisible} from "../../config/entryVisibility/runtime";
import {mathRender} from "../render/mathRender";
import {duplicateBlock} from "../wysiwyg/commonHotkey";
import {isEncryptedBox, movePathTo, useShell} from "../../util/pathName";
@@ -769,8 +770,15 @@ export class Gutter {
type: string,
level?: number,
}) {
+ let visibilityID = options.menuId;
+ if (!visibilityID && options.type === "Blockquote2Callout") {
+ visibilityID = "callout";
+ } else if (!visibilityID && options.type === "Callout2Blockquote") {
+ visibilityID = "quote";
+ }
return {
id: options.menuId,
+ ignore: visibilityID ? !isEntryVisible(`gutter.single.turnInto.${visibilityID}`) : false,
icon: options.icon,
label: options.label,
accelerator: options.accelerator,
@@ -2043,7 +2051,8 @@ export class Gutter {
type: "submenu",
icon: "iconTable",
label: window.siyuan.languages.table,
- submenu: tableMenu(protyle, nodeElement, cellElement as HTMLTableCellElement, range).menus as IMenu[]
+ submenu: tableMenu(protyle, nodeElement, cellElement as HTMLTableCellElement, range,
+ !isEntryVisible("gutter.single.table.title")).menus as IMenu[]
}).element);
}
} else if (type === "NodeAttributeView") {
@@ -3072,6 +3081,7 @@ export class Gutter {
copyMenu.splice(6, 0, {
iconHTML: "",
label: window.siyuan.languages.copyAVID,
+ ignore: !isEntryVisible("gutter.single.copy.copyAVID"),
click() {
writeText(nodeElement.getAttribute("data-av-id"));
}
diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.ts
index daace31746..76fa3e93c2 100644
--- a/app/src/protyle/header/openTitleMenu.ts
+++ b/app/src/protyle/header/openTitleMenu.ts
@@ -27,6 +27,7 @@ import {openFileById} from "../../editor/util";
import {hasTopClosestByClassName} from "../util/hasClosest";
import {showMessage} from "../../dialog/message";
import {removeZWJ} from "../util/normalizeText";
+import {isEntryVisible} from "../../config/entryVisibility/runtime";
export const openTitleMenu = (protyle: IProtyle, position: IPosition, from: string) => {
hideTooltip();
@@ -52,6 +53,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition, from: stri
iconHTML: "",
label: window.siyuan.languages.copyDoc,
accelerator: undefined,
+ ignore: !isEntryVisible("document.title.copy.copyDoc"),
click: async () => {
const [responseHTML, responseText] = await Promise.all([
fetchSyncPost("/api/block/getBlockDOM", {
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index 45ac4489df..897ffb493b 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -333,6 +333,22 @@ declare namespace Config {
themeVer: string;
statusBar: IAppearanceStatusBar;
notifications: IAppearanceNotifications;
+ entryVisibility: IEntryVisibility;
+ }
+
+ export type TEntryVisibilityBase = "simple" | "full";
+
+ export interface IEntryVisibilityProfile {
+ id: string;
+ name: string;
+ base: TEntryVisibilityBase;
+ entries: Record<string, boolean>;
+ }
+
+ export interface IEntryVisibility {
+ version: number;
+ active: string;
+ profiles: IEntryVisibilityProfile[];
}
export interface IAppearanceStatusBar {
diff --git a/app/src/window/index.ts b/app/src/window/index.ts
index 09a477cdb5..fb0bbd7dc5 100644
--- a/app/src/window/index.ts
+++ b/app/src/window/index.ts
@@ -31,6 +31,7 @@ import {setBodyHighlight} from "../util/assets";
import {reloadSync} from "../util/reloadSync";
import {setTitle} from "../util/processTitle";
import {ensureUILayout} from "../util/ensureUILayout";
+import {applyEntryVisibility} from "../config/entryVisibility/runtime";
class App {
public plugins: import("../plugin").Plugin[] = [];
@@ -56,6 +57,9 @@ class App {
case "setAppearance":
appearanceConfigApi.apply(data.data);
break;
+ case "setEntryVisibility":
+ applyEntryVisibility(data.data);
+ break;
case "setSnippet":
window.siyuan.config.snippet = data.data;
renderSnippet();
diff --git a/kernel/api/router.go b/kernel/api/router.go
index 47579d0179..f5868eb39f 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -438,6 +438,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/setting/setSearch", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSearch)
ginServer.Handle("POST", "/api/setting/setKeymap", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setKeymap)
ginServer.Handle("POST", "/api/setting/setAppearance", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setAppearance)
+ ginServer.Handle("POST", "/api/setting/setEntryVisibility", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setEntryVisibility)
ginServer.Handle("POST", "/api/setting/setIcon", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setIcon)
ginServer.Handle("POST", "/api/setting/setTheme", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setTheme)
ginServer.Handle("POST", "/api/setting/getCloudUser", model.CheckAuth, getCloudUser)
diff --git a/kernel/api/setting.go b/kernel/api/setting.go
index 4b9ae64f44..ff201933e2 100644
--- a/kernel/api/setting.go
+++ b/kernel/api/setting.go
@@ -710,6 +710,9 @@ func setAppearance(c *gin.Context) {
return
}
+ if nil == appearance.EntryVisibility {
+ appearance.EntryVisibility = model.Conf.Appearance.EntryVisibility
+ }
model.Conf.Appearance = appearance
util.StatusBarCfg = model.Conf.Appearance.StatusBar
if nil == util.StatusBarCfg {
@@ -729,6 +732,33 @@ func setAppearance(c *gin.Context) {
util.BroadcastByType("main", "setAppearance", 0, "", model.Conf.Appearance)
}
+func setEntryVisibility(c *gin.Context) {
+ ret := gulu.Ret.NewResult()
+ defer c.JSON(http.StatusOK, ret)
+
+ arg, ok := util.JsonArg(c, ret)
+ if !ok {
+ return
+ }
+ param, err := gulu.JSON.MarshalJSON(arg)
+ if err != nil {
+ ret.Code = -1
+ ret.Msg = err.Error()
+ return
+ }
+ entryVisibility := &conf.EntryVisibility{}
+ if err = gulu.JSON.UnmarshalJSON(param, entryVisibility); err != nil {
+ ret.Code = -1
+ ret.Msg = err.Error()
+ return
+ }
+ entryVisibility = conf.NormalizeEntryVisibility(entryVisibility, conf.EntryVisibilityProfileFull)
+ model.Conf.Appearance.EntryVisibility = entryVisibility
+ model.Conf.Save()
+ ret.Data = entryVisibility
+ util.BroadcastByType("main", "setEntryVisibility", 0, "", entryVisibility)
+}
+
func setIcon(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
diff --git a/kernel/conf/appearance.go b/kernel/conf/appearance.go
index 85e13d3c9e..a72e51520c 100644
--- a/kernel/conf/appearance.go
+++ b/kernel/conf/appearance.go
@@ -38,6 +38,7 @@ type Appearance struct {
HideStatusBar bool `json:"hideStatusBar"` // 是否隐藏底部状态栏
StatusBar *util.StatusBar `json:"statusBar"` // 底部状态栏配置
Notifications *util.Notifications `json:"notifications"` // 外观通知开关配置
+ EntryVisibility *EntryVisibility `json:"entryVisibility"` // 桌面端入口可见性配置
}
func NewAppearance() *Appearance {
@@ -55,9 +56,76 @@ func NewAppearance() *Appearance {
HideStatusBar: false,
StatusBar: &util.StatusBar{},
Notifications: util.NewNotifications(),
+ EntryVisibility: NewEntryVisibility(EntryVisibilityProfileSimple),
}
}
+const (
+ EntryVisibilityVersion = 1
+ EntryVisibilityProfileSimple = "simple"
+ EntryVisibilityProfileFull = "full"
+)
+
+type EntryVisibility struct {
+ Version int `json:"version"`
+ Active string `json:"active"`
+ Profiles []*EntryVisibilityProfile `json:"profiles"`
+}
+
+type EntryVisibilityProfile struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Base string `json:"base"`
+ Entries map[string]bool `json:"entries"`
+}
+
+func NewEntryVisibility(active string) *EntryVisibility {
+ if active != EntryVisibilityProfileSimple && active != EntryVisibilityProfileFull {
+ active = EntryVisibilityProfileFull
+ }
+ return &EntryVisibility{
+ Version: EntryVisibilityVersion,
+ Active: active,
+ Profiles: []*EntryVisibilityProfile{},
+ }
+}
+
+func NormalizeEntryVisibility(entryVisibility *EntryVisibility, fallback string) *EntryVisibility {
+ if nil == entryVisibility {
+ return NewEntryVisibility(fallback)
+ }
+ entryVisibility.Version = EntryVisibilityVersion
+ if nil == entryVisibility.Profiles {
+ entryVisibility.Profiles = []*EntryVisibilityProfile{}
+ }
+
+ profileIDs := map[string]bool{}
+ profiles := make([]*EntryVisibilityProfile, 0, len(entryVisibility.Profiles))
+ for _, profile := range entryVisibility.Profiles {
+ if nil == profile || "" == profile.ID || "" == profile.Name || profile.ID == EntryVisibilityProfileSimple ||
+ profile.ID == EntryVisibilityProfileFull || profileIDs[profile.ID] {
+ continue
+ }
+ if profile.Base != EntryVisibilityProfileSimple && profile.Base != EntryVisibilityProfileFull {
+ profile.Base = EntryVisibilityProfileFull
+ }
+ if nil == profile.Entries {
+ profile.Entries = map[string]bool{}
+ }
+ profileIDs[profile.ID] = true
+ profiles = append(profiles, profile)
+ }
+ entryVisibility.Profiles = profiles
+ if entryVisibility.Active != EntryVisibilityProfileSimple && entryVisibility.Active != EntryVisibilityProfileFull &&
+ !profileIDs[entryVisibility.Active] {
+ entryVisibility.Active = fallback
+ }
+ if entryVisibility.Active != EntryVisibilityProfileSimple && entryVisibility.Active != EntryVisibilityProfileFull {
+ entryVisibility.Active = EntryVisibilityProfileFull
+ }
+ return entryVisibility
+}
+
type AppearanceTheme struct {
Name string `json:"name"` // daylight
Label string `json:"label"` // i18n display name
diff --git a/kernel/conf/appearance_test.go b/kernel/conf/appearance_test.go
new file mode 100644
index 0000000000..d661392849
--- /dev/null
+++ b/kernel/conf/appearance_test.go
@@ -0,0 +1,54 @@
+// SiYuan - Refactor your thinking
+// Copyright (c) 2020-present, b3log.org
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+package conf
+
+import "testing"
+
+func TestNormalizeEntryVisibilityDefaults(t *testing.T) {
+ entryVisibility := NormalizeEntryVisibility(nil, EntryVisibilityProfileSimple)
+ if entryVisibility.Version != EntryVisibilityVersion || entryVisibility.Active != EntryVisibilityProfileSimple {
+ t.Fatalf("unexpected defaults: %+v", entryVisibility)
+ }
+ if nil == entryVisibility.Profiles || 0 != len(entryVisibility.Profiles) {
+ t.Fatalf("unexpected profiles: %+v", entryVisibility.Profiles)
+ }
+}
+
+func TestNormalizeEntryVisibilityProfiles(t *testing.T) {
+ entryVisibility := NormalizeEntryVisibility(&EntryVisibility{
+ Version: 99,
+ Active: "missing",
+ Profiles: []*EntryVisibilityProfile{
+ nil,
+ {ID: "", Name: "missing-id"},
+ {ID: EntryVisibilityProfileSimple, Name: "Reserved"},
+ {ID: "custom", Name: "Custom", Base: "invalid", Entries: map[string]bool{"future.entry": false}},
+ {ID: "custom", Name: "Duplicate"},
+ },
+ }, EntryVisibilityProfileFull)
+
+ if entryVisibility.Version != EntryVisibilityVersion || entryVisibility.Active != EntryVisibilityProfileFull {
+ t.Fatalf("unexpected normalized config: %+v", entryVisibility)
+ }
+ if 1 != len(entryVisibility.Profiles) {
+ t.Fatalf("unexpected profiles: %+v", entryVisibility.Profiles)
+ }
+ profile := entryVisibility.Profiles[0]
+ if profile.Base != EntryVisibilityProfileFull || profile.Entries["future.entry"] {
+ t.Fatalf("unexpected normalized profile: %+v", profile)
+ }
+}
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index c8ebfb9f62..01043bed26 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -149,10 +149,13 @@ func InitConf() {
Conf = NewAppConf()
clearEncryptedExportTempOnBoot()
confPath := filepath.Join(util.ConfDir, "conf.json")
- if gulu.File.IsExist(confPath) {
+ confFileExists := gulu.File.IsExist(confPath)
+ entryVisibilityConfigured := false
+ if confFileExists {
if data, err := os.ReadFile(confPath); err != nil {
logging.LogErrorf("load conf [%s] failed: %s", confPath, err)
} else {
+ entryVisibilityConfigured = bytes.Contains(data, []byte(`"entryVisibility"`))
// 解析失败时保留已成功写入的字段;未导出字段(m、userLock)与未触及的导出字段保持 NewAppConf() 初值。
if err = gulu.JSON.UnmarshalJSON(data, Conf); err != nil {
logging.LogWarnf("parse conf failed, parsed fields retained: %s", err)
@@ -237,6 +240,14 @@ func InitConf() {
if nil == Conf.Appearance {
Conf.Appearance = conf.NewAppearance()
}
+ entryVisibilityFallback := conf.EntryVisibilityProfileSimple
+ if confFileExists {
+ entryVisibilityFallback = conf.EntryVisibilityProfileFull
+ }
+ if confFileExists && !entryVisibilityConfigured {
+ Conf.Appearance.EntryVisibility = nil
+ }
+ Conf.Appearance.EntryVisibility = conf.NormalizeEntryVisibility(Conf.Appearance.EntryVisibility, entryVisibilityFallback)
var langOK bool
for _, l := range Conf.Langs {
if Conf.Lang == l.Name {