xctc-utils 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -8
- package/dist/index.d.ts +1 -2
- package/dist/index.js +6 -18
- package/dist/weixin/index.js +3 -2
- package/index.ts +10 -0
- package/package.json +30 -23
- package/tsconfig.json +9 -1
    
        package/README.md
    CHANGED
    
    | @@ -1,17 +1,70 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            ### 项目中常用的方法集合
         | 
| 2 | 
            +
            #### email: dybself@163.com
         | 
| 3 | 
            +
            #### 安装 npm i xctc-utils
         | 
| 4 | 
            +
            #### 项目中引入 import utils from "xctc-utils"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            #### LocalStorage使用,存取值时数据已经过处理
         | 
| 2 7 | 
             
            ```
         | 
| 3 | 
            -
            useLocalStorage(key,value)
         | 
| 8 | 
            +
            存储: utils.useLocalStorage(key,value)
         | 
| 9 | 
            +
            取值: utils.getLocalStorage(key)
         | 
| 4 10 | 
             
            ```
         | 
| 5 | 
            -
             | 
| 11 | 
            +
             | 
| 12 | 
            +
            #### 获取当前设备环境
         | 
| 13 | 
            +
            设备环境:
         | 
| 6 14 | 
             
            ```
         | 
| 7 | 
            -
             | 
| 15 | 
            +
            当前使用设备类型: utils.deviceEnvironment() // android ios
         | 
| 16 | 
            +
            是否在微信浏览器环境中:  utils.weixinBrowser() // true false
         | 
| 8 17 | 
             
            ```
         | 
| 9 | 
            -
             | 
| 18 | 
            +
             | 
| 19 | 
            +
             | 
| 20 | 
            +
            #### 加密解密方法
         | 
| 10 21 | 
             
            ```
         | 
| 11 | 
            -
             | 
| 22 | 
            +
            word: 需要加密的数据,数据可是字符串,对象等
         | 
| 23 | 
            +
            key: 加密 密钥
         | 
| 24 | 
            +
            iv:  密钥偏移量
         | 
| 25 | 
            +
            对数据进行加密
         | 
| 26 | 
            +
            utils.encrypt(word:any,key:any,iv:any)
         | 
| 27 | 
            +
            // 对数据进行解密
         | 
| 28 | 
            +
            utils.decrypt(word:any,key:any,iv:any)
         | 
| 12 29 | 
             
            ```
         | 
| 13 | 
            -
             | 
| 30 | 
            +
            #### 微信H5使用方法集合
         | 
| 31 | 
            +
            ##### 微信授权登录
         | 
| 32 | 
            +
            ```
         | 
| 33 | 
            +
            interface configOption {
         | 
| 34 | 
            +
                appId?:string, // 当前微信服务号 appId
         | 
| 35 | 
            +
                scope?:string,// 网页授权类型
         | 
| 36 | 
            +
                http?:any, // 执行微信登录时,请求后端的接口方法,默认请求数据格式 {"app_id":"","js_code":"" },app_id为当前传入的配置参数,js_code为自动截取。
         | 
| 37 | 
            +
                codeKey?:string, // 回调地址栏中code存储键
         | 
| 38 | 
            +
                stateKey?:string, // 回调地址栏中state 存储键
         | 
| 39 | 
            +
                cryptoiv?:string, // 将地址栏携带参数加密iv
         | 
| 40 | 
            +
                cryptokey?:string, // 将地址栏携带参数加密key
         | 
| 41 | 
            +
            }
         | 
| 42 | 
            +
            进入系统时,默认调用该方法,自动执行微信跳转授权,回调地址中code处理、state处理,
         | 
| 43 | 
            +
            utils.weixinUrlCode(config)
         | 
| 44 | 
            +
            ```
         | 
| 45 | 
            +
            #### 微信config接口权限注入
         | 
| 46 | 
            +
            ```
         | 
| 47 | 
            +
            interface ShareConfig{
         | 
| 48 | 
            +
                http:any, // 微信接口权限注入接口,后端接口,执行成功后返回数据格式:{appId:"",timestamp:"",noncestr:"",signature:""},成功后自动调取微信 wx.config 接口
         | 
| 49 | 
            +
                cb?:any, // wx.ready 成功后的回调方法
         | 
| 50 | 
            +
                appId:string, // 当前微信服务号 appId
         | 
| 51 | 
            +
                jsApiList?:string[],
         | 
| 52 | 
            +
            }
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            utils.weixinShareConfig(config:ShareConfig)
         | 
| 55 | 
            +
            ```
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            #### 微信分享接口加载
         | 
| 14 58 | 
             
            ```
         | 
| 15 | 
            -
             | 
| 59 | 
            +
            interface Share{
         | 
| 60 | 
            +
                title?:string, // 分享标题
         | 
| 61 | 
            +
                desc?:string, // 分享描述
         | 
| 62 | 
            +
                link: '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
         | 
| 63 | 
            +
                imgUrl: '', // 分享图标
         | 
| 64 | 
            +
                data?:any,//微信分享时需要携带的数据,默认传键值格式
         | 
| 65 | 
            +
                iv?:string, // 分享链接中对 state 数据加密的iv
         | 
| 66 | 
            +
                key?:string, // 分享链接中对 state 数据加密的 key
         | 
| 67 | 
            +
            }
         | 
| 68 | 
            +
            utils.weixinShareInit(config:Share)
         | 
| 16 69 | 
             
            ```
         | 
| 17 70 |  | 
    
        package/dist/index.d.ts
    CHANGED
    
    | @@ -1,2 +1 @@ | |
