Gathering detailed insights and metrics for mazey-taro-utils
Gathering detailed insights and metrics for mazey-taro-utils
Gathering detailed insights and metrics for mazey-taro-utils
Gathering detailed insights and metrics for mazey-taro-utils
npm install mazey-taro-utils
Typescript
Module System
Node Version
NPM Version
TypeScript (53.1%)
JavaScript (46.9%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
38 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jun 10, 2024
Latest Version
1.0.2
Package Id
mazey-taro-utils@1.0.2
Unpacked Size
46.54 kB
Size
9.14 kB
File Count
10
NPM Version
8.19.4
Node Version
16.20.2
Published on
Jun 10, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
50
Mazey's Taro utils.
Use mazey-taro-utils via npm.
1npm install mazey-taro-utils --save
Of course, you can also download this file and serve it yourself. The file locates at the lib/mazey-taro-utils.min.js
.
1import { getLoginCodeAsync } from "mazey-taro-utils"; 2 3getLoginCodeAsync() 4 .then((code) => { 5 console.log(`Login code: ${code}`); 6 }) 7 .catch((error) => { 8 console.error(error); 9 });
quickToast
Displays a toast message.
Parameters:
msg
(string): The message to display in the toast.Example Usage:
1quickToast('Hello, world!');
quickNavigateTo
Navigates to a specified page.
Parameters:
page
(string): The page to navigate to. This should be the name of the directory under /pages
without the /index
part.params
(object, optional): Query parameters to include in the URL.Example Usage:
1quickNavigateTo('home', { params: { userId: 123 } });
quickRedirectTo
Redirects to a specified page, without keeping the current page in the navigation history.
Parameters:
page
(string): The page to redirect to. This should be the name of the directory under /pages
without the /index
part.params
(object, optional): Query parameters to include in the URL.Example Usage:
1quickRedirectTo('home', { params: { userId: 123 } });
quickScrollTo
Quickly scrolls to a specified element on the page.
Parameters:
selector
(string): The selector of the element to scroll to.duration
(number, optional): The duration of the scroll animation in milliseconds. Default is 300ms.Example Usage:
1quickScrollTo('#elementId', 500);
getEnv
Gets the current environment the application is running in.
Returns: string
'h5'
, 'weapp'
, etc.).Example Usage:
1console.log(`Current environment: ${getEnv()}`);
getCurrentPage
Gets the path of the current page.
Returns: string
Example Usage:
1console.log(`Current page path: ${getCurrentPage()}`);
getAllParams
Gets all parameters of the current page.
Returns: object
Example Usage:
1console.log(`Current page params: ${JSON.stringify(getAllParams())}`);
getQueryParam
Gets the value of a query parameter from the current path.
Parameters:
name
(string): The name of the query parameter.Returns: string
Example Usage:
1const userId = getQueryParam('userId'); 2console.log(`User ID: ${userId}`);
getWindowSize
Gets the size of the current window.
Returns: object
width
(number): The width of the window.height
(number): The height of the window.ratio
(number): The width-to-height ratio.hwRatio
(number): The height-to-width ratio.Example Usage:
1const { width, height, ratio, hwRatio } = getWindowSize(); 2console.log(`Window size - Width: ${width}, Height: ${height}, Ratio: ${ratio}, HW Ratio: ${hwRatio}`);
getSystem
Gets the current system information, such as "iOS 14.4".
Returns: string
Example Usage:
1const systemInfo = getSystem(); 2console.log(`System Info: ${systemInfo}`);
getLoginCodeAsync
Calls the interface to get the login credential (code).
Returns: Promise<string>
Example Usage:
1getLoginCodeAsync().then(code => { 2 console.log(`Login code: ${code}`); 3}).catch(err => { 4 console.error(`Failed to get login code: ${err}`); 5});
isMiniProgram
Checks if the current environment is a WeChat Mini Program.
Returns: boolean
Example Usage:
1if (isMiniProgram()) { 2 console.log('Running in a WeChat Mini Program'); 3}
isH5
Determines if the current environment is a web environment (H5).
Returns: boolean
true
if the current environment is H5.false
otherwise.Example Usage:
1if (isH5()) { 2 console.log('Running in a web environment'); 3}
isWideScreen
Checks if the device has a wide screen.
Returns: boolean
Example Usage:
1if (isWideScreen()) { 2 console.log('Device has a wide screen'); 3}
isIOS
Checks if the system is iOS.
Returns: boolean
Example Usage:
1if (isIOS()) { 2 console.log('Running on iOS'); 3}
isAndroid
Checks if the system is Android.
Returns: boolean
Example Usage:
1if (isAndroid()) { 2 console.log('Running on Android'); 3}
Node.js Version: 16.x
Install Dependencies:
1npm i
Development:
1npm run dev
Build:
1npm run build
Document:
1npm run docs
Test:
1npm run test
This software is released under the terms of the MIT license.
No vulnerabilities found.
No security vulnerabilities found.