utils.js 595 B

123456789101112131415161718192021
  1. export const array2object = (list = [], k = 'id', v) => {
  2. const data = {}
  3. if (list) {
  4. for (const item of list) {
  5. data[item[k]] = v ? item[v] : item
  6. }
  7. }
  8. return data
  9. }
  10. export const getStuName = () => {
  11. if (location.hostname.indexOf('dev') > -1) {
  12. return 'http://mstudev.dayaedu.com'
  13. } else if (location.hostname.indexOf('online') > -1) {
  14. return 'https://mstuonline.dayaedu.com'
  15. } else if (location.hostname.indexOf('localhost') > -1) {
  16. return 'http://localhost:9001'
  17. } else {
  18. return 'https://mstutest.dayaedu.com' //'http://localhost:9001' //
  19. }
  20. }