fast-vue-multi-pages 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +63 -0
- package/dist/cjs/FastVueMultiTool.d.ts +60 -0
- package/dist/cjs/FastVueMultiTool.js +65 -0
- package/dist/cjs/http/FastVueMultiCookie.d.ts +18 -0
- package/dist/cjs/http/FastVueMultiCookie.js +30 -0
- package/dist/cjs/http/FastVueMultiHttp.d.ts +225 -0
- package/dist/cjs/http/FastVueMultiHttp.js +572 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/loader/FastTagBuilderLoader.d.ts +2 -0
- package/dist/cjs/loader/FastTagBuilderLoader.js +89 -0
- package/dist/cjs/other/FastVueMultiBoolean.d.ts +13 -0
- package/dist/cjs/other/FastVueMultiBoolean.js +56 -0
- package/dist/cjs/other/FastVueMultiClipboard.d.ts +21 -0
- package/dist/cjs/other/FastVueMultiClipboard.js +38 -0
- package/dist/cjs/other/FastVueMultiDate.d.ts +30 -0
- package/dist/cjs/other/FastVueMultiDate.js +166 -0
- package/dist/cjs/other/FastVueMultiElement.d.ts +46 -0
- package/dist/cjs/other/FastVueMultiElement.js +154 -0
- package/dist/cjs/other/FastVueMultiFunction.d.ts +19 -0
- package/dist/cjs/other/FastVueMultiFunction.js +68 -0
- package/dist/cjs/other/FastVueMultiStore.d.ts +13 -0
- package/dist/cjs/other/FastVueMultiStore.js +23 -0
- package/dist/cjs/other/FastVueMultiWindow.d.ts +21 -0
- package/dist/cjs/other/FastVueMultiWindow.js +53 -0
- package/dist/cjs/store/FastVueMultiStore.d.ts +13 -0
- package/dist/cjs/store/FastVueMultiStore.js +23 -0
- package/dist/cjs/vue/FastVueMultiConfig.d.ts +18 -0
- package/dist/cjs/vue/FastVueMultiConfig.js +43 -0
- package/dist/esm/FastVueMultiTool.d.ts +60 -0
- package/dist/esm/FastVueMultiTool.js +59 -0
- package/dist/esm/http/FastVueMultiCookie.d.ts +18 -0
- package/dist/esm/http/FastVueMultiCookie.js +34 -0
- package/dist/esm/http/FastVueMultiHttp.d.ts +225 -0
- package/dist/esm/http/FastVueMultiHttp.js +608 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/loader/FastTagBuilderLoader.d.ts +2 -0
- package/dist/esm/loader/FastTagBuilderLoader.js +89 -0
- package/dist/esm/other/FastVueMultiBoolean.d.ts +13 -0
- package/dist/esm/other/FastVueMultiBoolean.js +60 -0
- package/dist/esm/other/FastVueMultiClipboard.d.ts +21 -0
- package/dist/esm/other/FastVueMultiClipboard.js +56 -0
- package/dist/esm/other/FastVueMultiDate.d.ts +30 -0
- package/dist/esm/other/FastVueMultiDate.js +170 -0
- package/dist/esm/other/FastVueMultiElement.d.ts +46 -0
- package/dist/esm/other/FastVueMultiElement.js +158 -0
- package/dist/esm/other/FastVueMultiFunction.d.ts +19 -0
- package/dist/esm/other/FastVueMultiFunction.js +97 -0
- package/dist/esm/other/FastVueMultiStore.d.ts +13 -0
- package/dist/esm/other/FastVueMultiStore.js +27 -0
- package/dist/esm/other/FastVueMultiWindow.d.ts +21 -0
- package/dist/esm/other/FastVueMultiWindow.js +57 -0
- package/dist/esm/store/FastVueMultiStore.d.ts +13 -0
- package/dist/esm/store/FastVueMultiStore.js +27 -0
- package/dist/esm/vue/FastVueMultiConfig.d.ts +18 -0
- package/dist/esm/vue/FastVueMultiConfig.js +48 -0
- package/package.json +64 -0
- package/vue/FastBuildOption.d.ts +241 -0
- package/vue/FastBuildOption.js +249 -0
- package/vue/FastInjectJsPlugin.d.ts +11 -0
- package/vue/FastInjectJsPlugin.js +101 -0
- package/vue/FastPages.d.ts +25 -0
- package/vue/FastPages.js +173 -0
- package/vue/FastVueMultiConfig.d.ts +18 -0
- package/vue/FastVueMultiConfig.js +43 -0
- package/vue/FastVueMultiPages.d.ts +62 -0
- package/vue/FastVueMultiPages.js +294 -0
- package/vue/index.d.ts +2 -0
- package/vue/index.js +5 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiWindow = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
6
|
+
class FastVueMultiWindow {
|
7
|
+
/**
|
8
|
+
* 添加window的onLoad事件,如果存在onLoad函数名则进行合并
|
9
|
+
* @param callBack
|
10
|
+
*/
|
11
|
+
static addOnLoad(callBack) {
|
12
|
+
let oldOnload = window.onload;
|
13
|
+
if (lodash_1.default.isFunction(oldOnload)) {
|
14
|
+
window.onload = function () {
|
15
|
+
oldOnload();
|
16
|
+
callBack();
|
17
|
+
};
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
window.onload = callBack;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* 添加window的函数,如果存在相同的函数名则进行合并
|
25
|
+
* @param functionName 函数名
|
26
|
+
* @param functionBody 函数执行的代码
|
27
|
+
*/
|
28
|
+
static addFunction(functionName, functionBody) {
|
29
|
+
let targetFunction = window[functionName];
|
30
|
+
if (lodash_1.default.isFunction(targetFunction)) {
|
31
|
+
window[functionName] = function () {
|
32
|
+
targetFunction.apply(this, arguments);
|
33
|
+
functionBody.apply(this, arguments);
|
34
|
+
};
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
window[functionName] = functionBody;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
/**
|
41
|
+
* 安全的获取窗口宽度,有的手机渲染后document.body.clientWidth 莫明会返回0
|
42
|
+
*/
|
43
|
+
static safeGetClientWidth() {
|
44
|
+
return Math.max(document.documentElement.clientWidth, document.body.clientWidth);
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* 安全的获取窗口高度,有的手机渲染后document.body.clientHeight 莫明会返回0
|
48
|
+
*/
|
49
|
+
static safeGetClientHeight() {
|
50
|
+
return Math.max(document.documentElement.clientHeight, document.body.clientHeight);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
exports.FastVueMultiWindow = FastVueMultiWindow;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiStore = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const store2_1 = tslib_1.__importDefault(require("store2"));
|
6
|
+
class FastVueMultiStore {
|
7
|
+
/**
|
8
|
+
* 设置缓存的值
|
9
|
+
* @param key 键
|
10
|
+
* @param value 值
|
11
|
+
*/
|
12
|
+
static setValue(key, value) {
|
13
|
+
store2_1.default.set(key, value, true);
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* 获取缓存的值
|
17
|
+
* @param key 键
|
18
|
+
*/
|
19
|
+
static getValue(key) {
|
20
|
+
return store2_1.default.get(key);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
exports.FastVueMultiStore = FastVueMultiStore;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export declare class FastVueMultiConfig {
|
2
|
+
private static getGlobalConfigObj;
|
3
|
+
/**
|
4
|
+
* 获取系统全局变量值
|
5
|
+
*/
|
6
|
+
static getGlobalConfig(configKey: string): any;
|
7
|
+
/**
|
8
|
+
* 设置系统全局变量值
|
9
|
+
* @param configKey 变量名称
|
10
|
+
* @param configValue 变量值
|
11
|
+
*/
|
12
|
+
static setGlobalConfig(configKey: string, configValue: any): void;
|
13
|
+
/**
|
14
|
+
* 判断目标级别是否在项目配置的编译级别内
|
15
|
+
* @param targetLevel
|
16
|
+
*/
|
17
|
+
static isBuildLevel(targetLevel: number): boolean;
|
18
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiConfig = void 0;
|
4
|
+
class FastVueMultiConfig {
|
5
|
+
static getGlobalConfigObj() {
|
6
|
+
// @ts-ignore
|
7
|
+
if (!window["__SystemGlobalConfig"]) {
|
8
|
+
//注意:此处变量 SystemGlobalConfig 在 webpack.DefinePlugin 编译后会替换成原始值,所以需要用window对象存储一下
|
9
|
+
// @ts-ignore
|
10
|
+
window["__SystemGlobalConfig"] = SystemGlobalConfig;
|
11
|
+
}
|
12
|
+
// @ts-ignore
|
13
|
+
return window["__SystemGlobalConfig"];
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* 获取系统全局变量值
|
17
|
+
*/
|
18
|
+
static getGlobalConfig(configKey) {
|
19
|
+
try {
|
20
|
+
return this.getGlobalConfigObj()[configKey];
|
21
|
+
}
|
22
|
+
catch (e) {
|
23
|
+
console.error("获取全局变量配置异常!", e);
|
24
|
+
return null;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* 设置系统全局变量值
|
29
|
+
* @param configKey 变量名称
|
30
|
+
* @param configValue 变量值
|
31
|
+
*/
|
32
|
+
static setGlobalConfig(configKey, configValue) {
|
33
|
+
this.getGlobalConfigObj()[configKey] = configValue;
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* 判断目标级别是否在项目配置的编译级别内
|
37
|
+
* @param targetLevel
|
38
|
+
*/
|
39
|
+
static isBuildLevel(targetLevel) {
|
40
|
+
return BuildLevel >= targetLevel;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
exports.FastVueMultiConfig = FastVueMultiConfig;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import _ from "lodash";
|
2
|
+
import { FastVueMultiHttp } from "./http/FastVueMultiHttp";
|
3
|
+
import { FastVueMultiStore } from "./other/FastVueMultiStore";
|
4
|
+
import { FastVueMultiConfig } from "./vue/FastVueMultiConfig";
|
5
|
+
import { FastVueMultiCookie } from "./http/FastVueMultiCookie";
|
6
|
+
import { FastVueMultiClipboard } from "./other/FastVueMultiClipboard";
|
7
|
+
import { FastVueMultiDate } from "./other/FastVueMultiDate";
|
8
|
+
import { FastVueMultiBoolean } from "./other/FastVueMultiBoolean";
|
9
|
+
import { FastVueMultiFunction } from "./other/FastVueMultiFunction";
|
10
|
+
import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
11
|
+
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
|
+
/**
|
13
|
+
* FastBaseApp 手机APP功能工具类
|
14
|
+
*/
|
15
|
+
export declare class FastVueMultiTool {
|
16
|
+
/**
|
17
|
+
* 页面配置工具类
|
18
|
+
*/
|
19
|
+
static Config: typeof FastVueMultiConfig;
|
20
|
+
/**
|
21
|
+
* 网络请求工具类
|
22
|
+
*/
|
23
|
+
static Http: typeof FastVueMultiHttp.Simple;
|
24
|
+
/**
|
25
|
+
* 页面数据缓存工具类
|
26
|
+
*/
|
27
|
+
static Store: typeof FastVueMultiStore;
|
28
|
+
/**
|
29
|
+
* cookie操作
|
30
|
+
*/
|
31
|
+
static Cookie: typeof FastVueMultiCookie;
|
32
|
+
/**
|
33
|
+
* 剪贴板操作
|
34
|
+
*/
|
35
|
+
static Clipboard: typeof FastVueMultiClipboard;
|
36
|
+
/**
|
37
|
+
* Lodash工具类 https://lodash.com/docs/
|
38
|
+
*/
|
39
|
+
static Lodash: _.LoDashStatic;
|
40
|
+
/**
|
41
|
+
* 日期类操作
|
42
|
+
*/
|
43
|
+
static Date: typeof FastVueMultiDate;
|
44
|
+
/**
|
45
|
+
* boolean工具类
|
46
|
+
*/
|
47
|
+
static Boolean: typeof FastVueMultiBoolean;
|
48
|
+
/**
|
49
|
+
* function工具类
|
50
|
+
*/
|
51
|
+
static Function: typeof FastVueMultiFunction;
|
52
|
+
/**
|
53
|
+
* html元素操作工具类
|
54
|
+
*/
|
55
|
+
static Element: typeof FastVueMultiElement;
|
56
|
+
/**
|
57
|
+
* window对象相关操作
|
58
|
+
*/
|
59
|
+
static Window: typeof FastVueMultiWindow;
|
60
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./other/FastVueMultiStore", "./vue/FastVueMultiConfig", "./http/FastVueMultiCookie", "./other/FastVueMultiClipboard", "./other/FastVueMultiDate", "./other/FastVueMultiBoolean", "./other/FastVueMultiFunction", "./other/FastVueMultiElement", "./other/FastVueMultiWindow"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1, FastVueMultiStore_1, FastVueMultiConfig_1, FastVueMultiCookie_1, FastVueMultiClipboard_1, FastVueMultiDate_1, FastVueMultiBoolean_1, FastVueMultiFunction_1, FastVueMultiElement_1, FastVueMultiWindow_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.FastVueMultiTool = void 0;
|
5
|
+
lodash_1 = tslib_1.__importDefault(lodash_1);
|
6
|
+
/**
|
7
|
+
* FastBaseApp 手机APP功能工具类
|
8
|
+
*/
|
9
|
+
var FastVueMultiTool = /** @class */ (function () {
|
10
|
+
function FastVueMultiTool() {
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* 页面配置工具类
|
14
|
+
*/
|
15
|
+
FastVueMultiTool.Config = FastVueMultiConfig_1.FastVueMultiConfig;
|
16
|
+
/**
|
17
|
+
* 网络请求工具类
|
18
|
+
*/
|
19
|
+
FastVueMultiTool.Http = FastVueMultiHttp_1.FastVueMultiHttp.Simple;
|
20
|
+
/**
|
21
|
+
* 页面数据缓存工具类
|
22
|
+
*/
|
23
|
+
FastVueMultiTool.Store = FastVueMultiStore_1.FastVueMultiStore;
|
24
|
+
/**
|
25
|
+
* cookie操作
|
26
|
+
*/
|
27
|
+
FastVueMultiTool.Cookie = FastVueMultiCookie_1.FastVueMultiCookie;
|
28
|
+
/**
|
29
|
+
* 剪贴板操作
|
30
|
+
*/
|
31
|
+
FastVueMultiTool.Clipboard = FastVueMultiClipboard_1.FastVueMultiClipboard;
|
32
|
+
/**
|
33
|
+
* Lodash工具类 https://lodash.com/docs/
|
34
|
+
*/
|
35
|
+
FastVueMultiTool.Lodash = lodash_1.default;
|
36
|
+
/**
|
37
|
+
* 日期类操作
|
38
|
+
*/
|
39
|
+
FastVueMultiTool.Date = FastVueMultiDate_1.FastVueMultiDate;
|
40
|
+
/**
|
41
|
+
* boolean工具类
|
42
|
+
*/
|
43
|
+
FastVueMultiTool.Boolean = FastVueMultiBoolean_1.FastVueMultiBoolean;
|
44
|
+
/**
|
45
|
+
* function工具类
|
46
|
+
*/
|
47
|
+
FastVueMultiTool.Function = FastVueMultiFunction_1.FastVueMultiFunction;
|
48
|
+
/**
|
49
|
+
* html元素操作工具类
|
50
|
+
*/
|
51
|
+
FastVueMultiTool.Element = FastVueMultiElement_1.FastVueMultiElement;
|
52
|
+
/**
|
53
|
+
* window对象相关操作
|
54
|
+
*/
|
55
|
+
FastVueMultiTool.Window = FastVueMultiWindow_1.FastVueMultiWindow;
|
56
|
+
return FastVueMultiTool;
|
57
|
+
}());
|
58
|
+
exports.FastVueMultiTool = FastVueMultiTool;
|
59
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export declare class FastVueMultiCookie {
|
2
|
+
/**
|
3
|
+
* 设置cookie
|
4
|
+
* @param key 键
|
5
|
+
* @param value 值
|
6
|
+
*/
|
7
|
+
static setCookie(key: string, value: string): void;
|
8
|
+
/**
|
9
|
+
* 获取cookie
|
10
|
+
* @param key 键
|
11
|
+
*/
|
12
|
+
static getCookie(key: string): string | undefined;
|
13
|
+
/**
|
14
|
+
* 删除cookie
|
15
|
+
* @param key 键
|
16
|
+
*/
|
17
|
+
static removeCookie(key: string): void;
|
18
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
define(["require", "exports", "tslib", "js-cookie"], function (require, exports, tslib_1, js_cookie_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.FastVueMultiCookie = void 0;
|
5
|
+
js_cookie_1 = tslib_1.__importDefault(js_cookie_1);
|
6
|
+
var FastVueMultiCookie = /** @class */ (function () {
|
7
|
+
function FastVueMultiCookie() {
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* 设置cookie
|
11
|
+
* @param key 键
|
12
|
+
* @param value 值
|
13
|
+
*/
|
14
|
+
FastVueMultiCookie.setCookie = function (key, value) {
|
15
|
+
js_cookie_1.default.set(key, value);
|
16
|
+
};
|
17
|
+
/**
|
18
|
+
* 获取cookie
|
19
|
+
* @param key 键
|
20
|
+
*/
|
21
|
+
FastVueMultiCookie.getCookie = function (key) {
|
22
|
+
return js_cookie_1.default.get(key);
|
23
|
+
};
|
24
|
+
/**
|
25
|
+
* 删除cookie
|
26
|
+
* @param key 键
|
27
|
+
*/
|
28
|
+
FastVueMultiCookie.removeCookie = function (key) {
|
29
|
+
js_cookie_1.default.remove(key);
|
30
|
+
};
|
31
|
+
return FastVueMultiCookie;
|
32
|
+
}());
|
33
|
+
exports.FastVueMultiCookie = FastVueMultiCookie;
|
34
|
+
});
|
@@ -0,0 +1,225 @@
|
|
1
|
+
import { AxiosPromise } from "axios";
|
2
|
+
/**
|
3
|
+
* FastVueMultiHttp 网咯请求接口工具类
|
4
|
+
* @author Janesen
|
5
|
+
*/
|
6
|
+
export declare namespace FastVueMultiHttp {
|
7
|
+
/**
|
8
|
+
* 基本的网络请求接口
|
9
|
+
*/
|
10
|
+
class Base {
|
11
|
+
/**
|
12
|
+
* 获取地址栏携带的参数
|
13
|
+
* @param paramName 参数名
|
14
|
+
*/
|
15
|
+
static getWindowUrlParam(paramName: string): string | null;
|
16
|
+
/**
|
17
|
+
* 获取地址栏携带的参数对象信息
|
18
|
+
*/
|
19
|
+
static getWindowUrlInfo(): any;
|
20
|
+
/**
|
21
|
+
* 获取url的参数
|
22
|
+
* @param url 地址
|
23
|
+
* @param paramName 参数名
|
24
|
+
*/
|
25
|
+
static getUrlParam(url: string, paramName: string): string | null;
|
26
|
+
/**
|
27
|
+
* 获取url的参数实体对象
|
28
|
+
* @param url 地址
|
29
|
+
*/
|
30
|
+
static getUrlParamInfo(url: string): any;
|
31
|
+
/**
|
32
|
+
* 追加url参数
|
33
|
+
* @param url
|
34
|
+
* @param params
|
35
|
+
*/
|
36
|
+
static appendUrlParams(url: string, params: any): string;
|
37
|
+
/**
|
38
|
+
* 合并多个FormData参数
|
39
|
+
* @param formData
|
40
|
+
*/
|
41
|
+
static mergeFormData(...formData: FormData[]): FormData;
|
42
|
+
/**
|
43
|
+
* 如果是formData对象则转转换参数为object对象
|
44
|
+
* @param param
|
45
|
+
*/
|
46
|
+
static convertToObject(param: any): object;
|
47
|
+
/**
|
48
|
+
* 转换参数为FormData格式
|
49
|
+
* @param param 任意格式的参数,FormData、Object、Function
|
50
|
+
*/
|
51
|
+
static convertToFormData(param: any): FormData;
|
52
|
+
/**
|
53
|
+
* 合并参数并转换为FormData格式
|
54
|
+
* @param params 任意多个参数,FormData、Object、Function
|
55
|
+
*/
|
56
|
+
static mergeParams(...params: any[]): FormData;
|
57
|
+
/**
|
58
|
+
* 将数组格式的参数合并
|
59
|
+
* @param params 数组
|
60
|
+
*/
|
61
|
+
static mergeParamsByArray(params: any[]): FormData;
|
62
|
+
/**
|
63
|
+
* 发起接口请求
|
64
|
+
* @param method 请求方法,例如,post、get
|
65
|
+
* @param url 请求地址
|
66
|
+
* @param params 请求参数
|
67
|
+
*/
|
68
|
+
static doRequest(method: string, url: string, params: any): AxiosPromise;
|
69
|
+
/**
|
70
|
+
* 执行post请求
|
71
|
+
* @param url 请求地址
|
72
|
+
* @param params 请求参数,可为object或form data
|
73
|
+
*/
|
74
|
+
static doPost(url: string, params: any): AxiosPromise;
|
75
|
+
/**
|
76
|
+
* 执行get请求
|
77
|
+
* @param url 请求接口地址
|
78
|
+
* @param params 请求接口参数
|
79
|
+
*/
|
80
|
+
static doGet(url: string, params?: any): AxiosPromise;
|
81
|
+
/**
|
82
|
+
* 获取请求接口的默认头信息配置
|
83
|
+
*/
|
84
|
+
static getFinalHeaders(): any;
|
85
|
+
/**
|
86
|
+
* 设置请求头
|
87
|
+
* @param key
|
88
|
+
* @param value
|
89
|
+
*/
|
90
|
+
static setFinalHeader(key: string, value: string): void;
|
91
|
+
/**
|
92
|
+
* 获取接口的全局参数,同步获取了原生APP的全局参数
|
93
|
+
*/
|
94
|
+
static getFinalParams(): any;
|
95
|
+
/**
|
96
|
+
* 设置全局请求参数
|
97
|
+
* @param key
|
98
|
+
* @param value
|
99
|
+
*/
|
100
|
+
static setFinalParam(key: string, value: any): void;
|
101
|
+
/**
|
102
|
+
* 构建接口请求的缓存key
|
103
|
+
* @param url 请求地址
|
104
|
+
* @param params 请求参数
|
105
|
+
*/
|
106
|
+
static buildCacheKey(url: string, params: any): string;
|
107
|
+
}
|
108
|
+
/**
|
109
|
+
* 常规的接口请求类,返回格式要求为JSON:{success:true,message:"消息",data:{}}
|
110
|
+
*/
|
111
|
+
class Simple extends Base {
|
112
|
+
/**
|
113
|
+
* 发起请求接口
|
114
|
+
* @param method 请求方法,例如:post、get
|
115
|
+
* @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
|
116
|
+
* @param params 参数
|
117
|
+
* @param config 请求配置
|
118
|
+
* @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
|
119
|
+
*/
|
120
|
+
static request(method: string, url: string, params: any, config?: SimpleRequestConfig, callBack?: (result: SimpleJsonResponse) => void): Promise<SimpleJsonResponse>;
|
121
|
+
/**
|
122
|
+
* post请求接口
|
123
|
+
* @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
|
124
|
+
* @param params 参数
|
125
|
+
* @param config 请求配置
|
126
|
+
* @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
|
127
|
+
*/
|
128
|
+
static post(url: string, params: any, config?: SimpleRequestConfig, callBack?: (result: SimpleJsonResponse) => void): Promise<SimpleJsonResponse>;
|
129
|
+
/**
|
130
|
+
* get请求接口
|
131
|
+
* @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
|
132
|
+
* @param params 参数
|
133
|
+
* @param config 请求配置
|
134
|
+
* @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
|
135
|
+
*/
|
136
|
+
static get(url: string, params: any, config?: SimpleRequestConfig, callBack?: (result: SimpleJsonResponse) => void): Promise<SimpleJsonResponse>;
|
137
|
+
}
|
138
|
+
/**
|
139
|
+
* 常规返回数据的格式解析类 JSON:{success:true,message:"消息",data:{}}
|
140
|
+
*/
|
141
|
+
class SimpleJsonResponse {
|
142
|
+
responseData: any;
|
143
|
+
cacheData: boolean;
|
144
|
+
requestConfig: SimpleRequestConfig;
|
145
|
+
constructor(responseData: any, cacheData?: boolean);
|
146
|
+
/**
|
147
|
+
* 获取接口返回的原始数据
|
148
|
+
*/
|
149
|
+
getResponseData(): any;
|
150
|
+
/**
|
151
|
+
* 判断当前回调的数据是否是缓存的数据
|
152
|
+
*/
|
153
|
+
isCacheData(): boolean;
|
154
|
+
/**
|
155
|
+
* 判断接口是否请求成功-success
|
156
|
+
*/
|
157
|
+
isSuccess(): boolean;
|
158
|
+
/**
|
159
|
+
* 获取接口请求返回的状态值-code
|
160
|
+
*/
|
161
|
+
getCode(): number;
|
162
|
+
/**
|
163
|
+
* 获取接口请求返回的消息提示-message
|
164
|
+
*/
|
165
|
+
getMessage(): string;
|
166
|
+
/**
|
167
|
+
* 获取接口请求返回的数据-data
|
168
|
+
*/
|
169
|
+
getData(): any;
|
170
|
+
/**
|
171
|
+
* 获取接口请求返回的其他数据,例如:data_1、data_2
|
172
|
+
* @param suffixIndex 数据后缀,例如:data_1 后缀传 1
|
173
|
+
*/
|
174
|
+
getOtherData(suffixIndex: number): any;
|
175
|
+
/**
|
176
|
+
* 判断接口返回的数据data是否是分页的数据
|
177
|
+
*/
|
178
|
+
isPageData(): boolean;
|
179
|
+
/**
|
180
|
+
* 获取接口返回的数据列表,如果data是分页数据则返回分页的列表,否则返回data
|
181
|
+
*/
|
182
|
+
getList(): any[];
|
183
|
+
/**
|
184
|
+
* 获取接口列表分页数据的页数
|
185
|
+
*/
|
186
|
+
getPage(): number;
|
187
|
+
/**
|
188
|
+
* 获取接口列表分页数据的总页数
|
189
|
+
*/
|
190
|
+
getTotalPage(): number;
|
191
|
+
/**
|
192
|
+
* 获取接口列表分页数据的总行数
|
193
|
+
*/
|
194
|
+
getTotalRow(): number;
|
195
|
+
/**
|
196
|
+
* 获取接口列表分页数据的每页大小
|
197
|
+
*/
|
198
|
+
getPageSize(): number;
|
199
|
+
/**
|
200
|
+
* 是否已加载结束,当page>=totalPage 或 list 为空时,认为加载已结束
|
201
|
+
*/
|
202
|
+
isFinished(): boolean;
|
203
|
+
}
|
204
|
+
/**
|
205
|
+
* 接口请求配置类
|
206
|
+
*/
|
207
|
+
class SimpleRequestConfig {
|
208
|
+
/**
|
209
|
+
* 是否追加全局参数,默认true
|
210
|
+
*/
|
211
|
+
finalParams: boolean;
|
212
|
+
/**
|
213
|
+
* 是否缓存数据,true:检测到有当前接口的缓存数据时,将回调缓存的数据
|
214
|
+
*/
|
215
|
+
cache: boolean;
|
216
|
+
/**
|
217
|
+
* 是否总是缓存数据,true:无论是否已有缓存数据,都将请求接口并刷新当前缓存的数据,不支持then方法接收
|
218
|
+
*/
|
219
|
+
alwaysCache: boolean;
|
220
|
+
/**
|
221
|
+
* 是否总是回调接口请求返回的数据,true:如果有缓存第一次回调缓存数据,第二次回调接口返回的数据,否则值回调一次接口返回的数据,不支持then方法接收
|
222
|
+
*/
|
223
|
+
alwaysBackRequest: boolean;
|
224
|
+
}
|
225
|
+
}
|