e390134cc621dcb3aaa89a33234b453216682c1ce30117eea365b2867e3b2804.json 3.9 KB

1
  1. {"ast":null,"code":"import _regeneratorRuntime from \"E:/dev/MyProject/workflow/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js\";\nimport _asyncToGenerator from \"E:/dev/MyProject/workflow/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport \"core-js/modules/es.error.cause.js\";\nimport \"core-js/modules/es.error.to-string.js\";\nimport axios from 'axios';\n\n/**\r\n * 根据用户ID获取用户信息\r\n * @param {string} userId - 用户ID\r\n * @returns {Promise<{userName: string}>} 返回包含userName的Promise\r\n * @throws {Error} 当请求失败或userId未提供时抛出错误\r\n */\nexport var fetchUserInfo = /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(userId) {\n var response;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (userId) {\n _context.next = 2;\n break;\n }\n throw new Error('未提供用户ID参数');\n case 2:\n _context.prev = 2;\n _context.next = 5;\n return axios.get(\"http://localhost:8088/business/queryId?userId=\".concat(userId));\n case 5:\n response = _context.sent;\n return _context.abrupt(\"return\", response.data.data);\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](2);\n console.error('获取用户信息失败:', _context.t0);\n throw new Error('获取用户信息失败,请稍后再试');\n case 13:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[2, 9]]);\n }));\n return function fetchUserInfo(_x) {\n return _ref.apply(this, arguments);\n };\n}();","map":{"version":3,"names":["axios","fetchUserInfo","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","userId","response","wrap","_callee$","_context","prev","next","Error","get","concat","sent","abrupt","data","t0","console","error","stop","_x","apply","arguments"],"sources":["E:/dev/MyProject/workflow/src/api/user.js"],"sourcesContent":["import axios from 'axios';\r\n\r\n/**\r\n * 根据用户ID获取用户信息\r\n * @param {string} userId - 用户ID\r\n * @returns {Promise<{userName: string}>} 返回包含userName的Promise\r\n * @throws {Error} 当请求失败或userId未提供时抛出错误\r\n */\r\nexport const fetchUserInfo = async (userId) => {\r\n if (!userId) {\r\n throw new Error('未提供用户ID参数');\r\n }\r\n\r\n try {\r\n const response = await axios.get(`http://localhost:8088/business/queryId?userId=${userId}`);\r\n // 直接返回API响应中的data部分,这样调用者可以直接访问其中的属性\r\n return response.data.data;\r\n } catch (error) {\r\n console.error('获取用户信息失败:', error);\r\n throw new Error('获取用户信息失败,请稍后再试');\r\n }\r\n};\r\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,aAAa;EAAA,IAAAC,IAAA,GAAAC,iBAAA,cAAAC,mBAAA,GAAAC,IAAA,CAAG,SAAAC,QAAOC,MAAM;IAAA,IAAAC,QAAA;IAAA,OAAAJ,mBAAA,GAAAK,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAAA,IACnCN,MAAM;YAAAI,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,MACH,IAAIC,KAAK,CAAC,WAAW,CAAC;QAAA;UAAAH,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAE,IAAA;UAAA,OAILb,KAAK,CAACe,GAAG,kDAAAC,MAAA,CAAkDT,MAAM,CAAE,CAAC;QAAA;UAArFC,QAAQ,GAAAG,QAAA,CAAAM,IAAA;UAAA,OAAAN,QAAA,CAAAO,MAAA,WAEPV,QAAQ,CAACW,IAAI,CAACA,IAAI;QAAA;UAAAR,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAS,EAAA,GAAAT,QAAA;UAEzBU,OAAO,CAACC,KAAK,CAAC,WAAW,EAAAX,QAAA,CAAAS,EAAO,CAAC;UAAC,MAC5B,IAAIN,KAAK,CAAC,gBAAgB,CAAC;QAAA;QAAA;UAAA,OAAAH,QAAA,CAAAY,IAAA;MAAA;IAAA,GAAAjB,OAAA;EAAA,CAEpC;EAAA,gBAbYL,aAAaA,CAAAuB,EAAA;IAAA,OAAAtB,IAAA,CAAAuB,KAAA,OAAAC,SAAA;EAAA;AAAA,GAazB","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}