event.js 329 B

12345678910111213141516
  1. /**
  2. * 返回值或者Promise统一包装为返回promise
  3. * @param {*} result
  4. * @returns
  5. */
  6. export function resultJudge(result) {
  7. return new Promise((resolve) => {
  8. if (result && result.constructor == Promise) {
  9. result.then((resp) => {
  10. resolve(resp)
  11. })
  12. } else {
  13. resolve(result)
  14. }
  15. })
  16. }