|
|
|
@ -1,64 +1,65 @@ |
|
|
|
export const formatTime = (date: Date) => { |
|
|
|
export function formatTime(date: Date) { |
|
|
|
const year = date.getFullYear(); |
|
|
|
const year = date.getFullYear() |
|
|
|
const month = date.getMonth() + 1; |
|
|
|
const month = date.getMonth() + 1 |
|
|
|
const day = date.getDate(); |
|
|
|
const day = date.getDate() |
|
|
|
const hour = date.getHours(); |
|
|
|
const hour = date.getHours() |
|
|
|
const minute = date.getMinutes(); |
|
|
|
const minute = date.getMinutes() |
|
|
|
const second = date.getSeconds(); |
|
|
|
const second = date.getSeconds() |
|
|
|
|
|
|
|
|
|
|
|
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`; |
|
|
|
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const formatNumber = (n: number) => { |
|
|
|
export function formatNumber(n: number) { |
|
|
|
const s = n.toString(); |
|
|
|
const s = n.toString() |
|
|
|
return s[1] ? s : `0${s}`; |
|
|
|
return s[1] ? s : `0${s}` |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取当前页面路径 |
|
|
|
* 获取当前页面路径 |
|
|
|
* @returns string |
|
|
|
* @returns string |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export const getCurrentPageUrl = function () { |
|
|
|
export function getCurrentPageUrl() { |
|
|
|
const pages = getCurrentPages(); |
|
|
|
const pages = getCurrentPages() |
|
|
|
const currentPage = pages[pages.length - 1]; |
|
|
|
const currentPage = pages[pages.length - 1] |
|
|
|
const url = `/${currentPage.route}`; |
|
|
|
const url = `/${currentPage.route}` |
|
|
|
return url; |
|
|
|
return url |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取当前页面路径 & 参数 |
|
|
|
* 获取当前页面路径 & 参数 |
|
|
|
* @returns string |
|
|
|
* @returns string |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export const getCurrentPageUrlWithArgs = function () { |
|
|
|
export function getCurrentPageUrlWithArgs() { |
|
|
|
const pages = getCurrentPages(); |
|
|
|
const pages = getCurrentPages() |
|
|
|
const currentPage = pages[pages.length - 1]; |
|
|
|
const currentPage = pages[pages.length - 1] |
|
|
|
const url = currentPage.route; |
|
|
|
const url = currentPage.route |
|
|
|
const options = currentPage.options; |
|
|
|
const options = currentPage.options |
|
|
|
let urlWithArgs = `/${url}?`; |
|
|
|
let urlWithArgs = `/${url}?` |
|
|
|
for (const key in options) { |
|
|
|
for (const key in options) { |
|
|
|
const value = options[key]; |
|
|
|
const value = options[key] |
|
|
|
urlWithArgs += `${key}=${value}&`; |
|
|
|
urlWithArgs += `${key}=${value}&` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1) |
|
|
|
|
|
|
|
return urlWithArgs |
|
|
|
} |
|
|
|
} |
|
|
|
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1); |
|
|
|
|
|
|
|
return urlWithArgs; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const parseUrlArgsToArray = (urlArgs) => { |
|
|
|
export function parseUrlArgsToArray(urlArgs): any { |
|
|
|
urlArgs = urlArgs.split('&'); |
|
|
|
urlArgs = urlArgs.split('&') |
|
|
|
const results = {}; |
|
|
|
const results = {} |
|
|
|
urlArgs.forEach((arg) => { |
|
|
|
urlArgs.forEach((arg) => { |
|
|
|
arg = arg.split('='); |
|
|
|
arg = arg.split('=') |
|
|
|
if (arg[0] && arg[1]) { |
|
|
|
if (arg[0] && arg[1]) { |
|
|
|
results[arg[0]] = arg[1]; |
|
|
|
results[arg[0]] = arg[1] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return results |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return results; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const parseScene = (scene) => { |
|
|
|
export function parseScene(scene) { |
|
|
|
if (scene) { |
|
|
|
if (scene) { |
|
|
|
return parseUrlArgsToArray(decodeURIComponent(scene)); |
|
|
|
return parseUrlArgsToArray(decodeURIComponent(scene)) |
|
|
|
} else { |
|
|
|
} |
|
|
|
return null; |
|
|
|
else { |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|