askbot-dragon 1.7.44-beta → 1.7.48-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +27 -27
  2. package/babel.config.js +6 -6
  3. package/dragon.iml +7 -7
  4. package/package.json +56 -56
  5. package/public/index.html +75 -73
  6. package/src/App.vue +31 -31
  7. package/src/api/index.js +1 -1
  8. package/src/api/mock.http +2 -2
  9. package/src/api/requestUrl.js +185 -185
  10. package/src/assets/js/AliyunlssUtil.js +117 -141
  11. package/src/assets/js/Base64Util.js +22 -22
  12. package/src/assets/js/common.js +252 -252
  13. package/src/assets/js/hammer.js +89 -100
  14. package/src/assets/js/script.js +36 -36
  15. package/src/assets/less/common.css +6773 -6773
  16. package/src/assets/less/converSationContainer/common.less +192 -199
  17. package/src/assets/less/converSationContainer/converSatonContainer.less +493 -493
  18. package/src/assets/less/iconfont.css +37 -37
  19. package/src/assets/less/ticketMessage.less +294 -294
  20. package/src/components/ActionAlertIframe.vue +154 -177
  21. package/src/components/AiGuide.vue +471 -438
  22. package/src/components/AnswerDocknowledge.vue +1088 -1091
  23. package/src/components/AnswerVoice.vue +285 -285
  24. package/src/components/AskIFrame.vue +15 -15
  25. package/src/components/ConversationContainer.vue +10873 -10766
  26. package/src/components/FileType.vue +86 -86
  27. package/src/components/Message.vue +27 -27
  28. package/src/components/MyEditor.vue +341 -342
  29. package/src/components/QwFeedback.vue +301 -301
  30. package/src/components/actionSatisfaction.vue +107 -107
  31. package/src/components/actionSendToBot.vue +62 -62
  32. package/src/components/answerDissatisfaction.vue +62 -62
  33. package/src/components/answerRadio.vue +211 -211
  34. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  35. package/src/components/ask-components/Msgloading.vue +37 -37
  36. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  37. package/src/components/askVideo.vue +139 -162
  38. package/src/components/assetDetails.vue +378 -378
  39. package/src/components/assetMessage.vue +226 -228
  40. package/src/components/associationIntention.vue +374 -378
  41. package/src/components/attachmentPreview.vue +90 -90
  42. package/src/components/botActionSatisfactor.vue +68 -68
  43. package/src/components/chatContent.vue +513 -513
  44. package/src/components/feedBack.vue +136 -136
  45. package/src/components/fielListView.vue +351 -351
  46. package/src/components/file/AliyunOssComponents.vue +108 -108
  47. package/src/components/formTemplate.vue +3497 -3501
  48. package/src/components/imgView.vue +31 -31
  49. package/src/components/intelligentSummary.vue +229 -231
  50. package/src/components/kkview.vue +1138 -1138
  51. package/src/components/loadingProcess.vue +164 -164
  52. package/src/components/markDownText.vue +197 -197
  53. package/src/components/message/ActionAlertIframe.vue +112 -112
  54. package/src/components/message/ShopMessage.vue +164 -164
  55. package/src/components/message/TextMessage.vue +924 -928
  56. package/src/components/message/TicketMessage.vue +201 -201
  57. package/src/components/message/swiper/index.js +4 -4
  58. package/src/components/message/swiper/ticketSwiper.vue +503 -503
  59. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  60. package/src/components/msgLoading.vue +231 -231
  61. package/src/components/myPopup.vue +70 -70
  62. package/src/components/pdfPosition.vue +1342 -1514
  63. package/src/components/popup.vue +227 -227
  64. package/src/components/previewDoc.vue +247 -251
  65. package/src/components/previewPdf.vue +774 -1069
  66. package/src/components/receiverMessagePlatform.vue +66 -65
  67. package/src/components/recommend.vue +80 -80
  68. package/src/components/selector/hOption.vue +20 -20
  69. package/src/components/selector/hSelector.vue +199 -199
  70. package/src/components/selector/hWrapper.vue +216 -216
  71. package/src/components/senderMessagePlatform.vue +55 -50
  72. package/src/components/source/BotMessage.vue +24 -24
  73. package/src/components/source/CustomMessage.vue +24 -24
  74. package/src/components/test.vue +260 -260
  75. package/src/components/tree.vue +307 -307
  76. package/src/components/utils/AliyunIssUtil.js +103 -103
  77. package/src/components/utils/ckeditor.js +185 -185
  78. package/src/components/utils/format_date.js +25 -25
  79. package/src/components/utils/index.js +6 -6
  80. package/src/components/utils/math_utils.js +29 -29
  81. package/src/components/voiceComponent.vue +119 -119
  82. package/src/components/welcomeKnowledgeFile.vue +340 -344
  83. package/src/components/welcomeLlmCard.vue +140 -144
  84. package/src/components/welcomeSuggest.vue +97 -97
  85. package/src/locales/cn.json +61 -71
  86. package/src/locales/en.json +62 -73
  87. package/src/main.js +76 -75
  88. package/vue.config.js +54 -54
  89. package/src/components/newPdfPosition.vue +0 -878
  90. package/src/components/pagination.vue +0 -129
  91. package/src/components/preview/docView.vue +0 -107
  92. package/src/components/preview/excelView.vue +0 -177
  93. package/src/components/preview/newPositionPreview.vue +0 -351
  94. package/src/components/preview/pdfView.vue +0 -760
  95. package/src/locales/jp.json +0 -73
