fast-vue-multi-pages 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/README.md +63 -0
  2. package/dist/cjs/FastVueMultiTool.d.ts +60 -0
  3. package/dist/cjs/FastVueMultiTool.js +65 -0
  4. package/dist/cjs/http/FastVueMultiCookie.d.ts +18 -0
  5. package/dist/cjs/http/FastVueMultiCookie.js +30 -0
  6. package/dist/cjs/http/FastVueMultiHttp.d.ts +225 -0
  7. package/dist/cjs/http/FastVueMultiHttp.js +572 -0
  8. package/dist/cjs/index.d.ts +2 -0
  9. package/dist/cjs/index.js +5 -0
  10. package/dist/cjs/loader/FastTagBuilderLoader.d.ts +2 -0
  11. package/dist/cjs/loader/FastTagBuilderLoader.js +89 -0
  12. package/dist/cjs/other/FastVueMultiBoolean.d.ts +13 -0
  13. package/dist/cjs/other/FastVueMultiBoolean.js +56 -0
  14. package/dist/cjs/other/FastVueMultiClipboard.d.ts +21 -0
  15. package/dist/cjs/other/FastVueMultiClipboard.js +38 -0
  16. package/dist/cjs/other/FastVueMultiDate.d.ts +30 -0
  17. package/dist/cjs/other/FastVueMultiDate.js +166 -0
  18. package/dist/cjs/other/FastVueMultiElement.d.ts +46 -0
  19. package/dist/cjs/other/FastVueMultiElement.js +154 -0
  20. package/dist/cjs/other/FastVueMultiFunction.d.ts +19 -0
  21. package/dist/cjs/other/FastVueMultiFunction.js +68 -0
  22. package/dist/cjs/other/FastVueMultiStore.d.ts +13 -0
  23. package/dist/cjs/other/FastVueMultiStore.js +23 -0
  24. package/dist/cjs/other/FastVueMultiWindow.d.ts +21 -0
  25. package/dist/cjs/other/FastVueMultiWindow.js +53 -0
  26. package/dist/cjs/store/FastVueMultiStore.d.ts +13 -0
  27. package/dist/cjs/store/FastVueMultiStore.js +23 -0
  28. package/dist/cjs/vue/FastVueMultiConfig.d.ts +18 -0
  29. package/dist/cjs/vue/FastVueMultiConfig.js +43 -0
  30. package/dist/esm/FastVueMultiTool.d.ts +60 -0
  31. package/dist/esm/FastVueMultiTool.js +59 -0
  32. package/dist/esm/http/FastVueMultiCookie.d.ts +18 -0
  33. package/dist/esm/http/FastVueMultiCookie.js +34 -0
  34. package/dist/esm/http/FastVueMultiHttp.d.ts +225 -0
  35. package/dist/esm/http/FastVueMultiHttp.js +608 -0
  36. package/dist/esm/index.d.ts +2 -0
  37. package/dist/esm/index.js +6 -0
  38. package/dist/esm/loader/FastTagBuilderLoader.d.ts +2 -0
  39. package/dist/esm/loader/FastTagBuilderLoader.js +89 -0
  40. package/dist/esm/other/FastVueMultiBoolean.d.ts +13 -0
  41. package/dist/esm/other/FastVueMultiBoolean.js +60 -0
  42. package/dist/esm/other/FastVueMultiClipboard.d.ts +21 -0
  43. package/dist/esm/other/FastVueMultiClipboard.js +56 -0
  44. package/dist/esm/other/FastVueMultiDate.d.ts +30 -0
  45. package/dist/esm/other/FastVueMultiDate.js +170 -0
  46. package/dist/esm/other/FastVueMultiElement.d.ts +46 -0
  47. package/dist/esm/other/FastVueMultiElement.js +158 -0
  48. package/dist/esm/other/FastVueMultiFunction.d.ts +19 -0
  49. package/dist/esm/other/FastVueMultiFunction.js +97 -0
  50. package/dist/esm/other/FastVueMultiStore.d.ts +13 -0
  51. package/dist/esm/other/FastVueMultiStore.js +27 -0
  52. package/dist/esm/other/FastVueMultiWindow.d.ts +21 -0
  53. package/dist/esm/other/FastVueMultiWindow.js +57 -0
  54. package/dist/esm/store/FastVueMultiStore.d.ts +13 -0
  55. package/dist/esm/store/FastVueMultiStore.js +27 -0
  56. package/dist/esm/vue/FastVueMultiConfig.d.ts +18 -0
  57. package/dist/esm/vue/FastVueMultiConfig.js +48 -0
  58. package/package.json +64 -0
  59. package/vue/FastBuildOption.d.ts +241 -0
  60. package/vue/FastBuildOption.js +249 -0
  61. package/vue/FastInjectJsPlugin.d.ts +11 -0
  62. package/vue/FastInjectJsPlugin.js +101 -0
  63. package/vue/FastPages.d.ts +25 -0
  64. package/vue/FastPages.js +173 -0
  65. package/vue/FastVueMultiConfig.d.ts +18 -0
  66. package/vue/FastVueMultiConfig.js +43 -0
  67. package/vue/FastVueMultiPages.d.ts +62 -0
  68. package/vue/FastVueMultiPages.js +294 -0
  69. package/vue/index.d.ts +2 -0
  70. package/vue/index.js +5 -0
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # fast-vue-multi-pages
2
+ ### 快速搭建VUE项目工具类的基本库,主要用于每个功能页面独立生成html,不使用vue单页面功能。
3
+
4
+ ## Install
5
+ ```
6
+ npm i fast-vue-multi-pages
7
+ ```
8
+
9
+ ## Package.json配置
10
+
11
+ ```
12
+ "dependencies": {
13
+ "fast-vue-multi-pages": "^1.0.0", //具体版本以npm库更新为准
14
+ }
15
+ ```
16
+
17
+
18
+
19
+ ## 配置vue.config.js 文件,快速配置VUE项目代码,复制如下代码:
20
+ ```
21
+ const {FastVueMultiPages} = require("fast-vue-multi-pages/vue");
22
+
23
+ const result = FastVueMultiPages.getDefaultVueConfig(__dirname, {
24
+ projectTitle: "项目标题",
25
+ projectPagesDir: ["src/user_pages"],
26
+ projectOutDir: "dist",
27
+ autoCreateProjectIndexPage: false,
28
+ autoCreatePageConfigFile: true,
29
+ buildLevel: 1,
30
+ httpFinalParams: {
31
+ userTest: true,
32
+ },
33
+ httpBeforeRequest: function (config) {
34
+ console.log("httpBeforeRequest", config);
35
+ },
36
+ httpAfterRequest: function (response) {
37
+ console.log("httpAfterRequest", response);
38
+ },
39
+ globalConfig: {},
40
+ injectJsFiles: ["src/js/iconfont.js"],
41
+ clientStrict: true
42
+ });
43
+
44
+ module.exports = result;
45
+ ```
46
+
47
+
48
+ # 使用默认工具类
49
+
50
+ ### 引用库之后,在项目中导入即可,例如:
51
+ ```
52
+ import {FastVueMultiTool} from "fast-vue-multi-pages";
53
+
54
+ FastVueMultiTool.Http.get("接口地址", {
55
+ orderId: 1
56
+ }).then(result => {
57
+ if (result.isSuccess()) {
58
+ console.error(result.getData());
59
+ } else {
60
+ console.error(result.getMessage());
61
+ }
62
+ });
63
+ ```
@@ -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,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastVueMultiTool = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
+ const FastVueMultiHttp_1 = require("./http/FastVueMultiHttp");
7
+ const FastVueMultiStore_1 = require("./other/FastVueMultiStore");
8
+ const FastVueMultiConfig_1 = require("./vue/FastVueMultiConfig");
9
+ const FastVueMultiCookie_1 = require("./http/FastVueMultiCookie");
10
+ const FastVueMultiClipboard_1 = require("./other/FastVueMultiClipboard");
11
+ const FastVueMultiDate_1 = require("./other/FastVueMultiDate");
12
+ const FastVueMultiBoolean_1 = require("./other/FastVueMultiBoolean");
13
+ const FastVueMultiFunction_1 = require("./other/FastVueMultiFunction");
14
+ const FastVueMultiElement_1 = require("./other/FastVueMultiElement");
15
+ const FastVueMultiWindow_1 = require("./other/FastVueMultiWindow");
16
+ /**
17
+ * FastBaseApp 手机APP功能工具类
18
+ */
19
+ class FastVueMultiTool {
20
+ /**
21
+ * 页面配置工具类
22
+ */
23
+ static Config = FastVueMultiConfig_1.FastVueMultiConfig;
24
+ /**
25
+ * 网络请求工具类
26
+ */
27
+ static Http = FastVueMultiHttp_1.FastVueMultiHttp.Simple;
28
+ /**
29
+ * 页面数据缓存工具类
30
+ */
31
+ static Store = FastVueMultiStore_1.FastVueMultiStore;
32
+ /**
33
+ * cookie操作
34
+ */
35
+ static Cookie = FastVueMultiCookie_1.FastVueMultiCookie;
36
+ /**
37
+ * 剪贴板操作
38
+ */
39
+ static Clipboard = FastVueMultiClipboard_1.FastVueMultiClipboard;
40
+ /**
41
+ * Lodash工具类 https://lodash.com/docs/
42
+ */
43
+ static Lodash = lodash_1.default;
44
+ /**
45
+ * 日期类操作
46
+ */
47
+ static Date = FastVueMultiDate_1.FastVueMultiDate;
48
+ /**
49
+ * boolean工具类
50
+ */
51
+ static Boolean = FastVueMultiBoolean_1.FastVueMultiBoolean;
52
+ /**
53
+ * function工具类
54
+ */
55
+ static Function = FastVueMultiFunction_1.FastVueMultiFunction;
56
+ /**
57
+ * html元素操作工具类
58
+ */
59
+ static Element = FastVueMultiElement_1.FastVueMultiElement;
60
+ /**
61
+ * window对象相关操作
62
+ */
63
+ static Window = FastVueMultiWindow_1.FastVueMultiWindow;
64
+ }
65
+ exports.FastVueMultiTool = FastVueMultiTool;
@@ -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,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastVueMultiCookie = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const js_cookie_1 = tslib_1.__importDefault(require("js-cookie"));
6
+ class FastVueMultiCookie {
7
+ /**
8
+ * 设置cookie
9
+ * @param key 键
10
+ * @param value 值
11
+ */
12
+ static setCookie(key, value) {
13
+ js_cookie_1.default.set(key, value);
14
+ }
15
+ /**
16
+ * 获取cookie
17
+ * @param key 键
18
+ */
19
+ static getCookie(key) {
20
+ return js_cookie_1.default.get(key);
21
+ }
22
+ /**
23
+ * 删除cookie
24
+ * @param key 键
25
+ */
26
+ static removeCookie(key) {
27
+ js_cookie_1.default.remove(key);
28
+ }
29
+ }
30
+ exports.FastVueMultiCookie = FastVueMultiCookie;
@@ -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
+ }