emacroh5lib 1.0.0 → 1.0.3
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.
- package/README.md +10 -4
- package/package.json +16 -4
- package/src/components/HelloWorld.vue +3 -3
- package/src/components/MessageBox.jsx +117 -0
- package/src/components/MessageBoxTest.tsx +11 -0
- package/src/index.ts +34 -12
- package/src/main.ts +3 -1
- package/src/router/index.ts +11 -1
- package/src/shims-vue.d.ts +2 -2
- package/src/utilities/File.ts +51 -19
- package/src/views/DragResizeView/index.vue +3 -0
- package/src/views/DragResizeView/vue-drag-resize.css +46 -0
- package/src/views/DragResizeView/vue-drag-resize.html +17 -0
- package/src/views/DragResizeView/vue-drag-resize.js +868 -0
- package/src/views/ExcelExporter/index.less +16 -0
- package/src/views/ExcelExporter/index.vue +74 -0
- package/src/views/FileViewer/index.less +16 -0
- package/src/views/FileViewer/index.vue +78 -0
- package/src/views/HomeView.vue +2 -0
- package/src/views/ImageViewer/index.vue +505 -0
- package/src/views/ImageViewer/style/css/index.css +186 -0
- package/src/views/ImageViewer/style/css/index.less +212 -0
- package/src/views/ImageViewer/style/images/icons.png +0 -0
- package/src/views/TestView/Export2Excel.ts +496 -0
- package/src/views/TestView/index.less +25 -0
- package/src/views/TestView/index.vue +231 -0
- package/src/views/TestView/list.json +12007 -0
- package/src/vue-prototype.d.ts +7 -0
- package/tsconfig.json +4 -3
- package/typings.d.ts +1 -1
- package/webpack.config.js +52 -4
package/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
##
|
2
|
-
npm
|
1
|
+
## 安装
|
2
|
+
npm i emacroh5lib --registry https://registry.npmjs.org/
|
3
3
|
|
4
|
-
##
|
5
|
-
npm publish --registry https://registry.npmjs.org/
|
4
|
+
## 读取excel表格数据
|
6
5
|
|
6
|
+
``` JavaScript
|
7
|
+
EMacro.File.readLocalExcel((file, workbook) => {
|
8
|
+
console.log("file", file);
|
9
|
+
console.log("workbook", workbook);
|
10
|
+
console.log("数据", workbook.Sheets["工作表1"]["G32"]);
|
11
|
+
});
|
12
|
+
```
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "emacroh5lib",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
4
4
|
"description": "EMacro前端组件库",
|
5
5
|
"main": "./dist/emacroh5lib.min.js",
|
6
6
|
"types": "./dist/types/index.d.ts",
|
@@ -10,9 +10,10 @@
|
|
10
10
|
"build:prod": "webpack --mode=production --node-env=production",
|
11
11
|
"test:unit": "vue-cli-service test:unit",
|
12
12
|
"test:e2e": "vue-cli-service test:e2e",
|
13
|
+
"e2e": "vue-cli-service test:e2e",
|
13
14
|
"watch": "webpack --watch",
|
14
15
|
"serve": "webpack serve",
|
15
|
-
"dev": "
|
16
|
+
"dev": "vue-cli-service test:e2e",
|
16
17
|
"commit": "cz",
|
17
18
|
"test": "echo \"Error: no test specified\" && exit 1"
|
18
19
|
},
|
@@ -65,6 +66,8 @@
|
|
65
66
|
"ts-jest": "^27.1.4",
|
66
67
|
"ts-loader": "^9.2.8",
|
67
68
|
"typescript": "^4.6.3",
|
69
|
+
"vue-loader": "^15.7.0",
|
70
|
+
"vue-router": "^3.1.3",
|
68
71
|
"vue-template-compiler": "^2.6.14",
|
69
72
|
"webpack": "^5.72.0",
|
70
73
|
"webpack-cli": "^4.9.2",
|
@@ -72,15 +75,22 @@
|
|
72
75
|
},
|
73
76
|
"dependencies": {
|
74
77
|
"@tweenjs/tween.js": "^18.6.4",
|
78
|
+
"@types/file-saver": "^2.0.5",
|
75
79
|
"@types/js-cookie": "^3.0.1",
|
76
80
|
"@vue/cli-plugin-typescript": "^5.0.4",
|
77
81
|
"axios": "^0.26.1",
|
78
82
|
"core-js": "^3.22.2",
|
83
|
+
"deep-eql": "^4.0.0",
|
79
84
|
"echarts": "^5.3.2",
|
80
85
|
"echarts-gl": "^2.0.9",
|
81
86
|
"element-ui": "^2.15.8",
|
87
|
+
"file-saver": "^2.0.5",
|
88
|
+
"hammerjs": "^2.0.8",
|
82
89
|
"jquery": "^3.6.0",
|
83
90
|
"js-cookie": "^3.0.1",
|
91
|
+
"js-xlsx": "^0.8.22",
|
92
|
+
"lay-excel": "^1.7.6",
|
93
|
+
"query-string": "^7.0.1",
|
84
94
|
"register-service-worker": "^1.7.2",
|
85
95
|
"three": "^0.139.2",
|
86
96
|
"typings": "^2.1.1",
|
@@ -88,7 +98,9 @@
|
|
88
98
|
"vue-class-component": "^7.2.3",
|
89
99
|
"vue-echarts": "^6.0.2",
|
90
100
|
"vue-property-decorator": "^9.1.2",
|
91
|
-
"vue-
|
92
|
-
"vuex": "^3.6.2"
|
101
|
+
"vue-tsx-support": "^3.2.0",
|
102
|
+
"vuex": "^3.6.2",
|
103
|
+
"xlsx": "^0.18.5",
|
104
|
+
"xlsx-style": "^0.8.13"
|
93
105
|
}
|
94
106
|
}
|
@@ -83,11 +83,11 @@
|
|
83
83
|
<script lang="ts">
|
84
84
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
85
85
|
|
86
|
-
@Component
|
86
|
+
@Component({ name: "HelloWorld" })
|
87
87
|
export default class HelloWorld extends Vue {
|
88
|
-
@Prop() private msg!: string;
|
88
|
+
@Prop() private msg!: string;
|
89
89
|
|
90
|
-
public test():void{
|
90
|
+
public test(): void {
|
91
91
|
|
92
92
|
console.log(this.msg);
|
93
93
|
|
@@ -0,0 +1,117 @@
|
|
1
|
+
|
2
|
+
// 输入框支持搜索
|
3
|
+
//
|
4
|
+
export default {
|
5
|
+
data() {
|
6
|
+
return {
|
7
|
+
msg: "default",
|
8
|
+
};
|
9
|
+
},
|
10
|
+
props: {
|
11
|
+
data: { type: Array, default: [] },
|
12
|
+
placeholder: {
|
13
|
+
type: String,
|
14
|
+
default: ''
|
15
|
+
},
|
16
|
+
defaultValue: {
|
17
|
+
type: String,
|
18
|
+
default: ''
|
19
|
+
},
|
20
|
+
css: {
|
21
|
+
type: String,
|
22
|
+
default: 'width: 300px;'
|
23
|
+
},
|
24
|
+
// 失去焦点时回调
|
25
|
+
focus: {
|
26
|
+
type: Function,
|
27
|
+
default: () => {
|
28
|
+
console.log('focus');
|
29
|
+
}
|
30
|
+
},
|
31
|
+
blur: {
|
32
|
+
type: Function,
|
33
|
+
default: () => {
|
34
|
+
console.log('blur');
|
35
|
+
}
|
36
|
+
},
|
37
|
+
// 选中 option,或 input 的 value 变化(combobox 模式下)时,调用此函数
|
38
|
+
change: {
|
39
|
+
type: Function,
|
40
|
+
default: (value, option) => {
|
41
|
+
console.log('change');
|
42
|
+
}
|
43
|
+
},
|
44
|
+
// 键盘按下时回调
|
45
|
+
inputKeydown: {
|
46
|
+
type: Function,
|
47
|
+
default: (event) => {
|
48
|
+
console.log('inputKeydown', event);
|
49
|
+
}
|
50
|
+
},
|
51
|
+
// 鼠标移入时回调
|
52
|
+
mouseenter: {
|
53
|
+
type: Function,
|
54
|
+
default: (event) => {
|
55
|
+
console.log('mouseenter', event);
|
56
|
+
}
|
57
|
+
},
|
58
|
+
// 鼠标移出时回调
|
59
|
+
mouseleave: {
|
60
|
+
type: Function,
|
61
|
+
default: (event) => {
|
62
|
+
console.log('mouseleave', event);
|
63
|
+
}
|
64
|
+
},
|
65
|
+
// 下拉列表滚动时的回调
|
66
|
+
popupScroll: {
|
67
|
+
type: Function,
|
68
|
+
default: (event) => {
|
69
|
+
console.log('popupScroll', event);
|
70
|
+
}
|
71
|
+
},
|
72
|
+
// 文本框值变化时回调
|
73
|
+
search: {
|
74
|
+
type: Function,
|
75
|
+
default: (value) => {
|
76
|
+
console.log('search', value);
|
77
|
+
}
|
78
|
+
},
|
79
|
+
// 被选中时调用,参数为选中项的 value (或 key) 值
|
80
|
+
select: {
|
81
|
+
type: Function,
|
82
|
+
default: (value, option) => {
|
83
|
+
console.log('select', value, option);
|
84
|
+
}
|
85
|
+
},
|
86
|
+
// 展开下拉菜单的回调
|
87
|
+
dropdownVisibleChange: {
|
88
|
+
type: Function,
|
89
|
+
default: (open) => {
|
90
|
+
console.log('dropdownVisibleChange', open);
|
91
|
+
}
|
92
|
+
},
|
93
|
+
},
|
94
|
+
methods: {
|
95
|
+
click(msg) {
|
96
|
+
// 子组件 input的事件回调
|
97
|
+
// 实现 改变msg值
|
98
|
+
// this.user = '123';
|
99
|
+
console.log(msg);
|
100
|
+
}
|
101
|
+
},
|
102
|
+
render() {
|
103
|
+
return (
|
104
|
+
<div>
|
105
|
+
<div>你好撒发射点 </div>
|
106
|
+
<a-select show-search placeholder={this.placeholder} option-filter-prop="children" style={this.css}
|
107
|
+
onfocus={this.focus} onblur={this.blur} onchange={this.change} oninputKeydown={this.inputKeydown} defaultValue={this.defaultValue}>
|
108
|
+
{
|
109
|
+
this.data.map(item => {
|
110
|
+
return <a-select-option value={item}>{item}</a-select-option>
|
111
|
+
})
|
112
|
+
}
|
113
|
+
</a-select>
|
114
|
+
</div>
|
115
|
+
);
|
116
|
+
}
|
117
|
+
};
|
package/src/index.ts
CHANGED
@@ -1,21 +1,43 @@
|
|
1
1
|
|
2
|
+
import { EMacro } from "./utilities/File";
|
3
|
+
|
4
|
+
|
5
|
+
import FileViewer from './views/FileViewer/index.vue'
|
6
|
+
import ImageViewer from './views/ImageViewer/index.vue'
|
7
|
+
import DragResizeView from './views/DragResizeView/index.vue'
|
8
|
+
import MessageBoxTest from "@/components/MessageBoxTest";
|
9
|
+
|
10
|
+
const components = [FileViewer, ImageViewer, DragResizeView];
|
11
|
+
|
12
|
+
const install = (Vue: any) => {
|
13
|
+
if ((install as any).installed) return;
|
14
|
+
(install as any).installed = true;
|
15
|
+
components.map((component) => {
|
16
|
+
Vue.component(component.name, component);
|
17
|
+
});
|
18
|
+
};
|
19
|
+
// 这一步判断window.Vue是否存在,因为直接引用vue.min.js, 它会把Vue绑到Window上,我们直接引用打包好的js才能正常跑起来。
|
20
|
+
if (typeof window !== 'undefined' && (window as any).Vue) {
|
21
|
+
// window.Vue.use(install)
|
22
|
+
install((window as any).Vue);
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
// import HelloWorld from "@/components/HelloWorld.vue";
|
30
|
+
// import HelloWorld from "@/components/index";
|
31
|
+
|
32
|
+
|
33
|
+
|
2
34
|
|
3
|
-
class Test {
|
4
35
|
|
5
|
-
public static print(info: string): void {
|
6
|
-
console.log(info);
|
7
36
|
|
8
|
-
console.log('测试npm');
|
9
37
|
|
10
|
-
const arr = [1, 2]
|
11
|
-
console.log(arr[5]);
|
12
38
|
|
13
|
-
console.log('测试npm22');
|
14
|
-
console.log('测试npm33333');
|
15
39
|
|
16
|
-
}
|
17
40
|
|
18
|
-
}
|
19
41
|
|
20
|
-
export default
|
21
|
-
export { }
|
42
|
+
export default {}
|
43
|
+
export { EMacro, FileViewer }
|
package/src/main.ts
CHANGED
package/src/router/index.ts
CHANGED
@@ -17,7 +17,17 @@ const routes: Array<RouteConfig> = [
|
|
17
17
|
// this generates a separate chunk (about.[hash].js) for this route
|
18
18
|
// which is lazy-loaded when the route is visited.
|
19
19
|
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
|
20
|
-
}
|
20
|
+
},
|
21
|
+
{
|
22
|
+
path: '/FileViewer',
|
23
|
+
name: 'FileViewer',
|
24
|
+
component: () => import('../views/FileViewer/index.vue')
|
25
|
+
},
|
26
|
+
{
|
27
|
+
path: '/TestView',
|
28
|
+
name: 'TestView',
|
29
|
+
component: () => import('../views/TestView/index.vue')
|
30
|
+
},
|
21
31
|
]
|
22
32
|
|
23
33
|
const router = new VueRouter({
|
package/src/shims-vue.d.ts
CHANGED
package/src/utilities/File.ts
CHANGED
@@ -1,22 +1,54 @@
|
|
1
|
+
import * as XLSX from "xlsx";
|
1
2
|
|
3
|
+
export namespace EMacro {
|
2
4
|
|
3
|
-
const
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
export const version = "1.0"
|
6
|
+
|
7
|
+
export class File {
|
8
|
+
|
9
|
+
private static selectFile(options: any = { multiple: true, accept: "*/*" }) {
|
10
|
+
return new Promise((res: (value: FileList) => void, rej) => {
|
11
|
+
const el = document.createElement("input");
|
12
|
+
el.type = "file";
|
13
|
+
el.accept = options.accept;
|
14
|
+
el.multiple = options.multiple;
|
15
|
+
el.addEventListener("change", (_) => {
|
16
|
+
try {
|
17
|
+
if (el.files === null) {
|
18
|
+
rej(null)
|
19
|
+
} else {
|
20
|
+
res(el.files);
|
21
|
+
}
|
22
|
+
} catch (error) {
|
23
|
+
rej(error)
|
24
|
+
}
|
25
|
+
});
|
26
|
+
el.click();
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
public static readLocalExcel(onloadend: (file, workbook) => void, options: any = { multiple: true, accept: "*/*" }) {
|
31
|
+
|
32
|
+
this.selectFile(options).then((files: FileList) => {
|
33
|
+
for (let i = 0; i < files.length; i++) {
|
34
|
+
const file = files[i];
|
35
|
+
let reader = new FileReader();
|
36
|
+
reader.readAsArrayBuffer(file);
|
37
|
+
reader.onloadend = async function (e: any) {
|
38
|
+
let workbook = XLSX.read(e.target.result, { type: "binary" });
|
39
|
+
onloadend(file, workbook);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}).catch(e => {
|
43
|
+
throw e;
|
44
|
+
})
|
12
45
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
.vdr {
|
2
|
+
position: absolute;
|
3
|
+
box-sizing: border-box;
|
4
|
+
}
|
5
|
+
.vdr.active:before{
|
6
|
+
content: '';
|
7
|
+
width: 100%;
|
8
|
+
height: 100%;
|
9
|
+
position: absolute;
|
10
|
+
top: 0;
|
11
|
+
left: 0;
|
12
|
+
box-sizing: border-box;
|
13
|
+
outline: 1px dashed #d6d6d6;
|
14
|
+
}
|
15
|
+
.vdr-stick {
|
16
|
+
box-sizing: border-box;
|
17
|
+
position: absolute;
|
18
|
+
font-size: 1px;
|
19
|
+
background: #ffffff;
|
20
|
+
border: 1px solid #6c6c6c;
|
21
|
+
box-shadow: 0 0 2px #bbb;
|
22
|
+
}
|
23
|
+
.inactive .vdr-stick {
|
24
|
+
display: none;
|
25
|
+
}
|
26
|
+
.vdr-stick-tl, .vdr-stick-br {
|
27
|
+
cursor: nwse-resize;
|
28
|
+
}
|
29
|
+
.vdr-stick-tm, .vdr-stick-bm {
|
30
|
+
left: 50%;
|
31
|
+
cursor: ns-resize;
|
32
|
+
}
|
33
|
+
.vdr-stick-tr, .vdr-stick-bl {
|
34
|
+
cursor: nesw-resize;
|
35
|
+
}
|
36
|
+
.vdr-stick-ml, .vdr-stick-mr {
|
37
|
+
top: 50%;
|
38
|
+
cursor: ew-resize;
|
39
|
+
}
|
40
|
+
.vdr-stick.not-resizable{
|
41
|
+
display: none;
|
42
|
+
}
|
43
|
+
.content-container{
|
44
|
+
display: block;
|
45
|
+
position: relative;
|
46
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="vdr" :style="positionStyle"
|
2
|
+
:class="`${(active || isActive) ? 'active' : 'inactive'} ${contentClass ? contentClass: ''}`"
|
3
|
+
@mousedown="bodyDown($event)"
|
4
|
+
@touchstart="bodyDown($event)"
|
5
|
+
@touchend="up($event)">
|
6
|
+
<div :style="sizeStyle" class="content-container" ref="container">
|
7
|
+
<slot></slot>
|
8
|
+
</div>
|
9
|
+
<div
|
10
|
+
v-for="stick in sticks"
|
11
|
+
class="vdr-stick"
|
12
|
+
:class="['vdr-stick-' + stick, isResizable ? '' : 'not-resizable']"
|
13
|
+
@mousedown.stop.prevent="stickDown(stick, $event)"
|
14
|
+
@touchstart.stop.prevent="stickDown(stick, $event)"
|
15
|
+
:style="vdrStick(stick)">
|
16
|
+
</div>
|
17
|
+
</div>
|