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 \"core-js/modules/es.date.to-json.js\";\nimport \"core-js/modules/es.json.stringify.js\";\nimport axios from 'axios';\nimport dd from 'dingtalk-jsapi';\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}();\nexport var getAuthCode = /*#__PURE__*/function () {\n var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n //alert(\"开始获取钉钉code\");\n dd.getAuthCode({\n success: function success(res) {\n var code = res.code;\n console.log('code=', code);\n //alert(\"获取钉钉code\"+ code);\n //alert('http://vqs.tztek.com:8010/#/BreakpointLogin?username=' + code);\n //callApi(code);\n },\n fail: function fail(err) {\n alert('errMsg:' + JSON.stringify(err));\n },\n complete: function complete() {\n console.log('done');\n },\n corpId: 'ding8ee5c701147645d9'\n });\n case 1:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n return function getAuthCode() {\n return _ref2.apply(this, arguments);\n };\n}();","map":{"version":3,"names":["axios","dd","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","getAuthCode","_ref2","_callee2","_callee2$","_context2","success","res","code","log","fail","err","alert","JSON","stringify","complete","corpId"],"sources":["E:/dev/MyProject/workflow/src/api/user.js"],"sourcesContent":["import axios from 'axios';\r\nimport dd from 'dingtalk-jsapi';\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\r\n\r\nexport const getAuthCode = async () => {\r\n//alert(\"开始获取钉钉code\");\r\n dd.getAuthCode({\r\n success: (res) => {\r\n const { code } = res;\r\n console.log('code=', code);\r\n //alert(\"获取钉钉code\"+ code);\r\n //alert('http://vqs.tztek.com:8010/#/BreakpointLogin?username=' + code);\r\n //callApi(code);\r\n },\r\n fail: (err) => {\r\n alert('errMsg:' + JSON.stringify(err));\r\n },\r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