@goldnet/weapp
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

小程序框架

安装

pnpm i @goldnet/weapp

网络请求

import { Req } from '@goldnet/weapp';

全局设置选项

// 【可选】设置请求基地址
Req.getIns().baseUrl = process.env.TARO_APP_BASE_API;

// 【可选】设置请求头
Req.getIns().getDefaultHeaderCall = () => {
    return {
        'Authorization': 'Basic xxxxx',
        'Client-Code': 'qy',
        'Tenant-Id': '000000',
        'Tenantid': '000000',
        'GoldNet-Auth': getGD().l.get('token') || ''
    }
}

使用

/** 获取验证码 */
export async function getOauthCaptcha() {
    return await Req.getIns().send<any>(`/xxx/oauth/captcha`, 'get');
}

UI组件

常规组件

 import { GDiv,GImage } from '@goldnet/weapp';

GHtml,
GDiv,
GImage,
Button,
Swiper, SwiperItem

页面容器

import { GHtml, GHtmlProps } from '@goldnet/weapp';

搜索

import { GSearchBar, GSearchBarProps } from '@goldnet/weapp';

输入/密码输入框

import { GInput, GInputProps } from '@goldnet/weapp';

验证码展示

import { GCodeImageProps, IGCodeImagePropsProps } from '@goldnet/weapp';

可长按复制内容的标签

import { GLabel } from '@goldnet/weapp';

<GLabel text={'要复制的内容'} />

格子图标

import { GGridImage, GGridImageProps } from '@goldnet/weapp';

可滑动加载列表

import { GInfiniteLoading, GInfiniteLoadingContent, GInfiniteLoadingContentProps, GInfiniteLoadingRenderData, GInfiniteLoadingItem, GInfiniteLoadingProps, GInfiniteLoadingRef } from '@goldnet/weapp';

普通列表

import { GList, GListProps } from './component/g-list/g-list';

const source: IItemRender[] = [
        {
            label: '项目1',
            value: '1',
        },
        {
            label: '项目2',
            value: '2',
        },
];

<>
<GList source={source} icon={ArrowRightIcon} onClick={onClick} />
</>

工具函数

getEllipsis

截取字段串,多余的使用省略号

import { getEllipsis } from '@goldnet/weapp';

getEllipsis('abcdefg', 3); // 'abc...'

getStatusBarHeight

获取小程序状态栏高度

import { getStatusBarHeight } from '@goldnet/weapp';

getStatusBarHeight(); // 0 or x

getPageBodyHeight

获取页面可用高度,不包含状态栏高度

import { getPageBodyHeight } from '@goldnet/weapp';

getRAS 或 getSha256Digestt 加密

    import { getRAS, getSha256Digestt } from '@goldnet/weapp';

    getRAS(getSha256Digestt(password), RasPublicKey),

更多

/** 存储 */
import { LocalStorageSystem, getLocalStorage } from '@goldnet/weapp';
// 事件
import { EventSystem, getDefaultEventSystem } from '@goldnet/weapp';
// 页面跳转
import { GotoPage } from '@goldnet/weapp';

类型判断

import { isFile,isNumber,isString } from '@goldnet/weapp';

 isNumber(x)
 isString(x)
 isBoolean(x)
 isNull(x)
 isUndefined(x)
 isSymbol(x)
 isBigInt(x)
 isObject(x)
 isArray(x)
 isFunction(x)
 isDate(x)
 isRegExp(x)
 isPromise(x)
 isSet(x)
 isMap(x)
 isFile(x)

Readme

Keywords

none

Package Sidebar

Install

npm i @goldnet/weapp

Weekly Downloads

29

Version

1.2.0

License

none

Unpacked Size

295 kB

Total Files

139

Last publish

Collaborators

  • ifyx
  • cedrusweng
  • zakihuang