| 1 | 
            -
            declare  | 
| 2 | 
            -
            export default obj;
         | 
| 1 | 
            +
            declare function app(): void;
         | 
    
        package/dist/index.js
    CHANGED
    
    | @@ -1,19 +1,7 @@ | |
| 1 1 | 
             
            "use strict";
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
                    }
         | 
| 9 | 
            -
                    return t;
         | 
| 10 | 
            -
                };
         | 
| 11 | 
            -
                return __assign.apply(this, arguments);
         | 
| 12 | 
            -
            };
         | 
| 13 | 
            -
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 14 | 
            -
            var storage = require("./storage");
         | 
| 15 | 
            -
            var utils = require("./utils");
         | 
| 16 | 
            -
            var crypto = require("./crypto");
         | 
| 17 | 
            -
            var weixin = require("./weixin");
         | 
| 18 | 
            -
            var obj = __assign(__assign(__assign(__assign({}, storage), utils), weixin), crypto);
         | 
| 19 | 
            -
            exports.default = obj;
         | 
| 2 | 
            +
            // npm run build
         | 
| 3 | 
            +
            // npm publish
         | 
| 4 | 
            +
            function app() {
         | 
| 5 | 
            +
                console.log("xxxx");
         | 
| 6 | 
            +
            }
         | 
| 7 | 
            +
            app();
         | 
    
        package/dist/weixin/index.js
    CHANGED
    
    | @@ -1,7 +1,8 @@ | |
| 1 1 | 
             
            "use strict";
         | 
| 2 2 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 3 3 | 
             
            exports.weixinCode = exports.weixinInit = exports.formatSearch = exports.weixinUrlCode = void 0;
         | 
| 4 | 
            -
             | 
| 4 | 
            +
            // import * as weixin from 'weixin-js-sdk' // 引入微信SDK
         | 
| 5 | 
            +
            var weixin = require("weixin-js-sdk");
         | 
| 5 6 | 
             
            var utils_1 = require("../utils");
         | 
| 6 7 | 
             
            var crypto_1 = require("../crypto");
         | 
| 7 8 | 
             
            var w = window;
         | 
| @@ -140,7 +141,7 @@ function weixinInit() { | |
| 140 141 | 
             
                    wx = w.wx;
         | 
| 141 142 | 
             
                }
         | 
| 142 143 | 
             
                else {
         | 
| 143 | 
            -
                    wx =  | 
| 144 | 
            +
                    wx = weixin;
         | 
| 144 145 | 
             
                }
         | 
| 145 146 | 
             
                return wx;
         | 
| 146 147 | 
             
            }
         | 
    
        package/index.ts
    ADDED
    
    
    
        package/package.json
    CHANGED
    
    | @@ -1,23 +1,30 @@ | |
| 1 | 
            -
            {
         | 
| 2 | 
            -
              "name": "xctc-utils",
         | 
| 3 | 
            -
              "version": "1.0. | 
| 4 | 
            -
              "description": "",
         | 
| 5 | 
            -
              "main": "./dist/index.js",
         | 
| 6 | 
            -
              "types": "./dist/index.d.ts",
         | 
| 7 | 
            -
              "scripts": {
         | 
| 8 | 
            -
                "test": "echo \"Error: no test specified\" && exit 1",
         | 
| 9 | 
            -
                "prepublish": "npm run build",
         | 
| 10 | 
            -
                "build": "tsc"
         | 
| 11 | 
            -
              },
         | 
| 12 | 
            -
              "author": "",
         | 
| 13 | 
            -
              "license": "ISC",
         | 
| 14 | 
            -
              "devDependencies": {
         | 
| 15 | 
            -
                " | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
                " | 
| 21 | 
            -
                " | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "name": "xctc-utils",
         | 
| 3 | 
            +
              "version": "1.0.5",
         | 
| 4 | 
            +
              "description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```",
         | 
| 5 | 
            +
              "main": "./dist/index.js",
         | 
| 6 | 
            +
              "types": "./dist/index.d.ts",
         | 
| 7 | 
            +
              "scripts": {
         | 
| 8 | 
            +
                "test": "echo \"Error: no test specified\" && exit 1",
         | 
| 9 | 
            +
                "prepublish": "npm run build",
         | 
| 10 | 
            +
                "build": "tsc"
         | 
| 11 | 
            +
              },
         | 
| 12 | 
            +
              "author": "",
         | 
| 13 | 
            +
              "license": "ISC",
         | 
| 14 | 
            +
              "devDependencies": {
         | 
| 15 | 
            +
                "@types/node": "^18.11.19",
         | 
| 16 | 
            +
                "ts-node": "^10.9.1",
         | 
| 17 | 
            +
                "typescript": "^4.9.5"
         | 
| 18 | 
            +
              },
         | 
| 19 | 
            +
              "dependencies": {
         | 
| 20 | 
            +
                "@types/crypto-js": "^4.1.1",
         | 
| 21 | 
            +
                "crypto-js": "^4.1.1",
         | 
| 22 | 
            +
                "weixin-js-sdk": "^1.6.0",
         | 
| 23 | 
            +
                "weixin-js-sdk-ts": "^1.6.1"
         | 
| 24 | 
            +
              },
         | 
| 25 | 
            +
              "repository": {
         | 
| 26 | 
            +
                "type": "git",
         | 
| 27 | 
            +
                "url": "git@gitee.com:npm-management/xctc-utils.git"
         | 
| 28 | 
            +
              },
         | 
| 29 | 
            +
              "keywords": []
         | 
| 30 | 
            +
            }
         |