// 不能额外依赖其他包，要干净。因为会注入到globalVar中，不能循环依赖
/**
 * 刷新当前页面
 *
 * @param [isRedirect=false]
 */
export function refreshCurrentPage(isRedirect = false) {
  const pages = getCurrentPages();
  const currentPage = pages[pages.length - 1];
  if (!currentPage) {
    return;
  }

  if (currentPage && (currentPage as any).$page?.fullPath) {
    const { fullPath } = (currentPage as any).$page;
    const url = fullPath;


    if (isRedirect) {
      uni.redirectTo({
        url,
      });
      return;
    }

    uni.reLaunch({
      url,
    });
  }
}
