代码提交

This commit is contained in:
黄少君
2023-11-17 20:55:32 +08:00
parent 35b43ffd97
commit c3e62f8922
73 changed files with 1808 additions and 781 deletions

View File

@ -16,8 +16,11 @@ export const useRouter = () => {
* 使用此方法的跳转获取参数必须使用本hooks的getParams方法获取路由参数
* 注意2.8.9+以后版本可以使用events参数传递一个方法对象和新打开的页面建立一个channel通讯getOpenerEventChannel获取到这个channel
* @docs: https://uniapp.dcloud.net.cn/api/router.html#navigateto
* @param options{any} 原始参数
* @param config{{type?:'navigateTo'|'redirectTo'|'reLaunch',data?:any,timeout?:number}}
* @param {object} options 原始参数
* @param {object} config 配置参数
* @param {'navigateTo'|'redirectTo'|'reLaunch'} config.type 跳转类型
* @param {object} config.data 跳转参数
* @param {number} config.timeout 延时时间
* type跳转类型默认navigateTo ; data跳转参数默认空对象 ; timeout跳转延时默认0
* @returns {Promise<boolean>}
*/
@ -86,8 +89,8 @@ export const useRouter = () => {
/**
* 返回
* @param options{any} 默认参数对象
* @param timeout{number} 延时跳转
* @param {object} options 默认参数对象
* @param {number} timeout 延时跳转
* @returns {Promise<unknown>}
*/
function goBack(options, timeout = 0) {
@ -121,8 +124,8 @@ export const useRouter = () => {
/**
* 获取跳转页参数解析对象
* @param options{any} onLoad函数的原始参数
* @returns {any}
* @param {object} options onLoad函数的原始参数
* @returns {object}
*/
function getParams(options) {
if (typeof options !== 'object') return {}
@ -135,7 +138,7 @@ export const useRouter = () => {
/**
* 预加载页面
* @param url
* @param {string} url 路径
* @returns {Promise<boolean>}
*/
function preLoad(url) {
@ -157,7 +160,12 @@ export const useRouter = () => {
/**
* 获取当前页面对象
* @returns {{prePage: ((Page.PageInstance<AnyObject, {}> & {})|null), currentPages: Array<Page.PageInstance<AnyObject, {}> & {}>, nowPage: ((Page.PageInstance<AnyObject, {}> & {})|null)}}
* @returns {
* {
* prePage: (Page.PageInstance<AnyObject, {}>|{}|null),
* currentPages: Array<Page.PageInstance<AnyObject, {}> & {}>,
* nowPage: (Page.PageInstance<AnyObject, {}>|{}|null)}
* }
*/
function getCurrentPage() {
const currentPages = getCurrentPages();
@ -190,7 +198,7 @@ export const useRouter = () => {
/**
* 校验URL
* @param options
* @param {object} options
*/
const checkUrl = (options) => {
if (!options.url) throw new Error('options 必须携带url参数')
@ -199,8 +207,8 @@ const checkUrl = (options) => {
/**
* 处理参数
* 如果有参数的情况使用encodeURIComponent + JSON.stringify格式化掉
* @param options
* @param data
* @param {object} options
* @param {object} data
*/
const processingParameter = (options, data) => {
if (Object.keys(data).length > 0) {