-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(portal-web): 门户系统文件管理新增文件编辑功能 (#942)
# 文件编辑功能 ## 1. 查看页面采取预览模态框,取消现有的网页形式,同时还能解决现在文件较大时查看可能会崩溃的情况; ![image](https://github.com/PKUHPC/SCOW/assets/140392039/30bb6918-d125-4523-aa80-a01d2fb0191c) ![image](https://github.com/PKUHPC/SCOW/assets/140392039/ff18fdd0-0f07-496e-b5b9-09bfbb5819e8) ## 2. 点击文件为查看操作,此时需判断该文件是否支持在线查看,判断标准:文件格式,ppt、doc、exe等确定无法查看的文件 不允许查看,文件大小超标的(管理员配置,默认50M)的不允许查看。点击后弹出提示“文件过大或者格式不支持,请下载后查看”,不再自动下载文件。其余文件允许查看(仍然可能是乱码,但是没关系,除了明确无法查看的应该尽量允许用户查看)。 ![image](https://github.com/PKUHPC/SCOW/assets/140392039/469507b3-7b99-488c-a6b2-12b4f074e1ca) ![image](https://github.com/PKUHPC/SCOW/assets/140392039/113ba9bd-9ec8-47e8-a879-06873ae09977) ## 3. 在查看文件页面,右下角增加编辑按钮,右上角增加全屏/取消全屏和关闭按钮,点击编辑后进入编辑模式,右下角变为退出编辑和保存按钮; ![image](https://github.com/PKUHPC/SCOW/assets/140392039/752919f3-9848-4c0b-a1e1-afab6a96bf2d) ![image](https://github.com/PKUHPC/SCOW/assets/140392039/689d9732-6a28-4e6b-9184-c67cb1b12cbc) ## 4. 点击编辑时判断该文件是否支持在线编辑,判断标准:文件大小,文件大小超标的(管理员配置,默认10M)不允许编辑,点击后弹出提示“文件过大,请下载后编辑”。 ![image](https://github.com/PKUHPC/SCOW/assets/140392039/69ab36f0-6e1c-4ea7-8b49-eb3843bbe1ce) ## 5. 编辑页面,关闭按钮关闭页面,取消按钮退出编辑模式返回查看页面,点击关闭或取消时如果有编辑过内容,则弹出提示“文件未保存,是否保存该文件”; ![image](https://github.com/PKUHPC/SCOW/assets/140392039/31cf6866-f088-4d5a-8cde-cc079f4d7fcb) ## 6. 可编辑文件大小可配置 在 `portal.yaml` 中新增配置项: ```yaml # 文件管理 file: # 文件预览功能 preview: # 大小限制 # 可接受的格式为nginx的client_max_body_size可接受的值,默认为 50m limitSize: "40m" # 文件编辑功能 edit: # 文件编辑大小限制 # 可接受的格式为nginx的client_max_body_size可接受的值,默认为 1m limitSize: "2m" ``` 默认可预览文件大小为 50m 默认可编辑文件大小为 1m 目前只有 js、ts、json 等有代码提示,其余语言暂时只有语法高亮 ### 文件修改后显示已编辑状态 ![image](https://github.com/PKUHPC/SCOW/assets/140392039/962fc661-1d01-40fe-beed-7cc1492b9c21)
- Loading branch information
1 parent
a78a6e0
commit f577d9d
Showing
20 changed files
with
884 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@scow/portal-web": minor | ||
"@scow/config": minor | ||
"@scow/cli": minor | ||
--- | ||
|
||
门户系统文件管理新增文件编辑功能 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ yarn-error.log* | |
.next/ | ||
|
||
public/novnc | ||
public/monaco-assets | ||
|
||
api-routes-schemas.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy | ||
* SCOW is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
const fs = require("fs-extra"); | ||
const path = require("path"); | ||
|
||
const sourcePath = path.join(__dirname, "../node_modules/monaco-editor/min/vs"); | ||
const targetPath = path.join(__dirname, "../public/monaco-assets/vs"); | ||
|
||
// Check if the source directory exists | ||
if (!fs.existsSync(sourcePath)) { | ||
console.error( | ||
`Error: Source directory ${sourcePath} does not exist. Ensure the target package is correctly installed.`); | ||
process.exit(1); | ||
} | ||
|
||
// Ensure the target path exists, if not, create it | ||
fs.ensureDirSync(targetPath); | ||
|
||
// Attempt to copy | ||
try { | ||
fs.copySync(sourcePath, targetPath, { | ||
overwrite: true, | ||
errorOnExist: false, | ||
}); | ||
console.log(`Success: Copied from ${sourcePath} to ${targetPath}.`); | ||
} catch (error) { | ||
console.error(`Error: An issue occurred during the copy process. Details: ${error.message}`); | ||
process.exit(1); | ||
} | ||
|
||
console.log(`Copied files from ${sourcePath} to ${targetPath}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.