Преглед на файлове

feat 增加后端接口hooks

kuanghua liu преди 2 години
родител
ревизия
c5f95f51d8
променени са 2 файла, в които са добавени 61 реда и са изтрити 0 реда
  1. 20 0
      src/api/algo/algo.ts
  2. 41 0
      src/api/dashboard/algoManagement/use-algoData.ts

+ 20 - 0
src/api/algo/algo.ts

@@ -0,0 +1,20 @@
+import { http } from '@/utils/http/axios';
+
+export function getAlgoInfo() {
+  return http.request({
+    url: '/algo/getAlgoList',
+    method: 'get',
+  });
+}
+
+export function algoInfoModify(algoId: number, pushLinkPrompt: string, pushStatement: string) {
+  return http.request({
+    url: '/article/add',
+    method: 'post',
+    data: {
+      algoId,
+      pushLinkPrompt,
+      pushStatement,
+    },
+  });
+}

+ 41 - 0
src/api/dashboard/algoManagement/use-algoData.ts

@@ -0,0 +1,41 @@
+import { getAlgoInfo, algoInfoModify } from '@/api/algo/algo';
+import { ref } from 'vue';
+import { ElMessage } from 'element-plus';
+
+const algoList = ref([]);
+
+const algoId = ref(0);
+const pushLinkPrompt = ref('');
+const pushStatement = ref('');
+
+export function useAlgo() {
+  const getAlgoDatas = () => {
+    return getAlgoInfo().then((res) => {
+      algoList.value = res;
+    });
+  };
+
+  const modifyAlgoDatas = () => {
+    return algoInfoModify(algoId.value, pushLinkPrompt.value, pushStatement.value)
+      .then(function () {
+        ElMessage({
+          message: '表格数据保存成功',
+          type: 'success',
+        });
+      })
+      .catch(function () {
+        ElMessage.error('表格数据保存失败');
+      });
+  };
+
+  return {
+    algoList,
+    getAlgoDatas,
+    algoId,
+    pushLinkPrompt,
+    pushStatement,
+    modifyAlgoDatas,
+  };
+}
+
+export default useAlgo;