优化协同编辑查看功能,只读用户可以查看在线编辑用户编辑的内容
This commit is contained in:
@@ -81,29 +81,39 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|||||||
return documentEdit(map, collaborativeEditing, clientType);
|
return documentEdit(map, collaborativeEditing, clientType);
|
||||||
}
|
}
|
||||||
if (VIEW.equals(mode)) {
|
if (VIEW.equals(mode)) {
|
||||||
return documentView(map, clientType);
|
return documentView(map, collaborativeEditing, clientType);
|
||||||
}
|
}
|
||||||
|
// if (VIEW.equals(mode)) {
|
||||||
|
// return documentView(map, clientType);
|
||||||
|
// }
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
|
private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
|
||||||
FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing,clientType);
|
FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing, clientType);
|
||||||
String json = JSON.toJSONString(fileConfigDTO);
|
String json = JSON.toJSONString(fileConfigDTO);
|
||||||
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
||||||
config.put("type", clientType);
|
config.put("type", clientType);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map documentView(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
|
||||||
private Map documentView(Map<String, Object> map,String clientType) {
|
FileConfig fileConfigDTO = openEditConfig(map, "view", collaborativeEditing, clientType);
|
||||||
FileConfig fileConfigDTO = openEditConfig(map, "view", false,clientType);
|
|
||||||
String json = JSON.toJSONString(fileConfigDTO);
|
String json = JSON.toJSONString(fileConfigDTO);
|
||||||
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
||||||
config.put("type", clientType);
|
config.put("type", clientType);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing,String clientType) {
|
private Map documentView(Map<String, Object> map, String clientType) {
|
||||||
|
FileConfig fileConfigDTO = openEditConfig(map, "view", false, clientType);
|
||||||
|
String json = JSON.toJSONString(fileConfigDTO);
|
||||||
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
||||||
|
config.put("type", clientType);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing, String clientType) {
|
||||||
try {
|
try {
|
||||||
map.put("mode", mode);
|
map.put("mode", mode);
|
||||||
log.info("开始生成文件信息");
|
log.info("开始生成文件信息");
|
||||||
@@ -111,7 +121,7 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|||||||
FileMetadata tempFileInfo = fileHandler.handlerFile(map, collaborativeEditing);
|
FileMetadata tempFileInfo = fileHandler.handlerFile(map, collaborativeEditing);
|
||||||
//生成配置文件 TODO: 控制文件权限
|
//生成配置文件 TODO: 控制文件权限
|
||||||
log.info("开始生成编辑器配置信息");
|
log.info("开始生成编辑器配置信息");
|
||||||
FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName(),clientType);
|
FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName(), clientType);
|
||||||
log.info("生成编辑器配置信息结束");
|
log.info("生成编辑器配置信息结束");
|
||||||
// TODO: 添加更多详细的自定义信息
|
// TODO: 添加更多详细的自定义信息
|
||||||
return fileConfigDTO;
|
return fileConfigDTO;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.oo.onlyoffice.core;
|
package com.oo.onlyoffice.core;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.oo.onlyoffice.config.OnlyProperties;
|
import com.oo.onlyoffice.config.OnlyProperties;
|
||||||
import com.oo.onlyoffice.dto.DocumentConfig;
|
import com.oo.onlyoffice.dto.DocumentConfig;
|
||||||
import com.oo.onlyoffice.dto.EditorConfig;
|
import com.oo.onlyoffice.dto.EditorConfig;
|
||||||
@@ -43,7 +44,7 @@ public class FileConfigFactory implements OnlyOfficeConfigFactory {
|
|||||||
* @return 配置信息
|
* @return 配置信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FileConfig buildInitConfig(String fileUrl, String mode, String key, String fileName,String clientType) {
|
public FileConfig buildInitConfig(String fileUrl, String mode, String key, String fileName, String clientType) {
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
|
||||||
@@ -74,11 +75,15 @@ public class FileConfigFactory implements OnlyOfficeConfigFactory {
|
|||||||
String callBackUrl = onlyProperties.getLocalhostAddress() + onlyProperties.getCallBackUrl();
|
String callBackUrl = onlyProperties.getLocalhostAddress() + onlyProperties.getCallBackUrl();
|
||||||
|
|
||||||
EditorConfig editorConfig = new EditorConfig(callBackUrl, mode);
|
EditorConfig editorConfig = new EditorConfig(callBackUrl, mode);
|
||||||
editorConfig.setFileCustomization(getFileCustomization(mode,clientType));
|
editorConfig.setFileCustomization(getFileCustomization(mode, clientType));
|
||||||
editorConfig.setFileUser(user);
|
editorConfig.setFileUser(user);
|
||||||
editorConfig.setPlugins(getPlugins());
|
editorConfig.setPlugins(getPlugins());
|
||||||
|
//共同编辑"coEditing"配置:
|
||||||
|
// "coEditing": { "mode": "fast","change": true}
|
||||||
|
JSONObject coEditing = new JSONObject();
|
||||||
|
coEditing.put("mode", "fast");
|
||||||
|
coEditing.put("change", "true");
|
||||||
|
editorConfig.setCoEditing(coEditing);
|
||||||
fileConfigDTO.setEditorConfig(editorConfig);
|
fileConfigDTO.setEditorConfig(editorConfig);
|
||||||
map.put("editorConfig", editorConfig);
|
map.put("editorConfig", editorConfig);
|
||||||
|
|
||||||
@@ -112,13 +117,13 @@ public class FileConfigFactory implements OnlyOfficeConfigFactory {
|
|||||||
return LoadConfigUtil.getCustomization();
|
return LoadConfigUtil.getCustomization();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileCustomization getFileCustomization(String mode,String clientType) {
|
private FileCustomization getFileCustomization(String mode, String clientType) {
|
||||||
FileCustomization customization = LoadConfigUtil.getCustomization();
|
FileCustomization customization = LoadConfigUtil.getCustomization();
|
||||||
if (mode != null && !(mode.trim()).equals("") && mode.equals("edit")) {
|
if (mode != null && !(mode.trim()).equals("") && mode.equals("edit")) {
|
||||||
customization.setAutosave(true);
|
customization.setAutosave(true);
|
||||||
}
|
}
|
||||||
customization.setMobileForceView(false);
|
customization.setMobileForceView(false);
|
||||||
if(clientType!=null&&clientType!=""&&"mobile".equals(clientType)){
|
if (clientType != null && clientType != "" && "mobile".equals(clientType)) {
|
||||||
customization.setMobileForceView(true);
|
customization.setMobileForceView(true);
|
||||||
}
|
}
|
||||||
return customization;
|
return customization;
|
||||||
|
|||||||
@@ -77,8 +77,23 @@ public class FileHandlerImpl implements FileHandler {
|
|||||||
cache.set(user.getId() + "_" + id, key);
|
cache.set(user.getId() + "_" + id, key);
|
||||||
cache.set("getID_" + key, id);
|
cache.set("getID_" + key, id);
|
||||||
}
|
}
|
||||||
} else {//查看模式
|
} else {
|
||||||
key = id;
|
//查看模式
|
||||||
|
if (collaborativeEditing) {
|
||||||
|
if (cache.get("collaborativeEditing_" + id) != null) {
|
||||||
|
key = (String) cache.get("collaborativeEditing_" + id);
|
||||||
|
} else {
|
||||||
|
key = IdUtil.simpleUUID();
|
||||||
|
cache.set("collaborativeEditing_" + id, key);
|
||||||
|
cache.set("getID_" + key, id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
key = IdUtil.simpleUUID();
|
||||||
|
FileUser user = SecurityUtils.getUserSession();
|
||||||
|
cache.set(user.getId() + "_" + id, key);
|
||||||
|
cache.set("getID_" + key, id);
|
||||||
|
}
|
||||||
|
// key = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user