This commit is contained in:
2025-11-02 22:06:42 +08:00
parent e71b69db5f
commit c2aa65193d
19 changed files with 427 additions and 274 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@@ -68,7 +68,7 @@
let tempFilePath = '';
// 初始化Monaco Editor
require(['vs/editor/editor.main'], function () {
require(['vs/editor/editor.main'], function() {
// 从URL参数获取内容和语言
const urlParams = new URLSearchParams(window.location.search);
const contentParam = urlParams.get('content');
@@ -82,6 +82,7 @@
initialContent = Base.decode(contentParam);
} catch (e) {
console.error('解码内容失败:', e);
initialContent = contentParam; // 如果解码失败,使用原始内容
}
}
@@ -89,28 +90,33 @@
editor = monaco.editor.create(document.getElementById('container'), {
value: initialContent,
language: languageParam,
theme: 'vs-dark',
automaticLayout: true,
minimap: { enabled: true },
scrollBeyondLastLine: false,
fontSize: 14,
wordWrap: 'on',
fontFamily: 'Consolas, "Courier New", monospace',
scrollBeyondLastLine: false,
lineNumbers: 'on',
readOnly: false,
fontFamily: 'Consolas, "Microsoft YaHei", monospace'
roundedSelection: true,
scrollbar: {
useShadows: false,
verticalScrollbarSize: 10,
horizontalScrollbarSize: 10
}
});
// 添加内容变化监听器
editor.onDidChangeModelContent(function() {
// 内容变化处理
});
// 窗口大小改变时重新布局
window.onresize = function () {
// 监听窗口大小变化
window.addEventListener('resize', function() {
if (editor) {
editor.layout();
}
};
});
// 延迟执行,确保编辑器已初始化
setTimeout(function() {
if (editor) {
editor.focus();
}
}, 100);
});
// 暴露获取内容的方法给QWebEngineView调用
@@ -151,10 +157,7 @@
language: editor && editor.getModel() ? editor.getModel().getLanguageId() : 'text'
};
// 方法1: 保存到localStorage
localStorage.setItem('leonpan_editor_content', JSON.stringify(saveData));
// 方法2: 直接向本地服务器发送POST请求主要方式
// 直接向本地服务器发送POST请求主要方式
try {
// 获取当前端口号
const currentPort = window.location.port;
@@ -167,53 +170,38 @@
xhr.onload = function() {
if (xhr.status === 200) {
console.log('服务器接收保存成功');
alert('内容已成功保存并返回应用程序');
// 尝试使用自定义协议返回应用程序
try {
window.location.href = 'leonpan:save-success';
} catch (e) {
console.error('无法通过协议返回应用程序:', e);
}
// 尝试关闭窗口(某些浏览器可能阻止此操作)
setTimeout(function() {
window.close();
}, 500);
} else {
console.error('服务器返回错误状态:', xhr.status);
alert('保存失败,请重试');
}
};
xhr.onerror = function() {
console.error('向服务器发送保存请求失败');
alert('保存请求发送失败,请检查网络连接');
};
xhr.send(JSON.stringify(saveData));
} catch (e) {
console.error('发送保存请求时出错:', e);
alert('保存过程中发生错误: ' + e.message);
}
// 方法3: 创建一个下载链接作为备用方式
const blob = new Blob([JSON.stringify(saveData)], {type: 'application/json'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
// 设置文件名和下载路径
a.download = 'editor_content.json';
// 如果提供了临时文件路径,尝试使用该路径
if (tempFilePath) {
// 对于Windows路径需要进行特殊处理
if (navigator.platform.indexOf('Win') !== -1) {
// 在Windows中我们不能直接设置文件系统路径但可以提示用户
console.log('建议保存路径:', tempFilePath);
}
}
a.href = url;
// 显示成功提示
alert('内容已成功保存!应用程序将自动检测到您的更改。');
// 自动触发下载(作为备用机制)
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
// 尝试通过协议处理程序返回应用程序
try {
// 使用自定义协议打开应用程序
window.location.href = 'leonpan:save-success';
} catch (e) {
console.error('无法返回应用程序:', e);
}
// 备用: 保存到localStorage以便应用程序在POST失败时可以尝试读取
localStorage.setItem('leonpan_editor_content', JSON.stringify(saveData));
}
// 获取系统临时目录路径(用于显示给用户)
@@ -228,56 +216,28 @@
}
}
// 从URL参数获取初始化数据
// 初始化函数根据URL参数
function initFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
const contentParam = urlParams.get('content');
const languageParam = urlParams.get('language');
// 获取并设置内容
const encodedContent = urlParams.get('content');
if (encodedContent) {
if (contentParam) {
try {
const decodedContent = Base.decode(encodedContent);
const decodedContent = Base.decode(contentParam);
setEditorContent(decodedContent);
} catch (e) {
console.error('解码内容失败:', e);
console.error('从URL初始化内容失败:', e);
}
}
// 获取并设置语言
const language = urlParams.get('language') || 'text';
setEditorLanguage(language);
// 保存文件ID到本地存储
const fileId = urlParams.get('fileId');
if (fileId) {
localStorage.setItem('currentFileId', fileId);
if (languageParam) {
setEditorLanguage(languageParam);
}
// 获取临时文件路径
tempFilePath = urlParams.get('temp_file') || '';
}
// 初始化时从URL参数加载数据
// 页面加载完成后执行初始化
window.addEventListener('load', function() {
// 从localStorage中加载可能保存的内容
const savedContent = localStorage.getItem('leonpan_editor_content');
if (savedContent) {
try {
const parsed = JSON.parse(savedContent);
if (parsed.saved && parsed.content) {
// 延迟执行,确保编辑器已初始化
setTimeout(() => {
if (editor) {
const decodedContent = Base.decode(parsed.content);
editor.setValue(decodedContent);
}
}, 1000);
}
} catch (e) {
console.error('解析保存的内容失败:', e);
}
}
// 延迟执行,确保编辑器已初始化
setTimeout(initFromUrl, 1000);
});

103
_internal/lang/en.json Normal file
View File

@@ -0,0 +1,103 @@
{
"你好": "Hello",
"我的文件": "My Files",
"存储配额": "Storage Quota",
"任务管理": "Task Management",
"应用信息": "Application Information",
"此页面正在建设中...": "This page is under construction...",
"语言设置:": "Language Settings:",
"中文": "Chinese",
"English": "English",
"上传": "Upload",
"设置": "Settings",
"确定": "OK",
"取消": "Cancel",
"关闭": "Close",
"刷新": "Refresh",
"删除": "Delete",
"重命名": "Rename",
"移动": "Move",
"复制": "Copy",
"分享": "Share",
"新建文件夹": "New Folder",
"文件信息": "File Info",
"大小": "Size",
"类型": "Type",
"修改时间": "Modified Time",
"创建时间": "Created Time",
"状态": "Status",
"进度": "Progress",
"速度": "Speed",
"剩余时间": "Remaining Time",
"暂停": "Pause",
"继续": "Resume",
"重试": "Retry",
"完成": "Completed",
"失败": "Failed",
"等待中": "Waiting",
"进行中": "In Progress",
"仓内搜索": "Search Within Folder",
"站内搜索": "Search Within Site",
"搜索文件": "Search Files",
"添加标签": "Add Tag",
"标签名称": "Tag Name",
"标签通配符": "Tag Expression",
"文件上传": "File Upload",
"文件下载": "File Download",
"用户组基础容量": "User Group Basic Capacity",
"有效容量包附加附加容量": "Valid Capacity Package Additional Capacity",
"已使用容量": "Used Capacity",
"总容量": "Total Capacity",
"LeonPan": "LeonPan",
"修改昵称": "Modify Nickname",
"用户信息": "User Information",
"修改头像": "Modify Avatar",
"用户头像": "User Avatar",
"点击修改头像": "Click to Modify Avatar",
"电子邮箱": "Email Address",
"当前用户组": "Current User Group",
"用户注册时间": "User Registration Time",
"修改成功": "Modification Successful",
"昵称修改成功": "Nickname Modification Successful",
"选择图片": "Select Image",
"头像修改成功": "Avatar Modification Successful",
"选择下载保存路径": "Select Download Save Path",
"选择文件夹": "Select Folder",
"下载保存路径修改成功": "Download Save Path Modification Successful",
"背景图片设置": "Background Image Settings",
"官方背景图": "Official Background Image",
"选择自定义背景": "Select Custom Background",
"图片背景透明度": "Image Background Opacity",
"设置图片背景透明度": "Set Image Background Opacity",
"透明度": "Opacity",
"透明度范围": "Opacity Range",
"选择自定义图片,选择后请不要更改图片位置": "Select Custom Image, Do Not Change Image Location After Selection",
"隐私协议": "Privacy Policy",
"用户协议": "User Agreement",
"官方预设背景图片": "Official Preset Background Images",
"选择背景图片": "Select Background Image",
"自定义背景图片": "Custom Background Image",
"选择保存路径": "Select Save Path",
"用户昵称": "User Nickname",
"更新设置": "Update Settings",
"检查更新": "Check for Updates",
"检查是否有新版本可用": "Check if new version is available",
"当前版本": "Current Version",
"发现新版本": "New Version Found",
"最新版本": "Latest Version",
"更新内容": "Update Content",
"立即更新": "Update Now",
"稍后更新": "Update Later",
"检查更新失败": "Failed to Check Updates",
"无法连接到更新服务器,请稍后再试。": "Failed to connect to update server, please try again later.",
"开启自动更新": "Enable Auto Update",
"在应用启动时自动检查更新": "Automatically check for updates when the application starts",
"已是最新版本": "Already Latest Version",
"语言设置": "Language Settings",
"下载": "download",
"预览": "preview",
"进入": "enter",
"刷新当前": "refresh current",
"上传文件": "upload file",
"设置存储策略": "Set Storage Strategy"
}

103
_internal/lang/zh.json Normal file
View File

@@ -0,0 +1,103 @@
{
"你好": "你好",
"我的文件": "我的文件",
"存储配额": "存储配额",
"任务管理": "任务管理",
"应用信息": "应用信息",
"此页面正在建设中...": "此页面正在建设中...",
"语言设置:": "语言设置:",
"中文": "中文",
"English": "English",
"上传": "上传",
"设置": "设置",
"确定": "确定",
"取消": "取消",
"关闭": "关闭",
"刷新": "刷新",
"删除": "删除",
"重命名": "重命名",
"移动": "移动",
"复制": "复制",
"分享": "分享",
"新建文件夹": "新建文件夹",
"文件信息": "文件信息",
"大小": "大小",
"类型": "类型",
"修改时间": "修改时间",
"创建时间": "创建时间",
"状态": "状态",
"进度": "进度",
"速度": "速度",
"剩余时间": "剩余时间",
"暂停": "暂停",
"继续": "继续",
"重试": "重试",
"完成": "完成",
"失败": "失败",
"等待中": "等待中",
"进行中": "进行中",
"仓内搜索": "仓内搜索",
"站内搜索": "站内搜索",
"搜索文件": "搜索文件",
"添加标签": "添加标签",
"标签名称": "标签名称",
"标签通配符": "标签通配符",
"文件上传": "文件上传",
"文件下载": "文件下载",
"用户组基础容量": "用户组基础容量",
"有效容量包附加附加容量": "有效容量包附加附加容量",
"已使用容量": "已使用容量",
"总容量": "总容量",
"LeonPan": "LeonPan",
"修改昵称": "修改昵称",
"用户信息": "用户信息",
"修改头像": "修改头像",
"用户头像": "用户头像",
"点击修改头像": "点击修改头像",
"电子邮箱": "电子邮箱",
"当前用户组": "当前用户组",
"用户注册时间": "用户注册时间",
"修改成功": "修改成功",
"昵称修改成功": "昵称修改成功",
"选择图片": "选择图片",
"头像修改成功": "头像修改成功",
"选择下载保存路径": "选择下载保存路径",
"选择文件夹": "选择文件夹",
"下载保存路径修改成功": "下载保存路径修改成功",
"背景图片设置": "背景图片设置",
"官方背景图": "官方背景图",
"选择自定义背景": "选择自定义背景",
"图片背景透明度": "图片背景透明度",
"设置图片背景透明度": "设置图片背景透明度",
"透明度": "透明度",
"透明度范围": "透明度范围",
"选择自定义图片,选择后请不要更改图片位置": "选择自定义图片,选择后请不要更改图片位置",
"隐私协议": "隐私协议",
"用户协议": "用户协议",
"官方预设背景图片": "官方预设背景图片",
"选择背景图片": "选择背景图片",
"自定义背景图片": "自定义背景图片",
"选择保存路径": "选择保存路径",
"用户昵称": "用户昵称",
"更新设置": "更新设置",
"检查更新": "检查更新",
"检查是否有新版本可用": "检查是否有新版本可用",
"当前版本": "当前版本",
"发现新版本": "发现新版本",
"最新版本": "最新版本",
"更新内容": "更新内容",
"立即更新": "立即更新",
"稍后更新": "稍后更新",
"检查更新失败": "检查更新失败",
"无法连接到更新服务器,请稍后再试。": "无法连接到更新服务器,请稍后再试。",
"开启自动更新": "开启自动更新",
"在应用启动时自动检查更新": "在应用启动时自动检查更新",
"已是最新版本": "已是最新版本",
"语言设置": "语言设置",
"下载": "下载",
"预览": "预览",
"进入": "进入",
"刷新当前": "刷新当前",
"上传文件": "上传文件",
"设置存储策略": "设置存储策略"
}