xframelib 0.5.4 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,12 +20,18 @@ export interface IUIObject {
20
20
  WebSite?: string;
21
21
  /**
22
22
  * 超时锁屏时间(单位:秒s)
23
+ * 自动锁屏时间,为0不锁屏。
23
24
  */
24
25
  LockTime?: number;
25
26
  /**
26
27
  * 是否是能访问互联网,还是内网部署应用
27
28
  * */
28
29
  IsInternet?: boolean;
30
+ /**
31
+ * 网站灰色模式,用于可能悼念的日期开启
32
+ * 默认为false
33
+ */
34
+ GrayMode?: boolean;
29
35
  /**
30
36
  * 其他扩展的属性
31
37
  */
@@ -38,7 +44,19 @@ export interface IServiceURL {
38
44
  /**
39
45
  * 用户登录(统一用户登录)
40
46
  */
41
- LoginAuthURL: string;
47
+ LoginAuthURL?: string;
48
+ /**
49
+ * 文件管理服务地址(统一文件管理:后台)
50
+ */
51
+ FileServiceURL?: string;
52
+ /**
53
+ * 文件管理(统一文件管理:前台)
54
+ */
55
+ FileOnlineURL?: string;
56
+ /**
57
+ * 在线日志服务(统一文件管理)
58
+ */
59
+ LogServiceURL?: string;
42
60
  /**
43
61
  * Axios普通WebAPI的BaseURL
44
62
  * 全局默认的http请求地址(一般与主hprose相同或不同);文件上传地址
@@ -100,3 +118,26 @@ export interface ISystemConfig {
100
118
  APIPath?: object;
101
119
  [props: string]: any;
102
120
  }
121
+ import { Component } from 'vue';
122
+ export declare type Lazy<T> = () => Promise<T>;
123
+ /**
124
+ * 窗体内容配置接口
125
+ */
126
+ export interface IModalConfig {
127
+ /**
128
+ * 唯一ID,与组件名一致
129
+ */
130
+ id: string;
131
+ /**
132
+ * 说明信息
133
+ */
134
+ label?: string;
135
+ /**
136
+ * 动态加载的组件
137
+ */
138
+ component: Lazy<Component>;
139
+ /**
140
+ * 其他可扩展的属性
141
+ */
142
+ [props: string]: any;
143
+ }
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'vue';
2
- export declare type Lazy<T> = () => Promise<T>;
2
+ import type { Lazy } from './Config';
3
3
  /**
4
4
  *布局枚举类型
5
5
  */
@@ -12,155 +12,169 @@
12
12
  to open up a link that will start the download
13
13
  -->
14
14
  <script>
15
- // This will prevent the sw from restarting
16
- let keepAlive = () => {
17
- keepAlive = () => {}
18
- var ping = location.href.substr(0, location.href.lastIndexOf('/')) + '/ping'
19
- var interval = setInterval(() => {
20
- if (sw) {
21
- sw.postMessage('ping')
22
- } else {
23
- fetch(ping).then(res => res.text(!res.ok && clearInterval(interval)))
24
- }
25
- }, 10000)
26
- }
27
-
28
- // message event is the first thing we need to setup a listner for
29
- // don't want the opener to do a random timeout - instead they can listen for
30
- // the ready event
31
- // but since we need to wait for the Service Worker registration, we store the
32
- // message for later
33
- let messages = []
34
- window.onmessage = evt => messages.push(evt)
35
-
36
- let sw = null
37
- let scope = ''
38
-
39
- function registerWorker() {
40
- return navigator.serviceWorker.getRegistration('./').then(swReg => {
41
- return swReg || navigator.serviceWorker.register('sw.js', { scope: './' })
42
- }).then(swReg => {
43
- const swRegTmp = swReg.installing || swReg.waiting
44
-
45
- scope = swReg.scope
46
-
47
- return (sw = swReg.active) || new Promise(resolve => {
48
- swRegTmp.addEventListener('statechange', fn = () => {
49
- if (swRegTmp.state === 'activated') {
50
- swRegTmp.removeEventListener('statechange', fn)
51
- sw = swReg.active
52
- resolve()
53
- }
15
+ // This will prevent the sw from restarting
16
+ let keepAlive = () => {
17
+ keepAlive = () => {};
18
+ var ping = location.href.substring(0, location.href.lastIndexOf('/')) + '/ping';
19
+ var interval = setInterval(() => {
20
+ if (sw) {
21
+ sw.postMessage('ping');
22
+ } else {
23
+ fetch(ping).then(res => res.text(!res.ok && clearInterval(interval)));
24
+ }
25
+ }, 10000);
26
+ };
27
+
28
+ // message event is the first thing we need to setup a listner for
29
+ // don't want the opener to do a random timeout - instead they can listen for
30
+ // the ready event
31
+ // but since we need to wait for the Service Worker registration, we store the
32
+ // message for later
33
+ let messages = [];
34
+ window.onmessage = evt => messages.push(evt);
35
+
36
+ let sw = null;
37
+ let scope = '';
38
+
39
+ function registerWorker() {
40
+ return navigator.serviceWorker
41
+ .getRegistration('./')
42
+ .then(swReg => {
43
+ return swReg || navigator.serviceWorker.register('sw.js', { scope: './' });
54
44
  })
55
- })
56
- })
57
- }
58
-
59
- // Now that we have the Service Worker registered we can process messages
60
- function onMessage (event) {
61
- let { data, ports, origin } = event
62
-
63
- // It's important to have a messageChannel, don't want to interfere
64
- // with other simultaneous downloads
65
- if (!ports || !ports.length) {
66
- throw new TypeError("[StreamSaver] You didn't send a messageChannel")
45
+ .then(swReg => {
46
+ const swRegTmp = swReg.installing || swReg.waiting;
47
+
48
+ scope = swReg.scope;
49
+
50
+ return (
51
+ (sw = swReg.active) ||
52
+ new Promise(resolve => {
53
+ swRegTmp.addEventListener(
54
+ 'statechange',
55
+ (fn = () => {
56
+ if (swRegTmp.state === 'activated') {
57
+ swRegTmp.removeEventListener('statechange', fn);
58
+ sw = swReg.active;
59
+ resolve();
60
+ }
61
+ })
62
+ );
63
+ })
64
+ );
65
+ });
67
66
  }
68
67
 
69
- if (typeof data !== 'object') {
70
- throw new TypeError("[StreamSaver] You didn't send a object")
71
- }
68
+ // Now that we have the Service Worker registered we can process messages
69
+ function onMessage(event) {
70
+ let { data, ports, origin } = event;
72
71
 
73
- // the default public service worker for StreamSaver is shared among others.
74
- // so all download links needs to be prefixed to avoid any other conflict
75
- data.origin = origin
72
+ // It's important to have a messageChannel, don't want to interfere
73
+ // with other simultaneous downloads
74
+ if (!ports || !ports.length) {
75
+ throw new TypeError("[StreamSaver] You didn't send a messageChannel");
76
+ }
76
77
 
77
- // if we ever (in some feature versoin of streamsaver) would like to
78
- // redirect back to the page of who initiated a http request
79
- data.referrer = data.referrer || document.referrer || origin
78
+ if (typeof data !== 'object') {
79
+ throw new TypeError("[StreamSaver] You didn't send a object");
80
+ }
80
81
 
81
- // pass along version for possible backwards compatibility in sw.js
82
- data.streamSaverVersion = new URLSearchParams(location.search).get('version')
82
+ // the default public service worker for StreamSaver is shared among others.
83
+ // so all download links needs to be prefixed to avoid any other conflict
84
+ data.origin = origin;
83
85
 
84
- if (data.streamSaverVersion === '1.2.0') {
85
- console.warn('[StreamSaver] please update streamsaver')
86
- }
86
+ // if we ever (in some feature versoin of streamsaver) would like to
87
+ // redirect back to the page of who initiated a http request
88
+ data.referrer = data.referrer || document.referrer || origin;
87
89
 
88
- /** @since v2.0.0 */
89
- if (!data.headers) {
90
- console.warn("[StreamSaver] pass `data.headers` that you would like to pass along to the service worker\nit should be a 2D array or a key/val object that fetch's Headers api accepts")
91
- } else {
92
- // test if it's correct
93
- // should thorw a typeError if not
94
- new Headers(data.headers)
95
- }
90
+ // pass along version for possible backwards compatibility in sw.js
91
+ data.streamSaverVersion = new URLSearchParams(location.search).get('version');
96
92
 
97
- /** @since v2.0.0 */
98
- if (typeof data.filename === 'string') {
99
- console.warn("[StreamSaver] You shouldn't send `data.filename` anymore. It should be included in the Content-Disposition header option")
100
- // Do what File constructor do with fileNames
101
- data.filename = data.filename.replace(/\//g, ':')
102
- }
93
+ if (data.streamSaverVersion === '1.2.0') {
94
+ console.warn('[StreamSaver] please update streamsaver');
95
+ }
103
96
 
104
- /** @since v2.0.0 */
105
- if (data.size) {
106
- console.warn("[StreamSaver] You shouldn't send `data.size` anymore. It should be included in the content-length header option")
107
- }
97
+ /** @since v2.0.0 */
98
+ if (!data.headers) {
99
+ console.warn(
100
+ "[StreamSaver] pass `data.headers` that you would like to pass along to the service worker\nit should be a 2D array or a key/val object that fetch's Headers api accepts"
101
+ );
102
+ } else {
103
+ // test if it's correct
104
+ // should thorw a typeError if not
105
+ new Headers(data.headers);
106
+ }
108
107
 
109
- /** @since v2.0.0 */
110
- if (data.readableStream) {
111
- console.warn("[StreamSaver] You should send the readableStream in the messageChannel, not throught mitm")
112
- }
108
+ /** @since v2.0.0 */
109
+ if (typeof data.filename === 'string') {
110
+ console.warn(
111
+ "[StreamSaver] You shouldn't send `data.filename` anymore. It should be included in the Content-Disposition header option"
112
+ );
113
+ // Do what File constructor do with fileNames
114
+ data.filename = data.filename.replace(/\//g, ':');
115
+ }
113
116
 
114
- /** @since v2.0.0 */
115
- if (!data.pathname) {
116
- console.warn("[StreamSaver] Please send `data.pathname` (eg: /pictures/summer.jpg)")
117
- data.pathname = Math.random().toString().slice(-6) + '/' + data.filename
118
- }
117
+ /** @since v2.0.0 */
118
+ if (data.size) {
119
+ console.warn(
120
+ "[StreamSaver] You shouldn't send `data.size` anymore. It should be included in the content-length header option"
121
+ );
122
+ }
119
123
 
120
- // remove all leading slashes
121
- data.pathname = data.pathname.replace(/^\/+/g, '')
124
+ /** @since v2.0.0 */
125
+ if (data.readableStream) {
126
+ console.warn(
127
+ '[StreamSaver] You should send the readableStream in the messageChannel, not throught mitm'
128
+ );
129
+ }
122
130
 
123
- // remove protocol
124
- let org = origin.replace(/(^\w+:|^)\/\//, '')
131
+ /** @since v2.0.0 */
132
+ if (!data.pathname) {
133
+ console.warn('[StreamSaver] Please send `data.pathname` (eg: /pictures/summer.jpg)');
134
+ data.pathname = Math.random().toString().slice(-6) + '/' + data.filename;
135
+ }
125
136
 
126
- // set the absolute pathname to the download url.
127
- data.url = new URL(`${scope + org}/${data.pathname}`).toString()
137
+ // remove all leading slashes
138
+ data.pathname = data.pathname.replace(/^\/+/g, '');
128
139
 
129
- if (!data.url.startsWith(`${scope + org}/`)) {
130
- throw new TypeError('[StreamSaver] bad `data.pathname`')
131
- }
140
+ // remove protocol
141
+ let org = origin.replace(/(^\w+:|^)\/\//, '');
142
+
143
+ // set the absolute pathname to the download url.
144
+ data.url = new URL(`${scope + org}/${data.pathname}`).toString();
132
145
 
133
- // This sends the message data as well as transferring
134
- // messageChannel.port2 to the service worker. The service worker can
135
- // then use the transferred port to reply via postMessage(), which
136
- // will in turn trigger the onmessage handler on messageChannel.port1.
146
+ if (!data.url.startsWith(`${scope + org}/`)) {
147
+ throw new TypeError('[StreamSaver] bad `data.pathname`');
148
+ }
149
+
150
+ // This sends the message data as well as transferring
151
+ // messageChannel.port2 to the service worker. The service worker can
152
+ // then use the transferred port to reply via postMessage(), which
153
+ // will in turn trigger the onmessage handler on messageChannel.port1.
137
154
 
138
- const transferable = data.readableStream
139
- ? [ ports[0], data.readableStream ]
140
- : [ ports[0] ]
155
+ const transferable = data.readableStream ? [ports[0], data.readableStream] : [ports[0]];
156
+
157
+ if (!(data.readableStream || data.transferringReadable)) {
158
+ keepAlive();
159
+ }
141
160
 
142
- if (!(data.readableStream || data.transferringReadable)) {
143
- keepAlive()
161
+ return sw.postMessage(data, transferable);
144
162
  }
145
163
 
146
- return sw.postMessage(data, transferable)
147
- }
148
-
149
- if (window.opener) {
150
- // The opener can't listen to onload event, so we need to help em out!
151
- // (telling them that we are ready to accept postMessage's)
152
- window.opener.postMessage('StreamSaver::loadedPopup', '*')
153
- }
154
-
155
- if (navigator.serviceWorker) {
156
- registerWorker().then(() => {
157
- window.onmessage = onMessage
158
- messages.forEach(window.onmessage)
159
- })
160
- } else {
161
- // FF can ping sw with fetch from a secure hidden iframe
162
- // shouldn't really be possible?
163
- keepAlive()
164
- }
164
+ if (window.opener) {
165
+ // The opener can't listen to onload event, so we need to help em out!
166
+ // (telling them that we are ready to accept postMessage's)
167
+ window.opener.postMessage('StreamSaver::loadedPopup', '*');
168
+ }
165
169
 
170
+ if (navigator.serviceWorker) {
171
+ registerWorker().then(() => {
172
+ window.onmessage = onMessage;
173
+ messages.forEach(window.onmessage);
174
+ });
175
+ } else {
176
+ // FF can ping sw with fetch from a secure hidden iframe
177
+ // shouldn't really be possible?
178
+ keepAlive();
179
+ }
166
180
  </script>
@@ -95,4 +95,23 @@ export default class H5Tool {
95
95
  * @param text
96
96
  */
97
97
  static copyText: (text: string) => Promise<unknown>;
98
+ /**
99
+ * 设置是否开启网站灰模式
100
+ * @param isGray 是否暗灰模式
101
+ */
102
+ static setGrayMode(isGray: boolean): void;
103
+ /**
104
+ * 开关 HTML元素的Style类名
105
+ * @param flag
106
+ * @param clsName
107
+ * @param target
108
+ */
109
+ static toggleClass(flag: boolean, clsName: string, target?: HTMLElement): void;
110
+ /**
111
+ * 设置 css 变量(全局)
112
+ * @param prop
113
+ * @param val
114
+ * @param dom
115
+ */
116
+ static setCssVar(prop: string, val: any, dom?: HTMLElement): void;
98
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xframelib",
3
- "version": "0.5.4",
3
+ "version": "0.5.7",
4
4
  "description": "积累的前端开发基础库",
5
5
  "main": "dist/index.js",
6
6
  "common": "dist/index.cjs",
@@ -34,14 +34,14 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@rollup/plugin-alias": "^3.1.9",
37
- "@rollup/plugin-commonjs": "^21.0.2",
37
+ "@rollup/plugin-commonjs": "^21.0.3",
38
38
  "@rollup/plugin-json": "^4.1.0",
39
39
  "@rollup/plugin-node-resolve": "^13.1.3",
40
40
  "@rollup/plugin-typescript": "^8.3.1",
41
41
  "@types/streamsaver": "^2.0.1",
42
42
  "@vitejs/plugin-vue": "^2.2.4",
43
43
  "@vue/compiler-sfc": "^3.2.31",
44
- "esbuild": "^0.14.27",
44
+ "esbuild": "^0.14.28",
45
45
  "rimraf": "^3.0.2",
46
46
  "rollup-plugin-copy": "^3.4.0",
47
47
  "rollup-plugin-esbuild": "^4.8.2",
@@ -50,10 +50,10 @@
50
50
  "rollup-plugin-typescript2": "^0.31.2",
51
51
  "rollup-plugin-vue": "^6.0.0",
52
52
  "sass": "^1.49.9",
53
- "typescript": "^4.6.2",
53
+ "typescript": "^4.6.3",
54
54
  "vite": "^2.8.6",
55
55
  "vue": "^3.2.31",
56
56
  "vue-router": "^4.0.14",
57
- "vue-tsc": "^0.33.2"
57
+ "vue-tsc": "^0.33.9"
58
58
  }
59
59
  }