tingglelaoo / wxtoken Goto Github PK
View Code? Open in Web Editor NEW获取微信token
获取微信token
有几个问题,你可以优化下的:
方法应尽量定义在prototype里面,现在你大部分写在Token那个构造函数里面了,扣性能细节的话会影响Token类的实例化性能
现在用了轮询检查刷新的方法,其实可以不用轮询的。每次从服务端获取Token的时候,
2.1 看是否有文件缓存
2.2 如果没有,则从服务器端获取,并存入缓存
2.3 如果有,拿(当前时间戳 - 已缓存的Token的时间戳),看是否超出过期时间
2.3.1 如果超出过期时间,进入2.2
2.3.2 如果没过期,直接返回缓存的Token
新建一个utils的目录,将auth.js放到utils目录下
配置类型的信息都可以放config.js中
即将 APPID和APPSECRET抽到config.js中
module.exports = {
APPID: process.env.APP_ID
APPSECRET: process.env.APP_SECRET
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.