文件上传更改

This commit is contained in:
XaoLi717 2024-09-13 08:14:03 +08:00
parent 02c5fff316
commit 3099e798b2
6 changed files with 9704 additions and 0 deletions

View File

@ -87,5 +87,19 @@
<version>2.1.0-jdk8-snapshot</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.hashids</groupId>
<artifactId>hashids</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,26 @@
html {
height: 100%;
width: 100%;
}
body {
background: #fff;
color: #333;
font-family: Arial, Tahoma, sans-serif;
font-size: 12px;
font-weight: normal;
height: 100%;
margin: 0;
overflow-y: hidden;
padding: 0;
text-decoration: none;
}
.form {
height: 100%;
}
div {
margin: 0;
padding: 0;
}

View File

@ -0,0 +1,175 @@
var Editor = function () {
var docEditor;
var innerAlert = function (message) {
if (console && console.log)
console.log(message);
};
var onAppReady = function () {
innerAlert("文档编辑已就绪~");
};
var onDocumentStateChange = function (event) {
var title = document.title.replace(/\*$/g, "");
document.title = title + (event.data ? "*" : "");
};
var onError = function (event) {
if (event) {
innerAlert(event.data);
}
};
var onOutdatedVersion = function (event) {
//TODO
location.reload(true);
};
var onAppReady = function() {
console.log("ONLYOFFICE Document Editor is ready");
};
var onCollaborativeChanges = function () {
console.log("The document changed by collaborative user");
};
var onDocumentReady = function() {
console.log("Document is loaded");
};
var onDocumentStateChange = function (event) {
if (event.data) {
console.log("The document changed");
// docEditor.downloadAs();
} else {
console.log("Changes are collected on document editing service");
//
}
};
var onDownloadAs = function (event) {
console.log("ONLYOFFICE Document Editor create file: " + event.data);
window.top.postMessage(event.data);
createAndDownloadFile("test.docx",event.data)
};
window.addEventListener('message',function(e){
console.log(e.data)
if (e.data=="downloadAs") {
docEditor.downloadAs();
}
},false)
$("#insertImage").click(function(event) {
console.log("ONLYOFFICE Document Editor insertImage: "+ event.data);
docEditor.insertImage({
"fileType": "png",
"url": "http://192.168.0.58:20056/attachment/20190728测试上传文件名修改/2020January/1580363537940306800_small.png"
});
})
var onRequestInsertImage = function(event) {
console.log("ONLYOFFICE Document Editor insertImage" + event.data);
docEditor.insertImage({
"fileType": "png",
"url": "http://192.168.0.58:20056/attachment/20190728测试上传文件名修改/2020January/1580363537940306800_small.png"
});
};
var onError = function (event) {
console.log("ONLYOFFICE Document Editor reports an error: code " + event.data.errorCode + ", description " + event.data.errorDescription);
};
var onOutdatedVersion = function () {
location.reload(true);
};
var onRequestEditRights = function () {
console.log("ONLYOFFICE Document Editor requests editing rights");
// document.location.reload();
var he=location.href.replace("view","edit");
location.href=he;
};
//历史版本保留1个月。比如Unix时间戳Unix timestampexpires=1524547423
var onRequestHistory = function() {
};
var onRequestHistoryClose = function() {
document.location.reload();
};
var getUrlParam = function (name) {
//构造一个含有目标参数的正则表达式对象
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
//匹配目标参数
var r = window.location.search.substr(1).match(reg);
//返回参数值
if (r != null) {
return decodeURI(r[2]);
}
return null;
};
var getDocumentConfig = function (document) {
if (document) {
return {
"document": document
};
}
innerAlert("文档未指定!");
return null;
};
var onRequestHistoryData = function() {}
var сonnectEditor = function (document, documentEditParam) {
var config = getDocumentConfig(document);
console.log(document)
console.log(documentEditParam)
config.width = "100%";
config.height = "100%";
config.events = {
"onAppReady": onAppReady,
"onDocumentStateChange": onDocumentStateChange,
"onError": onError,
"onOutdatedVersion": onOutdatedVersion
};
//config.documentType = ""+document.fileType
config.editorConfig = {
"lang": "zh-CN",
"mode": "edit",
"recent": [],
// 自定义一些配置
"customization": {
"chat": true, // 禁用聊天菜单按钮
"commentAuthorOnly": false, // 仅能编辑和删除其注释
"comments": false, // 隐藏文档注释菜单按钮
"compactHeader": false, // 隐藏附加操作按钮
"compactToolbar": false, // 完整工具栏(true代表紧凑工具栏)
"feedback": {
"visible": true // 隐藏反馈按钮
},
"forcesave": false, // true 表示强制文件保存请求添加到回调处理程序
"goback": false,/*{
"blank": true, // 转到文档时,在新窗口打开网站(false表示当前窗口打开)
"text": "转到文档位置(可以考虑放文档打开源页面)",
// 文档打开失败时的跳转也是该地址
"url": "http://www.lezhixing.com.cn"
},*/
"help": false, // 隐藏帮助按钮
"hideRightMenu": false, // 首次加载时隐藏右侧菜单(true 为显示)
"showReviewChanges": false, // 加载编辑器时自动显示/隐藏审阅更改面板(true显示 false隐藏)
"toolbarNoTabs": false, // 清楚地显示顶部工具栏选项卡(true 代表仅突出显示以查看选择了哪一个)
"zoom": 100 // 定义文档显示缩放百分比值
},
};
$.extend(config.editorConfig, documentEditParam);
console.log(config)
docEditor = new DocsAPI.DocEditor("iframeEditor",config);
};
return {
init: function (document, documentEditParam) {
console.log("-----сonnectEditor-----")
сonnectEditor(document, documentEditParam);
}
}
}();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head>
<title th:text="${document.title}"></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" th:href="@{/css/viewer.css}">
</head>
<body>
<div class="form">
<div id="iframeEditor"></div>
<h1 th:text="${document.title}">Document Title</h1>
<pre th:text="${documentEditParam}">Document Edit Param</pre>
</div>
<script type="text/javascript" th:src="@{/js/jquery-1.8.2.js}"></script>
<!-- <script type="text/javascript" src="http://192.168.1.3:7878/web-apps/apps/api/documents/api.js"></script>-->
<script type="text/javascript" th:src="@{${documentServerApiJs}}"></script>
<script type="text/javascript" th:src="@{/js/editor.js}"></script>
<!-- 先通过 th:inline=“javascript” 添加到标签这样js代码即可访问model中的属性 -->
<script th:inline="javascript">
// js 中可以通过“[[${xxx}]]” 格式获得实际的值
Editor.init([[${document}]], [[${documentEditParam}]]);
</script>
</body>
</html>

View File

@ -93,6 +93,13 @@ spring:
redis:
repositories:
enabled: false # 项目未使用到 Spring Data Redis 的 Repository所以直接禁用保证启动速度
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML
encoding: UTF-8
cache: false
enabled: true
# VO 转换(数据翻译)相关
easy-trans:
@ -307,3 +314,20 @@ yudao:
customer: E77DF18BE109F454A5CD319E44BF5177
debug: false
document:
server:
host: 192.168.1.3:48080
# host: 192.168.1.3:20053
files:
savePath: D:\doc\
docservice:
convert-docs: .docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.xml|.epub|.fb2
edited-docs: .docx|.xlsx|.csv|.pptx|.txt
viewed-docs: .pdf|.djvu|.xps
url:
site: http://192.168.1.3:7878/
converter: ConvertService.ashx
command: coauthoring/CommandService.ashx
api: web-apps/apps/api/documents/api.js
preloader: web-apps/apps/api/documents/cache-scripts.html