GitLab Assistant

GitLab Viewer Publish and Deploy Project!

当前为 2023-07-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitLab Assistant
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0995
  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 http://192.168.201.159:9999/webapp/pages/default/onlinecase.html*
  14. // @match http://192.168.118.60:9999/webapp/pages/caselib/create.html*
  15. // @icon http://192.168.0.200/assets/favicon-7901bd695fb93edb07975966062049829afb56cf11511236e61bcf425070e36e.png
  16. // @require https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.min.js
  17. // @require https://unpkg.com/element-ui/lib/index.js
  18. // @require https://cdn.bootcdn.net/ajax/libs/jszip/3.7.1/jszip.min.js
  19. // @grant GM_getResourceURL
  20. // @grant GM_addStyle
  21. // @grant GM_getResourceText
  22. // @resource ElementCSS https://unpkg.com/element-ui/lib/theme-chalk/index.css
  23. // @grant GM_xmlhttpRequest
  24. // @license MIT
  25. // @run-at document-end
  26. // ==/UserScript==
  27.  
  28.  
  29. // 个性化 gitlab 样式,
  30. // 满足项目详情多行显示,
  31. // 项目列表中的链接新窗口打开,
  32. // 搜索框 placeholder 个性化提示
  33. // 增加CodePipeline 入口等
  34. (function() {
  35. 'use strict';
  36.  
  37. let regs = [/^http:\/\/192\.168\.0\.200\/fe3project\//,
  38. /^http:\/\/192\.168\.0\.200\/frontend_pc\/project\//,
  39. /^http:\/\/192\.168\.0\.200/,
  40. /^http:\/\/192\.168\.0\.200\//];
  41. let match = false;
  42.  
  43. for(let r = 0, lr = regs.length; r < lr; r++) {
  44. if(regs[r].test(location.href)) {
  45. match = true;
  46. break;
  47. }
  48. }
  49.  
  50. if(!match) {
  51. return;
  52. }
  53.  
  54. // 注入样式:改变容器宽度,项目描述多行展示
  55. 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;}";
  56.  
  57. injectStyle += ".container-fluid.container-limited.limit-container-width .file-holder.readme-holder.limited-width-container .file-content {max-width: none;}"
  58. injectStyle += 'button:focus {outline-color: transparent !important;}'
  59. injectStyle += '.has-description .description {word-break: break-all;}'
  60. // 添加注入样式
  61. let extraStyleElement = document.createElement("style");
  62. extraStyleElement.innerHTML = injectStyle;
  63. document.head.appendChild(extraStyleElement);
  64.  
  65. const fontUrl = 'https://element.eleme.io/2.11/static/element-icons.535877f.woff';
  66.  
  67. // 添加样式规则,将字体应用到指定元素上
  68. GM_addStyle(`
  69. @font-face {
  70. font-family: element-icons;
  71. src: url(${fontUrl}) format("woff");
  72. }
  73. `);
  74.  
  75. GM_addStyle(GM_getResourceText('ElementCSS'));
  76.  
  77. // 改变列表打开链接方式,改为新窗口打开
  78. let change = false;
  79. let tryTimes = 3;
  80.  
  81. function changeOpenType() {
  82. if(!change){
  83. setTimeout(()=> {
  84. let links = document.querySelectorAll('.description a');
  85. if(links.length) {
  86. for(let i = 0, l = links.length; i < l; i++) {
  87. links[i].target = "_blank";
  88. if(i === l - 1) {
  89. change = true;
  90. }
  91. }
  92. } else {
  93. changeOpenType();
  94. }
  95. }, 1000);
  96. }
  97. }
  98.  
  99. function stopLinkProp() {
  100. setTimeout(()=> {
  101. const links = document.querySelectorAll('.description a');
  102. for(let i = 0, l = links.length; i < l; i++) {
  103. links[i].addEventListener('click', ()=> {
  104. event.stopPropagation();
  105. });
  106. }
  107. }, 1000);
  108. }
  109.  
  110. // 等待页面加载完成
  111. window.addEventListener('load', function() {
  112.  
  113. var targetDiv = document.querySelector('section');
  114.  
  115. if(targetDiv) {
  116. // 创建一个 Mutation Observer 实例
  117. var observer = new MutationObserver(function(mutations) {
  118. // 在这里处理 div 子元素的变化
  119. mutations.forEach(function(mutation) {
  120. if(mutation.addedNodes && mutation.addedNodes.length) {
  121. change = false;
  122. changeOpenType();
  123.  
  124. stopLinkProp();
  125. }
  126. });
  127. });
  128.  
  129. // 配置 Mutation Observer
  130. var config = { childList: true, subtree: true };
  131.  
  132. // 开始观察目标 div 元素
  133. observer.observe(targetDiv, config);
  134. }
  135.  
  136. const placeholder = document.createElement('div');
  137.  
  138. // 创建 Vue 实例并挂载到页面
  139. const vueInstance = new Vue({
  140. el: placeholder,
  141. methods: {
  142. // 进入管理平台 code pipeline
  143. manage() {
  144. window.open('http://192.168.219.170/code-pipeline')
  145. }
  146. },
  147. template: `<div id="my-ext" style="margin-top:4px;">
  148. <el-tooltip content="进入 Code Pipeline 管理平台" placement="top" effect="light">
  149. <el-button type="primary" icon="el-icon-attract" size="small" circle @click="manage"></el-button>
  150. </el-tooltip>
  151. </div>`
  152. });
  153.  
  154. // 将占位元素追加到 body 元素中
  155. document.querySelector('.title-container').appendChild(vueInstance.$el);
  156.  
  157. // 修改 placehodler
  158. const listInput = document.getElementById('group-filter-form-field');
  159. const listInput2 = document.getElementById('project-filter-form-field');
  160.  
  161. if(listInput) {
  162. listInput.setAttribute("placeholder", "按项目名称、日期、开发者搜索,关键字≥3");
  163. listInput.style.width = '305px';
  164. }
  165. if(listInput2) {
  166. listInput2.setAttribute("placeholder", "按项目名称、日期、开发者搜索,关键字≥3");
  167. listInput2.style.width = '305px';
  168. }
  169. });
  170.  
  171.  
  172. })();
  173.  
  174. // GitLab Viewer Publish and Deploy Project
  175. // 查看项目、部署项目、发布项目功能
  176. (function() {
  177. 'use strict';
  178. let regs = [/^http:\/\/192\.168\.0\.200\/fe3project\//,
  179. /^http:\/\/192\.168\.0\.200\/frontend_pc\/project\//];
  180. let match = false;
  181.  
  182. for(let r = 0, lr = regs.length; r < lr; r++) {
  183. if(regs[r].test(location.href)) {
  184. match = true;
  185. break;
  186. }
  187. }
  188.  
  189. if(!match) {
  190. return;
  191. }
  192. /*
  193. const fontUrl = 'https://element.eleme.io/2.11/static/element-icons.535877f.woff';
  194.  
  195. // 添加样式规则,将字体应用到指定元素上
  196. GM_addStyle(`
  197. @font-face {
  198. font-family: element-icons;
  199. src: url(${fontUrl}) format("woff");
  200. }
  201. `);
  202.  
  203. GM_addStyle(GM_getResourceText('ElementCSS'));
  204. */
  205.  
  206. let epointCss = ".epoint-tool {position: fixed; bottom: 0%; right:10px; transform: translateY(-40%);}";
  207. epointCss += ".el-row { padding: 3px 0;} .el-dialog__body .el-tree{min-height: 420px; max-height: 500px;overflow: auto;}";
  208. epointCss += ".view-toolbar {padding-bottom: 10px;}";
  209. epointCss += ".deploy-body {height: 306px;}"
  210. epointCss += ".el-loading-spinner {margin-top: -60px;} .el-button--primary:focus {outline: 0 !important;}";
  211.  
  212. // 添加注入样式
  213. let extraStyleElement = document.createElement("style");
  214. extraStyleElement.innerHTML = epointCss;
  215. document.head.appendChild(extraStyleElement);
  216.  
  217. const MyComponent = {
  218. template: `<div class="epoint-wrap">
  219. <div class="epoint-tool">
  220. <el-row><el-button type="primary" icon="el-icon-search" round @click="viewProject">查看</el-button></el-row>
  221. <el-row>
  222. <el-tooltip content="一键部署到170服务器" placement="top" effect="light">
  223. <el-button type="primary" icon="el-icon-s-unfold" round @click="doDeploy">部署</el-button>
  224. </el-tooltip>
  225. </el-row>
  226. <el-row>
  227. <el-tooltip content="一键发布到项目案例库" placement="top" effect="light">
  228. <el-button type="primary" icon="el-icon-upload" round @click="publish">发布</el-button>
  229. </el-tooltip>
  230. </el-row>
  231. <el-row>
  232. <el-tooltip content="进入 Code Pipeline 管理平台进行更多操作" placement="top" effect="light">
  233. <el-button type="primary" icon="el-icon-attract" round @click="manage">管理</el-button>
  234. </el-tooltip>
  235. </el-row>
  236. </div>
  237. <el-dialog
  238. title="目录结构"
  239. width="900px"
  240. :append-to-body="true"
  241. :visible.sync="dialogVisible"
  242. :before-close="handleClose">
  243. <div class="view-body">
  244. <div class="view-toolbar" v-if="projectFtpUrl"><el-button type="primary" size="small" @click="viewAll">查看全部</el-button></div>
  245. <div class="view-content">
  246. <el-tree
  247. class="filter-tree"
  248. :data="data"
  249. :props="defaultProps"
  250. node-key="id"
  251. default-expand-all
  252. @node-click="handleNodeClick"
  253. v-loading="loadingTree"
  254. element-loading-background="rgba(255, 255, 255, 1)"
  255. element-loading-text="拼命加载中......"
  256. ref="tree">
  257. </el-tree>
  258. </div>
  259. </div>
  260. </el-dialog>
  261. <el-dialog
  262. title="部署"
  263. width="420px"
  264. :visible.sync="depDialogVisible">
  265. <div class="deploy-body"
  266. v-loading="loading"
  267. element-loading-text="正在打包部署至 170 服务器,请耐心等待"
  268. element-loading-spinner="el-icon-loading">
  269. </div>
  270. </el-dialog>
  271. <el-dialog title="部署提示" width="640px" :visible.sync="dialogDeployVisible">
  272. <el-alert
  273. title="此操作将把 GitLab 资源打包部署至 170 服务器,已部署过的项目会进行覆盖部署,是否继续?"
  274. type="warning" :closable="false" style="margin-bottom: 20px;">
  275. </el-alert>
  276. <el-form :model="form" ref="form" :rules="rules">
  277. <el-form-item label="框架类型" :label-width="formLabelWidth" prop="frame">
  278. <el-select v-model="form.frame" placeholder="请框架类型">
  279. <el-option v-for="item in framework" :key="item.value" :label="item.label" :value="item.value"></el-option>
  280. </el-select>
  281. </el-form-item>
  282. </el-form>
  283. <div slot="footer" class="dialog-footer">
  284. <el-button @click="dialogDeployVisible = false">取 消</el-button>
  285. <el-button type="primary" @click="doDeploy">确 定</el-button>
  286. </div>
  287. </el-dialog>
  288. </div>`,
  289. data() {
  290. return {
  291. dialogVisible: false, // 查看目录结构弹窗
  292. data: [], // 目录结构树的数据结构
  293. defaultProps: {
  294. children: 'children',
  295. label: 'label'
  296. },
  297. loadingTree: false,
  298. depDialogVisible: false, // 部署中弹窗
  299. loading: false,
  300. projectLibUrl: 'http://192.168.118.60:9999/webapp/pages/caselib/create.html', // 项目案例库地址
  301. projectIsDeployed: false, // 项目是否部署过
  302. projectFtpUrl: '', // ftp路径
  303. projectEntryUrl: '', // 项目案例库发布表单的入口页面
  304. supportDeploy: true, // 项目是否支持部署
  305. dialogDeployVisible: false,
  306. formLabelWidth: '120px',
  307. form: {
  308. frame: ''
  309. },
  310. framework: [
  311. {label: '重构模板', value: 1},
  312. {label: 'f9x1.0', value: 2},
  313. {label: 'f9x2.0', value: 3},
  314. {label: 'f950', value: 4},
  315. {label: 'f950sp1', value: 5},
  316. {label: 'f950sp2', value: 6},
  317. {label: 'f950sp3', value: 7},
  318. {label: 'f951', value: 18},
  319. {label: 'f940', value: 8},
  320. {label: 'f941', value: 10},
  321. {label: 'f942', value: 9},
  322. {label: 'f934', value: 11},
  323. {label: 'f933', value: 12},
  324. {label: 'f932', value: 13},
  325. {label: 'f9211', value: 14},
  326. {label: '骨架', value: 15},
  327. {label: 'Vue', value: 16},
  328. {label: 'React', value: 17}
  329. ],
  330. rules: {
  331. frame: [
  332. { required: true, message: '请选择框架类型', trigger: 'change' }
  333. ]
  334. },
  335. clickNodeEntry: null
  336. };
  337. },
  338. methods: {
  339. handleClose(done) {
  340. done();
  341. /*
  342. this.$confirm('确认关闭?')
  343. .then(_ => {
  344. done();
  345. })
  346. .catch(_ => {});*/
  347. },
  348. handleNodeClick(data) {
  349. console.log(data);
  350. if(data.type === 'folder') {
  351. return false;
  352. }
  353. var self = this;
  354. var entry = data.entry;
  355. self.clickNodeEntry = entry;
  356. if(self.projectFtpUrl) {
  357. window.open('http://192.168.219.170' + self.projectFtpUrl + data.entry);
  358. self.clickNodeEntry = null;
  359. } else {
  360. if(this.supportDeploy === false) {
  361. this.$message({
  362. type: 'error',
  363. message: '当前项目暂时只支持查看,请耐心等待功能升级。'
  364. });
  365. self.clickNodeEntry = null;
  366. return false;
  367. }
  368.  
  369. this.$confirm('资源未部署,部署至 170 服务器后可查看,是否部署?')
  370. .then(_ => {
  371.  
  372. this.dialogDeployVisible = true;
  373. /*
  374. this.depDialogVisible = true;
  375. this.loading = true;
  376. // 部署
  377. this.getDeployInfo({ type: '1' }, (data)=> {
  378. this.loading = false;
  379. this.depDialogVisible = false;
  380.  
  381. this.data = data.custom.detail;
  382. this.projectFtpUrl = data.custom.ftpUrl;
  383.  
  384. this.$alert('部署成功!', '提示', {
  385. confirmButtonText: '确定',
  386. callback: action => {
  387. window.open('http://192.168.219.170' + self.projectFtpUrl + entry)
  388. }
  389. });
  390.  
  391. });*/
  392. })
  393. .catch(_ => {});
  394. }
  395. },
  396. // 部署
  397. doDeploy () {
  398. if(!this.isDownLoadPage()) {
  399. return;
  400. }
  401. if(!this.dialogDeployVisible) {
  402. this.dialogDeployVisible = true;
  403. return;
  404. }
  405.  
  406. let self = this;
  407.  
  408. this.$refs['form'].validate((valid) => {
  409. if (valid) {
  410. this.dialogDeployVisible = false;
  411. this.depDialogVisible = true;
  412. this.loading = true;
  413. // 部署
  414. this.getDeployInfo({ type: '1', frame: this.form.frame }, (data)=> {
  415. this.loading = false;
  416. this.depDialogVisible = false;
  417.  
  418. if(!data.custom.text){
  419.  
  420. this.data = data.custom.pageTreeData;
  421. this.projectFtpUrl = data.custom.projectRootPath;
  422. this.supportDeploy = data.custom.supportDeploy;
  423.  
  424. this.setProjectEntry();
  425. // 从部署按钮直接过来的
  426. if(!this.clickNodeEntry) {
  427. this.$message({
  428. type: 'success',
  429. message: '部署成功!'
  430. });
  431. // 打开查看弹窗
  432. this.viewProject();
  433. } else {// 从点击目录结构过来的,可以调整点击的树节点页面
  434. this.$alert('部署成功!', '提示', {
  435. confirmButtonText: '确定',
  436. callback: action => {
  437. window.open('http://192.168.219.170' + self.projectFtpUrl + self.clickNodeEntry);
  438. self.clickNodeEntry = null;
  439. }
  440. });
  441. }
  442.  
  443. } else {
  444. this.$message({
  445. type: 'error',
  446. message: data.custom.text
  447. });
  448. }
  449. });
  450. } else {
  451. console.log('error submit!!');
  452. return false;
  453. }
  454. });
  455.  
  456. /*
  457. this.$confirm('此操作将把 GitLab 资源打包部署至 170 服务器,已部署过的项目会进行覆盖部署,是否继续?', '提示', {
  458. confirmButtonText: '确定',
  459. cancelButtonText: '取消',
  460. type: 'warning'
  461. }).then(() => {
  462. }).catch(() => {
  463. this.$message({
  464. type: 'info',
  465. message: '已取消部署'
  466. });
  467. });*/
  468. },
  469. // 发布项目案例库
  470. publish () {
  471. this.$confirm('此操作将把项目发布至 <a href="'+ this.projectLibUrl +'" target="_blank">项目案例库</a>,已发布过的项目案例库会有重复项,是否继续?', '提示', {
  472. confirmButtonText: '确定',
  473. cancelButtonText: '取消',
  474. dangerouslyUseHTMLString: true,
  475. type: 'warning'
  476. }).then(() => {
  477. const themes = document.querySelectorAll('.badge-secondary');
  478. let keys = [];
  479.  
  480. for(let i = 0, l = themes.length; i < l; i++) {
  481. if(themes[0].innerText == '智能设备' && i > 0) {
  482. keys.push(themes[i].innerText);
  483. } else if (themes[0].innerText !== '智能设备' && i > 1) {
  484. keys.push(themes[i].innerText);
  485. }
  486. }
  487. // 存在更多主题的情况
  488. const moreKeyEl = document.querySelector('.gl-w-full .text-nowrap');
  489. if(moreKeyEl) {
  490. const moreKeyElContent = moreKeyEl.getAttribute('data-content');
  491. const regex = />([^<]+)</g;
  492. const matches = moreKeyElContent.match(regex);
  493. const results = matches.filter(function(match) {
  494. return match.length > 3;
  495. });
  496. const moreKeyData = results.map(function(match) {
  497. return match.substring(2, match.length - 2);
  498. });
  499.  
  500. if(moreKeyData && moreKeyData.length) {
  501. keys = keys.concat(moreKeyData);
  502. }
  503. }
  504.  
  505. // 组织项目案例库所需参数
  506. const projectName = document.querySelector('.home-panel-title').innerText;
  507. const projectBU = themes[0] ? themes[0].innerText : null;
  508. const projectKeys = keys.join(' ');
  509. const entryUrl = this.projectEntryUrl;
  510. let projectType = themes[1] ? themes[1].innerText : null;
  511.  
  512. if(themes[0]) {
  513. if(themes[0].innerText == '智能设备') {
  514. projectType = themes[1] ? themes[0].innerText : null;
  515. } else {
  516. projectType = themes[1] ? themes[1].innerText : null;
  517. }
  518. }
  519.  
  520. const destUrl = this.projectLibUrl + '?projectName=' + projectName + '&projectBU=' + projectBU + '&projectType=' + projectType + '&projectKeys=' + projectKeys + '&entryUrl=' + entryUrl + '&git=' + window.location.href;
  521.  
  522. this.$message({
  523. type: 'success',
  524. message: destUrl
  525. });
  526.  
  527. window.open(destUrl);
  528.  
  529. }).catch(() => {
  530. this.$message({
  531. type: 'info',
  532. message: '已取消发布'
  533. });
  534. });
  535. },
  536. // 查看项目
  537. viewProject () {
  538. if(!this.isDownLoadPage()) {
  539. return;
  540. }
  541. this.dialogVisible = true;
  542. this.loadingTree = true;
  543. let self = this;
  544.  
  545. // 发送ajax请求,查看是否进行过部署
  546. this.getDeployInfo((data)=> {
  547. // 有部署信息,直接赋值,
  548. if(data) {
  549. self.projectIsDeployed = true;
  550. self.data = data.custom.pageTreeData;
  551. self.projectFtpUrl = data.custom.projectRootPath;
  552. self.supportDeploy = data.custom.supportDeploy;
  553. self.loadingTree = false;
  554.  
  555. self.setProjectEntry();
  556.  
  557. } else {
  558. // 无部署信息,仅查看文件目录
  559. getZipResource((data)=> {
  560. self.data = data;
  561. self.loadingTree = false;
  562. });
  563. }
  564. });
  565.  
  566. },
  567. // 查看项目的所有页面
  568. viewAll() {
  569. window.open('http://192.168.219.170/code-pipeline/#/project/deploy-preview?rowguid=' + document.body.getAttribute('data-project-id'));
  570. },
  571. // 项目部署信息
  572. getDeployInfo(params, callback) {
  573. const projectId = document.body.getAttribute('data-project-id');
  574. const downloadBtn = document.querySelector('.gl-button.btn-sm.btn-confirm');
  575.  
  576. const sourceUrl = downloadBtn.getAttribute('href');
  577. const downloadUrl = window.location.origin + sourceUrl;
  578. const files = document.body.getAttribute('data-find-file').split('/');
  579. const name = document.body.getAttribute('data-project') + '-' + files[files.length - 1];
  580. const author = document.querySelector('.current-user .gl-font-weight-bold').innerText.trim();
  581. const projectName = document.querySelector('.sidebar-context-title').innerText.trim();
  582. const deployManOA = document.querySelector('.current-user>a').getAttribute('data-user');
  583. const projectGitUrl = 'http://192.168.0.200' + document.body.getAttribute('data-find-file').split('/-/')[0];
  584.  
  585. if(typeof params == 'function') {
  586. callback = params;
  587. params = null;
  588. }
  589.  
  590. if(projectId && projectId.length && sourceUrl) {
  591. fetch('http://192.168.219.170:3008/api/getDeployInfo', {
  592. method: 'POST',
  593. // 允许跨域请求
  594. mode: 'cors',
  595. headers: {
  596. 'Accept': 'application/json',
  597. 'Content-Type': 'application/json'
  598. },
  599. body: JSON.stringify({//post请求参数
  600. params: {
  601. "type": (params && params.type !== undefined) ? params.type : '0',// 0 代表查看, 1代表部署
  602. "name": name, // 项目路径英文名
  603. "deployMan": author, // 部署人姓名
  604. "deployManOA": deployManOA, // 部署人账号
  605. "projectName": projectName, // 项目名称
  606. "downloadUrl": downloadUrl, // 下载地址
  607. "projectId": projectId, // 主键,gitlab上的项目id
  608. "projectGitUrl": projectGitUrl,
  609. "frame": (params && params.frame) ? params.frame : undefined
  610. }
  611. })
  612. })
  613. .then(response => response.text())
  614. .then((result) => {
  615. var data = JSON.parse(result);
  616. callback && callback(data);
  617. })
  618. .catch(error => {
  619. this.depDialogVisible = false;
  620. this.dialogVisible = false;
  621. this.$message({
  622. type: 'error',
  623. message: '系统故障,请联系管理员。'
  624. });
  625. console.error(error);
  626. });
  627. } else {
  628. this.$message({
  629. type: 'error',
  630. message: '本页不支持查看和部署,请至仓库页。'
  631. });
  632. console.error('部署信息请求参数error');
  633. }
  634. },
  635. // 进入管理平台 code pipeline
  636. manage() {
  637. window.open('http://192.168.219.170/code-pipeline')
  638. },
  639. // 设置入口
  640. setProjectEntry(){
  641. const firstNode = findFirstFileNode(this.data);
  642. if(firstNode) {
  643. this.projectEntryUrl = 'http://192.168.219.170' + this.projectFtpUrl + firstNode.entry;
  644. }else {
  645. this.projectEntryUrl = null;
  646. }
  647. },
  648. isDownLoadPage() {
  649. const downloadBtn = document.querySelector('.gl-button.btn-sm.btn-confirm');
  650. const sourceUrl = downloadBtn && downloadBtn.getAttribute('href');
  651.  
  652. if(downloadBtn && sourceUrl) {
  653. return true;
  654. } else {
  655. this.$message({
  656. type: 'error',
  657. message: '本页面不支持查看和部署,请移至仓库页。'
  658. });
  659. return false;
  660. }
  661. }
  662. },
  663. mounted() {
  664. }
  665. };
  666.  
  667. const placeholder = document.createElement('div');
  668.  
  669. // 创建 Vue 实例并挂载到页面
  670. const vueInstance = new Vue({
  671. el: placeholder,
  672. components: {
  673. MyComponent
  674. },
  675. methods: {
  676. },
  677. template: `<my-component></my-component>`
  678. });
  679.  
  680. // 等待页面加载完成
  681. window.addEventListener('load', function() {
  682. // 将占位元素追加到 body 元素中
  683. document.body.appendChild(vueInstance.$el);
  684. });
  685.  
  686. // 将文件条目组织成嵌套结构
  687. function organizeFileEntries(fileEntries) {
  688. const root = {
  689. label: document.querySelector('.home-panel-title').innerText || document.getElementById('project_name_edit').value,
  690. type: 'folder',
  691. children: []
  692. };
  693.  
  694. // 创建嵌套结构
  695. fileEntries.forEach(entry => {
  696. const pathSegments = entry.name.split('/');
  697. let currentFolder = root;
  698.  
  699. // 遍历路径中的每个部分,创建相应的文件夹节点
  700. for (let i = 0; i < pathSegments.length - 1; i++) {
  701. const folderName = pathSegments[i];
  702. let folder = currentFolder.children.find(child => child.label === folderName);
  703.  
  704. if(isExcludeFolder(entry.name)) {
  705. continue;
  706. }
  707.  
  708. if (!folder) {
  709. folder = {
  710. label: folderName,
  711. type: 'folder',
  712. children: []
  713. };
  714. currentFolder.children.push(folder);
  715. }
  716.  
  717. currentFolder = folder;
  718. }
  719.  
  720. // 创建文件节点并添加到相应的文件夹中
  721. const fileName = pathSegments[pathSegments.length - 1];
  722.  
  723. if(fileName && fileName.length && isIncludeFile(fileName) && !isExcludeFolder(entry.name)) {
  724. const fileNode = {
  725. label: fileName,
  726. type: 'file',
  727. entry: entry.name
  728. };
  729. currentFolder.children.push(fileNode);
  730. }
  731. });
  732.  
  733. return [root];
  734. }
  735. // 是否排除的文件夹
  736. function isExcludeFolder(entry) {
  737. if(entry.indexOf('css') > -1 ||
  738. entry.indexOf('scss') > -1 ||
  739. entry.indexOf('js') > -1 ||
  740. entry.indexOf('images') > -1 ||
  741. entry.indexOf('fui') > -1 ||
  742. entry.indexOf('lib') > -1 ||
  743. entry.indexOf('test') > -1 ||
  744. entry.indexOf('font') > -1 ||
  745. entry.indexOf('frame/fui') > -1) {
  746. return true;
  747. } else {
  748. return false;
  749. }
  750. }
  751. // 是否包含的文件
  752. function isIncludeFile(fileName) {
  753. if(fileName.indexOf('.html') > -1) {
  754. return true;
  755. } else {
  756. return false;
  757. }
  758. }
  759.  
  760. function getZipResource(callback) {
  761. const downloadUrl = window.location.origin + document.querySelector('.gl-button.btn-sm.btn-confirm').getAttribute('href');
  762.  
  763. fetch(downloadUrl)
  764. .then(response => response.arrayBuffer())
  765. .then(data => {
  766. // 将 ZIP 文件的二进制数据传递给 JSZip 进行解析
  767. return JSZip.loadAsync(data);
  768. })
  769. .then(zip => {
  770. // 获取 ZIP 文件中的所有条目(文件和目录)
  771. const zipEntries = Object.values(zip.files);
  772. const treeData = organizeFileEntries(zipEntries)
  773.  
  774. callback && callback(treeData);
  775.  
  776. })
  777. .catch(error => {
  778. console.error(error);
  779. });
  780. }
  781.  
  782. // 树结构第一个节点数据
  783. function findFirstFileNode(tree) {
  784. // 遍历树的节点
  785. for (let i = 0; i < tree.length; i++) {
  786. const node = tree[i];
  787.  
  788. // 如果节点的类型为 file,则返回该节点
  789. if (node.type === 'file') {
  790. return node;
  791. }
  792.  
  793. // 如果节点有子节点,则递归调用该函数查找子节点中的第一个 file 节点
  794. if (node.children && node.children.length > 0) {
  795. const fileNode = findFirstFileNode(node.children);
  796. if (fileNode) {
  797. return fileNode;
  798. }
  799. }
  800. }
  801.  
  802. // 如果没有找到 file 节点,则返回 null
  803. return null;
  804. }
  805. })();
  806.  
  807. // 修改项目描述的长度
  808. (function() {
  809. 'use strict';
  810. let regs = [/^http:\/\/192\.168\.0\.200\/fe3project\//,
  811. /^http:\/\/192\.168\.0\.200\/frontend_pc\/project\//];
  812. let match = false;
  813.  
  814. for(let r = 0, lr = regs.length; r < lr; r++) {
  815. if(regs[r].test(location.href)) {
  816. match = true;
  817. break;
  818. }
  819. }
  820.  
  821. if(!match) {
  822. return;
  823. }
  824.  
  825. let tryTimes = 6;
  826. let changed = false;
  827.  
  828. // 增加项目描述的输入长度
  829. function modifyTextareaLen() {
  830. if(tryTimes > 0 && !changed) {
  831. setTimeout(() => {
  832. const textarea = document.getElementById('project_description');
  833. tryTimes--;
  834. if(textarea) {
  835. textarea.setAttribute("maxlength", "1000");
  836. changed = true;
  837. } else {
  838. modifyTextareaLen();
  839. }
  840. }, 1000);
  841. }
  842. }
  843.  
  844. window.onload = function() {
  845. modifyTextareaLen();
  846. }
  847. })();
  848.  
  849. // 设计门户增加通往前端仓库的跳板
  850. (function() {
  851. 'use strict';
  852.  
  853. let regs = [/^https:\/\/oa\.epoint\.com\.cn\/interaction-design-portal\/portal\/pages\/casestemplates\/casetemplatesdetail/,
  854. /^https:\/\/oa\.epoint\.com\.cn\/interaction-design-portal\/portal\/pages\/generalpagetemplates\/generalpagetemplatesdetail/];
  855. let match = false;
  856.  
  857. for(let r = 0, lr = regs.length; r < lr; r++) {
  858. if(regs[r].test(location.href)) {
  859. match = true;
  860. break;
  861. }
  862. }
  863.  
  864. if(!match) {
  865. return;
  866. }
  867.  
  868.  
  869. function addStyle() {
  870. // 注入样式:增加按钮
  871. 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}";
  872.  
  873.  
  874. // 添加注入样式
  875. let extraStyleElement = document.createElement("style");
  876. extraStyleElement.innerHTML = injectStyle;
  877. document.head.appendChild(extraStyleElement);
  878. }
  879.  
  880. function getUrlParameters() {
  881. var params = {};
  882. var search = window.location.search.substring(1);
  883. var urlParams = search.split('&');
  884.  
  885. for (var i = 0; i < urlParams.length; i++) {
  886. var param = urlParams[i].split('=');
  887. var paramName = decodeURIComponent(param[0]);
  888. var paramValue = decodeURIComponent(param[1] || '');
  889. params[paramName] = paramValue;
  890. }
  891.  
  892. return params;
  893. }
  894.  
  895. window.onload = ()=> {
  896. addStyle();
  897. const $content = jQuery('.content');
  898.  
  899. $content.append('<div class="front-proto">前端原型</div>');
  900.  
  901. const $frontBtn = jQuery('.front-proto', $content);
  902.  
  903. $frontBtn.on('click', ()=> {
  904. window.open('http://192.168.0.200/?name=' + getUrlParameters().guid);
  905. });
  906. };
  907. })();
  908.  
  909. // 前端项目案例库增加获取参数的能力
  910. // 前端项目案例库增加部署能力
  911. (function() {
  912. 'use strict';
  913.  
  914. let regs = [/^http:\/\/192\.168\.118\.60:9999\/webapp\/pages\/caselib\/create\.html/,
  915. /^http:\/\/192\.168\.201\.159:9999\/webapp\/pages\/default\/onlinecase.html/];
  916. let match = false;
  917.  
  918. for(let r = 0, lr = regs.length; r < lr; r++) {
  919. if(regs[r].test(location.href)) {
  920. match = true;
  921. break;
  922. }
  923. }
  924.  
  925. if(!match) {
  926. return;
  927. }
  928.  
  929. const fontUrl = 'https://element.eleme.io/2.11/static/element-icons.535877f.woff';
  930.  
  931. // 添加样式规则,将字体应用到指定元素上
  932. GM_addStyle(`
  933. @font-face {
  934. font-family: element-icons;
  935. src: url(${fontUrl}) format("woff");
  936. }
  937. `);
  938.  
  939. GM_addStyle(GM_getResourceText('ElementCSS'));
  940.  
  941. const businessType = [
  942. { Value: '7a20e23c-30b8-47e2-8d8d-f2691c9c63c4', Text: '政务服务' },
  943. { Value: 'c12150bb-b358-452f-87f0-8a2254df87cb', Text: '政务协同' },
  944. { Value: '3845804e-de68-421c-9402-7b238cfb5a70', Text: '大数据' },
  945. { Value: '3c28ee56-f24d-4843-b9a2-93e6b96264f4', Text: '电子交易' },
  946. { Value: '673b5918-51bc-4f1a-ab73-fca86e54d7d1', Text: '数字建设' },
  947. { Value: '6d9e7d84-7de3-4e0f-bd4f-ed4722ed25b5', Text: '建筑企业' },
  948. { Value: 'c22f8d2f-518d-4381-b88c-1da68536ed3a', Text: '公共安全' },
  949. { Value: 'c5810829-1b21-4b22-85cd-390b1edd9614', Text: '智能设备' },
  950. { Value: '080c7560-c261-428b-a45d-b86b57b47ffb', Text: '中央研究院' }
  951. ];
  952.  
  953. const projectType = [
  954. { Value: 'dca44f63-be3f-4e9c-b78f-d786571c22c9', Text: '网站' },
  955. { Value: 'c7861460-163b-4060-80ec-d60604c50435', Text: '业务系统' },
  956. { Value: '49accc71-6f7d-43f3-b726-58decf58b6fa', Text: '智能设备' },
  957. { Value: '90209c65-1a55-4d8c-a836-2e5c6b834ada', Text: '大屏可视化' },
  958. { Value: 'fb0415fb-65ee-42c1-895a-dca042c2568e', Text: '中屏可视化' },
  959. { Value: '2b83f9b1-ec78-4819-a400-d7d49ea1ecc5', Text: '其他' }
  960. ];
  961.  
  962. let $businesstype;
  963. let $projecttype;
  964.  
  965. function getUrlParameters() {
  966. var params = {};
  967. var search = window.location.search.substring(1);
  968. var urlParams = search.split('&');
  969.  
  970. for (var i = 0; i < urlParams.length; i++) {
  971. var param = urlParams[i].split('=');
  972. var paramName = decodeURIComponent(param[0]);
  973. var paramValue = decodeURIComponent(param[1] || '');
  974. if(paramName) {
  975. params[paramName] = paramValue;
  976. }
  977. }
  978.  
  979. return params;
  980. }
  981.  
  982. function initForm (params) {
  983. if(typeof params === 'object') {
  984. document.getElementsByName('Title')[0].value = params.projectName ? params.projectName : '';
  985. document.getElementsByName('KeyWords')[0].value = params.projectKeys ? params.projectKeys : '';
  986. document.getElementsByName('Entry')[0].value = params.entryUrl ? params.entryUrl : '';
  987. document.getElementsByName('SourceCode')[0].value = params.git ? params.git : '';
  988. }
  989. }
  990.  
  991. let setSuccess = false;
  992. let setTimes = 5;
  993.  
  994. function initSelect(params) {
  995. if(typeof params !== 'object') {
  996. return;
  997. }
  998.  
  999. if(setTimes > 0 && !setSuccess) {
  1000. setTimeout(()=> {
  1001. setTimes--;
  1002.  
  1003. businessType.forEach((item)=> {
  1004. if(params.projectBU) {
  1005. if(item.Text === params.projectBU.trim()) {
  1006. $businesstype.val(item.Value);
  1007. } else if( params.projectBU.trim() == '一网统管' || params.projectBU.trim() == '一网协同' || params.projectBU.trim() == '一网通办' ) {
  1008. $businesstype.val('7a20e23c-30b8-47e2-8d8d-f2691c9c63c4');
  1009. }
  1010. $businesstype.trigger("chosen:updated");
  1011. }
  1012. });
  1013.  
  1014. projectType.forEach((item)=> {
  1015. if(params.projectType && item.Text === params.projectType.trim()) {
  1016. $projecttype.val(item.Value);
  1017. $projecttype.trigger("chosen:updated");
  1018. }
  1019. });
  1020.  
  1021. setSuccess = true;
  1022.  
  1023. }, 1000);
  1024. } else {
  1025. initSelect(params);
  1026. }
  1027. }
  1028.  
  1029. function addRelatedDom() {
  1030. const sourceInput = document.getElementsByName('SourceCode')[0];
  1031. const $sourceInput = jQuery(sourceInput);
  1032.  
  1033. $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>')
  1034. }
  1035.  
  1036. function addStyle() {
  1037. let epointCss = ".el-loading-spinner {margin-top: -50px;} .el-button--primary:focus {outline: 0 !important;}";
  1038. // 添加注入样式
  1039. let extraStyleElement = document.createElement("style");
  1040. extraStyleElement.innerHTML = epointCss;
  1041. document.head.appendChild(extraStyleElement);
  1042. }
  1043.  
  1044. window.onload = ()=> {
  1045. const params = getUrlParameters();
  1046.  
  1047. // 有参数,进行填充表单
  1048. if(params && params.git) {
  1049. $businesstype = jQuery('#businesstype');
  1050. $projecttype = jQuery('#projecttype');
  1051.  
  1052. initForm(params);
  1053. initSelect(params);
  1054.  
  1055. return false;
  1056. }
  1057.  
  1058. // 没有url参数填充,则做部署功能展示
  1059. addRelatedDom();
  1060. addStyle();
  1061.  
  1062. const placeholder = document.createElement('div');
  1063.  
  1064. // 创建 Vue 实例并挂载到页面
  1065. const vueInstance = new Vue({
  1066. el: placeholder,
  1067. data() {
  1068. return {
  1069. framework: [
  1070. {label: '重构模板', value: 1},
  1071. {label: 'f9x1.0', value: 2},
  1072. {label: 'f9x2.0', value: 3},
  1073. {label: 'f950', value: 4},
  1074. {label: 'f950sp1', value: 5},
  1075. {label: 'f950sp2', value: 6},
  1076. {label: 'f950sp3', value: 7},
  1077. {label: 'f951', value: 18},
  1078. {label: 'f940', value: 8},
  1079. {label: 'f941', value: 10},
  1080. {label: 'f942', value: 9},
  1081. {label: 'f934', value: 11},
  1082. {label: 'f933', value: 12},
  1083. {label: 'f932', value: 13},
  1084. {label: 'f9211', value: 14},
  1085. {label: '骨架', value: 15},
  1086. {label: 'Vue', value: 16},
  1087. {label: 'React', value: 17}
  1088. ],
  1089. data: [], // 目录结构树
  1090. defaultProps: {
  1091. children: 'children',
  1092. label: 'label'
  1093. },
  1094. loadingTree: false,
  1095. dialogVisible: false,
  1096. dialogDeployVisible: false,
  1097. showDeployPath: false,
  1098. depDialogVisible: false,
  1099. loading: false,
  1100. formLabelWidth: '120px',
  1101. supportDeploy: false,
  1102. form: {
  1103. frame: '',
  1104. deployPath: ''
  1105. },
  1106. rules: {
  1107. frame: [
  1108. { required: true, message: '请选择框架类型', trigger: 'change' }
  1109. ],
  1110. deployPath: [
  1111. { required: true, message: '请输入部署到 170/showcase 下的目标路径名称', trigger: 'change' }
  1112. ]
  1113. }
  1114. }
  1115. },
  1116. methods: {
  1117. // 部署
  1118. doDeploy() {
  1119. let self = this;
  1120.  
  1121. this.$refs['form'].validate((valid) => {
  1122. if (valid) {
  1123. this.dialogDeployVisible = false;
  1124. this.depDialogVisible = true;
  1125. this.loading = true;
  1126. // 部署
  1127. this.getDeployInfo({ type: '1', frame: this.form.frame, deployPath: this.form.deployPath }, (data)=> {
  1128. this.loading = false;
  1129. this.depDialogVisible = false;
  1130.  
  1131. if(!data.custom.text){
  1132.  
  1133. this.data = data.custom.pageTreeData;
  1134. this.projectFtpUrl = data.custom.projectRootPath;
  1135. this.supportDeploy = data.custom.supportDeploy;
  1136.  
  1137. this.$message({
  1138. type: 'success',
  1139. message: '部署成功!'
  1140. });
  1141. // 打开查看弹窗
  1142. this.viewProject();
  1143. this.toggleViewButton(true);
  1144.  
  1145. } else {
  1146. this.$message({
  1147. type: 'error',
  1148. message: data.custom.text
  1149. });
  1150. }
  1151. });
  1152. } else {
  1153. console.log('error submit!!');
  1154. return false;
  1155. }
  1156. });
  1157. },
  1158. // 项目部署
  1159. getDeployInfo(params, callback) {
  1160. const author = document.querySelector('#account a').innerText.trim().substring(4);
  1161. const projectName = document.getElementsByName('Title')[0].value.trim();
  1162. const projectGitUrl = document.getElementsByName('SourceCode')[0].value.trim();
  1163.  
  1164. if(typeof params == 'function') {
  1165. callback = params;
  1166. params = null;
  1167. }
  1168. if(author && author.length && projectGitUrl) {
  1169. fetch('http://192.168.219.170:3008/api/getDeployInfo', {
  1170. method: 'POST',
  1171. // 允许跨域请求
  1172. mode: 'cors',
  1173. headers: {
  1174. 'Accept': 'application/json',
  1175. 'Content-Type': 'application/json'
  1176. },
  1177. body: JSON.stringify({//post请求参数
  1178. params: {
  1179. "type": (params && params.type !== undefined) ? params.type : '0',// 0 代表查看, 1代表部署
  1180. "deployMan": author, // 部署人姓名
  1181. "projectName": projectName, // 项目名称
  1182. "projectGitUrl": projectGitUrl,
  1183. "frame": (params && params.frame) ? params.frame : undefined,
  1184. "deployPath": (params && params.deployPath) ? params.deployPath : undefined // 部署的目标目录
  1185. }
  1186. })
  1187. })
  1188. .then(response => response.text())
  1189. .then((result) => {
  1190. var data = JSON.parse(result);
  1191. callback && callback(data);
  1192. })
  1193. .catch(error => {
  1194. this.depDialogVisible = false;
  1195. this.dialogVisible = false;
  1196. this.$message({
  1197. type: 'error',
  1198. message: '系统故障,请联系管理员。'
  1199. });
  1200. console.error(error);
  1201. });
  1202. } else {
  1203. this.$message({
  1204. type: 'error',
  1205. message: '本页面不支持查看和部署,请先登录。'
  1206. });
  1207. console.error('部署信息请求参数error');
  1208. }
  1209. },
  1210. // 查看项目
  1211. viewProject () {
  1212. this.dialogVisible = true;
  1213. let self = this;
  1214.  
  1215. if(this.data) {
  1216. this.loadingTree = false;
  1217. } else {
  1218. this.loadingTree = true;
  1219. // 发送ajax请求,查看是否进行过部署
  1220. this.getDeployInfo((data)=> {
  1221. // 有部署信息,直接赋值,
  1222. if(data) {
  1223. self.projectIsDeployed = true;
  1224. self.data = data.custom.pageTreeData;
  1225. self.projectFtpUrl = data.custom.projectRootPath;
  1226. self.supportDeploy = data.custom.supportDeploy;
  1227. self.loadingTree = false;
  1228.  
  1229. self.toggleViewButton(true);
  1230.  
  1231. }
  1232. });
  1233. }
  1234. },
  1235. handleNodeClick(data) {
  1236. console.log(data);
  1237. if(data.type === 'folder') {
  1238. return false;
  1239. }
  1240. var self = this;
  1241. var entry = data.entry;
  1242. self.clickNodeEntry = entry;
  1243. if(self.projectFtpUrl) {
  1244. window.open('http://192.168.219.170' + self.projectFtpUrl + data.entry);
  1245. self.clickNodeEntry = null;
  1246. } else {
  1247. if(this.supportDeploy === false) {
  1248. this.$message({
  1249. type: 'error',
  1250. message: '当前项目暂时只支持查看,请耐心等待功能升级。'
  1251. });
  1252. self.clickNodeEntry = null;
  1253. return false;
  1254. }
  1255.  
  1256. this.$confirm('资源未部署,部署至 170 服务器后可查看,是否部署?')
  1257. .then(_ => {
  1258.  
  1259. this.dialogDeployVisible = true;
  1260. })
  1261. .catch(_ => {});
  1262. }
  1263. },
  1264. // svn 需要制定目录名称,showDeployPath
  1265. showDialog(showDeployPath) {
  1266. this.showDeployPath = showDeployPath;
  1267. this.dialogDeployVisible = true;
  1268. },
  1269. // 查看按钮显影控制
  1270. toggleViewButton(show) {
  1271. const $viewBtn = jQuery('#view');
  1272.  
  1273. if(!$viewBtn.length) {
  1274. return;
  1275. }
  1276.  
  1277. if(show) {
  1278. $viewBtn.removeClass('hidden');
  1279. } else {
  1280. $viewBtn.addClass('hidden');
  1281. }
  1282. }
  1283. },
  1284. mounted() {
  1285. const $btnDeloy = jQuery('#deploy');
  1286. const $btnView = jQuery('#view');
  1287.  
  1288. // 绑定vue组件外的事件
  1289. $btnDeloy.on('click', function() {
  1290. // 源码地址和项目名称判断
  1291. const sourceInput = document.getElementsByName('SourceCode');
  1292. const projectNameInput = document.getElementsByName('Title');
  1293.  
  1294. let sourceInputVal = sourceInput[0].value.trim(),
  1295. projectNameInputVal = projectNameInput[0].value.trim();
  1296.  
  1297. const gitpattern = /^http:\/\/192\.168/;
  1298. const svnpattern = /^svn:\/\/192\.168/;
  1299. const sourcepattern = /^(svn:\/\/192\.168|http:\/\/192\.168)/;
  1300.  
  1301. if (!sourceInputVal) {
  1302. vueInstance.$message({
  1303. type: 'error',
  1304. message: '请输入源码地址!'
  1305. });
  1306. return
  1307. }
  1308.  
  1309. if (!sourcepattern.test(sourceInputVal)) {
  1310. vueInstance.$message({
  1311. type: 'error',
  1312. message: '请输入准确的源码 gitlab 或 svn 地址!'
  1313. });
  1314. return
  1315. }
  1316.  
  1317. if (svnpattern.test(sourceInputVal) && !projectNameInputVal) {
  1318. vueInstance.$message({
  1319. type: 'error',
  1320. message: ' svn 仓库地址部署需要填写项目(案例)名称!'
  1321. });
  1322. return
  1323. }
  1324.  
  1325. vueInstance.showDialog(svnpattern.test(sourceInputVal));
  1326. });
  1327. // 查看项目
  1328. $btnView.on('click', function() {
  1329. vueInstance.viewProject();
  1330. });
  1331.  
  1332. },
  1333. template: `<div id="my-form">
  1334. <el-dialog title="部署提示" width="640px" :visible.sync="dialogDeployVisible">
  1335. <el-alert
  1336. title="此操作将把 GitLab / SVN 资源打包部署至 170 服务器,已部署过的项目会进行覆盖部署,是否继续?"
  1337. type="warning" :closable="false" style="margin-bottom: 20px;">
  1338. </el-alert>
  1339. <el-form :model="form" ref="form" :rules="rules">
  1340. <el-form-item label="框架类型" :label-width="formLabelWidth" prop="frame">
  1341. <el-select v-model="form.frame" placeholder="请框架类型" style="width:380px;">
  1342. <el-option v-for="item in framework" :key="item.value" :label="item.label" :value="item.value"></el-option>
  1343. </el-select>
  1344. </el-form-item>
  1345. <el-form-item label="部署路径" :label-width="formLabelWidth" prop="deployPath" v-if="showDeployPath">
  1346. <el-input v-model="form.deployPath" placeholder="请输入部署至服务器 170/showcase 下的目标路径名称" style="width:380px;"></el-input>
  1347. </el-form-item>
  1348. </el-form>
  1349. <div slot="footer" class="dialog-footer">
  1350. <el-button @click="dialogDeployVisible = false">取 消</el-button>
  1351. <el-button type="primary" @click="doDeploy">确 定</el-button>
  1352. </div>
  1353. </el-dialog>
  1354. <el-dialog
  1355. title="部署"
  1356. width="420px"
  1357. :visible.sync="depDialogVisible">
  1358. <div class="deploy-body"
  1359. style="height: 306px;"
  1360. v-loading="loading"
  1361. element-loading-text="正在打包部署至 170 服务器,请耐心等待"
  1362. element-loading-spinner="el-icon-loading">
  1363. </div>
  1364. </el-dialog>
  1365. <el-dialog
  1366. title="目录结构"
  1367. width="900px"
  1368. :append-to-body="true"
  1369. :visible.sync="dialogVisible">
  1370. <el-tree
  1371. class="filter-tree"
  1372. :data="data"
  1373. :props="defaultProps"
  1374. node-key="id"
  1375. default-expand-all
  1376. @node-click="handleNodeClick"
  1377. v-loading="loadingTree"
  1378. element-loading-background="rgba(255, 255, 255, 1)"
  1379. element-loading-text="拼命加载中......"
  1380. ref="tree">
  1381. </el-tree>
  1382. </el-dialog>
  1383. </div>`
  1384. });
  1385.  
  1386. // 将占位元素追加到 body 元素中
  1387. jQuery('.form-container').after(vueInstance.$el);
  1388. };
  1389. })();
  1390.  
  1391. // 新建项目提示
  1392. (function() {
  1393. 'use strict';
  1394. let regs = [/^http:\/\/192\.168\.0\.200\/projects\/new/];
  1395. let match = false;
  1396.  
  1397. for(let r = 0, lr = regs.length; r < lr; r++) {
  1398. if(regs[r].test(location.href)) {
  1399. match = true;
  1400. break;
  1401. }
  1402. }
  1403.  
  1404. if(!match) {
  1405. return;
  1406. }
  1407.  
  1408. // 等待页面加载完成
  1409. window.addEventListener('load', function() {
  1410. const $projectName = jQuery('#project_name');
  1411. const $projectDescription = jQuery('#project_description');
  1412. const $check = jQuery('#project_visibility_level_10');
  1413.  
  1414. if($projectName && $projectName.length) {
  1415. $projectName.attr('placeholder', '以需求或项目管理系统中的项目名称为准')
  1416. }
  1417.  
  1418. if($projectDescription && $projectDescription.length) {
  1419. $projectDescription.attr('placeholder', 'YYYY-M-D,张三,UI:https://oa.epoint.com.cn/interaction-design-portal/portal/pages/casestemplates/casetemplatesdetail?guid=');
  1420. $projectDescription.val('2023-M-D,张三,UI:https://oa.epoint.com.cn/interaction-design-portal/portal/pages/casestemplates/casetemplatesdetail?guid=');
  1421.  
  1422. // 增加主题表单
  1423. var themeHtml = '<div class="row">\
  1424. <div class="form-group col-md-9">\
  1425. <label class="label-bold" for="project_topics">主题</label>\
  1426. <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="">\
  1427. <p class="form-text text-muted">用逗号分隔主题。</p>\
  1428. <p class="form-text text-muted">业务条线:政务服务、大数据、一网统管、一网协同、智能设备、电子交易、数字建设、公共安全、中央研究院;</p>\
  1429. <p class="form-text text-muted">项目类型:网站、业务系统、智能设备、大屏可视化、中屏可视化、在线表单;</p>\
  1430. <p class="form-text text-muted">关键字:f942f951f950sp2f9x2.0f9x1.0vuereact、单页、gojselementAntDesign、全景、关系图、流程图、响应式、svg、视频、miniuiegisegis3d、高德、百度、超图、three、主题、瀑布流、上传、自定义用户控件等;</p>\
  1431. </div></div>';
  1432.  
  1433. $projectDescription.closest('.form-group').after(themeHtml);
  1434. // 规避中文,
  1435. $projectDescription.blur(function(event) {
  1436. this.value = this.value.replaceAll(',', ',');
  1437. });
  1438.  
  1439. var $theme = jQuery('#project_topics');
  1440.  
  1441. $theme.blur(function(event) {
  1442. this.value = this.value.replaceAll(',', ',');
  1443. });
  1444. }
  1445.  
  1446. if($check && $check.length) {
  1447. $check.trigger('click');
  1448. }
  1449. });
  1450.  
  1451. })();