Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
K
know-base
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
张京坤
know-base
Commits
fc13d1ea
提交
fc13d1ea
authored
1月 18, 2024
作者:
ZhangJingKun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
预览 zhangjingkun
上级
64c1e9bf
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
57 行增加
和
109 行删除
+57
-109
KbFileController.java
...n/java/com/zzsn/knowbase/controller/KbFileController.java
+13
-0
ILocalFileService.java
...ain/java/com/zzsn/knowbase/service/ILocalFileService.java
+10
-0
LocalFileServiceImpl.java
.../com/zzsn/knowbase/service/impl/LocalFileServiceImpl.java
+12
-1
viewer.js
src/main/resources/static/js/viewer.js
+0
-98
kk.html
src/main/resources/templates/kk.html
+0
-10
view.html
src/main/resources/templates/view.html
+22
-0
没有找到文件。
src/main/java/com/zzsn/knowbase/controller/KbFileController.java
浏览文件 @
fc13d1ea
...
@@ -59,6 +59,19 @@ public class KbFileController {
...
@@ -59,6 +59,19 @@ public class KbFileController {
}
}
/**
/**
* 预览文档接口
* @param fileName
* @param filePath
* @param userName
* @param model
* @return
*/
@GetMapping
(
"/viewer"
)
public
String
viewerDocFile
(
String
fileName
,
String
filePath
,
String
userName
,
Model
model
)
{
return
localFileService
.
viewerDocFile
(
fileName
,
filePath
,
userName
,
model
);
}
/**
* 编辑文档时的回调接口
* 编辑文档时的回调接口
* @param request
* @param request
* @param response
* @param response
...
...
src/main/java/com/zzsn/knowbase/service/ILocalFileService.java
浏览文件 @
fc13d1ea
...
@@ -56,6 +56,16 @@ public interface ILocalFileService {
...
@@ -56,6 +56,16 @@ public interface ILocalFileService {
String
editDocFile
(
String
fileName
,
String
filePath
,
String
userName
,
Model
model
);
String
editDocFile
(
String
fileName
,
String
filePath
,
String
userName
,
Model
model
);
/**
/**
* 预览文档
* @param fileName
* @param filePath
* @param userName
* @param model
* @return
*/
String
viewerDocFile
(
String
fileName
,
String
filePath
,
String
userName
,
Model
model
);
/**
* 编辑文档时的回调接口
* 编辑文档时的回调接口
* @param request
* @param request
* @param response
* @param response
...
...
src/main/java/com/zzsn/knowbase/service/impl/LocalFileServiceImpl.java
浏览文件 @
fc13d1ea
...
@@ -164,12 +164,23 @@ public class LocalFileServiceImpl implements ILocalFileService {
...
@@ -164,12 +164,23 @@ public class LocalFileServiceImpl implements ILocalFileService {
model
.
addAttribute
(
"document"
,
document
);
model
.
addAttribute
(
"document"
,
document
);
// 如果该格式不支持编辑,则返回预览页面
// 如果该格式不支持编辑,则返回预览页面
if
(!
documentService
.
canEdit
(
document
))
{
if
(!
documentService
.
canEdit
(
document
))
{
return
"/
demo
"
;
return
"/
view
"
;
}
}
model
.
addAttribute
(
"documentEditParam"
,
documentService
.
buildDocumentEditParam
(
userName
,
userName
,
filePath
));
model
.
addAttribute
(
"documentEditParam"
,
documentService
.
buildDocumentEditParam
(
userName
,
userName
,
filePath
));
return
"/editor"
;
return
"/editor"
;
}
}
@Override
public
String
viewerDocFile
(
String
fileName
,
String
filePath
,
String
userName
,
Model
model
)
{
Document
document
=
documentService
.
getDocument
(
documentService
.
buildDocument
(
filePath
,
fileName
));
model
.
addAttribute
(
"document"
,
document
);
// // 如果该格式不支持编辑,则返回预览页面
// if (!documentService.canEdit(document)) {
// return "/view";
// }
model
.
addAttribute
(
"documentEditParam"
,
documentService
.
buildDocumentEditParam
(
userName
,
userName
,
filePath
));
return
"/view"
;
}
//编辑文档时回调接口
//编辑文档时回调接口
@Override
@Override
public
void
callBack
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
void
callBack
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
...
...
src/main/resources/static/js/viewer.js
deleted
100644 → 0
浏览文件 @
64c1e9bf
var
Viewer
=
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
)
{
location
.
reload
(
true
);
};
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
с
onnectEditor
=
function
(
document
)
{
var
config
=
getDocumentConfig
(
document
);
config
.
width
=
"100%"
;
config
.
height
=
"100%"
;
config
.
events
=
{
"onAppReady"
:
onAppReady
,
"onDocumentStateChange"
:
onDocumentStateChange
,
"onError"
:
onError
,
"onOutdatedVersion"
:
onOutdatedVersion
};
config
.
editorConfig
=
{
"lang"
:
"zh-CN"
,
"mode"
:
"view"
,
"recent"
:
[],
// 自定义一些配置
"customization"
:
{
"chat"
:
false
,
// 禁用聊天菜单按钮
"commentAuthorOnly"
:
true
,
// 仅能编辑和删除其注释
"comments"
:
false
,
// 隐藏文档注释菜单按钮
"compactHeader"
:
false
,
// 隐藏附加操作按钮
"compactToolbar"
:
false
,
// 完整工具栏(true代表紧凑工具栏)
"feedback"
:
{
"visible"
:
false
// 隐藏反馈按钮
},
"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
// 定义文档显示缩放百分比值
}
};
docEditor
=
new
DocsAPI
.
DocEditor
(
"iframeEditor"
,
config
);
};
return
{
init
:
function
(
document
)
{
с
onnectEditor
(
document
);
}
}
}();
\ No newline at end of file
src/main/resources/templates/kk.html
deleted
100644 → 0
浏览文件 @
64c1e9bf
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
</head>
<body>
This is a page
</body>
</html>
src/main/resources/templates/view.html
0 → 100644
浏览文件 @
fc13d1ea
<!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>
</div>
<script
type=
"text/javascript"
th:src=
"@{/js/jquery-1.8.2.js}"
></script>
<script
type=
"text/javascript"
th:src=
"@{${documentServerApiJs}}"
></script>
<script
type=
"text/javascript"
th:src=
"@{/js/demo.js}"
></script>
<!-- 先通过 th:inline=“javascript” 添加到标签,这样js代码即可访问model中的属性 -->
<script
th:inline=
"javascript"
>
// js 中可以通过“[[${xxx}]]” 格式获得实际的值
Editor
.
init
([[
$
{
document
}]],
[[
$
{
documentEditParam
}]]);
</script>
</body>
</html>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论