GitLab Assistant

GitLab Viewer Publish and Deploy Project!

当前为 2023-09-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitLab Assistant
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.09991
  5. // @description GitLab Viewer Publish and Deploy Project!
  6. // @author Sean
  7. // @match http://192.168.0.200*
  8. // @match http://192.168.0.200/*
  9. // @match http://192.168.0.200/fe3project/*
  10. // @match http://192.168.0.200/frontend_pc/project/*
  11. // @match https://oa.epoint.com.cn/interaction-design-portal/portal/pages/casestemplates/casetemplatesdetail*
  12. // @match https://oa.epoint.com.cn/interaction-design-portal/portal/pages/generalpagetemplates/generalpagetemplatesdetail*
  13. // @match https://oa.epoint.com.cn/interaction-design-portal/portal/pages/dynamiceffecttemplates/dynamiceffecttemplatesdetail*
  14. // @match http://192.168.201.159:9999/webapp/pages/default/onlinecase.html*
  15. // @match http://192.168.118.60:9999/webapp/pages/caselib/create.html*
  16. // @match https://oa.epoint.com.cn/epointoa9/frame/fui/pages/themes/aide/aide*
  17. // @match https://oa.epoint.com.cn/interaction-design-portal/portal/pages/casestemplates/casetemplateslist*
  18. // @match https://oa.epoint.com.cn:8080/OA9/oa9/mail/mailreceivedetail*
  19. // @icon http://192.168.0.200/assets/favicon-7901bd695fb93edb07975966062049829afb56cf11511236e61bcf425070e36e.png
  20. // @require https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.min.js
  21. // @require https://unpkg.com/element-ui/lib/index.js
  22. // @require https://cdn.bootcdn.net/ajax/libs/jszip/3.7.1/jszip.min.js
  23. // @grant GM_getResourceURL
  24. // @grant GM_addStyle
  25. // @grant GM_getResourceText
  26. // @resource ElementCSS https://unpkg.com/element-ui/lib/theme-chalk/index.css
  27. // @grant GM_xmlhttpRequest
  28. // @license MIT
  29. // @run-at document-end
  30. // ==/UserScript==
  31.  
  32.  
  33. // 个性化 gitlab 样式,
  34. // 满足项目详情多行显示,
  35. // 项目列表中的链接新窗口打开,
  36. // 搜索框 placeholder 个性化提示
  37. // 增加CodePipeline 入口等
  38. (function() {
  39. 'use strict';
  40.  
  41. let regs = [/^http:\/\/192\.168\.0\.200\/fe3project\//,
  42. /^http:\/\/192\.168\.0\.200\/frontend_pc\/project\//,
  43. /^http:\/\/192\.168\.0\.200/,
  44. /^http:\/\/192\.168\.0\.200\//];
  45. let match = false;
  46.  
  47. for(let r = 0, lr = regs.length; r < lr; r++) {
  48. if(regs[r].test(location.href)) {
  49. match = true;
  50. break;
  51. }
  52. }
  53.  
  54. if(!match) {
  55. return;
  56. }
  57.  
  58. // 注入样式:改变容器宽度,项目描述多行展示
  59. let injectStyle = ".group-list-tree .group-row-contents .description p { white-space: normal; } .container-limited.limit-container-width { max-width: 1400px } .limit-container-width .info-well {max-width: none;}";
  60.  
  61. injectStyle += ".container-fluid.container-limited.limit-container-width .file-holder.readme-holder.limited-width-container .file-content {max-width: none;}"
  62. injectStyle += 'button:focus {outline-color: transparent !important;}'
  63. injectStyle += '.has-description .description {word-break: break-all;}'
  64. // 添加注入样式
  65. let extraStyleElement = document.createElement("style");
  66. extraStyleElement.innerHTML = injectStyle;
  67. document.head.appendChild(extraStyleElement);
  68.  
  69. const fontUrl = 'https://element.eleme.io/2.11/static/element-icons.535877f.woff';
  70.  
  71. // 添加样式规则,将字体应用到指定元素上
  72. GM_addStyle(`
  73. @font-face {
  74. font-family: element-icons;
  75. src: url(${fontUrl}) format("woff");
  76. }
  77. `);
  78.  
  79. GM_addStyle(GM_getResourceText('ElementCSS'));
  80.  
  81. // 改变列表打开链接方式,改为新窗口打开
  82. let change = false;
  83. let tryTimes = 3;
  84.  
  85. function changeOpenType() {
  86. if(!change){
  87. setTimeout(()=> {
  88. let links = document.querySelectorAll('.description a');
  89. if(links.length) {
  90. for(let i = 0, l = links.length; i < l; i++) {
  91. links[i].target = "_blank";
  92. if(i === l - 1) {
  93. change = true;
  94. }
  95. }
  96. } else {
  97. changeOpenType();
  98. }
  99. }, 1000);
  100. }
  101. }
  102.  
  103. function stopLinkProp() {
  104. setTimeout(()=> {
  105. const links = document.querySelectorAll('.description a');
  106. for(let i = 0, l = links.length; i < l; i++) {
  107. links[i].addEventListener('click', ()=> {
  108. event.stopPropagation();
  109. });
  110. }
  111. }, 1000);
  112. }
  113.  
  114. // 等待页面加载完成
  115. window.addEventListener('load', function() {
  116.  
  117. var targetDiv = document.querySelector('section');
  118.  
  119. if(targetDiv) {
  120. // 创建一个 Mutation Observer 实例
  121. var observer = new MutationObserver(function(mutations) {
  122. // 在这里处理 div 子元素的变化
  123. mutations.forEach(function(mutation) {
  124. if(mutation.addedNodes && mutation.addedNodes.length) {
  125. change = false;
  126. changeOpenType();
  127.  
  128. stopLinkProp();
  129. }
  130. });
  131. });
  132.  
  133. // 配置 Mutation Observer
  134. var config = { childList: true, subtree: true };
  135.  
  136. // 开始观察目标 div 元素
  137. observer.observe(targetDiv, config);
  138. }
  139.  
  140. const placeholder = document.createElement('div');
  141.  
  142. // 创建 Vue 实例并挂载到页面
  143. const vueInstance = new Vue({
  144. el: placeholder,
  145. methods: {
  146. // 进入管理平台 code pipeline
  147. manage() {
  148. window.open('http://192.168.219.170/code-pipeline')
  149. }
  150. },
  151. template: `<div id="my-ext" style="margin-top:4px;">
  152. <el-tooltip content="进入 Code Pipeline 管理平台" placement="top" effect="light">
  153. <el-button type="primary" icon="el-icon-attract" size="small" circle @click="manage"></el-button>
  154. </el-tooltip>
  155. </div>`
  156. });
  157.  
  158. // 将占位元素追加到 body 元素中
  159. document.querySelector('.title-container').appendChild(vueInstance.$el);
  160.  
  161. // 修改 placehodler
  162. const listInput = document.getElementById('group-filter-form-field');
  163. const listInput2 = document.getElementById('project-filter-form-field');
  164.  
  165. if(listInput) {
  166. listInput.setAttribute("placeholder", "按项目名称、日期、开发者搜索,关键字≥3");
  167. listInput.style.width = '305px';
  168. }
  169. if(listInput2) {
  170. listInput2.setAttribute("placeholder", "按项目名称、日期、开发者搜索,关键字≥3");
  171. listInput2.style.width = '305px';
  172. }
  173. });
  174.  
  175.  
  176. })();
  177.  
  178. (function(){
  179. function convertDateFormat(inputString) {
  180. // 匹配日期格式为yyyy-mm-dd或yyyy-m-dd或yyyy-mm-d或yyyy-m-d的正则表达式
  181. const dateRegex = /\d{4}-\d{1,2}-\d{1,2}/g;
  182.  
  183. // 找到所有匹配的日期格式
  184. const dates = inputString.match(dateRegex);
  185.  
  186. // 如果没有匹配到日期,则直接返回原始字符串
  187. if (!dates || dates.length === 0) {
  188. return inputString;
  189. }
  190.  
  191. // 遍历所有匹配到的日期,进行转换
  192. dates.forEach((date) => {
  193. const [year, month, day] = date.split('-');
  194. const formattedDate = `${parseInt(year, 10)}-${parseInt(month, 10)}-${parseInt(day, 10)}`;
  195. inputString = inputString.replace(date, formattedDate);
  196. });
  197.  
  198. return inputString;
  199. }
  200.  
  201. function getUrlParameters() {
  202. var params = {};
  203. var search = window.location.search.substring(1);
  204. var urlParams = search.split('&');
  205.  
  206. for (var i = 0; i < urlParams.length; i++) {
  207. var param = urlParams[i].split('=');
  208. var paramName = decodeURIComponent(param[0]);
  209. var paramValue = decodeURIComponent(param[1] || '');
  210. if(paramName) {
  211. params[paramName] = paramValue;
  212. }
  213. }
  214.  
  215. return params;
  216. }
  217.  
  218. window.convertDateFormat = convertDateFormat;
  219.  
  220. window.gitlabUtil = {
  221. getUrlParameters: getUrlParameters
  222. }
  223. })();
  224.  
  225. // GitLab Viewer Publish and Deploy Project
  226. // 查看项目、部署项目、发布项目功能
  227. // 添加搜索设计门户资源功能
  228. (function() {
  229. 'use strict';
  230. let regs = [/^http:\/\/192\.168\.0\.200\/fe3project\//,
  231. /^http:\/\/192\.168\.0\.200\/frontend_pc\/project\//];
  232. let match = false;
  233.  
  234. for(let r = 0, lr = regs.length; r < lr; r++) {
  235. if(regs[r].test(location.href)) {
  236. match = true;
  237. break;
  238. }
  239. }
  240.  
  241. if(!match) {
  242. return;
  243. }
  244. /*
  245. const fontUrl = 'https://element.eleme.io/2.11/static/element-icons.535877f.woff';
  246.  
  247. // 添加样式规则,将字体应用到指定元素上
  248. GM_addStyle(`
  249. @font-face {
  250. font-family: element-icons;
  251. src: url(${fontUrl}) format("woff");
  252. }
  253. `);
  254.  
  255. GM_addStyle(GM_getResourceText('ElementCSS'));
  256. */
  257.  
  258. let epointCss = ".epoint-tool {position: fixed; bottom: 0%; right:10px; transform: translateY(-40%);}";
  259. epointCss += ".el-row { padding: 6px 0;} .el-dialog__body .el-tree{min-height: 420px; max-height: 500px;overflow: auto;}";
  260. epointCss += ".view-toolbar {padding-bottom: 10px;}";
  261. epointCss += ".deploy-body {height: 306px;}"
  262. epointCss += ".el-loading-spinner {margin-top: -60px;} .el-button--primary:focus {outline: 0 !important;}";
  263.  
  264. // 添加注入样式
  265. let extraStyleElement = document.createElement("style");
  266. extraStyleElement.innerHTML = epointCss;
  267. document.head.appendChild(extraStyleElement);
  268.  
  269. const MyComponent = {
  270. template: `<div class="epoint-wrap">
  271. <div class="epoint-tool">
  272. <el-row>
  273. <el-tooltip content="查看项目页面和模块结构" placement="left" effect="light">
  274. <el-button type="primary" icon="el-icon-search" round @click="viewProject">查看</el-button>
  275. </el-tooltip>
  276. </el-row>
  277. <el-row>
  278. <el-tooltip content="一键部署到170服务器" placement="left" effect="light">
  279. <el-button type="primary" icon="el-icon-s-unfold" round @click="doDeploy">部署</el-button>
  280. </el-tooltip>
  281. </el-row>
  282. <el-row>
  283. <el-tooltip content="一键发布到项目案例库" placement="left" effect="light">
  284. <el-button type="primary" icon="el-icon-upload" round @click="publish">发布</el-button>
  285. </el-tooltip>
  286. </el-row>
  287. <el-row>
  288. <el-tooltip content="进入 Code Pipeline 管理平台进行更多操作" placement="left" effect="light">
  289. <el-button type="primary" icon="el-icon-attract" round @click="manage">管理</el-button>
  290. </el-tooltip>
  291. </el-row>
  292. </div>
  293. <el-dialog
  294. title="目录结构"
  295. width="900px"
  296. :append-to-body="true"
  297. :visible.sync="dialogVisible"
  298. :before-close="handleClose">
  299. <div class="view-body">
  300. <div class="view-toolbar" v-if="projectFtpUrl"><el-button type="primary" size="small" @click="viewAll">查看全部</el-button></div>
  301. <div class="view-content">
  302. <el-tree
  303. class="filter-tree"
  304. :data="data"
  305. :props="defaultProps"
  306. node-key="id"
  307. default-expand-all
  308. @node-click="handleNodeClick"
  309. v-loading="loadingTree"
  310. element-loading-background="rgba(255, 255, 255, 1)"
  311. element-loading-text="拼命加载中......"
  312. ref="tree">
  313. </el-tree>
  314. </div>
  315. </div>
  316. </el-dialog>
  317. <el-dialog
  318. title="部署"
  319. width="420px"
  320. :visible.sync="depDialogVisible">
  321. <div class="deploy-body"
  322. v-loading="loading"
  323. element-loading-text="正在打包部署至 170 服务器,请耐心等待"
  324. element-loading-spinner="el-icon-loading">
  325. </div>
  326. </el-dialog>
  327. <el-dialog title="部署提示" width="640px" :visible.sync="dialogDeployVisible">
  328. <el-alert
  329. title="此操作将把 GitLab 资源打包部署至 170 服务器,已部署过的项目会进行覆盖部署,是否继续?"
  330. type="warning" :closable="false" style="margin-bottom: 20px;">
  331. </el-alert>
  332. <el-form :model="form" ref="form" :rules="rules">
  333. <el-form-item label="框架类型" :label-width="formLabelWidth" prop="frame">
  334. <el-select v-model="form.frame" placeholder="请框架类型">
  335. <el-option v-for="item in framework" :key="item.value" :label="item.label" :value="item.value"></el-option>
  336. </el-select>
  337. </el-form-item>
  338. </el-form>
  339. <div slot="footer" class="dialog-footer">
  340. <el-button @click="dialogDeployVisible = false">取 消</el-button>
  341. <el-button type="primary" @click="doDeploy">确 定</el-button>
  342. </div>
  343. </el-dialog>
  344. </div>`,
  345. data() {
  346. return {
  347. dialogVisible: false, // 查看目录结构弹窗
  348. data: [], // 目录结构树的数据结构
  349. defaultProps: {
  350. children: 'children',
  351. label: 'label'
  352. },
  353. loadingTree: false,
  354. depDialogVisible: false, // 部署中弹窗
  355. loading: false,
  356. projectLibUrl: 'http://192.168.118.60:9999/webapp/pages/caselib/create.html', // 项目案例库地址
  357. projectIsDeployed: false, // 项目是否部署过
  358. projectFtpUrl: '', // ftp路径
  359. projectEntryUrl: '', // 项目案例库发布表单的入口页面
  360. supportDeploy: true, // 项目是否支持部署
  361. dialogDeployVisible: false,
  362. formLabelWidth: '120px',
  363. form: {
  364. frame: ''
  365. },
  366. framework: [
  367. {label: '重构模板', value: 1},
  368. {label: 'f9x1.0', value: 2},
  369. {label: 'f9x2.0', value: 3},
  370. {label: 'f950', value: 4},
  371. {label: 'f950sp1', value: 5},
  372. {label: 'f950sp2', value: 6},
  373. {label: 'f950sp3', value: 7},
  374. {label: 'f951', value: 18},
  375. {label: 'f940', value: 8},
  376. {label: 'f941', value: 10},
  377. {label: 'f942', value: 9},
  378. {label: 'f934', value: 11},
  379. {label: 'f933', value: 12},
  380. {label: 'f932', value: 13},
  381. {label: 'f9211', value: 14},
  382. {label: '骨架', value: 15},
  383. {label: 'Vue', value: 16},
  384. {label: 'React', value: 17}
  385. ],
  386. rules: {
  387. frame: [
  388. { required: true, message: '请选择框架类型', trigger: 'change' }
  389. ]
  390. },
  391. clickNodeEntry: null
  392. };
  393. },
  394. methods: {
  395. handleClose(done) {
  396. done();
  397. /*
  398. this.$confirm('确认关闭?')
  399. .then(_ => {
  400. done();
  401. })
  402. .catch(_ => {});*/
  403. },
  404. handleNodeClick(data) {
  405. console.log(data);
  406. if(data.type === 'folder') {
  407. return false;
  408. }
  409. var self = this;
  410. var entry = data.entry;
  411. self.clickNodeEntry = entry;
  412. if(self.projectFtpUrl) {
  413. window.open('http://192.168.219.170' + self.projectFtpUrl + data.entry);
  414. self.clickNodeEntry = null;
  415. } else {
  416. if(this.supportDeploy === false) {
  417. this.$message({
  418. type: 'error',
  419. message: '当前项目暂时只支持查看,请耐心等待功能升级。'
  420. });
  421. self.clickNodeEntry = null;
  422. return false;
  423. }
  424.  
  425. this.$confirm('资源未部署,部署至 170 服务器后可查看,是否部署?')
  426. .then(_ => {
  427.  
  428. this.dialogDeployVisible = true;
  429. /*
  430. this.depDialogVisible = true;
  431. this.loading = true;
  432. // 部署
  433. this.getDeployInfo({ type: '1' }, (data)=> {
  434. this.loading = false;
  435. this.depDialogVisible = false;
  436.  
  437. this.data = data.custom.detail;
  438. this.projectFtpUrl = data.custom.ftpUrl;
  439.  
  440. this.$alert('部署成功!', '提示', {
  441. confirmButtonText: '确定',
  442. callback: action => {
  443. window.open('http://192.168.219.170' + self.projectFtpUrl + entry)
  444. }
  445. });
  446.  
  447. });*/
  448. })
  449. .catch(_ => {});
  450. }
  451. },
  452. // 部署
  453. doDeploy () {
  454. if(!this.isDownLoadPage()) {
  455. return;
  456. }
  457. if(!this.dialogDeployVisible) {
  458. this.dialogDeployVisible = true;
  459. return;
  460. }
  461.  
  462. let self = this;
  463.  
  464. this.$refs['form'].validate((valid) => {
  465. if (valid) {
  466. this.dialogDeployVisible = false;
  467. this.depDialogVisible = true;
  468. this.loading = true;
  469. // 部署
  470. this.getDeployInfo({ type: '1', frame: this.form.frame }, (data)=> {
  471. this.loading = false;
  472. this.depDialogVisible = false;
  473.  
  474. if(!data.custom.text){
  475.  
  476. this.data = data.custom.pageTreeData;
  477. this.projectFtpUrl = data.custom.projectRootPath;
  478. this.supportDeploy = data.custom.supportDeploy;
  479.  
  480. this.setProjectEntry();
  481. // 从部署按钮直接过来的
  482. if(!this.clickNodeEntry) {
  483. this.$message({
  484. type: 'success',
  485. message: '部署成功!'
  486. });
  487. // 打开查看弹窗
  488. this.viewProject();
  489. } else {// 从点击目录结构过来的,可以调整点击的树节点页面
  490. this.$alert('部署成功!', '提示', {
  491. confirmButtonText: '确定',
  492. callback: action => {
  493. window.open('http://192.168.219.170' + self.projectFtpUrl + self.clickNodeEntry);
  494. self.clickNodeEntry = null;
  495. }
  496. });
  497. }
  498.  
  499. } else {
  500. this.$message({
  501. type: 'error',
  502. message: data.custom.text
  503. });
  504. }
  505. });
  506. } else {
  507. console.log('error submit!!');
  508. return false;
  509. }
  510. });
  511.  
  512. /*
  513. this.$confirm('此操作将把 GitLab 资源打包部署至 170 服务器,已部署过的项目会进行覆盖部署,是否继续?', '提示', {
  514. confirmButtonText: '确定',
  515. cancelButtonText: '取消',
  516. type: 'warning'
  517. }).then(() => {
  518. }).catch(() => {
  519. this.$message({
  520. type: 'info',
  521. message: '已取消部署'
  522. });
  523. });*/
  524. },
  525. // 发布项目案例库
  526. publish () {
  527. this.$confirm('此操作将把项目发布至 <a href="'+ this.projectLibUrl +'" target="_blank">项目案例库</a>,已发布过的项目案例库会有重复项,是否继续?', '提示', {
  528. confirmButtonText: '确定',
  529. cancelButtonText: '取消',
  530. dangerouslyUseHTMLString: true,
  531. type: 'warning'
  532. }).then(() => {
  533. const themes = document.querySelectorAll('.badge-secondary');
  534. let keys = [];
  535.  
  536. for(let i = 0, l = themes.length; i < l; i++) {
  537. if(themes[0].innerText == '智能设备' && i > 0) {
  538. keys.push(themes[i].innerText);
  539. } else if (themes[0].innerText !== '智能设备' && i > 1) {
  540. keys.push(themes[i].innerText);
  541. }
  542. }
  543. // 存在更多主题的情况
  544. const moreKeyEl = document.querySelector('.gl-w-full .text-nowrap');
  545. if(moreKeyEl) {
  546. const moreKeyElContent = moreKeyEl.getAttribute('data-content');
  547. const regex = />([^<]+)</g;
  548. const matches = moreKeyElContent.match(regex);
  549. const results = matches.filter(function(match) {
  550. return match.length > 3;
  551. });
  552. const moreKeyData = results.map(function(match) {
  553. return match.substring(2, match.length - 2);
  554. });
  555.  
  556. if(moreKeyData && moreKeyData.length) {
  557. keys = keys.concat(moreKeyData);
  558. }
  559. }
  560.  
  561. // 组织项目案例库所需参数
  562. const projectName = document.querySelector('.home-panel-title').innerText;
  563. const projectBU = themes[0] ? themes[0].innerText : null;
  564. const projectKeys = keys.join(' ');
  565. const entryUrl = this.projectEntryUrl;
  566. let projectType = themes[1] ? themes[1].innerText : null;
  567.  
  568. if(themes[0]) {
  569. if(themes[0].innerText == '智能设备') {
  570. projectType = themes[1] ? themes[0].innerText : null;
  571. } else {
  572. projectType = themes[1] ? themes[1].innerText : null;
  573. }
  574. }
  575.  
  576. const destUrl = this.projectLibUrl + '?projectName=' + projectName + '&projectBU=' + projectBU + '&projectType=' + projectType + '&projectKeys=' + projectKeys + '&entryUrl=' + entryUrl + '&git=' + window.location.href;
  577.  
  578. this.$message({
  579. type: 'success',
  580. message: destUrl
  581. });
  582.  
  583. window.open(destUrl);
  584.  
  585. }).catch(() => {
  586. this.$message({
  587. type: 'info',
  588. message: '已取消发布'
  589. });
  590. });
  591. },
  592. // 查看项目
  593. viewProject () {
  594. if(!this.isDownLoadPage()) {
  595. return;
  596. }
  597. this.dialogVisible = true;
  598. this.loadingTree = true;
  599. let self = this;
  600.  
  601. // 发送ajax请求,查看是否进行过部署
  602. this.getDeployInfo((data)=> {
  603. // 有部署信息,直接赋值,
  604. if(data) {
  605. self.projectIsDeployed = true;
  606. self.data = data.custom.pageTreeData;
  607. self.projectFtpUrl = data.custom.projectRootPath;
  608. self.supportDeploy = data.custom.supportDeploy;
  609. self.loadingTree = false;
  610.  
  611. self.setProjectEntry();
  612.  
  613. } else {
  614. // 无部署信息,仅查看文件目录
  615. getZipResource((data)=> {
  616. self.data = data;
  617. self.loadingTree = false;
  618. });
  619. }
  620. });
  621.  
  622. },
  623. // 查看项目的所有页面
  624. viewAll() {
  625. window.open('http://192.168.219.170/code-pipeline/#/project/deploy-preview?rowguid=' + document.body.getAttribute('data-project-id'));
  626. },
  627. // 项目部署信息
  628. getDeployInfo(params, callback) {
  629. const projectId = document.body.getAttribute('data-project-id');
  630. const downloadBtn = document.querySelector('.gl-button.btn-sm.btn-confirm');
  631.  
  632. const sourceUrl = downloadBtn.getAttribute('href');
  633. const downloadUrl = window.location.origin + sourceUrl;
  634. const files = document.body.getAttribute('data-find-file').split('/');
  635. const name = document.body.getAttribute('data-project') + '-' + files[files.length - 1];
  636. const author = document.querySelector('.current-user .gl-font-weight-bold').innerText.trim();
  637. const projectName = document.querySelector('.sidebar-context-title').innerText.trim();
  638. const deployManOA = document.querySelector('.current-user>a').getAttribute('data-user');
  639. const projectGitUrl = 'http://192.168.0.200' + document.body.getAttribute('data-find-file').split('/-/')[0];
  640.  
  641. if(typeof params == 'function') {
  642. callback = params;
  643. params = null;
  644. }
  645.  
  646. if(projectId && projectId.length && sourceUrl) {
  647. fetch('http://192.168.219.170:3008/api/getDeployInfo', {
  648. method: 'POST',
  649. // 允许跨域请求
  650. mode: 'cors',
  651. headers: {
  652. 'Accept': 'application/json',
  653. 'Content-Type': 'application/json'
  654. },
  655. body: JSON.stringify({//post请求参数
  656. params: {
  657. "type": (params && params.type !== undefined) ? params.type : '0',// 0 代表查看, 1代表部署
  658. "name": name, // 项目路径英文名
  659. "deployMan": author, // 部署人姓名
  660. "deployManOA": deployManOA, // 部署人账号
  661. "projectName": projectName, // 项目名称
  662. "downloadUrl": downloadUrl, // 下载地址
  663. "projectId": projectId, // 主键,gitlab上的项目id
  664. "projectGitUrl": projectGitUrl,
  665. "frame": (params && params.frame) ? params.frame : undefined
  666. }
  667. })
  668. })
  669. .then(response => response.text())
  670. .then((result) => {
  671. var data = JSON.parse(result);
  672. callback && callback(data);
  673. })
  674. .catch(error => {
  675. this.depDialogVisible = false;
  676. this.dialogVisible = false;
  677. this.$message({
  678. type: 'error',
  679. message: '系统故障,请联系管理员。'
  680. });
  681. console.error(error);
  682. });
  683. } else {
  684. this.$message({
  685. type: 'error',
  686. message: '本页不支持查看和部署,请至仓库页。'
  687. });
  688. console.error('部署信息请求参数error');
  689. }
  690. },
  691. // 进入管理平台 code pipeline
  692. manage() {
  693. window.open('http://192.168.219.170/code-pipeline')
  694. },
  695. // 设置入口
  696. setProjectEntry(){
  697. const firstNode = findFirstFileNode(this.data);
  698. if(firstNode) {
  699. this.projectEntryUrl = 'http://192.168.219.170' + this.projectFtpUrl + firstNode.entry;
  700. }else {
  701. this.projectEntryUrl = null;
  702. }
  703. },
  704. isDownLoadPage() {
  705. const downloadBtn = document.querySelector('.gl-button.btn-sm.btn-confirm');
  706. const sourceUrl = downloadBtn && downloadBtn.getAttribute('href');
  707.  
  708. if(downloadBtn && sourceUrl) {
  709. return true;
  710. } else {
  711. this.$message({
  712. type: 'error',
  713. message: '本页面不支持查看和部署,请移至仓库页。'
  714. });
  715. return false;
  716. }
  717. }
  718. },
  719. mounted() {
  720. }
  721. };
  722.  
  723. const placeholder = document.createElement('div');
  724.  
  725. // 创建 Vue 实例并挂载到页面
  726. const vueInstance = new Vue({
  727. el: placeholder,
  728. components: {
  729. MyComponent
  730. },
  731. methods: {
  732. },
  733. template: `<my-component></my-component>`
  734. });
  735.  
  736. // 开始在项目仓库页添加搜索设计门户按钮 start
  737. const panel = document.querySelector('.project-home-panel');
  738. let vueInstance2;
  739. const description = document.querySelector('.read-more-container');
  740. const descriptionText = description && description.innerText;
  741. let haveDesignBackupUrl = /casetemplatesdetail\?guid=(?!$)/.test(descriptionText);
  742.  
  743. if(panel && !haveDesignBackupUrl) {
  744. const btnPlaceholder = document.createElement('div');
  745. btnPlaceholder.setAttribute('class', 'epoint-portal-search');
  746. // 创建 Vue 实例并挂载到页面
  747. vueInstance2 = new Vue({
  748. el: btnPlaceholder,
  749. data: function() {
  750. return {
  751. proName: document.querySelector('.home-panel-title').innerText.trim().substring(0, 4)
  752. };
  753. },
  754. methods: {
  755. manage() {
  756. window.open('https://oa.epoint.com.cn/epointoa9/frame/fui/pages/themes/aide/aide?pageId=aide&redirect=https://oa.epoint.com.cn/interaction-design-portal/portal/pages/casestemplates/casetemplateslist?projectname' + this.proName)
  757. }
  758. },
  759. template: `<div style="margin-top:4px;">
  760. <el-tooltip content="新点设计门户中查找此项目" placement="top" effect="light">
  761. <el-button type="primary" icon="el-icon-search" size="small" @click="manage">查找UI备份地址</el-button>
  762. </el-tooltip>
  763. </div>`
  764. });
  765. // 开始在项目仓库页添加搜索设计门户按钮 end
  766. }
  767.  
  768.  
  769. // 等待页面加载完成
  770. window.addEventListener('load', function() {
  771. // 将占位元素追加到 body 元素中
  772. document.body.appendChild(vueInstance.$el);
  773.  
  774. panel && !haveDesignBackupUrl && panel.appendChild(vueInstance2.$el);
  775. });
  776.  
  777. // 将文件条目组织成嵌套结构
  778. function organizeFileEntries(fileEntries) {
  779. const root = {
  780. label: document.querySelector('.home-panel-title').innerText || document.getElementById('project_name_edit').value,
  781. type: 'folder',
  782. children: []
  783. };
  784.  
  785. // 创建嵌套结构
  786. fileEntries.forEach(entry => {
  787. const pathSegments = entry.name.split('/');
  788. let currentFolder = root;
  789.  
  790. // 遍历路径中的每个部分,创建相应的文件夹节点
  791. for (let i = 0; i < pathSegments.length - 1; i++) {
  792. const folderName = pathSegments[i];
  793. let folder = currentFolder.children.find(child => child.label === folderName);
  794.  
  795. if(isExcludeFolder(entry.name)) {
  796. continue;
  797. }
  798.  
  799. if (!folder) {
  800. folder = {
  801. label: folderName,
  802. type: 'folder',
  803. children: []
  804. };
  805. currentFolder.children.push(folder);
  806. }
  807.  
  808. currentFolder = folder;
  809. }
  810.  
  811. // 创建文件节点并添加到相应的文件夹中
  812. const fileName = pathSegments[pathSegments.length - 1];
  813.  
  814. if(fileName && fileName.length && isIncludeFile(fileName) && !isExcludeFolder(entry.name)) {
  815. const fileNode = {
  816. label: fileName,
  817. type: 'file',
  818. entry: entry.name
  819. };
  820. currentFolder.children.push(fileNode);
  821. }
  822. });
  823.  
  824. return [root];
  825. }
  826. // 是否排除的文件夹
  827. function isExcludeFolder(entry) {
  828. if(entry.indexOf('css') > -1 ||
  829. entry.indexOf('scss') > -1 ||
  830. entry.indexOf('js') > -1 ||
  831. entry.indexOf('images') > -1 ||
  832. entry.indexOf('fui') > -1 ||
  833. entry.indexOf('lib') > -1 ||
  834. entry.indexOf('test') > -1 ||
  835. entry.indexOf('font') > -1 ||
  836. entry.indexOf('frame/fui') > -1) {
  837. return true;
  838. } else {
  839. return false;
  840. }
  841. }
  842. // 是否包含的文件
  843. function isIncludeFile(fileName) {
  844. if(fileName.indexOf('.html') > -1) {
  845. return true;
  846. } else {
  847. return false;
  848. }
  849. }
  850.  
  851. function getZipResource(callback) {
  852. const downloadUrl = window.location.origin + document.querySelector('.gl-button.btn-sm.btn-confirm').getAttribute('href');
  853.  
  854. fetch(downloadUrl)
  855. .then(response => response.arrayBuffer())
  856. .then(data => {
  857. // 将 ZIP 文件的二进制数据传递给 JSZip 进行解析
  858. return JSZip.loadAsync(data);
  859. })
  860. .then(zip => {
  861. // 获取 ZIP 文件中的所有条目(文件和目录)
  862. const zipEntries = Object.values(zip.files);
  863. const treeData = organizeFileEntries(zipEntries)
  864.  
  865. callback && callback(treeData);
  866.  
  867. })
  868. .catch(error => {
  869. console.error(error);
  870. });
  871. }
  872.  
  873. // 树结构第一个节点数据
  874. function findFirstFileNode(tree) {
  875. // 遍历树的节点
  876. for (let i = 0; i < tree.length; i++) {
  877. const node = tree[i];
  878.  
  879. // 如果节点的类型为 file,则返回该节点
  880. if (node.type === 'file') {
  881. return node;
  882. }
  883.  
  884. // 如果节点有子节点,则递归调用该函数查找子节点中的第一个 file 节点
  885. if (node.children && node.children.length > 0) {
  886. const fileNode = findFirstFileNode(node.children);
  887. if (fileNode) {
  888. return fileNode;
  889. }
  890. }
  891. }
  892.  
  893. // 如果没有找到 file 节点,则返回 null
  894. return null;
  895. }
  896. })();
  897.  
  898. // 修改项目描述的长度
  899. (function() {
  900. 'use strict';
  901. let regs = [/^http:\/\/192\.168\.0\.200\/fe3project\//,
  902. /^http:\/\/192\.168\.0\.200\/frontend_pc\/project\//];
  903. let match = false;
  904.  
  905. for(let r = 0, lr = regs.length; r < lr; r++) {
  906. if(regs[r].test(location.href)) {
  907. match = true;
  908. break;
  909. }
  910. }
  911.  
  912. if(!match) {
  913. return;
  914. }
  915.  
  916. let tryTimes = 6;
  917. let changed = false;
  918.  
  919. // 增加项目描述的输入长度
  920. function modifyTextareaLen() {
  921. if(tryTimes > 0 && !changed) {
  922. setTimeout(() => {
  923. const textarea = document.getElementById('project_description');
  924. tryTimes--;
  925. if(textarea) {
  926. textarea.setAttribute("maxlength", "1000");
  927.  
  928. jQuery(textarea).blur(function(event) {
  929. this.value = this.value.replace(/,/g, ',').replace(/&isfwqfb=1/g, '');
  930. this.value = convertDateFormat(this.value);
  931. jQuery(this).trigger('change');
  932. });
  933. changed = true;
  934. } else {
  935. modifyTextareaLen();
  936. }
  937. }, 1000);
  938. }
  939. }
  940.  
  941. window.onload = function() {
  942. modifyTextareaLen();
  943. }
  944. })();
  945.  
  946. // 设计门户增加通往前端仓库的跳板
  947. (function() {
  948. 'use strict';
  949.  
  950. let regs = [/^https:\/\/oa\.epoint\.com\.cn\/interaction-design-portal\/portal\/pages\/casestemplates\/casetemplatesdetail/,
  951. /^https:\/\/oa\.epoint\.com\.cn\/interaction-design-portal\/portal\/pages\/generalpagetemplates\/generalpagetemplatesdetail/,
  952. /^https:\/\/oa\.epoint\.com\.cn\/interaction-design-portal\/portal\/pages\/dynamiceffecttemplates\/dynamiceffecttemplatesdetail/];
  953. let match = false;
  954.  
  955. for(let r = 0, lr = regs.length; r < lr; r++) {
  956. if(regs[r].test(location.href)) {
  957. match = true;
  958. break;
  959. }
  960. }
  961.  
  962. if(!match) {
  963. return;
  964. }
  965.  
  966. function addStyle() {
  967. // 注入样式:增加按钮
  968. let injectStyle = ".content { position: relative; } .front-proto { position: absolute; top: 20px; right: 20px; width: 106px; height: 36px; border-radius: 4px; cursor: pointer; line-height: 36px; background: #25c2c9; color: #fff; text-align: center; font-size: 14px}";
  969.  
  970.  
  971. // 添加注入样式
  972. let extraStyleElement = document.createElement("style");
  973. extraStyleElement.innerHTML = injectStyle;
  974. document.head.appendChild(extraStyleElement);
  975. }
  976.  
  977. function getUrlParameters() {
  978. var params = {};
  979. var search = window.location.search.substring(1);
  980. var urlParams = search.split('&');
  981.  
  982. for (var i = 0; i < urlParams.length; i++) {
  983. var param = urlParams[i].split('=');
  984. var paramName = decodeURIComponent(param[0]);
  985. var paramValue = decodeURIComponent(param[1] || '');
  986. params[paramName] = paramValue;
  987. }
  988.  
  989. return params;
  990. }
  991.  
  992. window.onload = ()=> {
  993. addStyle();
  994. const $content = jQuery('.content');
  995.  
  996. $content.append('<div class="front-proto">前端原型</div>');
  997.  
  998. const $frontBtn = jQuery('.front-proto', $content);
  999.  
  1000. $frontBtn.on('click', ()=> {
  1001. window.open('http://192.168.0.200/?name=' + getUrlParameters().guid);
  1002. });
  1003. };
  1004. })();
  1005.  
  1006. // 前端项目案例库增加获取参数的能力
  1007. // 前端项目案例库增加部署能力
  1008. (function() {
  1009. 'use strict';
  1010.  
  1011. let regs = [/^http:\/\/192\.168\.118\.60:9999\/webapp\/pages\/caselib\/create\.html/,
  1012. /^http:\/\/192\.168\.201\.159:9999\/webapp\/pages\/default\/onlinecase.html/];
  1013. let match = false;
  1014.  
  1015. for(let r = 0, lr = regs.length; r < lr; r++) {
  1016. if(regs[r].test(location.href)) {
  1017. match = true;
  1018. break;
  1019. }
  1020. }
  1021.  
  1022. if(!match) {
  1023. return;
  1024. }
  1025.  
  1026. const fontUrl = 'https://element.eleme.io/2.11/static/element-icons.535877f.woff';
  1027.  
  1028. // 添加样式规则,将字体应用到指定元素上
  1029. GM_addStyle(`
  1030. @font-face {
  1031. font-family: element-icons;
  1032. src: url(${fontUrl}) format("woff");
  1033. }
  1034. `);
  1035.  
  1036. GM_addStyle(GM_getResourceText('ElementCSS'));
  1037.  
  1038. const businessType = [
  1039. { Value: '7a20e23c-30b8-47e2-8d8d-f2691c9c63c4', Text: '政务服务' },
  1040. { Value: 'c12150bb-b358-452f-87f0-8a2254df87cb', Text: '政务协同' },
  1041. { Value: '3845804e-de68-421c-9402-7b238cfb5a70', Text: '大数据' },
  1042. { Value: '3c28ee56-f24d-4843-b9a2-93e6b96264f4', Text: '电子交易' },
  1043. { Value: '673b5918-51bc-4f1a-ab73-fca86e54d7d1', Text: '数字建设' },
  1044. { Value: '6d9e7d84-7de3-4e0f-bd4f-ed4722ed25b5', Text: '建筑企业' },
  1045. { Value: 'c22f8d2f-518d-4381-b88c-1da68536ed3a', Text: '公共安全' },
  1046. { Value: 'c5810829-1b21-4b22-85cd-390b1edd9614', Text: '智能设备' },
  1047. { Value: '080c7560-c261-428b-a45d-b86b57b47ffb', Text: '中央研究院' }
  1048. ];
  1049.  
  1050. const projectType = [
  1051. { Value: 'dca44f63-be3f-4e9c-b78f-d786571c22c9', Text: '网站' },
  1052. { Value: 'c7861460-163b-4060-80ec-d60604c50435', Text: '业务系统' },
  1053. { Value: '49accc71-6f7d-43f3-b726-58decf58b6fa', Text: '智能设备' },
  1054. { Value: '90209c65-1a55-4d8c-a836-2e5c6b834ada', Text: '大屏可视化' },
  1055. { Value: 'fb0415fb-65ee-42c1-895a-dca042c2568e', Text: '中屏可视化' },
  1056. { Value: '2b83f9b1-ec78-4819-a400-d7d49ea1ecc5', Text: '其他' }
  1057. ];
  1058.  
  1059. let $businesstype;
  1060. let $projecttype;
  1061.  
  1062. function getUrlParameters() {
  1063. var params = {};
  1064. var search = window.location.search.substring(1);
  1065. var urlParams = search.split('&');
  1066.  
  1067. for (var i = 0; i < urlParams.length; i++) {
  1068. var param = urlParams[i].split('=');
  1069. var paramName = decodeURIComponent(param[0]);
  1070. var paramValue = decodeURIComponent(param[1] || '');
  1071. if(paramName) {
  1072. params[paramName] = paramValue;
  1073. }
  1074. }
  1075.  
  1076. return params;
  1077. }
  1078.  
  1079. function initForm (params) {
  1080. if(typeof params === 'object') {
  1081. document.getElementsByName('Title')[0].value = params.projectName ? params.projectName : '';
  1082. document.getElementsByName('KeyWords')[0].value = params.projectKeys ? params.projectKeys : '';
  1083. document.getElementsByName('Entry')[0].value = params.entryUrl ? params.entryUrl : '';
  1084. document.getElementsByName('SourceCode')[0].value = params.git ? params.git : '';
  1085. }
  1086. }
  1087.  
  1088. let setSuccess = false;
  1089. let setTimes = 5;
  1090.  
  1091. function initSelect(params) {
  1092. if(typeof params !== 'object') {
  1093. return;
  1094. }
  1095.  
  1096. if(setTimes > 0 && !setSuccess) {
  1097. setTimeout(()=> {
  1098. setTimes--;
  1099.  
  1100. businessType.forEach((item)=> {
  1101. if(params.projectBU) {
  1102. if(item.Text === params.projectBU.trim()) {
  1103. $businesstype.val(item.Value);
  1104. } else if( params.projectBU.trim() == '一网统管' || params.projectBU.trim() == '一网协同' || params.projectBU.trim() == '一网通办' ) {
  1105. $businesstype.val('7a20e23c-30b8-47e2-8d8d-f2691c9c63c4');
  1106. }
  1107. $businesstype.trigger("chosen:updated");
  1108. }
  1109. });
  1110.  
  1111. projectType.forEach((item)=> {
  1112. if(params.projectType && item.Text === params.projectType.trim()) {
  1113. $projecttype.val(item.Value);
  1114. $projecttype.trigger("chosen:updated");
  1115. }
  1116. });
  1117.  
  1118. setSuccess = true;
  1119.  
  1120. }, 1000);
  1121. } else {
  1122. initSelect(params);
  1123. }
  1124. }
  1125.  
  1126. function addRelatedDom() {
  1127. const sourceInput = document.getElementsByName('SourceCode')[0];
  1128. const $sourceInput = jQuery(sourceInput);
  1129.  
  1130. $sourceInput.after('<a class="btn" style="cursor: pointer;margin-left:10px;" id="deploy">部署</a><a class="btn hidden" style="cursor: pointer;margin-left:10px" id="view">查看</a>')
  1131. }
  1132.  
  1133. function addStyle() {
  1134. let epointCss = ".el-loading-spinner {margin-top: -50px;} .el-button--primary:focus {outline: 0 !important;}";
  1135. // 添加注入样式
  1136. let extraStyleElement = document.createElement("style");
  1137. extraStyleElement.innerHTML = epointCss;
  1138. document.head.appendChild(extraStyleElement);
  1139. }
  1140.  
  1141. window.onload = ()=> {
  1142. const params = getUrlParameters();
  1143.  
  1144. // 有参数,进行填充表单
  1145. if(params && params.git) {
  1146. $businesstype = jQuery('#businesstype');
  1147. $projecttype = jQuery('#projecttype');
  1148.  
  1149. initForm(params);
  1150. initSelect(params);
  1151.  
  1152. return false;
  1153. }
  1154.  
  1155. // 没有url参数填充,则做部署功能展示
  1156. addRelatedDom();
  1157. addStyle();
  1158.  
  1159. const placeholder = document.createElement('div');
  1160.  
  1161. // 创建 Vue 实例并挂载到页面
  1162. const vueInstance = new Vue({
  1163. el: placeholder,
  1164. data() {
  1165. return {
  1166. framework: [
  1167. {label: '重构模板', value: 1},
  1168. {label: 'f9x1.0', value: 2},
  1169. {label: 'f9x2.0', value: 3},
  1170. {label: 'f950', value: 4},
  1171. {label: 'f950sp1', value: 5},
  1172. {label: 'f950sp2', value: 6},
  1173. {label: 'f950sp3', value: 7},
  1174. {label: 'f951', value: 18},
  1175. {label: 'f940', value: 8},
  1176. {label: 'f941', value: 10},
  1177. {label: 'f942', value: 9},
  1178. {label: 'f934', value: 11},
  1179. {label: 'f933', value: 12},
  1180. {label: 'f932', value: 13},
  1181. {label: 'f9211', value: 14},
  1182. {label: '骨架', value: 15},
  1183. {label: 'Vue', value: 16},
  1184. {label: 'React', value: 17}
  1185. ],
  1186. data: [], // 目录结构树
  1187. defaultProps: {
  1188. children: 'children',
  1189. label: 'label'
  1190. },
  1191. loadingTree: false,
  1192. dialogVisible: false,
  1193. dialogDeployVisible: false,
  1194. showDeployPath: false,
  1195. depDialogVisible: false,
  1196. loading: false,
  1197. formLabelWidth: '120px',
  1198. supportDeploy: false,
  1199. form: {
  1200. frame: '',
  1201. deployPath: ''
  1202. },
  1203. rules: {
  1204. frame: [
  1205. { required: true, message: '请选择框架类型', trigger: 'change' }
  1206. ],
  1207. deployPath: [
  1208. { required: true, message: '请输入部署到 170/showcase 下的目标路径名称', trigger: 'change' }
  1209. ]
  1210. }
  1211. }
  1212. },
  1213. methods: {
  1214. // 部署
  1215. doDeploy() {
  1216. let self = this;
  1217.  
  1218. this.$refs['form'].validate((valid) => {
  1219. if (valid) {
  1220. this.dialogDeployVisible = false;
  1221. this.depDialogVisible = true;
  1222. this.loading = true;
  1223. // 部署
  1224. this.getDeployInfo({ type: '1', frame: this.form.frame, deployPath: this.form.deployPath }, (data)=> {
  1225. this.loading = false;
  1226. this.depDialogVisible = false;
  1227.  
  1228. if(!data.custom.text){
  1229.  
  1230. this.data = data.custom.pageTreeData;
  1231. this.projectFtpUrl = data.custom.projectRootPath;
  1232. this.supportDeploy = data.custom.supportDeploy;
  1233.  
  1234. this.$message({
  1235. type: 'success',
  1236. message: '部署成功!'
  1237. });
  1238. // 打开查看弹窗
  1239. this.viewProject();
  1240. this.toggleViewButton(true);
  1241.  
  1242. } else {
  1243. this.$message({
  1244. type: 'error',
  1245. message: data.custom.text
  1246. });
  1247. }
  1248. });
  1249. } else {
  1250. console.log('error submit!!');
  1251. return false;
  1252. }
  1253. });
  1254. },
  1255. // 项目部署
  1256. getDeployInfo(params, callback) {
  1257. const author = document.querySelector('#account a').innerText.trim().substring(4);
  1258. const projectName = document.getElementsByName('Title')[0].value.trim();
  1259. const projectGitUrl = document.getElementsByName('SourceCode')[0].value.trim();
  1260.  
  1261. if(typeof params == 'function') {
  1262. callback = params;
  1263. params = null;
  1264. }
  1265. if(author && author.length && projectGitUrl) {
  1266. fetch('http://192.168.219.170:3008/api/getDeployInfo', {
  1267. method: 'POST',
  1268. // 允许跨域请求
  1269. mode: 'cors',
  1270. headers: {
  1271. 'Accept': 'application/json',
  1272. 'Content-Type': 'application/json'
  1273. },
  1274. body: JSON.stringify({//post请求参数
  1275. params: {
  1276. "type": (params && params.type !== undefined) ? params.type : '0',// 0 代表查看, 1代表部署
  1277. "deployMan": author, // 部署人姓名
  1278. "projectName": projectName, // 项目名称
  1279. "projectGitUrl": projectGitUrl,
  1280. "frame": (params && params.frame) ? params.frame : undefined,
  1281. "deployPath": (params && params.deployPath) ? params.deployPath : undefined // 部署的目标目录
  1282. }
  1283. })
  1284. })
  1285. .then(response => response.text())
  1286. .then((result) => {
  1287. var data = JSON.parse(result);
  1288. callback && callback(data);
  1289. })
  1290. .catch(error => {
  1291. this.depDialogVisible = false;
  1292. this.dialogVisible = false;
  1293. this.$message({
  1294. type: 'error',
  1295. message: '系统故障,请联系管理员。'
  1296. });
  1297. console.error(error);
  1298. });
  1299. } else {
  1300. this.$message({
  1301. type: 'error',
  1302. message: '本页面不支持查看和部署,请先登录。'
  1303. });
  1304. console.error('部署信息请求参数error');
  1305. }
  1306. },
  1307. // 查看项目
  1308. viewProject () {
  1309. this.dialogVisible = true;
  1310. let self = this;
  1311.  
  1312. if(this.data) {
  1313. this.loadingTree = false;
  1314. } else {
  1315. this.loadingTree = true;
  1316. // 发送ajax请求,查看是否进行过部署
  1317. this.getDeployInfo((data)=> {
  1318. // 有部署信息,直接赋值,
  1319. if(data) {
  1320. self.projectIsDeployed = true;
  1321. self.data = data.custom.pageTreeData;
  1322. self.projectFtpUrl = data.custom.projectRootPath;
  1323. self.supportDeploy = data.custom.supportDeploy;
  1324. self.loadingTree = false;
  1325.  
  1326. self.toggleViewButton(true);
  1327.  
  1328. }
  1329. });
  1330. }
  1331. },
  1332. handleNodeClick(data) {
  1333. console.log(data);
  1334. if(data.type === 'folder') {
  1335. return false;
  1336. }
  1337. var self = this;
  1338. var entry = data.entry;
  1339. self.clickNodeEntry = entry;
  1340. if(self.projectFtpUrl) {
  1341. window.open('http://192.168.219.170' + self.projectFtpUrl + data.entry);
  1342. self.clickNodeEntry = null;
  1343. } else {
  1344. if(this.supportDeploy === false) {
  1345. this.$message({
  1346. type: 'error',
  1347. message: '当前项目暂时只支持查看,请耐心等待功能升级。'
  1348. });
  1349. self.clickNodeEntry = null;
  1350. return false;
  1351. }
  1352.  
  1353. this.$confirm('资源未部署,部署至 170 服务器后可查看,是否部署?')
  1354. .then(_ => {
  1355.  
  1356. this.dialogDeployVisible = true;
  1357. })
  1358. .catch(_ => {});
  1359. }
  1360. },
  1361. // svn 需要制定目录名称,showDeployPath
  1362. showDialog(showDeployPath) {
  1363. this.showDeployPath = showDeployPath;
  1364. this.dialogDeployVisible = true;
  1365. },
  1366. // 查看按钮显影控制
  1367. toggleViewButton(show) {
  1368. const $viewBtn = jQuery('#view');
  1369.  
  1370. if(!$viewBtn.length) {
  1371. return;
  1372. }
  1373.  
  1374. if(show) {
  1375. $viewBtn.removeClass('hidden');
  1376. } else {
  1377. $viewBtn.addClass('hidden');
  1378. }
  1379. }
  1380. },
  1381. mounted() {
  1382. const $btnDeloy = jQuery('#deploy');
  1383. const $btnView = jQuery('#view');
  1384.  
  1385. // 绑定vue组件外的事件
  1386. $btnDeloy.on('click', function() {
  1387. // 源码地址和项目名称判断
  1388. const sourceInput = document.getElementsByName('SourceCode');
  1389. const projectNameInput = document.getElementsByName('Title');
  1390.  
  1391. let sourceInputVal = sourceInput[0].value.trim(),
  1392. projectNameInputVal = projectNameInput[0].value.trim();
  1393.  
  1394. const gitpattern = /^http:\/\/192\.168/;
  1395. const svnpattern = /^svn:\/\/192\.168/;
  1396. const sourcepattern = /^(svn:\/\/192\.168|http:\/\/192\.168)/;
  1397.  
  1398. if (!sourceInputVal) {
  1399. vueInstance.$message({
  1400. type: 'error',
  1401. message: '请输入源码地址!'
  1402. });
  1403. return
  1404. }
  1405.  
  1406. if (!sourcepattern.test(sourceInputVal)) {
  1407. vueInstance.$message({
  1408. type: 'error',
  1409. message: '请输入准确的源码 gitlab 或 svn 地址!'
  1410. });
  1411. return
  1412. }
  1413.  
  1414. if (svnpattern.test(sourceInputVal) && !projectNameInputVal) {
  1415. vueInstance.$message({
  1416. type: 'error',
  1417. message: ' svn 仓库地址部署需要填写项目(案例)名称!'
  1418. });
  1419. return
  1420. }
  1421.  
  1422. vueInstance.showDialog(svnpattern.test(sourceInputVal));
  1423. });
  1424. // 查看项目
  1425. $btnView.on('click', function() {
  1426. vueInstance.viewProject();
  1427. });
  1428.  
  1429. },
  1430. template: `<div id="my-form">
  1431. <el-dialog title="部署提示" width="640px" :visible.sync="dialogDeployVisible">
  1432. <el-alert
  1433. title="此操作将把 GitLab / SVN 资源打包部署至 170 服务器,已部署过的项目会进行覆盖部署,是否继续?"
  1434. type="warning" :closable="false" style="margin-bottom: 20px;">
  1435. </el-alert>
  1436. <el-form :model="form" ref="form" :rules="rules">
  1437. <el-form-item label="框架类型" :label-width="formLabelWidth" prop="frame">
  1438. <el-select v-model="form.frame" placeholder="请框架类型" style="width:380px;">
  1439. <el-option v-for="item in framework" :key="item.value" :label="item.label" :value="item.value"></el-option>
  1440. </el-select>
  1441. </el-form-item>
  1442. <el-form-item label="部署路径" :label-width="formLabelWidth" prop="deployPath" v-if="showDeployPath">
  1443. <el-input v-model="form.deployPath" placeholder="请输入部署至服务器 170/showcase 下的目标路径名称" style="width:380px;"></el-input>
  1444. </el-form-item>
  1445. </el-form>
  1446. <div slot="footer" class="dialog-footer">
  1447. <el-button @click="dialogDeployVisible = false">取 消</el-button>
  1448. <el-button type="primary" @click="doDeploy">确 定</el-button>
  1449. </div>
  1450. </el-dialog>
  1451. <el-dialog
  1452. title="部署"
  1453. width="420px"
  1454. :visible.sync="depDialogVisible">
  1455. <div class="deploy-body"
  1456. style="height: 306px;"
  1457. v-loading="loading"
  1458. element-loading-text="正在打包部署至 170 服务器,请耐心等待"
  1459. element-loading-spinner="el-icon-loading">
  1460. </div>
  1461. </el-dialog>
  1462. <el-dialog
  1463. title="目录结构"
  1464. width="900px"
  1465. :append-to-body="true"
  1466. :visible.sync="dialogVisible">
  1467. <el-tree
  1468. class="filter-tree"
  1469. :data="data"
  1470. :props="defaultProps"
  1471. node-key="id"
  1472. default-expand-all
  1473. @node-click="handleNodeClick"
  1474. v-loading="loadingTree"
  1475. element-loading-background="rgba(255, 255, 255, 1)"
  1476. element-loading-text="拼命加载中......"
  1477. ref="tree">
  1478. </el-tree>
  1479. </el-dialog>
  1480. </div>`
  1481. });
  1482.  
  1483. // 将占位元素追加到 body 元素中
  1484. jQuery('.form-container').after(vueInstance.$el);
  1485. };
  1486. })();
  1487.  
  1488. // 新建项目提示
  1489. // 新建项目查找重复项目
  1490. (function() {
  1491. 'use strict';
  1492. let regs = [/^http:\/\/192\.168\.0\.200\/projects\/new/];
  1493. let match = false;
  1494.  
  1495. for(let r = 0, lr = regs.length; r < lr; r++) {
  1496. if(regs[r].test(location.href)) {
  1497. match = true;
  1498. break;
  1499. }
  1500. }
  1501.  
  1502. if(!match) {
  1503. return;
  1504. }
  1505.  
  1506. // 等待页面加载完成
  1507. window.addEventListener('load', function() {
  1508. const $projectName = jQuery('#project_name');
  1509. const $projectDescription = jQuery('#project_description');
  1510. const $check = jQuery('#project_visibility_level_10');
  1511. const $projectPath = jQuery('#project_path');
  1512.  
  1513. // 页面参数
  1514. const p = gitlabUtil.getUrlParameters();
  1515. const projectName = p.projectName;
  1516. const projectBu = p.bu;
  1517. const projectType = p.projectType;
  1518. const frame = p.frame;
  1519. let vueInstance;
  1520. let uiUrl = p.uiUrl;
  1521. if(uiUrl && uiUrl !== '后补' && uiUrl.indexOf('interaction-design-portal') > -1 ) {
  1522. uiUrl += '=' + location.href.substr(location.href.length - 50, 36);
  1523. }
  1524.  
  1525. if($projectName && $projectName.length) {
  1526. $projectName.attr('placeholder', '以需求或项目管理系统中的项目名称为准');
  1527. if(projectName) {
  1528. $projectName.val(projectName);
  1529. $projectName.trigger('change');
  1530. // 防止项目名称中有英文单词时,会自动填充项目标识串。
  1531. $projectPath.val('');
  1532. }
  1533.  
  1534. // 添加检索重复项目按钮
  1535. const btnPlaceholder = document.createElement('div');
  1536.  
  1537. // 创建 Vue 实例并挂载到页面
  1538. vueInstance = new Vue({
  1539. el: btnPlaceholder,
  1540. data: function() {
  1541. return {
  1542. showBtn: false
  1543. };
  1544. },
  1545. methods: {
  1546. // 打开检索弹窗
  1547. check: function() {
  1548. let name = $projectName.val().trim();
  1549. // 去除临时
  1550. name = name.replace('(临时)', '').replace('临时', '');
  1551. // 去除项目
  1552. // name = name.replace('项目', '');
  1553. // 去除子系统,即第一个 - 后面的字符串
  1554. name = name.split('-')[0];
  1555. name = name.split('——')[0];
  1556. if(name.length > 20) {
  1557. name = name.substring(0, 20);
  1558. }
  1559. window.open('http://192.168.0.200/?name=' + name);
  1560.  
  1561. },
  1562. // 同步输入框和按钮状态
  1563. checkInput: function() {
  1564. if($projectName.val().trim() != '') {
  1565. this.showBtn = true;
  1566. } else {
  1567. this.showBtn = false;
  1568. }
  1569. }
  1570. },
  1571. mounted: function() {
  1572. let self = this;
  1573. self.checkInput();
  1574.  
  1575. $projectName.on('change', function() {
  1576. self.checkInput();
  1577. });
  1578. },
  1579. template: `<div>
  1580. <div style="position:absolute; top: 29px; left: 343px;" v-show="showBtn">
  1581. <el-tooltip content="检索已创建的项目,避免重复创建" placement="top" effect="light">
  1582. <el-button type="primary" style="vertical-align: top;" icon="el-icon-search" size="small" id="create-project" @click="check">检索</el-button>
  1583. </el-tooltip>
  1584. </div>
  1585. </div>`
  1586. });
  1587.  
  1588. // 将占位元素追加到 项目名称输入框 后面
  1589. $projectName.parent('.form-group')[0].appendChild(vueInstance.$el);
  1590. }
  1591.  
  1592. if($projectDescription && $projectDescription.length) {
  1593. let date = new Date();
  1594. const imgEl = document.querySelector('.header-user-avatar');
  1595. let name = imgEl ? imgEl.getAttribute('alt') : '张三';
  1596. name = name.replace('(前端研发3部)', '');
  1597. $projectDescription.attr('placeholder', 'YYYY-M-D,张三,UI:https://oa.epoint.com.cn/interaction-design-portal/portal/pages/casestemplates/casetemplatesdetail?guid=');
  1598. $projectDescription.val(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ','+ name +',UI:' + (uiUrl ? uiUrl : 'https://oa.epoint.com.cn/interaction-design-portal/portal/pages/casestemplates/casetemplatesdetail?guid='));
  1599. $projectDescription.prev('.label-bold').find('span').text(' (UI备份地址完善后会自动获取项目名称、业务条线和项目类型)')
  1600.  
  1601. // 增加主题表单
  1602. var themeHtml = '<div class="row">\
  1603. <div class="form-group col-md-9">\
  1604. <label class="label-bold" for="project_topics">主题<i style="color:red; font-style:normal; font-weight: 400; padding-left: 5px;">业务系统类型关键字添加框架版本</i></label>\
  1605. <input value="" maxlength="2000" class="form-control gl-form-input" placeholder="业务条线(政务服务|一网协同...),项目类型(网站|业务系统|中屏可视化...),关键字(f950sp2|gojs|vue...)" size="2000" type="text" name="project[topics]" id="project_topics" data-is-dirty-submit-input="true" data-dirty-submit-original-value="">\
  1606. <p class="form-text text-muted">用逗号分隔主题。</p>\
  1607. <p class="form-text text-muted">业务条线:政务服务、大数据、一网统管、一网协同、智能设备、电子交易、数字建设、公共安全、支撑产品;</p>\
  1608. <p class="form-text text-muted">项目类型:网站、业务系统、智能设备、大屏可视化、中屏可视化、在线表单;</p>\
  1609. <p class="form-text text-muted">关键字:f942f951f950sp2f9x2.0f9x1.0、骨架、vuereact、单页、gojselementAntDesign、全景、关系图、流程图、响应式、svg、视频、miniuiegisegis3d、高德、百度、超图、three、主题、瀑布流、上传、自定义用户控件等;</p>\
  1610. </div></div>';
  1611.  
  1612. $projectDescription.closest('.form-group').after(themeHtml);
  1613.  
  1614. var $theme = jQuery('#project_topics');
  1615.  
  1616. // 规避中文,
  1617. $projectDescription.blur(function(event) {
  1618. this.value = this.value.replace(/,/g, ',').replace(/&isfwqfb=1/g, '');
  1619. // 日期转换
  1620. this.value = convertDateFormat(this.value);
  1621.  
  1622. // 检测主题是否为空,且是否已输入uiUrl
  1623. if ($theme.val().trim() == '') {
  1624. var regex = /guid=([0-9a-fA-F-]{36})/; // 匹配整个URL字符串中的guid后的36位字符
  1625.  
  1626. var match = this.value.match(regex);
  1627.  
  1628. if (match) {
  1629. var extractedGuid = match[1];
  1630. // console.log(extractedGuid);
  1631. // 通过 guid 请求数据
  1632. var apiUrl = 'https://oa.epoint.com.cn/interaction-design-portal/rest/portal/pages/casestemplates/casestemplatesdetailaction/page_load'
  1633. if(this.value.indexOf('dynamiceffecttemplates') > -1) {
  1634. apiUrl = 'https://oa.epoint.com.cn/interaction-design-portal/rest/portal/pages/dynamiceffecttemplates/dynamiceffecttemplatesdetailaction/page_load';
  1635. }
  1636.  
  1637. // 获取项目信息
  1638. GM_xmlhttpRequest({
  1639. method: 'GET',
  1640. url: apiUrl + '?guid='+ extractedGuid +'&isCommondto=true',
  1641. headers: {
  1642. 'Content-Type': 'application/json; charset=utf-8'
  1643. },
  1644. onload: function(res) {
  1645. const data = JSON.parse(res.response);
  1646. let pData = data.custom.casetemplatedata || data.custom.dynamiceffecttemplatesdata;
  1647. let proBu = pData.stripline || pData.line;
  1648. const proType = pData.type;
  1649. const proName = pData.project || pData.title;
  1650. switch(proBu) {
  1651. case '政务BG':
  1652. proBu = '政务服务';
  1653. break;
  1654. case '建设BG':
  1655. proBu = '数字建设';
  1656. break;
  1657. case '交易BG':
  1658. proBu = '电子交易';
  1659. break;
  1660. case '智能设备BU':
  1661. proBu = '智能设备';
  1662. break;
  1663. }
  1664. proName && $projectName.val(proName);
  1665. proBu && proType && $theme.val(proBu + ', ' + proType);
  1666. $projectName.trigger('change');
  1667. }
  1668. });
  1669. }
  1670. }
  1671. });
  1672.  
  1673.  
  1674. if(projectBu) {
  1675. $theme.val(projectBu);
  1676. }
  1677.  
  1678. if(projectType && projectType !== '智能化设备') {
  1679. $theme.val($theme.val() + ', ' + projectType);
  1680. }
  1681.  
  1682. if(frame) {
  1683. $theme.val($theme.val() + ', ' + frame);
  1684. }
  1685.  
  1686. $theme.blur(function(event) {
  1687. this.value = this.value.replaceAll(',', ',');
  1688.  
  1689. });
  1690. }
  1691.  
  1692. if($check && $check.length) {
  1693. $check.trigger('click');
  1694. }
  1695. });
  1696.  
  1697. })();
  1698.  
  1699. // 通过 oa 首页中转,跳过跨站访问的限制
  1700. (function(){
  1701. 'use strict';
  1702. let regs = [/^https:\/\/oa\.epoint\.com\.cn\/epointoa9\/frame\/fui\/pages\/themes\/aide/];
  1703. let match = false;
  1704.  
  1705. for(let r = 0, lr = regs.length; r < lr; r++) {
  1706. if(regs[r].test(location.href)) {
  1707. match = true;
  1708. break;
  1709. }
  1710. }
  1711.  
  1712. if(!match) {
  1713. return;
  1714. }
  1715.  
  1716. let redirectUlr = gitlabUtil.getUrlParameters().redirect;
  1717.  
  1718. if(redirectUlr) {
  1719. window.location.href = redirectUlr;
  1720. }
  1721. })();
  1722.  
  1723. // 设计门户瀑布流页面,查找对应项目
  1724. (function(){
  1725. 'use strict';
  1726. let regs = [/^https:\/\/oa\.epoint\.com\.cn\/interaction-design-portal\/portal\/pages\/casestemplates\/casetemplateslist/];
  1727. let match = false;
  1728.  
  1729. for(let r = 0, lr = regs.length; r < lr; r++) {
  1730. if(regs[r].test(location.href)) {
  1731. match = true;
  1732. break;
  1733. }
  1734. }
  1735.  
  1736. if(!match) {
  1737. return;
  1738. }
  1739.  
  1740. let projectName = location.href.split('projectname');
  1741.  
  1742. window.addEventListener('load', function() {
  1743. if(projectName[1]) {
  1744. projectName = decodeURIComponent(projectName[1]);
  1745.  
  1746. const $input = jQuery('#search-input');
  1747. const $searchBtn = jQuery('.search-icon');
  1748.  
  1749. setTimeout(() => {
  1750. $input.val(projectName);
  1751. $searchBtn.trigger('click');
  1752. }, 1000);
  1753. }
  1754. });
  1755. })();
  1756.  
  1757. // 邮件详情页可以创建项目
  1758. (function() {
  1759. 'use strict';
  1760. let regs = [/^https:\/\/oa\.epoint\.com\.cn\:8080\/OA9\/oa9\/mail\/mailreceivedetail/,
  1761. /^https:\/\/oa\.epoint\.com\.cn\/OA9\/oa9\/mail\/mailreceivedetail/];
  1762. let match = false;
  1763.  
  1764. for(let r = 0, lr = regs.length; r < lr; r++) {
  1765. if(regs[r].test(location.href)) {
  1766. match = true;
  1767. break;
  1768. }
  1769. }
  1770.  
  1771. if(!match) {
  1772. return;
  1773. }
  1774.  
  1775. const fontUrl = 'https://element.eleme.io/2.11/static/element-icons.535877f.woff';
  1776.  
  1777. // 添加样式规则,将字体应用到指定元素上
  1778. GM_addStyle(`
  1779. @font-face {
  1780. font-family: element-icons;
  1781. src: url(${fontUrl}) format("woff");
  1782. }
  1783. `);
  1784.  
  1785. GM_addStyle(GM_getResourceText('ElementCSS'));
  1786.  
  1787. // 在邮件签收情况后添加按钮-新建项目
  1788. function initCreate() {
  1789. const title = document.querySelector('#mail-detail-container .dtt');
  1790. let vueInstance;
  1791. let gitUrl = 'http://192.168.0.200/projects/new?namespace_id=4817';
  1792.  
  1793. if(title) {
  1794. const btnPlaceholder = document.createElement('div');
  1795. const tds = jQuery('#mailcontent table').find("td[colspan='3']");
  1796. const projectName = tds.eq(0).text().replace('(临时)', '').replace('(临时)', '');
  1797. const isFrontEndEmail = jQuery('#mailcontent table').length;
  1798. let bu = '政务服务';
  1799. let projectType = '';
  1800. let frame = '';
  1801. const demandUrl = tds.eq(1).text();
  1802. let uiUrl = '';
  1803.  
  1804. // 由于表格格式不固定,重新遍历一遍获取 uiUrl 和 frame
  1805. tds.each(function(i, el) {
  1806. if(jQuery(el).prev().text() == '备份地址') {
  1807. uiUrl = jQuery(el).text();
  1808. }
  1809. if(jQuery(el).prev().text() == '框架版本') {
  1810. frame = jQuery(el).text();
  1811. }
  1812. if(jQuery(el).prev().text() == '设计类型') {
  1813. projectType = jQuery(el).text();
  1814. }
  1815. });
  1816.  
  1817. uiUrl = uiUrl ? removeQueryStringParameter(uiUrl, 'isfwqfb') : '';
  1818. const backGuid = extractGuidFromUrl(uiUrl);
  1819.  
  1820. if(!isFrontEndEmail) {
  1821. return;
  1822. }
  1823.  
  1824. // 请求项目信息地址
  1825. let apiUrl = '';
  1826.  
  1827. apiUrl = uiUrl.split('?')[0];
  1828. apiUrl = apiUrl.split('interaction-design-portal')[0] + 'interaction-design-portal/rest' + apiUrl.split('interaction-design-portal')[1] + 'action/page_load';
  1829.  
  1830. if(apiUrl.indexOf('casetemplatesdetailaction') > -1) {
  1831. apiUrl = apiUrl.replace('casetemplatesdetailaction', 'casestemplatesdetailaction');
  1832. }
  1833.  
  1834. // 创建 Vue 实例并挂载到页面
  1835. vueInstance = new Vue({
  1836. el: btnPlaceholder,
  1837. data: function() {
  1838. return {
  1839. proBu: bu,
  1840. proType: projectType
  1841. };
  1842. },
  1843. methods: {
  1844. create: function() {
  1845. window.open(gitUrl + '&projectName=' + projectName + '&bu=' + this.proBu + '&projectType=' + this.proType + '&frame=' + frame + '&uiUrl=' + uiUrl + '#blank_project');
  1846. },
  1847. search: function() {
  1848. window.open('http://192.168.0.200/?name=' + projectName);
  1849. }
  1850. },
  1851. mounted: function() {
  1852. let self = this;
  1853. // 获取项目信息
  1854. GM_xmlhttpRequest({
  1855. method: 'GET',
  1856. url: apiUrl + '?guid='+ backGuid +'&isfwqfb=1&isCommondto=true',
  1857. headers: {
  1858. 'Content-Type': 'application/json; charset=utf-8'
  1859. },
  1860. onload: function(res) {
  1861. const data = JSON.parse(res.response);
  1862. let pData = data.custom.casetemplatedata || data.custom.dynamiceffecttemplatesdata;
  1863. self.proBu = pData.stripline || pData.line;
  1864. self.proType = pData.type;
  1865. switch(self.proBu) {
  1866. case '政务BG':
  1867. self.proBu = '政务服务';
  1868. break;
  1869. case '建设BG':
  1870. self.proBu = '数字建设';
  1871. break;
  1872. case '交易BG':
  1873. self.proBu = '电子交易';
  1874. break;
  1875. case '智能设备BU':
  1876. self.proBu = '智能设备';
  1877. break;
  1878. }
  1879. }
  1880. });
  1881. },
  1882. template: `<div style="display:inline-block; margin-left: 5px; vertical-align: top;">
  1883. <el-tooltip content="去 GitLab 创建项目" placement="top" effect="light">
  1884. <el-button type="primary" style="vertical-align: top;" icon="el-icon-folder-add" circle size="mini" id="create-project" @click="create"></el-button>
  1885. </el-tooltip>
  1886. <el-tooltip content="去 GitLab 查找项目" placement="top" effect="light">
  1887. <el-button type="primary" style="vertical-align: top;" icon="el-icon-search" circle size="mini" @click="search"></el-button>
  1888. </el-tooltip>
  1889. </div>`
  1890. });
  1891.  
  1892. // 将占位元素追加到 邮件标题后 元素中
  1893. // f9 框架会冲突
  1894. title.appendChild(vueInstance.$el);
  1895. // jQuery(title).append(vueInstance.$el.outerHTML);
  1896.  
  1897. /*
  1898. jQuery('#create-project').on('click', function() {
  1899. window.open(gitUrl);
  1900. });*/
  1901. }
  1902. }
  1903.  
  1904. function extractGuidFromUrl(url) {
  1905. const regex = /[?&]guid=([^&]+)/;
  1906. const match = url.match(regex);
  1907.  
  1908. if (match) {
  1909. return match[1]; // 第一个捕获组中的值即为 guid
  1910. } else {
  1911. return null; // 如果没有匹配到 guid,则返回 null
  1912. }
  1913. }
  1914.  
  1915. function removeQueryStringParameter(url, parameterName) {
  1916. const urlParts = url.split('?');
  1917.  
  1918. if (urlParts.length === 2) {
  1919. const baseUrl = urlParts[0];
  1920. const queryString = urlParts[1];
  1921.  
  1922. const parameters = queryString.split('&').filter(param => {
  1923. const paramName = param.split('=')[0];
  1924. return paramName !== parameterName;
  1925. });
  1926.  
  1927. if (parameters.length > 0) {
  1928. return baseUrl + '?' + parameters.join('&');
  1929. } else {
  1930. return baseUrl;
  1931. }
  1932. }
  1933.  
  1934. return url;
  1935. }
  1936.  
  1937. window.addEventListener('load', function() {
  1938. setTimeout(function() {
  1939. initCreate();
  1940. }, 500);
  1941. });
  1942.  
  1943. })();