UNPKG

@choerodon/master

Version:
77 lines (62 loc) 2.91 kB
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import { useLocalStore } from 'mobx-react-lite'; import { axios } from "../../.."; export default function useStore() { return useLocalStore(function () { return { data: {}, get getData() { return this.data; }, setData: function setData(value) { this.data = _objectSpread({}, value); }, lineData: {}, get getLineDatas() { return this.lineData; }, setLineData: function setLineData(value) { this.lineData = _objectSpread({}, value); }, task: {}, get getTask() { return this.task; }, setTask: function setTask(value) { this.task = _objectSpread({}, value); }, retry: function retry(id, organizationId, type, apiGetway) { switch (type) { case 'organization': return axios.put("/iam/choerodon/v1/organization/".concat(organizationId, "/").concat(id, "/org/retry")); case 'project': return axios.put("".concat(apiGetway, "tasks/instances/").concat(id, "/retry")); case 'site': return axios.put("/iam/choerodon/v1/site/0/".concat(id, "/site/retry")); default: break; } return true; }, unLock: function unLock(id, apiGetway) { return axios.put("".concat(apiGetway, "tasks/instances/").concat(id, "/unlock")); }, /** * 强制失败 * @param id */ abort: function abort(id, apiGetway) { return axios.put("".concat(apiGetway, "tasks/instances/").concat(id, "/failed")); }, /** * 详情 * @param id */ loadDetailData: function loadDetailData(id, apiGetway) { return axios.get("".concat(apiGetway, "instances/").concat(id)); } }; }); }