diff --git a/back/package.json b/back/package.json index e9ac8253..ced391e7 100644 --- a/back/package.json +++ b/back/package.json @@ -34,6 +34,7 @@ "lodash": "^4.17.19", "monaco-editor": "^0.20.0", "monaco-editor-webpack-plugin": "^1.9.0", + "pinyin-pro": "^3.11.0", "qs": "^6.9.4", "quill": "^1.3.7", "sass": "^1.51.0", diff --git a/back/public/index.html b/back/public/index.html index 3e830a61..c8f9e70b 100644 --- a/back/public/index.html +++ b/back/public/index.html @@ -1,8 +1,8 @@ @@ -27,7 +27,8 @@ 'isTab': true, // 是否通过tab展示内容? 'iframeURL': '' // 是否通过iframe嵌套展示内容? (以http[s]://开头, 自动匹配) }; - window.SITE_CONFIG['frontUrl'] = 'http://15.2.21.243:9796/#/vueTemplateDemo'; + window.SITE_CONFIG['frontUrl'] = 'http://localhost:8080/#/vueTemplateDemo'; + // window.SITE_CONFIG['frontUrl'] = 'http://15.2.21.243:9796/#/vueTemplateDemo'; // window.SITE_CONFIG['frontUrl'] = 'http://124.222.94.39:9796/#/vueTemplateDemo'; // window.SITE_CONFIG['frontUrl'] = 'http://15.72.183.90:7008/#/vueTemplateDemo'; // window.SITE_CONFIG['frontUrl'] = 'http://10.134.135.9:9797/#/vueTemplateDemo'; @@ -45,7 +46,7 @@ // window.SITE_CONFIG['apiURL'] = 'http://124.222.94.39:8888/renren-admin'; // window.SITE_CONFIG['apiURL'] = 'http://10.16.5.35:8888/renren-admin'; window.SITE_CONFIG['apiURL'] = 'http://15.2.21.236:8888/renren-admin'; - window.SITE_CONFIG['previewUrl'] = 'http://15.2.21.236:9796/'; + window.SITE_CONFIG['previewUrl'] = 'http://localhost:8080/'; // window.SITE_CONFIG['apiURL'] = 'http://15.2.23.141:8000/renren-admin'; // WebSocket地址 window.SITE_CONFIG['socketURL'] ='ws://localhost:8080/renren-admin/websocket'; diff --git a/back/src/views/modules/ability/bsabilityai.vue b/back/src/views/modules/ability/bsabilityai.vue index 810dcd2b..3ad53de6 100644 --- a/back/src/views/modules/ability/bsabilityai.vue +++ b/back/src/views/modules/ability/bsabilityai.vue @@ -241,6 +241,7 @@ import mixinViewModule from '@/mixins/view-module' import AddOrUpdate from './bsabilityai-add-or-update' import dictionaries from '@/utils/dictionaries' import qs from 'qs' +import { pinyin } from 'pinyin-pro' import RelateApplication from './bsabilityai-relate-application.vue' import putOnTheShelf from '@/views/modules/putOnTheShelf' export default { @@ -292,7 +293,10 @@ export default { responseData: {}, linkType: '' }, - typeInput: '组件服务' + typeInput: '组件服务', + uuidOne: '', + uuidTwo: '', + uuidSnum: '' } }, watch: {}, @@ -384,11 +388,89 @@ export default { // }) // this.disabled = true }, + // 创建uuid + uuid (len, radix) { + var chars = + '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + var uuid = [] + var i + radix = radix || chars.length + + if (len) { + // Compact form + for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)] + } else { + // rfc4122, version 4 form + var r + + // rfc4122 requires these characters + uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-' + uuid[14] = '4' + + // Fill in random data. At i==19 set the high bits of clock sequence as + // per rfc4122, sec. 4.1.5 + for (i = 0; i < 36; i++) { + if (!uuid[i]) { + r = 0 | (Math.random() * 16) + uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r] + } + } + } + + return uuid.join('') + }, + uuidSplice () { + this.uuidOne = this.uuid(13, 16) + this.uuidTwo = this.uuid(13, 16) + this.uuidSnum = this.uuidOne + this.uuidTwo + this.uuidSnum = this.uuidSnum.replace(/\s+/g, '') + console.log('this.uuidOne', this.uuidSnum) + }, showDocument (val) { - window.open( - window.SITE_CONFIG.frontUrl + '?id=' + val.id + '&&type=' + val.type, - '_blank' - ) + // 第一步:创建文档 + // 不存在文档时创建空文档 + this.uuidSplice() + const uuidParam = val.infoList.filter((item) => { + if (item.attrType === '技术文档') { + return item + } + }) + if (uuidParam.length > 0) { + this.uuidSnum = uuidParam[0].attrValue.split('/')[1].split('.')[0] + } else { + const type = pinyin(val.type, { + pattern: 'initial' + }).replace(/\s*/g, '') + const obj = { + attrType: '技术文档', + attrValue: type + '/' + this.uuidSnum + '.md', + delFlag: 0 + } + val.infoList.push(obj) + } + + // 存在时加入文档 + this.$http + .put('/resource/update', val) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg) + } + this.$message({ + message: this.$t('prompt.success'), + type: 'success', + duration: 500, + onClose: () => { + // 打开这个空的开发文档 + window.open( + window.SITE_CONFIG.frontUrl + '?id=' + this.uuidSnum + '&&type=' + val.type, + '_blank' + ) + } + }) + }) + .catch(() => {}) + // 第二部,update列数据,成功后打开文档编辑 }, getDataList2 (names) { if (names != null) { diff --git a/front/src/views/personalCenter/VueTemplateDemo.vue b/front/src/views/personalCenter/VueTemplateDemo.vue index 46658761..73eed452 100644 --- a/front/src/views/personalCenter/VueTemplateDemo.vue +++ b/front/src/views/personalCenter/VueTemplateDemo.vue @@ -2,7 +2,7 @@ * @Author: hisense.wuhongjian * @Date: 2022-04-19 17:18:48 * @LastEditors: hisense.wuhongjian - * @LastEditTime: 2022-07-18 16:40:21 + * @LastEditTime: 2022-07-27 10:34:02 * @Description: markdown编辑器 -->