{"size": 980, "ext": "js", "max_stars_repo_path": "templates/project/src/utils/index.js", "max_stars_repo_name": "guchongxi/dxd-we-cli", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "templates/project/src/utils/index.js", "max_issues_repo_name": "guchongxi/dxd-we-cli", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "templates/project/src/utils/index.js", "max_forks_repo_name": "guchongxi/dxd-we-cli", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.3333333333, "max_line_length": 114, "alphanum_fraction": 0.612244898}
const formatNumber = n => {
  n = n.toString();
  return n[1] ? n : `0${n}`;
};

export const formatTime = date => {
  const year = date.getFullYear();
  const month = date.getMonth() + 1;
  const day = date.getDate();
  const hour = date.getHours();
  const minute = date.getMinutes();
  const second = date.getSeconds();

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
};

/**
 * 返回当前页面完整的url（包括参数）
 *
 * @param {Int} pageId 页面 id
 * pageId 0 当前页面
 * pageId -1 上一个页面
 */
export function getPageUrl(pageId = 0, needOptions = true) {

  const routeList = getCurrentPages();
  const curPage = routeList[routeList.length - 1 + pageId];

  if (!curPage) {
    return {};
  }

  const { route, options } = curPage;
  if (needOptions) {
    const queryStr = Object.keys(options).map(key => `${key}=${options[key]}`).join('&');

    return queryStr ? `${route}?${queryStr}` : route;
  } else {
    return route;
  }
}
