prefixUrl.js 935 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Snackbar from '@/plugins/snackbar'
  2. const prefixList = ['/app-api', '/admin-api']
  3. export const getSuffixAfterPrefix = (str) => {
  4. const matchingPrefix = prefixList.find(prefix => str.startsWith(prefix))
  5. if (matchingPrefix) {
  6. const matchUrl = str.slice(matchingPrefix.length)
  7. const hasQuery = matchUrl.indexOf('?') !== -1
  8. if (hasQuery) {
  9. const arr = matchUrl.split('?')
  10. return arr[0]
  11. }
  12. else return matchUrl
  13. }
  14. return undefined
  15. }
  16. // 展示积分
  17. export function showNextAction(actions, currentIndex = 0) {
  18. if (currentIndex < actions.length) {
  19. const action = actions[currentIndex]
  20. if (action.match) {
  21. Snackbar.success(`恭喜您${action.title}获得${action.point}积分`)
  22. setTimeout(() => {
  23. showNextAction(actions, currentIndex + 1)
  24. }, 3000)
  25. } else {
  26. setTimeout(() => {
  27. showNextAction(actions, currentIndex + 1)
  28. }, 0)
  29. }
  30. }
  31. }