fast-vue-multi-pages 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,10 +17,14 @@ export declare class FastVueMultiTool {
17
17
  * 页面配置工具类
18
18
  */
19
19
  static Config: typeof FastVueMultiConfig;
20
+ /**
21
+ * 常规的网络接口请求类,返回格式要求为JSON:{success:true,message:"消息",data:{}}
22
+ */
23
+ static SimpleHttp: typeof FastVueMultiHttp.Simple;
20
24
  /**
21
25
  * 网络请求工具类
22
26
  */
23
- static Http: typeof FastVueMultiHttp.Simple;
27
+ static Http: typeof FastVueMultiHttp.Base;
24
28
  /**
25
29
  * 页面数据缓存工具类
26
30
  */
@@ -21,10 +21,14 @@ class FastVueMultiTool {
21
21
  * 页面配置工具类
22
22
  */
23
23
  static Config = FastVueMultiConfig_1.FastVueMultiConfig;
24
+ /**
25
+ * 常规的网络接口请求类,返回格式要求为JSON:{success:true,message:"消息",data:{}}
26
+ */
27
+ static SimpleHttp = FastVueMultiHttp_1.FastVueMultiHttp.Simple;
24
28
  /**
25
29
  * 网络请求工具类
26
30
  */
27
- static Http = FastVueMultiHttp_1.FastVueMultiHttp.Simple;
31
+ static Http = FastVueMultiHttp_1.FastVueMultiHttp.Base;
28
32
  /**
29
33
  * 页面数据缓存工具类
30
34
  */
@@ -3,18 +3,5 @@ export declare class FastVueMultiClipboard {
3
3
  * 将内容复制到剪贴板中
4
4
  * @param content
5
5
  */
6
- static copy(content: string): Promise<void>;
7
- /**
8
- * 将blob复制到剪贴板中
9
- * @param blob
10
- */
11
- static copyBlob(blob: Blob): Promise<void>;
12
- /**
13
- * 获取剪贴板的文本内容
14
- */
15
- static getText(): Promise<string | undefined>;
16
- /**
17
- * 获取剪贴板的ClipboardItem内容
18
- */
19
- static getItems(): Promise<ClipboardItems | undefined>;
6
+ static copy(content: string): void;
20
7
  }
@@ -1,40 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FastVueMultiClipboard = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const copy_to_clipboard_1 = tslib_1.__importDefault(require("copy-to-clipboard"));
4
6
  class FastVueMultiClipboard {
5
7
  /**
6
8
  * 将内容复制到剪贴板中
7
9
  * @param content
8
10
  */
9
11
  static copy(content) {
10
- const clipboard = require("clipboard-polyfill");
11
- return clipboard.writeText(content);
12
- }
13
- /**
14
- * 将blob复制到剪贴板中
15
- * @param blob
16
- */
17
- static copyBlob(blob) {
18
- const clipboard = require("clipboard-polyfill");
19
- let contentType = blob.type;
20
- let items = {};
21
- items[contentType] = blob;
22
- const item = new clipboard.ClipboardItem(items);
23
- return clipboard.write([item]);
24
- }
25
- /**
26
- * 获取剪贴板的文本内容
27
- */
28
- static async getText() {
29
- const clipboard = require("clipboard-polyfill");
30
- return await clipboard.readText();
31
- }
32
- /**
33
- * 获取剪贴板的ClipboardItem内容
34
- */
35
- static async getItems() {
36
- const clipboard = require("clipboard-polyfill");
37
- return await clipboard.read();
12
+ (0, copy_to_clipboard_1.default)(content);
38
13
  }
39
14
  }
40
15
  exports.FastVueMultiClipboard = FastVueMultiClipboard;
@@ -18,4 +18,13 @@ export declare class FastVueMultiWindow {
18
18
  * 安全的获取窗口高度,有的手机渲染后document.body.clientHeight 莫明会返回0
19
19
  */
20
20
  static safeGetClientHeight(): number;
21
+ /**
22
+ * 获取地址栏携带的参数
23
+ * @param paramName 参数名
24
+ */
25
+ static getWindowUrlParam(paramName: string): string | null;
26
+ /**
27
+ * 获取地址栏携带的参数对象信息
28
+ */
29
+ static getWindowUrlInfo(): any;
21
30
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FastVueMultiWindow = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
+ const FastVueMultiHttp_1 = require("../http/FastVueMultiHttp");
6
7
  class FastVueMultiWindow {
7
8
  /**
8
9
  * 添加window的onLoad事件,如果存在onLoad函数名则进行合并
@@ -49,5 +50,18 @@ class FastVueMultiWindow {
49
50
  static safeGetClientHeight() {
50
51
  return Math.max(document.documentElement.clientHeight, document.body.clientHeight);
51
52
  }
53
+ /**
54
+ * 获取地址栏携带的参数
55
+ * @param paramName 参数名
56
+ */
57
+ static getWindowUrlParam(paramName) {
58
+ return FastVueMultiHttp_1.FastVueMultiHttp.Base.getUrlParam(window.location.href, paramName);
59
+ }
60
+ /**
61
+ * 获取地址栏携带的参数对象信息
62
+ */
63
+ static getWindowUrlInfo() {
64
+ return FastVueMultiHttp_1.FastVueMultiHttp.Base.getUrlParamInfo(window.location.href);
65
+ }
52
66
  }
53
67
  exports.FastVueMultiWindow = FastVueMultiWindow;
@@ -17,10 +17,14 @@ export declare class FastVueMultiTool {
17
17
  * 页面配置工具类
18
18
  */
19
19
  static Config: typeof FastVueMultiConfig;
20
+ /**
21
+ * 常规的网络接口请求类,返回格式要求为JSON:{success:true,message:"消息",data:{}}
22
+ */
23
+ static SimpleHttp: typeof FastVueMultiHttp.Simple;
20
24
  /**
21
25
  * 网络请求工具类
22
26
  */
23
- static Http: typeof FastVueMultiHttp.Simple;
27
+ static Http: typeof FastVueMultiHttp.Base;
24
28
  /**
25
29
  * 页面数据缓存工具类
26
30
  */
@@ -13,10 +13,14 @@ define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./o
13
13
  * 页面配置工具类
14
14
  */
15
15
  FastVueMultiTool.Config = FastVueMultiConfig_1.FastVueMultiConfig;
16
+ /**
17
+ * 常规的网络接口请求类,返回格式要求为JSON:{success:true,message:"消息",data:{}}
18
+ */
19
+ FastVueMultiTool.SimpleHttp = FastVueMultiHttp_1.FastVueMultiHttp.Simple;
16
20
  /**
17
21
  * 网络请求工具类
18
22
  */
19
- FastVueMultiTool.Http = FastVueMultiHttp_1.FastVueMultiHttp.Simple;
23
+ FastVueMultiTool.Http = FastVueMultiHttp_1.FastVueMultiHttp.Base;
20
24
  /**
21
25
  * 页面数据缓存工具类
22
26
  */
@@ -3,18 +3,5 @@ export declare class FastVueMultiClipboard {
3
3
  * 将内容复制到剪贴板中
4
4
  * @param content
5
5
  */
6
- static copy(content: string): Promise<void>;
7
- /**
8
- * 将blob复制到剪贴板中
9
- * @param blob
10
- */
11
- static copyBlob(blob: Blob): Promise<void>;
12
- /**
13
- * 获取剪贴板的文本内容
14
- */
15
- static getText(): Promise<string | undefined>;
16
- /**
17
- * 获取剪贴板的ClipboardItem内容
18
- */
19
- static getItems(): Promise<ClipboardItems | undefined>;
6
+ static copy(content: string): void;
20
7
  }
@@ -1,7 +1,8 @@
1
- define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
1
+ define(["require", "exports", "tslib", "copy-to-clipboard"], function (require, exports, tslib_1, copy_to_clipboard_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.FastVueMultiClipboard = void 0;
5
+ copy_to_clipboard_1 = tslib_1.__importDefault(copy_to_clipboard_1);
5
6
  var FastVueMultiClipboard = /** @class */ (function () {
6
7
  function FastVueMultiClipboard() {
7
8
  }
@@ -10,52 +11,7 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
10
11
  * @param content
11
12
  */
12
13
  FastVueMultiClipboard.copy = function (content) {
13
- var clipboard = require("clipboard-polyfill");
14
- return clipboard.writeText(content);
15
- };
16
- /**
17
- * 将blob复制到剪贴板中
18
- * @param blob
19
- */
20
- FastVueMultiClipboard.copyBlob = function (blob) {
21
- var clipboard = require("clipboard-polyfill");
22
- var contentType = blob.type;
23
- var items = {};
24
- items[contentType] = blob;
25
- var item = new clipboard.ClipboardItem(items);
26
- return clipboard.write([item]);
27
- };
28
- /**
29
- * 获取剪贴板的文本内容
30
- */
31
- FastVueMultiClipboard.getText = function () {
32
- return tslib_1.__awaiter(this, void 0, void 0, function () {
33
- var clipboard;
34
- return tslib_1.__generator(this, function (_a) {
35
- switch (_a.label) {
36
- case 0:
37
- clipboard = require("clipboard-polyfill");
38
- return [4 /*yield*/, clipboard.readText()];
39
- case 1: return [2 /*return*/, _a.sent()];
40
- }
41
- });
42
- });
43
- };
44
- /**
45
- * 获取剪贴板的ClipboardItem内容
46
- */
47
- FastVueMultiClipboard.getItems = function () {
48
- return tslib_1.__awaiter(this, void 0, void 0, function () {
49
- var clipboard;
50
- return tslib_1.__generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0:
53
- clipboard = require("clipboard-polyfill");
54
- return [4 /*yield*/, clipboard.read()];
55
- case 1: return [2 /*return*/, _a.sent()];
56
- }
57
- });
58
- });
14
+ (0, copy_to_clipboard_1.default)(content);
59
15
  };
60
16
  return FastVueMultiClipboard;
61
17
  }());
@@ -18,4 +18,13 @@ export declare class FastVueMultiWindow {
18
18
  * 安全的获取窗口高度,有的手机渲染后document.body.clientHeight 莫明会返回0
19
19
  */
20
20
  static safeGetClientHeight(): number;
21
+ /**
22
+ * 获取地址栏携带的参数
23
+ * @param paramName 参数名
24
+ */
25
+ static getWindowUrlParam(paramName: string): string | null;
26
+ /**
27
+ * 获取地址栏携带的参数对象信息
28
+ */
29
+ static getWindowUrlInfo(): any;
21
30
  }
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "lodash"], function (require, exports, tslib_1, lodash_1) {
1
+ define(["require", "exports", "tslib", "lodash", "../http/FastVueMultiHttp"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.FastVueMultiWindow = void 0;
@@ -51,6 +51,19 @@ define(["require", "exports", "tslib", "lodash"], function (require, exports, ts
51
51
  FastVueMultiWindow.safeGetClientHeight = function () {
52
52
  return Math.max(document.documentElement.clientHeight, document.body.clientHeight);
53
53
  };
54
+ /**
55
+ * 获取地址栏携带的参数
56
+ * @param paramName 参数名
57
+ */
58
+ FastVueMultiWindow.getWindowUrlParam = function (paramName) {
59
+ return FastVueMultiHttp_1.FastVueMultiHttp.Base.getUrlParam(window.location.href, paramName);
60
+ };
61
+ /**
62
+ * 获取地址栏携带的参数对象信息
63
+ */
64
+ FastVueMultiWindow.getWindowUrlInfo = function () {
65
+ return FastVueMultiHttp_1.FastVueMultiHttp.Base.getUrlParamInfo(window.location.href);
66
+ };
54
67
  return FastVueMultiWindow;
55
68
  }());
56
69
  exports.FastVueMultiWindow = FastVueMultiWindow;
@@ -0,0 +1,2 @@
1
+ declare const htmlparser2: any;
2
+ declare const singleTag: string[];
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ const htmlparser2 = require("htmlparser2");
3
+ const singleTag = ["br", "hr", "img", "input", "param", "meta", "link", "slot"];
4
+ /**
5
+ * 标签builder插件,用来处理是否排除标签内的代码
6
+ * @author Janesen
7
+ * @param source
8
+ */
9
+ module.exports = function (source) {
10
+ //对应配置的options
11
+ // @ts-ignore
12
+ let legacyLoaderConfig = this.query;
13
+ let parseNewHtml = "";
14
+ let isBreak = false, hasResolve = false;
15
+ const tagName = legacyLoaderConfig.buildLevelTagName;
16
+ const parser = new htmlparser2.Parser({
17
+ onopentag(name, attributes) {
18
+ if (isBreak) {
19
+ return;
20
+ }
21
+ let attr = "";
22
+ let buildConfig = {
23
+ level: 1,
24
+ };
25
+ for (let attributesKey in attributes) {
26
+ let attributesValue = attributes[attributesKey];
27
+ if (attributesValue.length === 0) {
28
+ attr += " " + attributesKey;
29
+ continue;
30
+ }
31
+ if (attributesKey === "level") {
32
+ buildConfig.level = parseInt(attributesValue);
33
+ }
34
+ attr += " " + attributesKey + "=\"" + attributesValue + "\"";
35
+ }
36
+ if (name === tagName) {
37
+ hasResolve = true;
38
+ if (legacyLoaderConfig.buildLevel < buildConfig.level) {
39
+ isBreak = true;
40
+ }
41
+ }
42
+ else {
43
+ if (attr.length > 0) {
44
+ parseNewHtml += "<" + name + " " + attr + " ";
45
+ }
46
+ else {
47
+ parseNewHtml += "<" + name;
48
+ }
49
+ if (singleTag.indexOf(name) >= 0) {
50
+ parseNewHtml += "/>";
51
+ }
52
+ else {
53
+ parseNewHtml += ">";
54
+ }
55
+ }
56
+ },
57
+ ontext(text) {
58
+ if (isBreak) {
59
+ return;
60
+ }
61
+ parseNewHtml += text;
62
+ },
63
+ onclosetag(name) {
64
+ if (name === tagName) {
65
+ isBreak = false;
66
+ }
67
+ if (isBreak) {
68
+ return;
69
+ }
70
+ if (singleTag.indexOf(name) >= 0) {
71
+ return;
72
+ }
73
+ if (name === tagName) {
74
+ return;
75
+ }
76
+ parseNewHtml += "</" + name + ">";
77
+ },
78
+ }, {
79
+ recognizeSelfClosing: true,
80
+ lowerCaseTags: false,
81
+ lowerCaseAttributeNames: false
82
+ });
83
+ parser.write(source);
84
+ parser.end();
85
+ if (hasResolve) {
86
+ return parseNewHtml;
87
+ }
88
+ return source;
89
+ };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "fast-vue-multi-pages",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "author": "janesen",
5
5
  "description": "快速搭建VUE项目工具类的基本库,主要用于每个功能页面独立生成html",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",
8
8
  "scripts": {
9
- "tsc": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && tsc -p ./src/vue/tsconfig-cjs.json",
9
+ "tsc": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && tsc -p ./src/vue/tsconfig-cjs.json && tsc -p ./src/loader/tsconfig-cjs.json",
10
10
  "login": "npm login",
11
11
  "buildLocal": "npm run tsc",
12
12
  "push-fastchar-appjs": "npm run buildLocal && npm publish"
@@ -29,8 +29,8 @@
29
29
  "store2": "^2.14.3",
30
30
  "moment": "^2.30.1",
31
31
  "@types/js-cookie": "^3.0.6",
32
- "clipboard-polyfill": "^4.1.0",
33
- "@types/lodash": "^4.17.6"
32
+ "@types/lodash": "^4.17.6",
33
+ "copy-to-clipboard": "^3.3.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@typescript-eslint/eslint-plugin": "^7.16.0",
@@ -43,7 +43,8 @@
43
43
  "files": [
44
44
  "dist/cjs",
45
45
  "dist/esm",
46
- "vue"
46
+ "vue",
47
+ "loader"
47
48
  ],
48
49
  "eslintConfig": {
49
50
  "root": true,
@@ -10,7 +10,7 @@ export declare class FastVueMultiPages {
10
10
  * @param dirName 项目根目录,建议取值 {@link __dirname}
11
11
  * @param options 更多选项配置 {@link FastBuildOption}
12
12
  */
13
- static getDefaultVueConfig(dirName: string, options: FastBuildOption): any;
13
+ static getVueConfig(dirName: string, options: FastBuildOption): any;
14
14
  /**
15
15
  * 设置全局变量值
16
16
  * @param key 变量名
@@ -42,14 +42,6 @@ export declare class FastVueMultiPages {
42
42
  * @param argument
43
43
  */
44
44
  static getScriptArgumentValue(argument: string): string | null;
45
- /**
46
- * 获取命令参数 --src
47
- */
48
- static getSrcPageDir(): string | null;
49
- /**
50
- * 获取命令参数 --out
51
- */
52
- static getOutPageDir(): string | null;
53
45
  /**
54
46
  * 获取命令参数 --debug 的值
55
47
  */
@@ -15,7 +15,7 @@ class FastVueMultiPages {
15
15
  * @param dirName 项目根目录,建议取值 {@link __dirname}
16
16
  * @param options 更多选项配置 {@link FastBuildOption}
17
17
  */
18
- static getDefaultVueConfig(dirName, options) {
18
+ static getVueConfig(dirName, options) {
19
19
  if (options) {
20
20
  options = FastBuildOption_1.FastBuildOption.merge(options, new FastBuildOption_1.FastBuildOption());
21
21
  }
@@ -74,13 +74,9 @@ class FastVueMultiPages {
74
74
  const cacheDir = path.join(dirName, options.nodeModulesDir, ".cache", "vue-loader");
75
75
  this.removeFile(cacheDir);
76
76
  }
77
- let outPageDir = this.getOutPageDir();
78
- if (!outPageDir) {
79
- outPageDir = options.projectOutDir;
80
- }
81
77
  const { defineConfig } = require('@vue/cli-service');
82
78
  return defineConfig({
83
- outputDir: outPageDir,
79
+ outputDir: options.projectOutDir,
84
80
  assetsDir: options.projectAssetsDir,
85
81
  productionSourceMap: false,
86
82
  publicPath: this.isVueCliServerBuild() ? "./" : '/',
@@ -90,7 +86,7 @@ class FastVueMultiPages {
90
86
  extract: false, //取消css单独生成文件
91
87
  },
92
88
  chainWebpack: (config) => {
93
- let tagLoaderPath = "fast-vue-multi-pages/dist/cjs/loader/FastTagBuilderLoader";
89
+ let tagLoaderPath = "fast-vue-multi-pages/loader";
94
90
  //版本标签加载器
95
91
  config.module
96
92
  .rule('vue')
@@ -244,18 +240,6 @@ class FastVueMultiPages {
244
240
  }
245
241
  return null;
246
242
  }
247
- /**
248
- * 获取命令参数 --src
249
- */
250
- static getSrcPageDir() {
251
- return this.getScriptArgumentValue("--src");
252
- }
253
- /**
254
- * 获取命令参数 --out
255
- */
256
- static getOutPageDir() {
257
- return this.getScriptArgumentValue("--out");
258
- }
259
243
  /**
260
244
  * 获取命令参数 --debug 的值
261
245
  */