Browse Source

feat: 完善提交和回退逻辑

cuiyalong 10 months ago
parent
commit
0ccc65beb3
3 changed files with 56 additions and 43 deletions
  1. 33 33
      frontend/src/views/CodeList.vue
  2. 11 6
      frontend/wailsjs/go/main/App.d.ts
  3. 12 4
      frontend/wailsjs/go/main/App.js

+ 33 - 33
frontend/src/views/CodeList.vue

@@ -124,7 +124,7 @@ import { useRouter } from 'vue-router';
 import { useStore } from 'vuex';
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { BrowserOpenURL, EventsOn } from "../../wailsjs/runtime"
-import { VerifySpiderConfig, SwitchSpiderConfig } from "../../wailsjs/go/main/App"
+import { VerifySpiderConfig, ServerActionUpdateCodeState } from "../../wailsjs/go/main/App"
 import Breadcrumb from "../components/Breadcrumb.vue"
 import EditSpider from "../components/spider/EditSpider.vue"
 import RunSpiderDialog from "../components/spider/RunSpiderDialog.vue"
@@ -570,43 +570,43 @@ const tableEvents = {
         onlyClickHighlight(row, '_action_clicked_submit')
         const mark = getMarkWithRow(row)
         console.log(mark)
-        // ServerActionUpdateCodeState(mark, 1).then(r => {
-        //     if (r.err === 1) {
-        //         ElMessage({
-        //             message: '提交成功',
-        //             type: 'error',
-        //             duration: 3000,
-        //         })
-        //         getTableList()
-        //     } else {
-        //         return ElMessage({
-        //             message: r.msg || '提交失败',
-        //             type: 'error',
-        //             duration: 3000,
-        //         })
-        //     }
-        // })
+        ServerActionUpdateCodeState(mark, 1).then(r => {
+            if (r.err === 1) {
+                ElMessage({
+                    message: '提交成功',
+                    type: 'error',
+                    duration: 3000,
+                })
+                getTableList()
+            } else {
+                return ElMessage({
+                    message: r.msg || '提交失败',
+                    type: 'error',
+                    duration: 3000,
+                })
+            }
+        })
     },
     handleRollback(index, row) {
         onlyClickHighlight(row, '_action_clicked_rollback')
         const mark = getMarkWithRow(row)
         console.log(mark)
-        // ServerActionUpdateCodeState(mark, -1).then(r => {
-        //     if (r.err === 1) {
-        //         ElMessage({
-        //             message: '回退成功',
-        //             type: 'error',
-        //             duration: 3000,
-        //         })
-        //         getTableList()
-        //     } else {
-        //         return ElMessage({
-        //             message: r.msg || '回退失败',
-        //             type: 'error',
-        //             duration: 3000,
-        //         })
-        //     }
-        // })
+        ServerActionUpdateCodeState(mark, -1).then(r => {
+            if (r.err === 1) {
+                ElMessage({
+                    message: '回退成功',
+                    type: 'error',
+                    duration: 3000,
+                })
+                getTableList()
+            } else {
+                return ElMessage({
+                    message: r.msg || '回退失败',
+                    type: 'error',
+                    duration: 3000,
+                })
+            }
+        })
     },
 }
 

+ 11 - 6
frontend/wailsjs/go/main/App.d.ts

@@ -1,10 +1,11 @@
 // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
 // This file is automatically generated. DO NOT EDIT
 import {backend} from '../models';
+import {main} from '../models';
 
 export function CountYestodayArts(arg1:string,arg2:number,arg3:number,arg4:boolean,arg5:boolean):Promise<void>;
 
-export function DebugSpider(arg1:string,arg2:number,arg3:number,arg4:number,arg5:number,arg6:boolean,arg7:boolean,arg8:string,arg9:number):Promise<void>;
+export function DebugSpider(arg1:string,arg2:string,arg3:number,arg4:number,arg5:number,arg6:number,arg7:boolean,arg8:boolean,arg9:number,arg10:{[key: string]: any}):Promise<void>;
 
 export function DeleteJob(arg1:string):Promise<string>;
 
@@ -38,13 +39,15 @@ export function SelectSaveFilePath(arg1:string,arg2:string):Promise<string>;
 
 export function ServerActionCheckLogin():Promise<{[key: string]: any}>;
 
-export function ServerActionClaimCodes():Promise<{[key: string]: any}>;
+export function ServerActionClaimCodes():Promise<main.Result>;
 
-export function ServerActionCodeList(arg1:{[key: string]: any}):Promise<{[key: string]: any}>;
+export function ServerActionCodeList(arg1:{[key: string]: any}):Promise<main.Result>;
 
-export function ServerActionGetModifyUsers():Promise<{[key: string]: any}>;
+export function ServerActionGetModifyUsers():Promise<main.Result>;
 
-export function ServerActionUpdateCode(arg1:Array<{[key: string]: any}>):Promise<{[key: string]: any}>;
+export function ServerActionUpdateCode(arg1:{[key: string]: any}):Promise<main.Result>;
+
+export function ServerActionUpdateCodeState(arg1:{[key: string]: any}):Promise<main.Result>;
 
 export function ServerActionUserLogin(arg1:{[key: string]: any}):Promise<{[key: string]: any}>;
 
@@ -56,6 +59,8 @@ export function StopJob(arg1:string):Promise<string>;
 
 export function SwitchSpiderConfig(arg1:string):Promise<string>;
 
+export function VerifySpiderConfig(arg1:{[key: string]: any}):Promise<backend.SpiderConfigVerifyResult>;
+
 export function ViewCurrentSpiderConfig():Promise<backend.SpiderConfig>;
 
-export function ViewResultItemAll():Promise<backend.ResultItems>;
+export function ViewResultItemAll(arg1:string):Promise<backend.ResultItems>;

+ 12 - 4
frontend/wailsjs/go/main/App.js

@@ -6,8 +6,8 @@ export function CountYestodayArts(arg1, arg2, arg3, arg4, arg5) {
   return window['go']['main']['App']['CountYestodayArts'](arg1, arg2, arg3, arg4, arg5);
 }
 
-export function DebugSpider(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
-  return window['go']['main']['App']['DebugSpider'](arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+export function DebugSpider(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
+  return window['go']['main']['App']['DebugSpider'](arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
 }
 
 export function DeleteJob(arg1) {
@@ -90,6 +90,10 @@ export function ServerActionUpdateCode(arg1) {
   return window['go']['main']['App']['ServerActionUpdateCode'](arg1);
 }
 
+export function ServerActionUpdateCodeState(arg1) {
+  return window['go']['main']['App']['ServerActionUpdateCodeState'](arg1);
+}
+
 export function ServerActionUserLogin(arg1) {
   return window['go']['main']['App']['ServerActionUserLogin'](arg1);
 }
@@ -110,10 +114,14 @@ export function SwitchSpiderConfig(arg1) {
   return window['go']['main']['App']['SwitchSpiderConfig'](arg1);
 }
 
+export function VerifySpiderConfig(arg1) {
+  return window['go']['main']['App']['VerifySpiderConfig'](arg1);
+}
+
 export function ViewCurrentSpiderConfig() {
   return window['go']['main']['App']['ViewCurrentSpiderConfig']();
 }
 
-export function ViewResultItemAll() {
-  return window['go']['main']['App']['ViewResultItemAll']();
+export function ViewResultItemAll(arg1) {
+  return window['go']['main']['App']['ViewResultItemAll'](arg1);
 }