askbot-dragon 1.7.29-beta → 1.7.31-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.
@@ -1,28 +1,16 @@
1
1
  /* eslint-disable */
2
- import { multipartUpload, ossFileUrl } from "./AliyunIssUtil";
2
+ import {multipartUpload, ossFileUrl} from "./AliyunIssUtil";
3
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
- };
4
+ const ossConfig = {
5
+ region: "oss-cn-zhangjiakou",
6
+ //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
7
+ accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
8
+ accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
9
+ // stsToken: '<Your securityToken(STS)>',
10
+ bucket: "guoranopen-zjk",
22
11
  }
23
- }
24
12
  class MyUploadAdapter {
25
- constructor(loader, editor) {
13
+ constructor( loader , editor ) {
26
14
  // 要在上载期间使用的文件加载器实例
27
15
  this.loader = loader;
28
16
  this.editor = editor
@@ -31,7 +19,7 @@ class MyUploadAdapter {
31
19
  // 启动上载过程
32
20
  upload() {
33
21
  return this.loader.file
34
- .then(file => new Promise(() => {
22
+ .then( file => new Promise(() => {
35
23
  /* this._initRequest();
36
24
  this._initListeners( resolve, reject, file );
37
25
  this._sendRequest( file );*/
@@ -49,8 +37,8 @@ class MyUploadAdapter {
49
37
  options: {
50
38
  name: file.name + '正在上传...',
51
39
  data: uid,
52
- editable: false,
53
- type: 'upload'
40
+ editable:false,
41
+ type:'upload'
54
42
  }
55
43
  })
56
44
  this.uploadFile(file)
@@ -59,32 +47,33 @@ class MyUploadAdapter {
59
47
 
60
48
  // 中止上载过程
61
49
  abort() {
62
- if (this.xhr) {
50
+ if ( this.xhr ) {
63
51
  this.xhr.abort();
64
52
  }
65
53
  }
66
- uploadFile(file) {
54
+ uploadFile(file){
67
55
  let imgInfo = {
68
- url: '',
56
+ url:'',
69
57
  }
70
58
  let res = multipartUpload(
59
+ ossConfig,
71
60
  file,
72
61
  null,
73
62
  imgInfo
74
63
  );
75
- res.then(resp => {
76
- imgInfo.url = ossFileUrl(resp.name)
77
- let root = this.editor.model.document.getRoot()
64
+ res.then(resp=>{
65
+ imgInfo.url = ossFileUrl(ossConfig, resp.name)
66
+ let root = this.editor.model.document.getRoot()
78
67
  let children = root.getChildren()
79
- for (let child of children) {
68
+ for(let child of children){
80
69
  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]) {
70
+ if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
71
+ if(child._children._nodes[index]._children._nodes[0]) {
83
72
  let attrs = child._children._nodes[index]._children._nodes[0]._attrs
84
- if (attrs) {
73
+ if(attrs) {
85
74
  let attrsList = [...attrs.keys()]
86
75
  for (let j = 0; j < attrsList.length; j++) {
87
- if (attrsList[j] == 'data') {
76
+ if(attrsList[j] == 'data') {
88
77
  // this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j])})
89
78
  this.editor.model.change(writer => {
90
79
  writer.remove(child._children._nodes[index]);
@@ -100,7 +89,7 @@ class MyUploadAdapter {
100
89
  command.execute({
101
90
  tag: "img",
102
91
  options: {
103
- width: '100%',
92
+ width:'100%',
104
93
  alt: resp.name + 0,
105
94
  src: imgInfo.url
106
95
  },
@@ -114,68 +103,68 @@ class MyUploadAdapter {
114
103
  _initRequest() {
115
104
  const xhr = this.xhr = new XMLHttpRequest();
116
105
  console.log(xhr)
117
- xhr.open('POST', '/open-api/oss/public?token=8c98087dfd2d48f856d8c95c09115def', true);
106
+ xhr.open( 'POST', '/open-api/oss/public?token=8c98087dfd2d48f856d8c95c09115def', true );
118
107
  xhr.responseType = '';
119
108
  }
120
109
 
121
110
  // 初始化 XMLHttpRequest 监听.
122
- _initListeners(resolve, reject, file) {
111
+ _initListeners( resolve, reject, file ) {
123
112
  const xhr = this.xhr;
124
113
  const loader = this.loader;
125
114
  console.log(this.loader)
126
- const genericErrorText = `无法上传文件: ${file.name}.`;
115
+ const genericErrorText = `无法上传文件: ${ file.name }.`;
127
116
 
128
- xhr.addEventListener('error', () => reject(genericErrorText));
129
- xhr.addEventListener('abort', () => reject());
130
- xhr.addEventListener('load', () => {
117
+ xhr.addEventListener( 'error', () => reject( genericErrorText ) );
118
+ xhr.addEventListener( 'abort', () => reject() );
119
+ xhr.addEventListener( 'load', () => {
131
120
  const response = xhr.response;
132
121
  // 当code==200说明上传成功,可以增加弹框提示;
133
122
  // 当上传失败时,必须调用reject()函数。
134
123
 
135
124
  console.log('response', xhr)
136
125
 
137
- if (!response || response.error) {
138
- return reject(response && response.error ? response.error.message : genericErrorText);
126
+ if ( !response || response.error ) {
127
+ return reject( response && response.error ? response.error.message : genericErrorText );
139
128
  }
140
129
  //上传成功,从后台获取图片的url地址
141
- resolve({
130
+ resolve( {
142
131
  default: response
143
- });
144
- });
132
+ } );
133
+ } );
145
134
 
146
135
  // 支持时上传进度。文件加载器有#uploadTotal和#upload属性,用于在编辑器用户界面中显示上载进度栏。
147
- if (xhr.upload) {
148
- xhr.upload.addEventListener('progress', evt => {
149
- if (evt.lengthComputable) {
136
+ if ( xhr.upload ) {
137
+ xhr.upload.addEventListener( 'progress', evt => {
138
+ if ( evt.lengthComputable ) {
150
139
  loader.uploadTotal = evt.total;
151
140
  loader.uploaded = evt.loaded;
152
141
  }
153
- });
142
+ } );
154
143
  }
155
144
  }
156
145
 
157
146
  // 准备数据并发送请求
158
- _sendRequest(file) {
147
+ _sendRequest( file ) {
159
148
  //通过FormData构造函数创建一个空对象
160
149
  const data = new FormData();
161
150
  //通过append()方法在末尾追加key为files值为file的数据
162
151
 
163
- console.log('file', file)
164
- data.append('file', file);//上传的参数data
152
+ console.log('file',file)
153
+ data.append( 'file', file );//上传的参数data
165
154
  // data.append( 'memberId', "666" );
166
155
  /**
167
156
  * 重要提示:这是实现诸如身份验证和CSRF保护等安全机制的正确位置。
168
157
  * 例如,可以使用XMLHttpRequest.setRequestHeader()设置包含应用程序先前生成的CSRF令牌的请求头。
169
158
  */
170
- this.xhr.send(data);
159
+ this.xhr.send( data );
171
160
  }
172
161
  }
173
162
 
174
- function MyCustomUploadAdapterPlugin(editor) {
175
- editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
163
+ function MyCustomUploadAdapterPlugin( editor ) {
164
+ editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
176
165
  // 在这里将URL配置为后端上载脚本
177
- console.log(loader, 'loader');
178
- return new MyUploadAdapter(loader, editor);
166
+ console.log(loader,'loader');
167
+ return new MyUploadAdapter( loader,editor );
179
168
  }
180
169
  }
181
170
 
@@ -31,7 +31,7 @@
31
31
  <!-- v-if="msgContent.totalCount > msgContent.knowledgeFileInfos.length" -->
32
32
 
33
33
  <div class="load_moreKnowledge" v-if="page < msgContent.totalPages" @click="loadMore">
34
- <span>{{$t('dragonCommon.viewMore')}}</span>
34
+ <span>查看更多</span>
35
35
  </div>
36
36
  </div>
37
37
  <previewPdf ref="previewPdf"
@@ -4,7 +4,7 @@
4
4
  <div class="title_desc">{{ msg.content.problemRecommendationDesc }}</div>
5
5
  <div class="title_change_batch" v-if="msg.content.page && msg.content.problemRecommendationValue.length > msg.content.pageCount" @click="changeBatch">
6
6
  <i class="iconfont guoran-tongyichicun-huanyipi"></i>
7
- <span>{{$t('dragonCommon.refresh')}}</span>
7
+ <span>换一批</span>
8
8
  </div>
9
9
  </div>
10
10
  <div class="content">
package/src/main.js CHANGED
@@ -47,27 +47,11 @@ Viewer.setDefaults({
47
47
  Options: { "inline": true, "button": true, "navbar": true, "title": true, "toolbar": true, "tooltip": true, "movable": true, "zoomable": true, "rotatable": true, "scalable": true, "transition": true, "fullscreen": true, "keyboard": true, "url": "data-source" }
48
48
  })
49
49
 
50
- import VueI18n from 'vue-i18n'; //多语言
51
50
 
52
- // 导入多语言的 JSON 文件
53
- import enLocale from './locales/en.json';
54
- import cnLocale from './locales/cn.json';
55
-
56
- Vue.use(VueI18n);
57
- // 创建 VueI18n 实例,并设置默认语言和多语言内容
58
- const i18n = new VueI18n({
59
- locale: 'en', // 默认语言
60
- messages: {
61
- en: enLocale, // 英文
62
- cn: cnLocale, // 中文
63
- // 其他语言...
64
- }
65
- });
66
51
 
67
52
  Vue.prototype.requestUrl = requestUrl;
68
53
  Vue.prototype.utils = utils;
69
54
 
70
55
  new Vue({
71
56
  render: h => h(App),
72
- i18n,
73
57
  }).$mount('#app')
@@ -1,32 +0,0 @@
1
- <template>
2
- <div>
3
- <el-image-viewer :zIndex="999999" :on-close="closeViewer" :url-list="urlList" />
4
- </div>
5
- </template>
6
-
7
- <script>
8
- import ElementUI from 'element-ui';
9
- // import ElImageViewer from ElementUI.Image.components.ImageViewer;
10
-
11
- export default {
12
- name: "imgView",
13
- components: {
14
- ElImageViewer: ElementUI.Image.components.ImageViewer
15
- },
16
- data () {
17
- return {};
18
- },
19
- props: ["urlList"],
20
- methods: {
21
- closeViewer () {
22
- // 关闭组件后从父级dom销毁这个挂载
23
- if (this.$el.parentNode) {
24
- this.$el.parentNode.removeChild(this.$el);
25
- }
26
- this.$emit("closeViewer");
27
- },
28
- },
29
- };
30
- </script>
31
-
32
- <style scoped></style>
@@ -1,164 +0,0 @@
1
- <template>
2
- <div @click="lookImage">
3
- <vue-markdown class="mark_down" :source="typedContent" :ref="'markdown' + msgId">
4
- </vue-markdown>
5
- <div v-if="showPreview">
6
- <img-view :url-list="imgList" @closeViewer="closeViewer"></img-view>
7
- </div>
8
- </div>
9
- </template>
10
-
11
- <script>
12
- import VueMarkdown from "vue-markdown";
13
- import ImgView from "./imgView.vue";
14
-
15
- export default {
16
- name: "markDownText",
17
- data() {
18
- return {
19
- typedContent: "",
20
- typingSpeed: 15,
21
- showPreview: false,
22
- imgList: [],
23
- };
24
- },
25
- props: {
26
- chainValues: {
27
- type: String,
28
- default: "",
29
- },
30
- msgId: {
31
- type: String,
32
- default: "",
33
- },
34
- isHistory: {
35
- type: Boolean,
36
- default: false,
37
- },
38
- },
39
- components: {
40
- ImgView,
41
- VueMarkdown,
42
- },
43
- mounted() {
44
- this.$nextTick(() => {
45
- // let ref = 'markdown' + this.msgId
46
- // const el = this.$refs[ref].$el;
47
- // if (this.isHistory){
48
- // el.innerHTML = this.chainValues;
49
- // } else {
50
- // new Typed(el, {
51
- // strings: [this.chainValues],
52
- // typeSpeed: 30,
53
- // showCursor: false
54
- // })
55
- // }
56
- this.typedContent = this.chainValues;
57
- // if (this.isHistory) {
58
- // this.typedContent = this.chainValues;
59
- // } else {
60
- // this.startTypingEffect();
61
- // }
62
- });
63
- },
64
- methods: {
65
- startTypingEffect() {
66
- let i = 0;
67
- const interval = setInterval(() => {
68
- if (i < this.chainValues.length) {
69
- this.typedContent += this.chainValues.charAt(i);
70
- i++;
71
- } else {
72
- clearInterval(interval);
73
- }
74
- }, this.typingSpeed);
75
- },
76
- lookImage(e) {
77
- let previewImageUrl = "";
78
- console.log("e.target", e.target);
79
- if (e.target.localName == "img") {
80
- previewImageUrl = e.target.currentSrc;
81
- this.showPreview = true;
82
- }
83
- let richtext = JSON.parse(JSON.stringify(this.typedContent));
84
- this.imgList = [];
85
- richtext.replace(
86
- /<img [^>]*src=['"]([^'"]+)[^>]*>/g,
87
- (match, capture) => {
88
- this.imgList.push(capture);
89
- }
90
- );
91
- /*当前点击的图片作为第一个图片*/
92
- let index = this.imgList.indexOf(previewImageUrl);
93
- this.imgList.splice(index, 1);
94
- this.imgList.unshift(previewImageUrl);
95
- },
96
- closeViewer() {
97
- this.showPreview = false;
98
- },
99
- },
100
- };
101
- </script>
102
-
103
- <style scoped lang="less">
104
- .mark_down {
105
- line-height: 24px;
106
-
107
- /deep/p {
108
- margin-bottom: 14px;
109
- font-size: 16px;
110
- }
111
-
112
- /deep/p:only-child {
113
- margin: 0 !important;
114
- }
115
-
116
- /deep/p:last-child {
117
- margin-bottom: 0 !important;
118
- }
119
-
120
- /deep/ul {
121
- margin-bottom: 16px ;
122
- li {
123
- margin: 7px 0 !important;
124
- font-size: 16px;
125
-
126
- }
127
- }
128
-
129
- /deep/ ol {
130
- li {
131
- margin: 7px 0 !important;
132
- font-size: 16px;
133
- }
134
- }
135
-
136
- /deep/img {
137
- max-width: 400px;
138
- }
139
-
140
- /deep/h3,
141
- /deep/h2,
142
- /deep/h1,
143
- /deep/h4,
144
- /deep/h5,
145
- /deep/h6 {
146
- color: #000000;
147
- font-weight: 500;
148
- line-height: 26px;
149
- }
150
-
151
- /deep/h3 {
152
- font-size: 20px;
153
- }
154
- /deep/h2 {
155
- font-size: 22px;
156
- }
157
- /deep/h1 {
158
- font-size: 24px;
159
- }
160
- /deep/h3 {
161
- font-size: 20px;
162
- }
163
- }
164
- </style>
@@ -1,60 +0,0 @@
1
- {
2
- "组件多语言使用说明": "在使用多语言配置文件时,需要在使用的项目中添加对应的配置,默认都配置在dragonCommon字段中,也可以看看有没有其他方式",
3
- "dragonCommon": {
4
- "download": "下载",
5
- "smartSummary": "智能摘要",
6
- "chat": "聊一聊",
7
- "viewDetails": "查看详情",
8
- "folderName": "文件夹名称",
9
- "loading": "加载中...",
10
- "Safaridownload": "下载地址已复制,请前往Safari浏览器访问下载",
11
- "reduce": "缩小",
12
- "zoom": "放大",
13
- "selectScale": "请选择",
14
- "previous": "上一段",
15
- "next": "下一段",
16
- "answersGeneratedByPre": "答案由",
17
- "answersGeneratedByAfter": "段内容生成",
18
- "scaleAuto": "自动缩放",
19
- "scaleReality": "实际比例",
20
- "firstParagraph": "当前已经是第一段了",
21
- "lastParagraph": "当前已经是最后一段了",
22
- "fileloadException": "文件加载异常",
23
- "regenerate": "重新生成",
24
- "generating": "生成中",
25
- "close": "关闭",
26
- "summaryGeneratedByAI": "AI为您总结生成了以下摘要",
27
- "viewMore": "查看更多",
28
- "from": "出自",
29
- "viewOriginal": "查看原文",
30
- "lastUpdateTime": "最后更新时间",
31
- "owner": "所有者",
32
- "enterprise": "所属企业",
33
- "source": "文件来源",
34
- "folder": "文件夹",
35
- "personalknowledge": "个人知识",
36
- "enterpriseknowledge": "企业知识",
37
- "satisfaction": "满意",
38
- "unsatisfied": "不满意",
39
- "refresh": "换一批",
40
- "AIrecommends": "AI为您推荐以下内容",
41
- "youareconsulting": "您正在咨询",
42
- "description": "描述",
43
- "location": "位置",
44
- "user": "使用者",
45
- "department": "部门",
46
- "manager": "管理者",
47
- "uploadImgFile": "上传图片或附件",
48
- "cancel": "取消",
49
- "confirm": "确定",
50
- "noMore": "没有更多了",
51
- "establishConversationWith": "与",
52
- "you": "您",
53
- "bot": "机器人",
54
- "transferTo": "您将会话转接给",
55
- "transferFrom": "将会话转接给您",
56
- "imService": "IM人工",
57
- "botService": "机器人",
58
- "willServeYou": "将为您服务"
59
- }
60
- }
@@ -1,60 +0,0 @@
1
- {
2
- "组件多语言使用说明": "在使用多语言配置文件时,需要在使用的项目中添加对应的配置,默认都配置在dragonCommon字段中,也可以看看有没有其他方式",
3
- "dragonCommon": {
4
- "download": "Download",
5
- "smartSummary": "Smart Summary",
6
- "chat": "Chat",
7
- "viewDetails": "View Details",
8
- "folderName": "Folder Name",
9
- "loading": "Loading...",
10
- "Safaridownload": "The download address has been copied, please go to Safari to access the download",
11
- "reduce": "Reduce",
12
- "zoom": "Zoom",
13
- "selectScale": "Select Scale",
14
- "previous": "Previous",
15
- "next": "Next",
16
- "answersGeneratedByPre": "Answers generated by",
17
- "answersGeneratedByAfter": "segments of content",
18
- "scaleAuto": "Auto",
19
- "scaleReality": "Reality",
20
- "firstParagraph": "It's already the first paragraph",
21
- "lastParagraph": "It's already the last paragraph",
22
- "fileloadException": "File load exception",
23
- "regenerate": "Regenerate",
24
- "generating": "Generating",
25
- "close": "Close",
26
- "summaryGeneratedByAI": "AI has generated the following summary for you",
27
- "viewMore": "View More",
28
- "from": "From",
29
- "viewOriginal": "View Original",
30
- "lastUpdateTime": "Last Update Time",
31
- "owner": "Owner",
32
- "enterprise": "Enterprise",
33
- "source": "Source",
34
- "folder": "Folder",
35
- "personalknowledge": "Personal Knowledge",
36
- "enterpriseknowledge": "Enterprise Knowledge",
37
- "satisfaction": "Satisfaction",
38
- "unsatisfied": "Unsatisfied",
39
- "refresh": "Refresh",
40
- "AIrecommends": "AI recommends the following for you",
41
- "youareconsulting": "You are consulting",
42
- "description": "Description",
43
- "location": "Location",
44
- "user": "User",
45
- "department": "Department",
46
- "manager": "Manager",
47
- "uploadImgFile": "Upload",
48
- "cancel": "Cancel",
49
- "confirm": "Confirm",
50
- "noMore": "No more",
51
- "establishConversationWith": "Establish conversation with",
52
- "you": "You",
53
- "bot": "Bot",
54
- "transferTo": "You will transfer the conversation to",
55
- "transferFrom": "will transfer the conversation to you",
56
- "imService": "IM agent",
57
- "botService": "Bot",
58
- "willServeYou": "will serve you"
59
- }
60
- }