@@ -1,103 +1,103 @@
1
- // const OSS = require('ali-oss');
2
- const OSS = window.OSS
3
-
4
- const getPrivateOssConfig = () => {
5
- let mainSource = sessionStorage.getItem('_mainSource') ? sessionStorage.getItem('_mainSource') : "askbot";
6
- switch (mainSource) {
7
- case "askbot":
8
- return {
9
- region: "oss-cn-zhangjiakou",
10
- accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
11
- accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
12
- bucket: "guoranopen-zjk",
13
- }
14
- case "lishi":
15
- return {
16
- region: "oss-ap-southeast-1",
17
- accessKeyId: "LTAI5tAusPLDNJJwkvUbqi2T",
18
- accessKeySecret: "xqPVaunOIbvTe3g9qsXal2IZO6RftK",
19
- bucket: "askbotopen-ls",
20
- };
21
- }
22
- }
23
-
24
- let IDX = 256, HEX = [], SIZE = 256, BUFFER;
25
- while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
26
- let mainId = sessionStorage.getItem('_mainId') ? sessionStorage.getItem('_mainId') : "";
27
- function uid(len) {
28
- let i = 0, tmp = (len || 11);
29
- if (!BUFFER || ((IDX + tmp) > SIZE * 2)) {
30
- for (BUFFER = '', IDX = 0; i < SIZE; i++) {
31
- BUFFER += HEX[Math.random() * 256 | 0];
32
- }
33
- }
34
-
35
- return BUFFER.substring(IDX, IDX++ + tmp);
36
- }
37
-
38
- function dataFormat(fmt, date = new Date()) {
39
- const o = {
40
- "M+": date.getMonth() + 1, //月份
41
- "d+": date.getDate(), //日
42
- "h+": date.getHours(), //小时
43
- "m+": date.getMinutes(), //分
44
- "s+": date.getSeconds(), //秒
45
- "q+": Math.floor((date.getMonth() + 3) / 3), //季度
46
- "S": date.getMilliseconds() //毫秒
47
- };
48
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
49
- for (const k in o)
50
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
51
- return fmt;
52
- }
53
-
54
- function pathGenerate(filename) {
55
- return "front-oss/" + mainId + '/' + dataFormat("yyyy/MM/dd/hh/mm/") + uid(32) + "/" + filename;
56
- }
57
-
58
-
59
- function upload(data) {
60
- let ossClient = new OSS(getPrivateOssConfig());
61
- // object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
62
- let objectKey = pathGenerate(data.name);
63
- let result = ossClient.put(objectKey, data, {
64
- headers: {
65
- // 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
66
- 'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
67
- },
68
- });
69
- console.debug(result);
70
- return result;
71
- }
72
-
73
- function multipartUpload(data, callback, extCallback) {
74
- let ossClient = new OSS(getPrivateOssConfig());
75
- // object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
76
- let objectKey = pathGenerate(data.name);
77
-
78
- let res = ossClient.multipartUpload(objectKey, data, {
79
- headers: {
80
- // 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
81
- 'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
82
- },
83
- progress: function (p, checkpoint) {
84
- console.debug('progress callback', p, checkpoint);
85
- // 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
86
- if (callback && callback instanceof Function) {
87
- callback(p, checkpoint, data, extCallback);
88
- }
89
- }
90
- })
91
- return res;
92
- }
93
-
94
- function ossFileUrl(path, cname) {
95
- let ossConfig = getPrivateOssConfig();
96
- if (cname == null) {
97
- return 'https://' + ossConfig.bucket + '.' + ossConfig.region + '.aliyuncs.com/' + path;
98
- } else {
99
- return cname + '/' + path;
100
- }
101
- }
102
-
103
- export { upload, multipartUpload, ossFileUrl }
1
+ // const OSS = require('ali-oss');
2
+ const OSS = window.OSS
3
+
4
+ const getPrivateOssConfig = () => {
5
+ let mainSource = sessionStorage.getItem('_mainSource') ? sessionStorage.getItem('_mainSource') : "askbot";
6
+ switch (mainSource) {
7
+ case "askbot":
8
+ return {
9
+ region: "oss-cn-zhangjiakou",
10
+ accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
11
+ accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
12
+ bucket: "guoranopen-zjk",
13
+ }
14
+ case "lishi":
15
+ return {
16
+ region: "oss-ap-southeast-1",
17
+ accessKeyId: "LTAI5tAusPLDNJJwkvUbqi2T",
18
+ accessKeySecret: "xqPVaunOIbvTe3g9qsXal2IZO6RftK",
19
+ bucket: "askbotopen-ls",
20
+ };
21
+ }
22
+ }
23
+
24
+ let IDX = 256, HEX = [], SIZE = 256, BUFFER;
25
+ while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
26
+ let mainId = sessionStorage.getItem('_mainId') ? sessionStorage.getItem('_mainId') : "";
27
+ function uid(len) {
28
+ let i = 0, tmp = (len || 11);
29
+ if (!BUFFER || ((IDX + tmp) > SIZE * 2)) {
30
+ for (BUFFER = '', IDX = 0; i < SIZE; i++) {
31
+ BUFFER += HEX[Math.random() * 256 | 0];
32
+ }
33
+ }
34
+
35
+ return BUFFER.substring(IDX, IDX++ + tmp);
36
+ }
37
+
38
+ function dataFormat(fmt, date = new Date()) {
39
+ const o = {
40
+ "M+": date.getMonth() + 1, //月份
41
+ "d+": date.getDate(), //日
42
+ "h+": date.getHours(), //小时
43
+ "m+": date.getMinutes(), //分
44
+ "s+": date.getSeconds(), //秒
45
+ "q+": Math.floor((date.getMonth() + 3) / 3), //季度
46
+ "S": date.getMilliseconds() //毫秒
47
+ };
48
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
49
+ for (const k in o)
50
+ if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
51
+ return fmt;
52
+ }
53
+
54
+ function pathGenerate(filename) {
55
+ return "front-oss/" + mainId + '/' + dataFormat("yyyy/MM/dd/hh/mm/") + uid(32) + "/" + filename;
56
+ }
57
+
58
+
59
+ function upload(data) {
60
+ let ossClient = new OSS(getPrivateOssConfig());
61
+ // object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
62
+ let objectKey = pathGenerate(data.name);
63
+ let result = ossClient.put(objectKey, data, {
64
+ headers: {
65
+ // 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
66
+ 'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
67
+ },
68
+ });
69
+ console.debug(result);
70
+ return result;
71
+ }
72
+
73
+ function multipartUpload(data, callback, extCallback) {
74
+ let ossClient = new OSS(getPrivateOssConfig());
75
+ // object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
76
+ let objectKey = pathGenerate(data.name);
77
+
78
+ let res = ossClient.multipartUpload(objectKey, data, {
79
+ headers: {
80
+ // 通过文件URL访问文件时,指定以附件形式下载文件,下载后的文件名称定义为example.jpg。
81
+ 'Content-Disposition': `attachment; filename="${encodeURIComponent(data.name)}"`
82
+ },
83
+ progress: function (p, checkpoint) {
84
+ console.debug('progress callback', p, checkpoint);
85
+ // 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
86
+ if (callback && callback instanceof Function) {
87
+ callback(p, checkpoint, data, extCallback);
88
+ }
89
+ }
90
+ })
91
+ return res;
92
+ }
93
+
94
+ function ossFileUrl(path, cname) {
95
+ let ossConfig = getPrivateOssConfig();
96
+ if (cname == null) {
97
+ return 'https://' + ossConfig.bucket + '.' + ossConfig.region + '.aliyuncs.com/' + path;
98
+ } else {
99
+ return cname + '/' + path;
100
+ }
101
+ }
102
+
103
+ export { upload, multipartUpload, ossFileUrl }
@@ -1,185 +1,185 @@
1
- /* eslint-disable */
2
- import { multipartUpload, ossFileUrl } from "../../assets/js/AliyunIssUtil";
3
- import { v4 as uuidv4 } from "uuid";
4
-
5
- const getPrivateOssConfig = () => {
6
- let mainSource = sessionStorage.getItem('_mainSource') ? sessionStorage.getItem('_mainSource') : "askbot";
7
- switch (mainSource) {
8
- case "askbot":
9
- return {
10
- region: "oss-cn-zhangjiakou",
11
- accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
12
- accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
13
- bucket: "guoranopen-zjk",
14
- }
15
- case "lishi":
16
- return {
17
- region: "oss-ap-southeast-1",
18
- accessKeyId: "LTAI5tAusPLDNJJwkvUbqi2T",
19
- accessKeySecret: "xqPVaunOIbvTe3g9qsXal2IZO6RftK",
20
- bucket: "askbotopen-ls",
21
- };
22
- }
23
- }
24
- class MyUploadAdapter {
25
- constructor(loader, editor) {
26
- // 要在上载期间使用的文件加载器实例
27
- this.loader = loader;
28
- this.editor = editor
29
- }
30
-
31
- // 启动上载过程
32
- upload() {
33
- return this.loader.file
34
- .then(file => new Promise(() => {
35
- /* this._initRequest();
36
- this._initListeners( resolve, reject, file );
37
- this._sendRequest( file );*/
38
- let command = this.editor.commands.get("insertAskComponent");
39
- let uid = uuidv4()
40
- command.execute({
41
- tag: "section",
42
- options: {
43
- className: 'self-p-section',
44
- data: 'self-p-section'
45
- },
46
- });
47
- command.execute({
48
- tag: "span-editable",
49
- options: {
50
- name: file.name + '正在上传...',
51
- data: uid,
52
- editable: false,
53
- type: 'upload'
54
- }
55
- })
56
- this.uploadFile(file)
57
- }));
58
- }
59
-
60
- // 中止上载过程
61
- abort() {
62
- if (this.xhr) {
63
- this.xhr.abort();
64
- }
65
- }
66
- uploadFile(file) {
67
- let imgInfo = {
68
- url: '',
69
- }
70
- let res = multipartUpload(
71
- file,
72
- null,
73
- imgInfo
74
- );
75
- res.then(resp => {
76
- imgInfo.url = ossFileUrl(resp.name)
77
- let root = this.editor.model.document.getRoot()
78
- let children = root.getChildren()
79
- for (let child of children) {
80
- for (let index = 0; index < child._children._nodes.length; index++) {
81
- if (child._children._nodes[index].name == 'askComponentPlaceholderContainer') {
82
- if (child._children._nodes[index]._children._nodes[0]) {
83
- let attrs = child._children._nodes[index]._children._nodes[0]._attrs
84
- if (attrs) {
85
- let attrsList = [...attrs.keys()]
86
- for (let j = 0; j < attrsList.length; j++) {
87
- if (attrsList[j] == 'data') {
88
- // this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j])})
89
- this.editor.model.change(writer => {
90
- writer.remove(child._children._nodes[index]);
91
- });
92
- }
93
- }
94
- }
95
- }
96
- }
97
- }
98
- }
99
- let command = this.editor.commands.get("insertAskComponent");
100
- command.execute({
101
- tag: "img",
102
- options: {
103
- width: '100%',
104
- alt: resp.name + 0,
105
- src: imgInfo.url
106
- },
107
- });
108
- this.editor.execute('insertParagraph', {
109
- position: this.editor.model.document.selection.focus
110
- })
111
- })
112
- }
113
- // 使用传递给构造函数的URL初始化XMLHttpRequest对象.
114
- _initRequest() {
115
- const xhr = this.xhr = new XMLHttpRequest();
116
- console.log(xhr)
117
- xhr.open('POST', '/open-api/oss/public?token=8c98087dfd2d48f856d8c95c09115def', true);
118
- xhr.responseType = '';
119
- }
120
-
121
- // 初始化 XMLHttpRequest 监听.
122
- _initListeners(resolve, reject, file) {
123
- const xhr = this.xhr;
124
- const loader = this.loader;
125
- console.log(this.loader)
126
- const genericErrorText = `无法上传文件: ${file.name}.`;
127
-
128
- xhr.addEventListener('error', () => reject(genericErrorText));
129
- xhr.addEventListener('abort', () => reject());
130
- xhr.addEventListener('load', () => {
131
- const response = xhr.response;
132
- // 当code==200说明上传成功,可以增加弹框提示;
133
- // 当上传失败时,必须调用reject()函数。
134
-
135
- console.log('response', xhr)
136
-
137
- if (!response || response.error) {
138
- return reject(response && response.error ? response.error.message : genericErrorText);
139
- }
140
- //上传成功,从后台获取图片的url地址
141
- resolve({
142
- default: response
143
- });
144
- });
145
-
146
- // 支持时上传进度。文件加载器有#uploadTotal和#upload属性,用于在编辑器用户界面中显示上载进度栏。
147
- if (xhr.upload) {
148
- xhr.upload.addEventListener('progress', evt => {
149
- if (evt.lengthComputable) {
150
- loader.uploadTotal = evt.total;
151
- loader.uploaded = evt.loaded;
152
- }
153
- });
154
- }
155
- }
156
-
157
- // 准备数据并发送请求
158
- _sendRequest(file) {
159
- //通过FormData构造函数创建一个空对象
160
- const data = new FormData();
161
- //通过append()方法在末尾追加key为files值为file的数据
162
-
163
- console.log('file', file)
164
- data.append('file', file);//上传的参数data
165
- // data.append( 'memberId', "666" );
166
- /**
167
- * 重要提示:这是实现诸如身份验证和CSRF保护等安全机制的正确位置。
168
- * 例如,可以使用XMLHttpRequest.setRequestHeader()设置包含应用程序先前生成的CSRF令牌的请求头。
169
- */
170
- this.xhr.send(data);
171
- }
172
- }
173
-
174
- function MyCustomUploadAdapterPlugin(editor) {
175
- editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
176
- // 在这里将URL配置为后端上载脚本
177
- console.log(loader, 'loader');
178
- return new MyUploadAdapter(loader, editor);
179
- }
180
- }
181
-
182
- export {
183
- MyUploadAdapter,
184
- MyCustomUploadAdapterPlugin
185
- }
1
+ /* eslint-disable */
2
+ import { multipartUpload, ossFileUrl } from "./AliyunIssUtil";
3
+ import { v4 as uuidv4 } from "uuid";
4
+
5
+ const getPrivateOssConfig = () => {
6
+ let mainSource = sessionStorage.getItem('_mainSource') ? sessionStorage.getItem('_mainSource') : "askbot";
7
+ switch (mainSource) {
8
+ case "askbot":
9
+ return {
10
+ region: "oss-cn-zhangjiakou",
11
+ accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
12
+ accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
13
+ bucket: "guoranopen-zjk",
14
+ }
15
+ case "lishi":
16
+ return {
17
+ region: "oss-ap-southeast-1",
18
+ accessKeyId: "LTAI5tAusPLDNJJwkvUbqi2T",
19
+ accessKeySecret: "xqPVaunOIbvTe3g9qsXal2IZO6RftK",
20
+ bucket: "askbotopen-ls",
21
+ };
22
+ }
23
+ }
24
+ class MyUploadAdapter {
25
+ constructor(loader, editor) {
26
+ // 要在上载期间使用的文件加载器实例
27
+ this.loader = loader;
28
+ this.editor = editor
29
+ }
30
+
31
+ // 启动上载过程
32
+ upload() {
33
+ return this.loader.file
34
+ .then(file => new Promise(() => {
35
+ /* this._initRequest();
36
+ this._initListeners( resolve, reject, file );
37
+ this._sendRequest( file );*/
38
+ let command = this.editor.commands.get("insertAskComponent");
39
+ let uid = uuidv4()
40
+ command.execute({
41
+ tag: "section",
42
+ options: {
43
+ className: 'self-p-section',
44
+ data: 'self-p-section'
45
+ },
46
+ });
47
+ command.execute({
48
+ tag: "span-editable",
49
+ options: {
50
+ name: file.name + '正在上传...',
51
+ data: uid,
52
+ editable: false,
53
+ type: 'upload'
54
+ }
55
+ })
56
+ this.uploadFile(file)
57
+ }));
58
+ }
59
+
60
+ // 中止上载过程
61
+ abort() {
62
+ if (this.xhr) {
63
+ this.xhr.abort();
64
+ }
65
+ }
66
+ uploadFile(file) {
67
+ let imgInfo = {
68
+ url: '',
69
+ }
70
+ let res = multipartUpload(
71
+ file,
72
+ null,
73
+ imgInfo
74
+ );
75
+ res.then(resp => {
76
+ imgInfo.url = ossFileUrl(resp.name)
77
+ let root = this.editor.model.document.getRoot()
78
+ let children = root.getChildren()
79
+ for (let child of children) {
80
+ for (let index = 0; index < child._children._nodes.length; index++) {
81
+ if (child._children._nodes[index].name == 'askComponentPlaceholderContainer') {
82
+ if (child._children._nodes[index]._children._nodes[0]) {
83
+ let attrs = child._children._nodes[index]._children._nodes[0]._attrs
84
+ if (attrs) {
85
+ let attrsList = [...attrs.keys()]
86
+ for (let j = 0; j < attrsList.length; j++) {
87
+ if (attrsList[j] == 'data') {
88
+ // this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j])})
89
+ this.editor.model.change(writer => {
90
+ writer.remove(child._children._nodes[index]);
91
+ });
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ let command = this.editor.commands.get("insertAskComponent");
100
+ command.execute({
101
+ tag: "img",
102
+ options: {
103
+ width: '100%',
104
+ alt: resp.name + 0,
105
+ src: imgInfo.url
106
+ },
107
+ });
108
+ this.editor.execute('insertParagraph', {
109
+ position: this.editor.model.document.selection.focus
110
+ })
111
+ })
112
+ }
113
+ // 使用传递给构造函数的URL初始化XMLHttpRequest对象.
114
+ _initRequest() {
115
+ const xhr = this.xhr = new XMLHttpRequest();
116
+ console.log(xhr)
117
+ xhr.open('POST', '/open-api/oss/public?token=8c98087dfd2d48f856d8c95c09115def', true);
118
+ xhr.responseType = '';
119
+ }
120
+
121
+ // 初始化 XMLHttpRequest 监听.
122
+ _initListeners(resolve, reject, file) {
123
+ const xhr = this.xhr;
124
+ const loader = this.loader;
125
+ console.log(this.loader)
126
+ const genericErrorText = `无法上传文件: ${file.name}.`;
127
+
128
+ xhr.addEventListener('error', () => reject(genericErrorText));
129
+ xhr.addEventListener('abort', () => reject());
130
+ xhr.addEventListener('load', () => {
131
+ const response = xhr.response;
132
+ // 当code==200说明上传成功,可以增加弹框提示;
133
+ // 当上传失败时,必须调用reject()函数。
134
+
135
+ console.log('response', xhr)
136
+
137
+ if (!response || response.error) {
138
+ return reject(response && response.error ? response.error.message : genericErrorText);
139
+ }
140
+ //上传成功,从后台获取图片的url地址
141
+ resolve({
142
+ default: response
143
+ });
144
+ });
145
+
146
+ // 支持时上传进度。文件加载器有#uploadTotal和#upload属性,用于在编辑器用户界面中显示上载进度栏。
147
+ if (xhr.upload) {
148
+ xhr.upload.addEventListener('progress', evt => {
149
+ if (evt.lengthComputable) {
150
+ loader.uploadTotal = evt.total;
151
+ loader.uploaded = evt.loaded;
152
+ }
153
+ });
154
+ }
155
+ }
156
+
157
+ // 准备数据并发送请求
158
+ _sendRequest(file) {
159
+ //通过FormData构造函数创建一个空对象
160
+ const data = new FormData();
161
+ //通过append()方法在末尾追加key为files值为file的数据
162
+
163
+ console.log('file', file)
164
+ data.append('file', file);//上传的参数data
165
+ // data.append( 'memberId', "666" );
166
+ /**
167
+ * 重要提示:这是实现诸如身份验证和CSRF保护等安全机制的正确位置。
168
+ * 例如,可以使用XMLHttpRequest.setRequestHeader()设置包含应用程序先前生成的CSRF令牌的请求头。
169
+ */
170
+ this.xhr.send(data);
171
+ }
172
+ }
173
+
174
+ function MyCustomUploadAdapterPlugin(editor) {
175
+ editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
176
+ // 在这里将URL配置为后端上载脚本
177
+ console.log(loader, 'loader');
178
+ return new MyUploadAdapter(loader, editor);
179
+ }
180
+ }
181
+
182
+ export {
183
+ MyUploadAdapter,
184
+ MyCustomUploadAdapterPlugin
185
+ }
@@ -1,26 +1,26 @@
1
- const formatDate = (fmt) => { //author: meizz
2
- var o = {
3
- "M+": this.getMonth() + 1, //月份
4
- "d+": this.getDate(), //日
5
- "h+": this.getHours(), //小时
6
- "m+": this.getMinutes(), //分
7
- "s+": this.getSeconds(), //秒
8
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
9
- "S": this.getMilliseconds() //毫秒
10
- };
11
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
12
- for (var k in o)
13
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
14
- return fmt;
15
- }
16
- function forMatTime(value){
17
- let startTime = ''
18
- let currentTime = new Date(), year = currentTime.getFullYear(),
19
- month = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1,
20
- day = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
21
- startTime = year + "-" + month + "-" + day +' ' + value;
22
- return new Date(startTime)
23
- }
24
- export { formatDate,forMatTime };
25
-
1
+ const formatDate = (fmt) => { //author: meizz
2
+ var o = {
3
+ "M+": this.getMonth() + 1, //月份
4
+ "d+": this.getDate(), //日
5
+ "h+": this.getHours(), //小时
6
+ "m+": this.getMinutes(), //分
7
+ "s+": this.getSeconds(), //秒
8
+ "q+": Math.floor((this.getMonth() + 3) / 3), //季度
9
+ "S": this.getMilliseconds() //毫秒
10
+ };
11
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
12
+ for (var k in o)
13
+ if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
14
+ return fmt;
15
+ }
16
+ function forMatTime(value){
17
+ let startTime = ''
18
+ let currentTime = new Date(), year = currentTime.getFullYear(),
19
+ month = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1,
20
+ day = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
21
+ startTime = year + "-" + month + "-" + day +' ' + value;
22
+ return new Date(startTime)
23
+ }
24
+ export { formatDate,forMatTime };
25
+
26
26
  // new Date("2019-12-14T00:09:16.000+0000").Format("yyyy-MM-dd hh:mm:ss")
@@ -1,7 +1,7 @@
1
- import {formatDate} from './format_date';
2
-
3
- let utils = {
4
- formatDate
5
- }
6
-
1
+ import {formatDate} from './format_date';
2
+
3
+ let utils = {
4
+ formatDate
5
+ }
6
+
7
7
  export { utils }