1234567891011121314151617181920212223242526272829303132333435 |
- import Snackbar from '@/plugins/snackbar'
- const prefixList = ['/app-api', '/admin-api']
- export const getSuffixAfterPrefix = (str) => {
- const matchingPrefix = prefixList.find(prefix => str.startsWith(prefix))
- if (matchingPrefix) {
- const matchUrl = str.slice(matchingPrefix.length)
- const hasQuery = matchUrl.indexOf('?') !== -1
- if (hasQuery) {
- const arr = matchUrl.split('?')
- return arr[0]
- }
- else return matchUrl
- }
- return undefined
- }
- // 展示积分
- export function showNextAction(actions, currentIndex = 0) {
- if (currentIndex < actions.length) {
- const action = actions[currentIndex]
- if (action.match) {
- Snackbar.success(`恭喜您${action.title}获得${action.point}积分`)
- setTimeout(() => {
- showNextAction(actions, currentIndex + 1)
- }, 3000)
- } else {
- setTimeout(() => {
- showNextAction(actions, currentIndex + 1)
- }, 0)
- }
- }
- }
|