本文整理汇总了TypeScript中nprogress.done函数的典型用法代码示例。如果您正苦于以下问题:TypeScript done函数的具体用法?TypeScript done怎么用?TypeScript done使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了done函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: next
router.beforeEach((to: Route, from: Route, next: any) => {
NProgress.start();
if (getToken()) {
if (to.path === '/login') {
next({ path: '/' });
NProgress.done(); // If current page is dashboard will not trigger afterEach hook, so manually handle it
} else {
next()
// if (UserModule.roles.length === 0) {
// UserModule.GetInfo().then(() => {
// next();
// }).catch((err) => {
// UserModule.FedLogOut().then(() => {
// Message.error(err || 'Verification failed, please login again');
// next({ path: '/' });
// });
// });
// } else {
// next();
// }
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
next();
} else {
next(`/login?redirect=${to.path}`); // 否则全部重定向到登录页
NProgress.done();
}
}
// next();
});
示例2: createAction
export const getUsers = createAction('GET_USERS', async () => {
try {
NProgress.start();
return await client.users.getUsers();
} finally {
NProgress.done();
}
});
示例3: createAction
export const fetch = createAction('FETCH', async (url: string) => {
try {
NProgress.start();
const response = await request.get(url);
return response.text;
} finally {
NProgress.done();
}
}, (url: string) => ({ url }));
示例4: Message
}, (error: any) => {
NProgress.done()
let resData = error.response.data || {}
Message({
message: resData.message || error.message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
})
示例5:
service.interceptors.response.use((response) => {
NProgress.done()
const res = response.data;
if (res.code !== 20000) {
// return Promise.reject('error');
} else {
return response.data;
}
}, (error: any) => {
示例6: setTimeout
setTimeout(()=> NProgress.done(), 1000);
示例8:
Router.onRouteChangeComplete = () => progress.done();
示例9:
router.afterEach(() => {
console.log(121);
NProgress.done(); // 结束Progress
});