CodeList.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <template>
  2. <Breadcrumb pageTitle="爬虫列表"></Breadcrumb>
  3. <div class="space"></div>
  4. <el-card v-loading="loading">
  5. <el-header>
  6. <div class="action-bar-container">
  7. <el-space class="action-bar-item-container action-bar-action-left">
  8. <el-button-group class="ml-4">
  9. <el-button type="primary" :icon="Refresh" @click="resetFilterAndRefreshTableList">刷新</el-button>
  10. <el-button type="primary" :icon="Box" @click="clickClaimCodes" v-if="showRenLingButton">认领</el-button>
  11. </el-button-group>
  12. </el-space>
  13. <el-space class="action-bar-item-container action-bar-action-right">
  14. <div class="action-bar-item" v-if="showModifyUserFilter">
  15. <span class="action-bar-name">维护人:</span>
  16. <el-select v-model="filters.modifyuser" style="width: 110px" @change="onModifyUserSelectChange" :disabled="modifyUserSelectDisabled">
  17. <el-option
  18. v-for="item in filterConfig.modifyUserList"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value"
  22. />
  23. </el-select>
  24. </div>
  25. <div class="action-bar-item">
  26. <span class="action-bar-name">爬虫状态:</span>
  27. <el-select v-model="filters.state" placeholder="爬虫状态" style="width: 110px" @change="onStateSelectChange">
  28. <el-option
  29. v-for="item in filterConfig.stateOptions"
  30. :key="item.value"
  31. :label="item.label"
  32. :value="item.value"
  33. />
  34. </el-select>
  35. </div>
  36. <div class="action-bar-item">
  37. <span class="action-bar-name">认领状态:</span>
  38. <el-select v-model="filters.claimtype" placeholder="认领状态" style="width: 110px" @change="onClaimSelectChange">
  39. <el-option
  40. v-for="item in filterConfig.claimOptions"
  41. :key="item.value"
  42. :label="item.label"
  43. :value="item.value"
  44. :disabled="item.disabled"
  45. />
  46. </el-select>
  47. </div>
  48. <div class="action-bar-item">
  49. <el-input v-model="filters.search" placeholder="按照爬虫代码搜索" @keydown.enter="onInputSearch" />
  50. </div>
  51. <div class="action-bar-item">
  52. <el-button type="primary" :icon="Search" @click="onInputSearch">搜索</el-button>
  53. </div>
  54. </el-space>
  55. </div>
  56. </el-header>
  57. <el-main>
  58. <el-table ref="spiderTable" :data="listState.list" stripe :row-style="getRowStyle" v-loading="listState.loading">
  59. <el-table-column prop="code" label="代码" align="center" show-overflow-tooltip></el-table-column>
  60. <el-table-column prop="site" label="网站" align="center" show-overflow-tooltip></el-table-column>
  61. <el-table-column prop="channel" label="栏目" align="center" show-overflow-tooltip></el-table-column>
  62. <el-table-column prop="stateText" label="爬虫状态" width="80" align="center" show-overflow-tooltip></el-table-column>
  63. <el-table-column prop="claimText" label="认领状态" width="100" align="center" show-overflow-tooltip></el-table-column>
  64. <el-table-column prop="href" label="栏目地址" show-overflow-tooltip></el-table-column>
  65. <el-table-column prop="modifyUserText" label="维护人" width="120" align="center" show-overflow-tooltip></el-table-column>
  66. <el-table-column label="操作" width="160" align="center">
  67. <template #default="scope">
  68. <!-- <el-tooltip content="标注" placement="top">
  69. <el-button size="small" :class="{ active: scope.row._action_clicked_mark }" @click="tableEvents.handleDataTag(scope.row)">
  70. <el-icon><Link /></el-icon>
  71. </el-button>
  72. </el-tooltip>-->
  73. <el-tooltip content="编辑" placement="top">
  74. <el-button size="small" :class="{ active: scope.row._action_clicked_edit }" @click="tableEvents.handleEdit(scope.$index, scope.row)">
  75. <el-icon><Edit /></el-icon>
  76. </el-button>
  77. </el-tooltip>
  78. <el-tooltip content="调试" placement="top">
  79. <el-button size="small" :class="{ active: scope.row._action_clicked_debug }" @click="tableEvents.handleDebug(scope.$index, scope.row)">
  80. <el-icon><SetUp /></el-icon>
  81. </el-button>
  82. </el-tooltip>
  83. <el-tooltip content="验证" placement="top">
  84. <el-button size="small" :class="{ active: scope.row._action_clicked_verify }" @click="tableEvents.handleVerify(scope.$index, scope.row)">
  85. <el-icon><Aim /></el-icon>
  86. </el-button>
  87. </el-tooltip>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="功能" width="120" align="center">
  91. <template #default="scope">
  92. <el-tooltip content="提交" placement="top" v-if="showListDevelopeButton">
  93. <!-- 爬虫状态是待完成,才可点击提交 -->
  94. <el-button size="small" :disabled="scope.row.state !== 0" :class="{ active: scope.row._action_clicked_submit }" @click="tableEvents.handleSubmit(scope.$index, scope.row)">
  95. <el-icon><Promotion /></el-icon>
  96. </el-button>
  97. </el-tooltip>
  98. <el-tooltip content="退回" placement="top" v-if="showListRollbackButton">
  99. <!-- 爬虫状态是待完成,才可点击退回 -->
  100. <el-button size="small" :disabled="scope.row.state !== 0" :class="{ active: scope.row._action_clicked_rollback }" @click="tableEvents.handleRollback(scope.$index, scope.row)">
  101. <el-icon><DArrowLeft /></el-icon>
  102. </el-button>
  103. </el-tooltip>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <div class="space"></div>
  108. <div class="pagination-container">
  109. <el-pagination align="right" @size-change="handleSizeChange" @current-change="handleCurrentChange"
  110. :current-page="listState.pageNum" :page-sizes="[10, 20, 30, 40]" :page-size="listState.pageSize"
  111. layout="total, sizes, prev, pager, next, jumper" :total="listState.total">
  112. </el-pagination>
  113. </div>
  114. </el-main>
  115. </el-card>
  116. <EditSpider ref="editSpiderDialog" @custom-event="dialogEvents.editSpiderConfigSaveEvent" @data-tag="editDialogMarkClick($event)" />
  117. <RunSpiderDialog ref="runSpiderDialog" />
  118. <VerifySpider ref="verifySpiderDialog" />
  119. </template>
  120. <script setup>
  121. import { ref, computed, onMounted, onUnmounted, reactive, watch } from 'vue'
  122. import { useRouter } from 'vue-router';
  123. import { useStore } from 'vuex';
  124. import { ElMessage, ElMessageBox } from 'element-plus'
  125. import { BrowserOpenURL, EventsOn } from "../../wailsjs/runtime"
  126. import { VerifySpiderConfig, ServerActionUpdateCodeState, ServerActionCurrentOpenTab } from "../../wailsjs/go/main/App"
  127. import Breadcrumb from "../components/Breadcrumb.vue"
  128. import EditSpider from "../components/spider/EditSpider.vue"
  129. import RunSpiderDialog from "../components/spider/RunSpiderDialog.vue"
  130. import VerifySpider from "../components/spider/VerifySpider.vue"
  131. import { useCodeListFiltersWithRole } from '../composables/filter-options'
  132. import { USER_ROLE_ADMIN, USER_ROLE_DEVELOPER, USER_ROLE_REVIEWER } from '../data/user'
  133. import { Refresh, Search, Box } from '@element-plus/icons-vue'
  134. const router = useRouter();
  135. const store = useStore();
  136. const spiderTable = ref(null)
  137. const { stateOptions, claimOptions } = useCodeListFiltersWithRole()
  138. const loading = ref(false)
  139. const filterConfig = reactive({
  140. // 爬虫状态备选项
  141. stateOptions: stateOptions,
  142. // 认领状态备选项
  143. claimOptions: claimOptions,
  144. // 维护人备选项
  145. modifyUserList: [
  146. {
  147. label: '全部',
  148. value: '-1',
  149. }
  150. ]
  151. })
  152. // 选择器数据
  153. const filters = reactive({
  154. // 搜索
  155. search: '',
  156. // 爬虫状态
  157. state: -1,
  158. // 维护人
  159. modifyuser: '-1',
  160. // 认领状态
  161. claimtype: -1,
  162. })
  163. // 选择器数据(用来重置)
  164. const defaultFilters = {
  165. search: '',
  166. state: -1,
  167. modifyuser: '-1',
  168. claimtype: -1,
  169. }
  170. // 列表数据
  171. const listState = reactive({
  172. loaded: false,
  173. loading: false,
  174. pageNum: 1, // 页码
  175. pageSize: 10, // 每页多少条
  176. total: 0, // 返回的总数据条数
  177. list: [ // 数据列表
  178. // {
  179. // code: '爬虫代码',
  180. // site: '网站',
  181. // channel: '栏目',
  182. // href: '栏目地址',
  183. // modifyuser: '维护人',
  184. // _id: 'asfasf',
  185. // },
  186. ],
  187. })
  188. // 列表默认数据(用来重置)
  189. const defaultListState = {
  190. loaded: false,
  191. loading: false,
  192. pageNum: 1,
  193. pageSize: 10,
  194. total: 0,
  195. list: [],
  196. }
  197. // 当前编辑的row的数据
  198. const currentEditRow = ref({})
  199. // 上一个点击的row的数据
  200. const prevClickedRow = ref({})
  201. // 用户身份标识
  202. const userRole = computed(() => store.getters.userRole)
  203. // 是否展示维护人模块(管理员和审核员展示)
  204. const showModifyUserFilter = computed(() => [USER_ROLE_ADMIN, USER_ROLE_REVIEWER].includes(userRole.value))
  205. // 是否展示认领按钮(仅开发人员展示)
  206. const showRenLingButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
  207. // 是否展示提交按钮(仅开发人员展示)
  208. const showListDevelopeButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
  209. // 是否展示退回按钮(仅开发人员展示)
  210. const showListRollbackButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
  211. // 实现待认领不能和维护人同时筛选
  212. // 是否禁用维护人模块(待认领筛选下,禁用维护人筛选模块)
  213. const modifyUserSelectDisabled = computed(() => filters.claimtype === 0)
  214. // 是否禁用待认领筛选(维护人不为全部,则禁用待认领的选中)
  215. const stopWatch = watch(() => filters.modifyuser, (n) => {
  216. const target = filterConfig.claimOptions.find(i => i.value === 0)
  217. if (target) {
  218. if (n === defaultFilters.modifyuser) {
  219. // 解除禁用待认领
  220. target.disabled = false
  221. } else {
  222. // 禁用待认领
  223. target.disabled = true
  224. }
  225. } else {
  226. stopWatch()
  227. }
  228. })
  229. const editSpiderDialog = ref(null)
  230. const runSpiderDialog = ref(null)
  231. const verifySpiderDialog = ref(null)
  232. // 取消prevClicked的高亮
  233. const cancelOtherHighlight = () => {
  234. for (const key in prevClickedRow.value) {
  235. if (key.includes('_action_clicked')) {
  236. prevClickedRow.value[key] = false
  237. }
  238. }
  239. }
  240. // 页面按钮点击高亮
  241. const onlyClickHighlight = (row, key) => {
  242. cancelOtherHighlight()
  243. row[key] = true
  244. prevClickedRow.value = row
  245. }
  246. const getRowStyle = ({ row }) => {
  247. return row.selected ? { backgroundColor: '#F7F7F7' } : {};
  248. };
  249. // 计算爬虫状态
  250. const calcStateText = (state) => {
  251. const target = filterConfig.stateOptions.find(r => r.value === state)
  252. if (target) {
  253. return target.label
  254. } else {
  255. return ''
  256. }
  257. }
  258. // 计算认领状态
  259. const calcClaimText = (state) => {
  260. const target = filterConfig.claimOptions.find(r => r.value === state)
  261. if (target) {
  262. return target.label
  263. } else {
  264. return ''
  265. }
  266. }
  267. const calcModifyUserText = (state) => {
  268. // 未认领状态。维护人返回无
  269. if (state.claimtype === 0) {
  270. return '无'
  271. } else {
  272. return state.modifyuser
  273. }
  274. }
  275. // 获取列表数据
  276. async function getTableList() {
  277. listState.loading = true
  278. try {
  279. const r = await store.dispatch('rulesList/getCodeList', {
  280. modifyuser: filters.modifyuser, // 维护人
  281. state: filters.state, // 爬虫状态
  282. search: filters.search, // 搜索内容
  283. claimtype: filters.claimtype,
  284. pageType: 'codelist',
  285. pageSize: listState.pageSize,
  286. pageNum: listState.pageNum
  287. });
  288. const { data, err, msg } = r
  289. if (data) {
  290. listState.total = data.total || 0
  291. if (Array.isArray(data.list)) {
  292. const sList = data.list.map(t => {
  293. return {
  294. ...t,
  295. stateText: calcStateText(t.state),
  296. claimText: calcClaimText(t.claimtype),
  297. modifyUserText: calcModifyUserText(t),
  298. // 操作按钮是否点击过
  299. _action_clicked_mark: false,
  300. _action_clicked_edit: false,
  301. _action_clicked_debug: false,
  302. _action_clicked_verify: false,
  303. _action_clicked_submit: false,
  304. _action_clicked_rollback: false,
  305. }
  306. })
  307. listState.list = sList || []
  308. }
  309. }
  310. } catch (error) {
  311. listState.loaded = true
  312. } finally {
  313. listState.loading = false
  314. }
  315. }
  316. // 重置列表数据
  317. const resetListState = () => {
  318. Object.assign(listState, defaultListState)
  319. }
  320. // 重置选择器数据
  321. const resetFilterState = () => {
  322. Object.assign(filters, defaultFilters)
  323. }
  324. // 刷新列表(不重置选择器)
  325. function refreshTableList() {
  326. resetListState()
  327. getTableList()
  328. }
  329. // 刷新列表(并重置选择器)
  330. function resetFilterAndRefreshTableList() {
  331. resetFilterState()
  332. refreshTableList()
  333. }
  334. // 认领按钮事件
  335. const userClaimCodes = async () => {
  336. try {
  337. const r = await store.dispatch('rulesList/userClaimCodes')
  338. const { msg, err } = r
  339. if (err === 1) {
  340. ElMessage({
  341. message: msg || '认领成功',
  342. type: 'success',
  343. duration: 3000,
  344. })
  345. resetFilterAndRefreshTableList()
  346. } else {
  347. ElMessage({
  348. message: msg || '认领失败',
  349. type: 'error',
  350. duration: 3000,
  351. })
  352. }
  353. } catch (error) {
  354. ElMessage({
  355. message: '认领失败',
  356. type: 'error',
  357. duration: 3000,
  358. })
  359. }
  360. }
  361. const clickClaimCodes = () => {
  362. ElMessageBox.confirm('确定要认领一批爬虫?', '提示',
  363. {
  364. customClass: 'j-confirm-message-box',
  365. confirmButtonText: '确定',
  366. cancelButtonText: '取消',
  367. showCancelButton: false,
  368. }
  369. ).then(() => {
  370. userClaimCodes()
  371. })
  372. }
  373. getTableList()
  374. const handleSizeChange = (val) => {
  375. listState.pageSize = val;
  376. listState.pageNum = 1;
  377. getTableList()
  378. };
  379. const handleCurrentChange = (val) => {
  380. listState.pageNum = val;
  381. getTableList()
  382. };
  383. // 获取维护人劣列表
  384. const getModifyUserList = async () => {
  385. const r = await store.dispatch('rulesList/getModifyUserList')
  386. const { data, err, msg } = r
  387. if (data) {
  388. if (Array.isArray(data.list)) {
  389. const arr = filterConfig.modifyUserList
  390. const reqArr = data.list.map(r => {
  391. return {
  392. label: r.s_name,
  393. value: r.s_name,
  394. }
  395. })
  396. filterConfig.modifyUserList = arr.concat(reqArr)
  397. }
  398. }
  399. }
  400. getModifyUserList()
  401. const onModifyUserSelectChange = () => {
  402. refreshTableList()
  403. }
  404. const onStateSelectChange = () => {
  405. refreshTableList()
  406. }
  407. const onInputSearch = () => {
  408. refreshTableList()
  409. }
  410. const onClaimSelectChange = () => {
  411. refreshTableList()
  412. }
  413. // 保存完成后(不刷新优化),同步更新表单内的数据
  414. const refreshRowData = (code, payload) => {
  415. const target = listState.list.find(item => item.code === code)
  416. if (target) {
  417. if (target.cssmark) {
  418. Object.assign(target.cssmark, payload)
  419. } else {
  420. target.cssmark = payload
  421. }
  422. }
  423. }
  424. // 更新编辑弹窗数据
  425. const refreshAndAsyncEditDialog = (key, value) => {
  426. editSpiderDialog.value.refreshPageData(key, value)
  427. }
  428. // 打开编辑弹窗(如果传数据了,则恢复数据)
  429. const openEditDialog = (row) => {
  430. editSpiderDialog.value.dialogVisible = true
  431. if (row) {
  432. editSpiderDialog.value.setPageData({
  433. ...row,
  434. ...row.cssmark,
  435. })
  436. }
  437. }
  438. const dialogEvents = {
  439. editSpiderConfigSaveEvent: async function (data) {
  440. // 整理数据结构
  441. // [{ query: {code: 'code'}, set: {} }, {query:{},set:{}}]
  442. const rowData = data._originData
  443. const payload = data.value
  444. const code = rowData.code
  445. const updateRule = [
  446. {
  447. query: { code: code },
  448. set: {
  449. cssmark: payload,
  450. }
  451. }
  452. ]
  453. const params = {
  454. stype: 'save',
  455. update: updateRule
  456. }
  457. console.log("change data:", data, params)
  458. try {
  459. const r = await store.dispatch('rulesList/editCodeItem', params)
  460. const { msg, err } = r
  461. if (err === 1) {
  462. refreshRowData(code, payload)
  463. ElMessage({
  464. message: msg || '保存成功',
  465. type: 'success',
  466. duration: 3000,
  467. })
  468. // getTableList()
  469. } else {
  470. ElMessage({
  471. message: msg || '保存失败',
  472. type: 'error',
  473. duration: 3000,
  474. })
  475. }
  476. } catch (error) {
  477. ElMessage({
  478. message: '保存失败',
  479. type: 'error',
  480. duration: 3000,
  481. })
  482. }
  483. },
  484. }
  485. const getMarkWithRow = row => {
  486. const baseInfo = {
  487. code: row.code,
  488. site: row.site,
  489. channel: row.channel,
  490. href: row.href,
  491. modifyuser: row.modifyuser,
  492. }
  493. if (row.cssmark) {
  494. return {
  495. ...row.cssmark,
  496. ...baseInfo,
  497. }
  498. } else {
  499. return baseInfo
  500. }
  501. }
  502. const getLuaParams = row => {
  503. const baseInfo = {
  504. code: row.code,
  505. site: row.site,
  506. channel: row.channel,
  507. modifyuser: row.modifyuser,
  508. claimtime: row.claimtime,
  509. recovertime: row.recovertime,
  510. priority: row.priority,
  511. spiderimportant: row.spiderimportant,
  512. modifytime: row.modifytime,
  513. }
  514. return baseInfo
  515. }
  516. const editDialogMarkClick = (row) => {
  517. // 自定义关闭时间
  518. ElMessage({
  519. message: `${row.site} ${row.channel} ${row.href}`,
  520. showClose: true,
  521. duration: 3000,
  522. });
  523. BrowserOpenURL(row.href)
  524. }
  525. // table的按钮事件集合
  526. const tableEvents = {
  527. handleDataTag(row) {
  528. onlyClickHighlight(row, '_action_clicked_mark')
  529. // 自定义关闭时间
  530. editDialogMarkClick(row)
  531. },
  532. handleEdit: (index, row) => {
  533. currentEditRow.value = row
  534. onlyClickHighlight(row, '_action_clicked_edit')
  535. prevClickedRow.value = row
  536. ElMessage({
  537. message: `${row.site} ${row.channel} ${row.href}`,
  538. showClose: true,
  539. duration: 3000,
  540. });
  541. const mark = getMarkWithRow(row)
  542. ServerActionCurrentOpenTab(mark)
  543. openEditDialog(row)
  544. },
  545. handleDebug(index, row) {
  546. onlyClickHighlight(row, '_action_clicked_debug')
  547. runSpiderDialog.value.dialogVisible = true
  548. runSpiderDialog.value.setPageData(row)
  549. // router.push({
  550. // path: '/run'
  551. // });
  552. },
  553. handleVerify(index, row) {
  554. onlyClickHighlight(row, '_action_clicked_verify')
  555. loading.value = true
  556. if (!row.cssmark) {
  557. return ElMessage({
  558. message: '没有找到标注信息',
  559. type: 'error',
  560. duration: 3000,
  561. })
  562. }
  563. const mark = getMarkWithRow(row)
  564. VerifySpiderConfig(mark).then(r => {
  565. if (r.err === 1 && r.ret) {
  566. verifySpiderDialog.value.dialogVisible = true
  567. verifySpiderDialog.value.formData = r.ret
  568. } else {
  569. return ElMessage({
  570. message: r.msg || '验证异常',
  571. type: 'error',
  572. duration: 3000,
  573. })
  574. }
  575. }).finally(() => {
  576. loading.value = false
  577. })
  578. },
  579. handleSubmit(index, row) {
  580. onlyClickHighlight(row, '_action_clicked_submit')
  581. const lua = getLuaParams(row)
  582. lua.state = 1
  583. ServerActionUpdateCodeState({ lua: lua }).then(r => {
  584. if (r.err === 1) {
  585. ElMessage({
  586. message: '提交成功',
  587. type: 'success',
  588. duration: 3000,
  589. })
  590. getTableList()
  591. } else {
  592. return ElMessage({
  593. message: r.msg || '提交失败',
  594. type: 'error',
  595. duration: 3000,
  596. })
  597. }
  598. })
  599. },
  600. handleRollback(_, row) {
  601. onlyClickHighlight(row, '_action_clicked_rollback')
  602. // ElMessageBox.alert('确定退回?', '提示', {
  603. // customClass: 'j-confirm-message-box',
  604. // confirmButtonText: '确定',
  605. // callback: (action) => {
  606. // if (action === 'confirm') {
  607. //
  608. // }
  609. // },
  610. // })
  611. ElMessageBox.confirm('确定退回?', '提示',
  612. {
  613. customClass: 'j-confirm-message-box',
  614. confirmButtonText: '确定',
  615. cancelButtonText: '取消',
  616. showCancelButton: false,
  617. }
  618. ).then(() => {
  619. this.confirmRollback(row)
  620. })
  621. },
  622. confirmRollback(row) {
  623. const lua = getLuaParams(row)
  624. lua.state = 12
  625. ServerActionUpdateCodeState({ lua: lua }).then(r => {
  626. if (r.err === 1) {
  627. ElMessage({
  628. message: '退回成功',
  629. type: 'success',
  630. duration: 3000,
  631. })
  632. getTableList()
  633. } else {
  634. return ElMessage({
  635. message: r.msg || '退回失败',
  636. type: 'error',
  637. duration: 3000,
  638. })
  639. }
  640. })
  641. },
  642. }
  643. //Wails事件绑定
  644. EventsOn("spiderConfigChange", data => {
  645. console.log(data)
  646. const { key, css, url } = data
  647. refreshAndAsyncEditDialog(key, css)
  648. // 当触发修改时候,同步给客服端一份
  649. if (currentEditRow.value && Object.keys(currentEditRow.value).length <= 0) {
  650. const mark = getMarkWithRow(currentEditRow.value)
  651. ServerActionCurrentOpenTab(mark)
  652. }
  653. // 判断标注url和编辑url是否相同
  654. // const editUrl = currentEditRow.href
  655. // if (url === editUrl) {
  656. // refreshAndAsyncEditDialog(key, css[key])
  657. // } else {
  658. // ElMessage({
  659. // message: `标注url和编辑url不匹配,此次更新取消。当前标注url: ${url},当前编辑url: ${editUrl}`,
  660. // type: 'warn',
  661. // duration: 4000,
  662. // })
  663. // }
  664. })
  665. </script>
  666. <style lang="scss" scoped>
  667. ::v-deep {
  668. .el-button {
  669. &.active {
  670. background-color: var(--el-button-hover-bg-color);
  671. border-color: var(--el-button-hover-border-color);
  672. color: var(--el-button-hover-text-color);
  673. outline: none;
  674. }
  675. }
  676. }
  677. .pagination-container {
  678. display: flex;
  679. align-items: center;
  680. justify-content: flex-end;
  681. }
  682. .action-bar-container {
  683. display: flex;
  684. justify-content: space-between;
  685. }
  686. .action-bar-item-container {
  687. }
  688. .action-bar-item {
  689. display: flex;
  690. align-items: center;
  691. }
  692. .action-bar-name {
  693. font-size: 14px;
  694. white-space: nowrap;
  695. }
  696. </style>