feat: support version option (#23)

* feat: support version option

* docs(README): added version option
This commit is contained in:
Sail
2019-04-01 17:47:17 +08:00
committed by Ivin Wu
parent 68927d274b
commit 0df7cb6bb3
9 changed files with 64 additions and 24 deletions

View File

@@ -384,6 +384,10 @@ wx.chooseImage({
```[不建议使用]``` 设置用户票据的值
### .version
获取 weRequest 版本号
## FAQ
### 我希望在请求时候页面能出现最简单的loading状态该怎么办

View File

@@ -72,4 +72,5 @@ export interface weRequest {
getConfig?: () => IGetConfigResult;
login?: (callback: Function) => void;
setSession?: (x: string) => void;
version?: string;
}

2
build/version.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
declare const version: string;
export { version };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -6,6 +6,7 @@ import login from "./api/login"
import getSession from "./api/getSession"
import getConfig from "./api/getConfig"
import { weRequest } from "./interface"
import { version } from './version'
const weRequestObject: weRequest = {
init,
@@ -14,7 +15,8 @@ const weRequestObject: weRequest = {
setSession,
login,
getSession,
getConfig
getConfig,
version
};
export default weRequestObject;

View File

@@ -152,4 +152,6 @@ export interface weRequest {
login?: (callback: Function) => void;
/* [不建议使用] 设置用户票据的值 */
setSession?: (x: string) => void;
/* 获取weRequest版本 */
version?: string;
}

5
src/version.ts Normal file
View File

@@ -0,0 +1,5 @@
declare const __VERSION__: string;
const version = __VERSION__;
export { version };

View File

@@ -26,6 +26,9 @@ module.exports = [
libraryExport: "default"
},
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pk.version)
}),
new webpack.BannerPlugin({
banner: `weRequest ${pk.version}\n${pk.homepage}`
})
@@ -55,6 +58,9 @@ module.exports = [
},
devtool: "inline-source-map",
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pk.version)
}),
new webpack.BannerPlugin({
banner: `weRequest ${pk.version}\n${pk.homepage}`
})