index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <template>
  2. <el-container class="data-source-container">
  3. <el-aside width="300px" class="data-source-aside">
  4. <el-container>
  5. <el-header height="42px">
  6. <el-button link type="primary" size="default" @click="handleAdd">
  7. <i class="fm-iconfont icon-plus" style="font-size: 12px; margin: 5px;"></i>
  8. {{$t('fm.datasource.config.add')}}
  9. </el-button>
  10. </el-header>
  11. <el-main>
  12. <el-scrollbar>
  13. <el-menu class="data-source-aside-menu" :default-active="selectKey" >
  14. <el-menu-item
  15. :class="{
  16. 'is-disabled': isFormChange || !saved,
  17. 'is-active2': selectKey == item.key
  18. }"
  19. :index="item.key" v-for="(item, index) in list" :key="item.key" @click="handleSelect(item.key)">
  20. <template #title>
  21. <div>
  22. <el-badge is-dot style="position: absolute; top: 2px; left: 2px;" v-if="(isFormChange || !saved) && selectKey == item.key"></el-badge>
  23. <span class="data-source-menu-i" :class="item.method">{{item.method}}</span>
  24. <div class="data-source-menu-label">{{item.name}}</div>
  25. <div class="data-source-menu-action">
  26. <i class="fm-iconfont icon-icon_clone" @click.stop="handleClone(index)" :title="$t('fm.tooltip.clone')"></i>
  27. <i class="fm-iconfont icon-trash" @click.stop="handleRemove(index)" :title="$t('fm.tooltip.trash')"></i>
  28. </div>
  29. </div>
  30. </template>
  31. </el-menu-item>
  32. </el-menu>
  33. </el-scrollbar>
  34. </el-main>
  35. </el-container>
  36. </el-aside>
  37. <el-main class="data-source-main">
  38. <el-container v-if="selectIndex >= 0">
  39. <el-header height="42px">
  40. <div class="data-source-action">
  41. <el-button type="primary" size="default" @click="handleSave">{{$t('fm.datasource.config.save')}}</el-button>
  42. <el-button size="default" @click="handleTest">{{$t('fm.datasource.config.test')}}</el-button>
  43. <el-button size="default" @click="handleCancal">{{$t('fm.datasource.config.cancel')}}</el-button>
  44. </div>
  45. </el-header>
  46. <el-main>
  47. <el-form ref="dataForm" :model="formData" :rules="formRules" :label-width="$i18n.locale == 'zh-cn' ? '80px' : '119px'" size="default" label-position="right" :key="selectKey" @submit.prevent>
  48. <el-form-item :label="$t('fm.datasource.edit.name')" prop="name">
  49. <el-input v-model="formData.name"></el-input>
  50. </el-form-item>
  51. <el-form-item :label="$t('fm.datasource.edit.url')" prop="url">
  52. <el-input type="textarea" :rows="1" v-model="formData.url" autosize></el-input>
  53. </el-form-item>
  54. <el-form-item :label="$t('fm.datasource.edit.method')" prop="method">
  55. <el-radio-group v-model="formData.method">
  56. <el-radio-button label="GET" value="GET" ></el-radio-button>
  57. <el-radio-button label="POST" value="POST"></el-radio-button>
  58. <el-radio-button label="PUT" value="PUT"></el-radio-button>
  59. <el-radio-button label="DELETE" value="DELETE"></el-radio-button>
  60. </el-radio-group>
  61. </el-form-item>
  62. <el-form-item :label="$t('fm.datasource.edit.headers')">
  63. <array-dynamic v-model="formData.headers" :show-arguments="false" is-args></array-dynamic>
  64. </el-form-item>
  65. <el-form-item :label="$t('fm.datasource.edit.params')">
  66. <array-dynamic v-model="formData.params" :show-arguments="false" is-args></array-dynamic>
  67. </el-form-item>
  68. <el-form-item :label="$t('fm.datasource.edit.auto')" :label-width="$i18n.locale == 'zh-cn' ? '175px' : '340px'">
  69. <el-switch
  70. v-model="formData.auto">
  71. </el-switch>
  72. </el-form-item>
  73. <el-form-item :label="$t('fm.datasource.edit.response')">
  74. <el-collapse :modelValue="collapseAppend">
  75. <el-collapse-item name="1" :title="$t('fm.datasource.edit.willRequest')">
  76. <div class="code-desc" v-if="$i18n.locale == 'zh-cn'">// config: 发出请求的可用配置选项;</div>
  77. <div class="code-desc" v-if="$i18n.locale == 'zh-cn'">// 通过 config.url 可以更改请求地址,通过 config.headers 可以更改请求头部</div>
  78. <div class="code-desc" v-if="$i18n.locale == 'zh-cn'">// 通过 config.data 可以更改发送的数据,(GET 请求不适用,需要更改 config.params)</div>
  79. <div class="code-line">(config, args) => {</div>
  80. <code-editor v-model="formData.requestFunc" mode="javascript" height="150px"></code-editor>
  81. <div class="code-line">}</div>
  82. </el-collapse-item>
  83. <el-collapse-item :title="$t('fm.datasource.edit.responseSuccess')" name="2">
  84. <div class="code-desc" v-if="$i18n.locale == 'zh-cn'">// {{$t('fm.datasource.edit.annotation')}}</div>
  85. <div class="code-line">(res, args) => {</div>
  86. <code-editor v-model="formData.responseFunc" mode="javascript" height="150px"></code-editor>
  87. <div class="code-line">}</div>
  88. </el-collapse-item>
  89. <el-collapse-item :title="$t('fm.datasource.edit.requestError')" name="3">
  90. <div class="code-line">(error) => {</div>
  91. <code-editor v-model="formData.errorFunc" mode="javascript" height="150px"></code-editor>
  92. <div class="code-line">}</div>
  93. </el-collapse-item>
  94. </el-collapse>
  95. </el-form-item>
  96. </el-form>
  97. </el-main>
  98. </el-container>
  99. </el-main>
  100. </el-container>
  101. </template>
  102. <script>
  103. import ArrayDynamic from './arrayDynamic.vue'
  104. import CodeEditor from '../CodeEditor/index.vue'
  105. import axios from 'axios'
  106. import { ElMessage } from '../../util/message'
  107. import { h } from 'vue'
  108. import { isExpression, extractExpression, executeExpression } from '../../util/expression'
  109. import _ from 'lodash'
  110. export default {
  111. components: {
  112. ArrayDynamic,
  113. CodeEditor
  114. },
  115. props: {
  116. modelValue: {
  117. type: Array,
  118. default: () => []
  119. }
  120. },
  121. emits: ['update:modelValue'],
  122. data () {
  123. return {
  124. formData: {
  125. key: '',
  126. name: '',
  127. url: '',
  128. method: 'GET',
  129. auto: true,
  130. params: [],
  131. headers: [],
  132. responseFunc: `return res;`,
  133. requestFunc: `return config;`,
  134. errorFunc: ``
  135. },
  136. formRules: {
  137. name: [
  138. {required: true, message: ' '},
  139. { validator: (rule, value, callback) => {
  140. let currentItem = this.historyList.find(item => item.name ==value)
  141. if (currentItem && currentItem.key != this.selectKey) {
  142. callback(new Error(this.$t('fm.datasource.message.repeat')))
  143. } else {
  144. callback()
  145. }
  146. }}
  147. ],
  148. url: [
  149. {required: true, message: ' '}
  150. ]
  151. },
  152. list: [...this.modelValue],
  153. selectIndex: -1,
  154. selectKey: '',
  155. historyList: [...this.modelValue],
  156. saved: true,
  157. requestError: false,
  158. collapseAppend: [],
  159. tempFormData: {
  160. key: '',
  161. name: '',
  162. url: '',
  163. method: 'GET',
  164. auto: true,
  165. params: [],
  166. headers: [],
  167. responseFunc: `return res;`,
  168. requestFunc: `return config;`,
  169. errorFunc: ``
  170. }
  171. }
  172. },
  173. computed: {
  174. isFormChange () {
  175. return !_.isEqual(this.formData, this.tempFormData)
  176. }
  177. },
  178. methods: {
  179. _getAttributeFunction (funcStrs) {
  180. let matchReg1 = new RegExp("(?<=args.)\\w*(?=[\\s|,|;]|$)", "g") // 匹配 args.a 形式的参数
  181. let matchReg2 = new RegExp("(?<=args\\[\\s*['|\"])\\w*(?=['|\"]\\s*\\])", "g") // 匹配 args[] 形式的参数
  182. let matchReg3 = new RegExp("(?<=\{)[\\s+\\w*\\s+,{0|1}]+(?=\}\\s+=\\s+args)", "g") // 匹配 {} = args 形式的参数
  183. let args = new Set()
  184. funcStrs.forEach(funcStr => {
  185. funcStr?.match(matchReg1)?.forEach(item => item && args.add(item.trim()))
  186. funcStr?.match(matchReg2)?.forEach(item => item && args.add(item.trim()))
  187. funcStr?.match(matchReg3)?.forEach(item => item && item.split(',').forEach(sitem => sitem && args.add(sitem.trim())))
  188. })
  189. return args
  190. },
  191. _getArgsObject (argSet) {
  192. const args = {}
  193. for (let arg of argSet) {
  194. args[arg] = ''
  195. }
  196. return args
  197. },
  198. handleTest () {
  199. this.$refs.dataForm.validate((valid) => {
  200. if (valid) {
  201. const argSet = this._getAttributeFunction([this.formData.requestFunc, this.formData.responseFunc,
  202. ...this.formData.params.filter(item => item.fx).map(item => item.value),
  203. ...this.formData.headers.filter(item => item.fx).map(item => item.value)
  204. ])
  205. if (argSet.size > 0) {
  206. let argsModel = this._getArgsObject(argSet)
  207. this.$msgbox({
  208. title: 'Data source arguments',
  209. customStyle: 'z-index: 3000',
  210. customClass: 'fm-messagebox',
  211. class: 'aaa',
  212. draggable: true,
  213. key: new Date().getTime(),
  214. message: h ('div', null, [
  215. h(
  216. CodeEditor,{
  217. modelValue: argsModel,
  218. mode: (typeof data == 'object' ? 'javascript' : 'xml'),
  219. height: '200px',
  220. key: new Date().getTime(),
  221. 'onUpdate:modelValue' : (value) => {
  222. argsModel = value
  223. }
  224. }
  225. )
  226. ]
  227. ),
  228. callback: (action) => {
  229. if (action == 'confirm') {
  230. let args = {}
  231. if (typeof argsModel == 'string') {
  232. args = Function('"use strict";return (' + argsModel + ')')()
  233. } else {
  234. args = argsModel
  235. }
  236. this.requestTest(args)
  237. }
  238. }
  239. })
  240. } else {
  241. this.requestTest()
  242. }
  243. } else {
  244. ElMessage({
  245. message: this.$t('fm.datasource.message.settingError'),
  246. type: 'warning'
  247. }, this)
  248. }
  249. })
  250. },
  251. requestTest (args = {}) {
  252. let options = {
  253. method: this.formData.method,
  254. url: this.formData.url,
  255. headers: (() => {
  256. let headObj = {}
  257. this.formData.headers.forEach(item => {
  258. if (item.key) {
  259. headObj[item.key] = item.fx ? executeExpression(item.value, args) : item.value
  260. }
  261. })
  262. return headObj
  263. })()
  264. }
  265. if (this.formData.method === 'POST' || this.formData.method === 'PUT') {
  266. options.data = (() => {
  267. let paramsObj = {}
  268. this.formData.params.forEach(item => {
  269. if (item.key) {
  270. paramsObj[item.key] = item.fx ? executeExpression(item.value, args) : item.value
  271. }
  272. })
  273. return paramsObj
  274. })()
  275. } else {
  276. options.params = (() => {
  277. let paramsObj = {}
  278. this.formData.params.forEach(item => {
  279. if (item.key) {
  280. paramsObj[item.key] = item.fx ? executeExpression(item.value, args) : item.value
  281. }
  282. })
  283. return paramsObj
  284. })()
  285. }
  286. this.requestError = false
  287. if (this.formData.requestFunc) {
  288. const requestDynamicFunc = new Function('config', 'args', this.formData.requestFunc)
  289. try {
  290. options = requestDynamicFunc(options, args)
  291. } catch(error) {
  292. this.requestError = true
  293. }
  294. }
  295. axios(options).then(res => {
  296. try {
  297. let data = new Function('res', 'args', this.formData.responseFunc)(res.data, args)
  298. this.$msgbox({
  299. title: 'Response',
  300. customStyle: 'z-index: 3000',
  301. customClass: 'fm-messagebox',
  302. class: 'aaa',
  303. draggable: true,
  304. key: new Date().getTime(),
  305. message: h ('div', null, [
  306. h('div', {style: this.requestError ? 'margin: 10px 0; ' : 'display: none;'}, [
  307. 'The request test does not support ',
  308. h('b', {style: 'color: red;'}, 'this'),
  309. ', has been ignored.'
  310. ]),
  311. h(
  312. CodeEditor,{
  313. modelValue: data,
  314. mode: (typeof data == 'object' ? 'javascript' : 'xml'),
  315. height: '300px',
  316. key: new Date().getTime()
  317. }
  318. )
  319. ]
  320. ),
  321. })
  322. } catch (error) {
  323. this.$msgbox({
  324. title: 'Response',
  325. customStyle: 'z-index: 3000',
  326. customClass: 'fm-messagebox',
  327. class: 'aaa',
  328. draggable: true,
  329. key: new Date().getTime(),
  330. message: h ('div', null, [
  331. h('div', {style: this.requestError ? 'margin: 10px 0; ' : 'display: none;'}, [
  332. 'The request test does not support ',
  333. h('b', {style: 'color: red;'}, 'this'),
  334. ', has been ignored.'
  335. ]),
  336. h(
  337. CodeEditor,{
  338. modelValue: res.data,
  339. mode: (typeof res.data == 'object' ? 'javascript' : 'xml'),
  340. height: '300px',
  341. key: new Date().getTime()
  342. }
  343. )
  344. ]
  345. ),
  346. })
  347. }
  348. }).catch(err => {
  349. this.$msgbox.alert(err.message)
  350. })
  351. },
  352. handleSave () {
  353. return new Promise((resolve, reject) => {
  354. this.$refs.dataForm.validate((valid) => {
  355. if (valid) {
  356. const argSet = this._getAttributeFunction([this.formData.requestFunc, this.formData.responseFunc,
  357. ...this.formData.params.filter(item => item.fx).map(item => item.value),
  358. ...this.formData.headers.filter(item => item.fx).map(item => item.value)
  359. ])
  360. let options = {
  361. ...this.formData,
  362. params: (() => {
  363. let paramsObj = {}
  364. this.formData.params.forEach(item => {
  365. if (item.key) {
  366. paramsObj[item.key] = item.fx ? `{{${item.value}}}` : item.value
  367. }
  368. })
  369. return paramsObj
  370. })(),
  371. headers: (() => {
  372. let headersObj = {}
  373. this.formData.headers.forEach(item => {
  374. if (item.key) {
  375. headersObj[item.key] = item.fx ? `{{${item.value}}}` : item.value
  376. }
  377. })
  378. return headersObj
  379. })(),
  380. args: [...argSet]
  381. }
  382. this.list[this.list.findIndex(item => item.key === this.selectKey)] = options
  383. this.historyList = [...this.list]
  384. this.saved = true
  385. this.$emit('update:modelValue', this.historyList)
  386. ElMessage({
  387. message: this.$t('fm.datasource.message.saveSuccess'),
  388. type: 'success'
  389. }, this)
  390. this.tempFormData = _.cloneDeep(this.formData)
  391. setTimeout(() => {
  392. resolve()
  393. }, 300)
  394. } else {
  395. ElMessage({
  396. message: this.$t('fm.datasource.message.settingError'),
  397. type: 'warning'
  398. }, this)
  399. reject()
  400. }
  401. })
  402. })
  403. },
  404. handleAdd () {
  405. if (!this.saved || this.isFormChange) {
  406. ElMessage({
  407. message: this.$t('fm.datasource.message.saveError'),
  408. type: 'warning'
  409. }, this)
  410. return;
  411. }
  412. let key = Math.random().toString(36).slice(-8)
  413. this.list.push({
  414. key: key,
  415. name: 'DataSource_'+key,
  416. url: '',
  417. method: 'GET',
  418. auto: false,
  419. params: {},
  420. headers: {},
  421. responseFunc: 'return res;',
  422. requestFunc: `return config;`,
  423. errorFunc: ``
  424. })
  425. this.selectKey = key
  426. this.saved = false
  427. },
  428. loadForm () {
  429. let currentData = this.list[this.selectIndex]
  430. this.formData = {
  431. ...currentData,
  432. params: currentData.params && Object.keys(currentData.params).map(item => ({
  433. key: item,
  434. fx: isExpression(currentData.params[item]),
  435. value: isExpression(currentData.params[item]) ? extractExpression(currentData.params[item]) : currentData.params[item]
  436. })) || [],
  437. headers: currentData.headers && Object.keys(currentData.headers).map(item => ({
  438. key: item,
  439. fx: isExpression(currentData.headers[item]),
  440. value: isExpression(currentData.headers[item]) ? extractExpression(currentData.headers[item]) : currentData.headers[item]
  441. })) || [],
  442. requestFunc: currentData.requestFunc || `return config;`
  443. }
  444. this.tempFormData = _.cloneDeep(this.formData)
  445. let append = []
  446. this.formData.requestFunc != 'return config;' && append.push('1')
  447. this.formData.responseFunc != 'return res;' && append.push('2')
  448. this.formData.errorFunc && append.push('3')
  449. this.collapseAppend = append
  450. },
  451. handleSelect (key) {
  452. if (key === this.selectKey) {
  453. return
  454. }
  455. if (this.selectKey && (!this.saved || this.isFormChange)) {
  456. ElMessage({
  457. message: this.$t('fm.datasource.message.saveError'),
  458. type: 'warning'
  459. }, this)
  460. return;
  461. }
  462. this.selectKey = key
  463. },
  464. handleCancal () {
  465. this.beforeClose(() => {
  466. this.selectKey = ''
  467. this.list = [...this.historyList]
  468. this.saved = true
  469. })
  470. },
  471. handleClone (index) {
  472. if (!this.saved) {
  473. ElMessage({
  474. message: this.$t('fm.datasource.message.saveError'),
  475. type: 'warning'
  476. }, this)
  477. return;
  478. }
  479. let currentData = this.list[index]
  480. let key = Math.random().toString(36).slice(-8)
  481. let cloneData = {
  482. ...currentData,
  483. key,
  484. name: currentData.name + '_copy'
  485. }
  486. this.list.push(cloneData)
  487. this.selectKey = key
  488. this.saved = false
  489. },
  490. handleRemove (index) {
  491. let currentData = this.list[index]
  492. this.$msgbox.confirm(`${this.$t('fm.datasource.message.confirmRemove')} [${currentData.name}] ?`, '', {
  493. type: 'warning'
  494. }).then(() => {
  495. if (currentData.key === this.selectKey) {
  496. this.selectKey = ''
  497. this.saved = true
  498. }
  499. this.list.splice(index, 1)
  500. if (index < this.historyList.length) {
  501. this.historyList.splice(index, 1)
  502. }
  503. this.$emit('update:modelValue', this.historyList)
  504. }).catch(() => {})
  505. },
  506. beforeClose (done) {
  507. if (!_.isEqual(this.formData, this.tempFormData) || !this.saved) {
  508. this.$msgbox.confirm(
  509. this.$t('fm.eventscript.message.saveConfirm'),
  510. 'Confirm',
  511. {
  512. distinguishCancelAndClose: true,
  513. confirmButtonText: this.$t('fm.eventscript.config.save'),
  514. cancelButtonText: this.$t('fm.eventscript.config.notSave'),
  515. type: 'warning'
  516. }
  517. )
  518. .then(() => {
  519. this.handleSave().then(() => {
  520. done()
  521. })
  522. })
  523. .catch((action) => {
  524. if (action === 'cancel') {
  525. done()
  526. }
  527. })
  528. } else {
  529. done()
  530. }
  531. }
  532. },
  533. watch: {
  534. selectKey (val) {
  535. if (val) {
  536. this.selectIndex = this.list.findIndex(item => item.key === val)
  537. this.loadForm()
  538. } else {
  539. this.selectIndex = -1
  540. }
  541. }
  542. }
  543. }
  544. </script>
  545. <style lang="scss">
  546. .data-source-container{
  547. .data-source-main{
  548. padding: 0;
  549. .el-form-item .el-form-item__content{
  550. display: block;
  551. }
  552. >.el-container{
  553. display: flex;
  554. height: 100%;
  555. >.el-header{
  556. padding: 5px;
  557. border-bottom: 1px solid var(--el-border-color-lighter);
  558. background: var(--el-border-color-extra-light);
  559. }
  560. }
  561. .data-source-action{
  562. text-align: right;
  563. }
  564. .code-line{
  565. font-size: 14px;
  566. color: var(--el-color-primary);
  567. font-weight: 500;
  568. }
  569. .code-desc{
  570. margin-left: 2px;
  571. font-size: 12px;
  572. color: var(--el-text-color-secondary);
  573. }
  574. .el-collapse{
  575. width: 100%;
  576. }
  577. .el-collapse-item{
  578. border: 1px solid var(--el-border-color-lighter);
  579. &+.el-collapse-item{
  580. margin-top: 5px;
  581. }
  582. }
  583. .el-collapse-item__header{
  584. background: var(--el-border-color-lighter);
  585. // border: 0;
  586. height: 36px;
  587. line-height: 36px;
  588. padding: 5px;
  589. }
  590. .el-collapse-item__wrap{
  591. border: 0;
  592. .el-collapse-item__content{
  593. padding: 5px;
  594. }
  595. }
  596. }
  597. .data-source-aside{
  598. border-right: 1px solid var(--el-border-color-lighter);
  599. >.el-container{
  600. display: flex;
  601. height: 100%;
  602. >.el-main{
  603. margin: 0;
  604. padding: 0;
  605. }
  606. >.el-header{
  607. padding: 5px;
  608. border-bottom: 1px solid var(--el-border-color-lighter);
  609. background: var(--el-border-color-extra-light);
  610. }
  611. }
  612. .data-source-aside-menu{
  613. margin: 10px;
  614. border-right: 0;
  615. .el-menu-item{
  616. border: 1px solid var(--el-border-color);
  617. background: var(--el-bg-color);
  618. border-radius: 3px;
  619. padding: 10px !important;
  620. height: auto;
  621. line-height: 1;
  622. cursor: default;
  623. position: relative;
  624. &.is-disabled{
  625. opacity: 1;
  626. cursor: default;
  627. background: var(--el-bg-color);
  628. }
  629. &.is-active2{
  630. background: var(--el-border-color-light) !important;
  631. color: var(--el-text-color-primary);
  632. }
  633. &.is-active.is-disabled{
  634. color: var(--el-menu-text-color);
  635. }
  636. +.el-menu-item{
  637. margin-top: 6px;
  638. }
  639. }
  640. .data-source-menu-label{
  641. overflow:hidden;
  642. text-overflow:ellipsis;
  643. white-space:nowrap;
  644. display: inline-block;
  645. width: 180px;
  646. margin-left: 40px;
  647. }
  648. .data-source-menu-i{
  649. position: absolute;
  650. font-size: 12px;
  651. left: 2px;
  652. top: 13px;
  653. width: 45px;
  654. text-align: center;
  655. &.GET{
  656. color: #67C23A;
  657. }
  658. &.POST{
  659. color: #E6A23C;
  660. }
  661. &.PUT{
  662. color: #409EFF;
  663. }
  664. &.DELETE{
  665. color: #F56C6C;
  666. }
  667. }
  668. .data-source-menu-action{
  669. display: inline-block;
  670. padding-right: 10px;
  671. color: var(--el-text-color-regular);
  672. font-weight: 600;
  673. >i{
  674. cursor: pointer;
  675. margin-left: 5px;
  676. }
  677. }
  678. }
  679. }
  680. }
  681. </style>