🎨 Updated
This commit is contained in:
BIN
build/linux/appimage/appicon.png
Normal file
BIN
build/linux/appimage/appicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
10
build/linux/voidraft.desktop
Normal file
10
build/linux/voidraft.desktop
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=voidraft
|
||||||
|
Exec=voidraft
|
||||||
|
Icon=appicon
|
||||||
|
Categories=Development;
|
||||||
|
Terminal=false
|
||||||
|
Keywords=wails
|
||||||
|
Version=1.0
|
||||||
|
StartupNotify=false
|
@@ -9,7 +9,6 @@ import {createBasicSetup} from '@/views/editor/extensions/basicSetup';
|
|||||||
import {
|
import {
|
||||||
createStatsUpdateExtension,
|
createStatsUpdateExtension,
|
||||||
getTabExtensions,
|
getTabExtensions,
|
||||||
updateStats,
|
|
||||||
updateTabConfig,
|
updateTabConfig,
|
||||||
createAutoSavePlugin,
|
createAutoSavePlugin,
|
||||||
createSaveShortcutPlugin,
|
createSaveShortcutPlugin,
|
||||||
@@ -22,7 +21,7 @@ import { useThemeStore } from './themeStore';
|
|||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { SystemThemeType } from '@/../bindings/voidraft/internal/models/models';
|
import { SystemThemeType } from '@/../bindings/voidraft/internal/models/models';
|
||||||
import { DocumentService } from '@/../bindings/voidraft/internal/services';
|
import { DocumentService } from '@/../bindings/voidraft/internal/services';
|
||||||
|
import {ensureSyntaxTree } from "@codemirror/language"
|
||||||
export interface DocumentStats {
|
export interface DocumentStats {
|
||||||
lines: number;
|
lines: number;
|
||||||
characters: number;
|
characters: number;
|
||||||
@@ -199,15 +198,15 @@ export const useEditorStore = defineStore('editor', () => {
|
|||||||
|
|
||||||
// 将编辑器实例保存到store
|
// 将编辑器实例保存到store
|
||||||
setEditorView(view);
|
setEditorView(view);
|
||||||
|
|
||||||
isEditorInitialized.value = true;
|
isEditorInitialized.value = true;
|
||||||
|
|
||||||
// 确保编辑器已渲染后再滚动到底部
|
|
||||||
scrollToBottom(view);
|
scrollToBottom(view);
|
||||||
|
|
||||||
|
ensureSyntaxTree(view.state, view.state.doc.length, 5000)
|
||||||
|
|
||||||
// 应用初始字体大小
|
// 应用初始字体大小
|
||||||
applyFontSize();
|
applyFontSize();
|
||||||
|
|
||||||
// 立即更新统计信息
|
|
||||||
updateStats(view, updateDocumentStats);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重新配置编辑器
|
// 重新配置编辑器
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
import {Extension} from '@codemirror/state';
|
import {Extension} from '@codemirror/state';
|
||||||
import {EditorView} from '@codemirror/view';
|
import {EditorView} from '@codemirror/view';
|
||||||
import {DocumentStats} from '@/stores/editorStore';
|
import {DocumentStats} from '@/stores/editorStore';
|
||||||
|
import {getActiveNoteBlock} from '@/views/editor/extensions/codeblock/state';
|
||||||
|
|
||||||
// 更新编辑器文档统计信息
|
// 更新编辑器文档统计信息
|
||||||
export const updateStats = (
|
export const updateStats = (
|
||||||
view: EditorView,
|
view: EditorView,
|
||||||
@@ -9,22 +11,44 @@ export const updateStats = (
|
|||||||
if (!view) return;
|
if (!view) return;
|
||||||
|
|
||||||
const state = view.state;
|
const state = view.state;
|
||||||
const doc = state.doc;
|
|
||||||
const text = doc.toString();
|
|
||||||
|
|
||||||
// 计算选中的字符数
|
// 获取当前光标所在的代码块
|
||||||
|
const activeBlock = getActiveNoteBlock(state as any);
|
||||||
|
|
||||||
|
if (!activeBlock) {
|
||||||
|
// 如果没有活动块,显示空统计
|
||||||
|
updateDocumentStats({
|
||||||
|
lines: 0,
|
||||||
|
characters: 0,
|
||||||
|
selectedCharacters: 0
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前块的内容范围
|
||||||
|
const blockContent = state.doc.sliceString(activeBlock.content.from, activeBlock.content.to);
|
||||||
|
|
||||||
|
// 计算块内容的行数
|
||||||
|
const blockLines = blockContent.split('\n').length;
|
||||||
|
|
||||||
|
// 计算选中的字符数(只统计在当前块内的选中内容)
|
||||||
let selectedChars = 0;
|
let selectedChars = 0;
|
||||||
const selections = state.selection;
|
const selections = state.selection;
|
||||||
if (selections) {
|
if (selections) {
|
||||||
for (let i = 0; i < selections.ranges.length; i++) {
|
for (let i = 0; i < selections.ranges.length; i++) {
|
||||||
const range = selections.ranges[i];
|
const range = selections.ranges[i];
|
||||||
selectedChars += range.to - range.from;
|
// 计算选中范围与当前块内容范围的交集
|
||||||
|
const selectionStart = Math.max(range.from, activeBlock.content.from);
|
||||||
|
const selectionEnd = Math.min(range.to, activeBlock.content.to);
|
||||||
|
if (selectionStart < selectionEnd) {
|
||||||
|
selectedChars += selectionEnd - selectionStart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDocumentStats({
|
updateDocumentStats({
|
||||||
lines: doc.lines,
|
lines: blockLines,
|
||||||
characters: text.length,
|
characters: blockContent.length,
|
||||||
selectedCharacters: selectedChars
|
selectedCharacters: selectedChars
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -103,19 +101,10 @@ type ConfigMetadata struct {
|
|||||||
|
|
||||||
// NewDefaultAppConfig 创建默认应用配置
|
// NewDefaultAppConfig 创建默认应用配置
|
||||||
func NewDefaultAppConfig() *AppConfig {
|
func NewDefaultAppConfig() *AppConfig {
|
||||||
// 获取当前工作目录
|
|
||||||
currentDir, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
currentDir = "."
|
|
||||||
}
|
|
||||||
|
|
||||||
// 默认路径配置 - 使用当前目录
|
|
||||||
dataDir := filepath.Join(currentDir, "data")
|
|
||||||
|
|
||||||
return &AppConfig{
|
return &AppConfig{
|
||||||
General: GeneralConfig{
|
General: GeneralConfig{
|
||||||
AlwaysOnTop: false,
|
AlwaysOnTop: false,
|
||||||
DataPath: dataDir,
|
DataPath: "./data",
|
||||||
EnableSystemTray: true,
|
EnableSystemTray: true,
|
||||||
StartAtLogin: false,
|
StartAtLogin: false,
|
||||||
EnableGlobalHotkey: false,
|
EnableGlobalHotkey: false,
|
||||||
|
@@ -36,6 +36,6 @@ func NewDefaultDocument() *Document {
|
|||||||
LastUpdated: now,
|
LastUpdated: now,
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
},
|
},
|
||||||
Content: "\n∞∞∞text-a\n",
|
Content: "∞∞∞text-a\n",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v3/pkg/services/log"
|
"github.com/wailsapp/wails/v3/pkg/services/log"
|
||||||
|
Reference in New Issue
Block a user