shijiplus-web-plugin 0.1.0
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 +24 -0
- package/package.json +56 -0
- package/src/App.vue +35 -0
- package/src/assets/logo.png +0 -0
- package/src/directive/directives.js +17 -0
- package/src/directive/index.js +26 -0
- package/src/directive/module/authAccess.js +17 -0
- package/src/directive/module/clipboard.js +30 -0
- package/src/directive/module/draggable.js +41 -0
- package/src/directive/module/loading-icon.js +38 -0
- package/src/directive/module/loading-text.js +24 -0
- package/src/directive/module/loading.js +48 -0
- package/src/extentionPlugin/array.js +81 -0
- package/src/extentionPlugin/date.js +265 -0
- package/src/extentionPlugin/index.js +18 -0
- package/src/extentionPlugin/object.js +114 -0
- package/src/extentionPlugin/regular.js +72 -0
- package/src/extentionPlugin/string.js +113 -0
- package/src/index.less +504 -0
- package/src/locale/index.js +40 -0
- package/src/locale/lang/en-US.js +46 -0
- package/src/locale/lang/zh-CN.js +46 -0
- package/src/locale/lang/zh-TW.js +46 -0
- package/src/main.js +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# shijiplus-web-tool
|
|
2
|
+
|
|
3
|
+
## Project setup
|
|
4
|
+
```
|
|
5
|
+
npm install
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### Compiles and hot-reloads for development
|
|
9
|
+
```
|
|
10
|
+
npm run serve
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Compiles and minifies for production
|
|
14
|
+
```
|
|
15
|
+
npm run build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Lints and fixes files
|
|
19
|
+
```
|
|
20
|
+
npm run lint
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Customize configuration
|
|
24
|
+
See [Configuration Reference](https://cli.vuejs.org/config/).
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shijiplus-web-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"src"
|
|
6
|
+
],
|
|
7
|
+
"description": "A company project",
|
|
8
|
+
"author": "jia",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"private": false,
|
|
11
|
+
"main": "./src/main.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"serve": "vue-cli-service serve",
|
|
14
|
+
"build": "vue-cli-service build",
|
|
15
|
+
"lint": "vue-cli-service lint"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"iview": "^3.5.4"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"vue": "^2.6.14",
|
|
22
|
+
"vue-i18n": "^7.8.0",
|
|
23
|
+
"less": "^2.7.3",
|
|
24
|
+
"less-loader": "^4.0.5",
|
|
25
|
+
"@babel/core": "^7.12.16",
|
|
26
|
+
"@babel/eslint-parser": "^7.12.16",
|
|
27
|
+
"@vue/cli-plugin-babel": "~5.0.0",
|
|
28
|
+
"@vue/cli-plugin-eslint": "~5.0.0",
|
|
29
|
+
"@vue/cli-service": "~5.0.0",
|
|
30
|
+
"eslint": "^7.32.0",
|
|
31
|
+
"eslint-plugin-vue": "^8.0.3",
|
|
32
|
+
"vue-template-compiler": "^2.6.14"
|
|
33
|
+
},
|
|
34
|
+
"eslintConfig": {
|
|
35
|
+
"root": true,
|
|
36
|
+
"env": {
|
|
37
|
+
"browser": true,
|
|
38
|
+
"node": true
|
|
39
|
+
},
|
|
40
|
+
"extends": [
|
|
41
|
+
"plugin:vue/essential",
|
|
42
|
+
"eslint:recommended"
|
|
43
|
+
],
|
|
44
|
+
"parserOptions": {
|
|
45
|
+
"parser": "@babel/eslint-parser"
|
|
46
|
+
},
|
|
47
|
+
"rules": {
|
|
48
|
+
"no-unused-vars": "off"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"browserslist": [
|
|
52
|
+
"> 1%",
|
|
53
|
+
"last 2 versions",
|
|
54
|
+
"not dead"
|
|
55
|
+
]
|
|
56
|
+
}
|
package/src/App.vue
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<img id="img" alt="Vue logo" src="./assets/logo.png" />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import HelloWorld from './components/HelloWorld.vue'
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: 'App',
|
|
12
|
+
components: {},
|
|
13
|
+
mounted() {
|
|
14
|
+
console.log(
|
|
15
|
+
'web-tool mounted!',
|
|
16
|
+
new Date().formatDate('yyyy-MM-dd hh:mm:ss')
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<style lang="less">
|
|
23
|
+
#app {
|
|
24
|
+
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
25
|
+
-webkit-font-smoothing: antialiased;
|
|
26
|
+
-moz-osx-font-smoothing: grayscale;
|
|
27
|
+
text-align: center;
|
|
28
|
+
color: #2c3e50;
|
|
29
|
+
margin-top: 60px;
|
|
30
|
+
#img {
|
|
31
|
+
width: 1000px;
|
|
32
|
+
height: 100px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import draggable from './module/draggable'
|
|
2
|
+
import clipboard from './module/clipboard'
|
|
3
|
+
import authAccess from './module/authAccess'
|
|
4
|
+
import loading from './module/loading'
|
|
5
|
+
import loadingText from './module/loading-text'
|
|
6
|
+
import loadingIcon from './module/loading-icon'
|
|
7
|
+
|
|
8
|
+
const directives = {
|
|
9
|
+
draggable,
|
|
10
|
+
clipboard,
|
|
11
|
+
authAccess,
|
|
12
|
+
loading,
|
|
13
|
+
loadingText,
|
|
14
|
+
loadingIcon
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default directives
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import directive from './directives'
|
|
2
|
+
|
|
3
|
+
const importDirective = Vue => {
|
|
4
|
+
/**
|
|
5
|
+
* 拖拽指令 v-draggable="options"
|
|
6
|
+
* options = {
|
|
7
|
+
* trigger: /这里传入作为拖拽触发器的CSS选择器/,
|
|
8
|
+
* body: /这里传入需要移动容器的CSS选择器/,
|
|
9
|
+
* recover: /拖动结束之后是否恢复到原来的位置/
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
Vue.directive('draggable', directive.draggable)
|
|
13
|
+
/**
|
|
14
|
+
* clipboard指令 v-draggable="options"
|
|
15
|
+
* options = {
|
|
16
|
+
* value: /在输入框中使用v-model绑定的值/,
|
|
17
|
+
* success: /复制成功后的回调/,
|
|
18
|
+
* error: /复制失败后的回调/
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
Vue.directive('clipboard', directive.clipboard)
|
|
22
|
+
Vue.directive('access', directive.authAccess)
|
|
23
|
+
Vue.directive('loading', directive.loading)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default importDirective
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import store from '@/store'
|
|
2
|
+
export default {
|
|
3
|
+
inserted(el, binding, vnode, oldVnode) {
|
|
4
|
+
if (document.location.hostname == 'localhost') {
|
|
5
|
+
return
|
|
6
|
+
}
|
|
7
|
+
if (store.state.user.access === undefined || store.state.user.access.length === 0) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
if (binding.value === undefined) {
|
|
11
|
+
throw new Error('v-access必须有值')
|
|
12
|
+
}
|
|
13
|
+
if (store.state.user.access.indexOf(binding.value) === -1) {
|
|
14
|
+
el.parentNode.removeChild(el)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Clipboard from 'clipboard'
|
|
2
|
+
export default {
|
|
3
|
+
bind: (el, binding) => {
|
|
4
|
+
const clipboard = new Clipboard(el, {
|
|
5
|
+
text: () => binding.value.value
|
|
6
|
+
})
|
|
7
|
+
el.__success_callback__ = binding.value.success
|
|
8
|
+
el.__error_callback__ = binding.value.error
|
|
9
|
+
clipboard.on('success', e => {
|
|
10
|
+
const callback = el.__success_callback__
|
|
11
|
+
callback && callback(e)
|
|
12
|
+
})
|
|
13
|
+
clipboard.on('error', e => {
|
|
14
|
+
const callback = el.__error_callback__
|
|
15
|
+
callback && callback(e)
|
|
16
|
+
})
|
|
17
|
+
el.__clipboard__ = clipboard
|
|
18
|
+
},
|
|
19
|
+
update: (el, binding) => {
|
|
20
|
+
el.__clipboard__.text = () => binding.value.value
|
|
21
|
+
el.__success_callback__ = binding.value.success
|
|
22
|
+
el.__error_callback__ = binding.value.error
|
|
23
|
+
},
|
|
24
|
+
unbind: (el, binding) => {
|
|
25
|
+
delete el.__success_callback__
|
|
26
|
+
delete el.__error_callback__
|
|
27
|
+
el.__clipboard__.destroy()
|
|
28
|
+
delete el.__clipboard__
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { on } from '@/libs/tools'
|
|
2
|
+
export default {
|
|
3
|
+
inserted: (el, binding, vnode) => {
|
|
4
|
+
let triggerDom = document.querySelector(binding.value.trigger)
|
|
5
|
+
triggerDom.style.cursor = 'move'
|
|
6
|
+
let bodyDom = document.querySelector(binding.value.body)
|
|
7
|
+
let pageX = 0
|
|
8
|
+
let pageY = 0
|
|
9
|
+
let transformX = 0
|
|
10
|
+
let transformY = 0
|
|
11
|
+
let canMove = false
|
|
12
|
+
const handleMousedown = e => {
|
|
13
|
+
let transform = /\(.*\)/.exec(bodyDom.style.transform)
|
|
14
|
+
if (transform) {
|
|
15
|
+
transform = transform[0].slice(1, transform[0].length - 1)
|
|
16
|
+
let splitxy = transform.split('px, ')
|
|
17
|
+
transformX = parseFloat(splitxy[0])
|
|
18
|
+
transformY = parseFloat(splitxy[1].split('px')[0])
|
|
19
|
+
}
|
|
20
|
+
pageX = e.pageX
|
|
21
|
+
pageY = e.pageY
|
|
22
|
+
canMove = true
|
|
23
|
+
}
|
|
24
|
+
const handleMousemove = e => {
|
|
25
|
+
let xOffset = e.pageX - pageX + transformX
|
|
26
|
+
let yOffset = e.pageY - pageY + transformY
|
|
27
|
+
if (canMove) bodyDom.style.transform = `translate(${xOffset}px, ${yOffset}px)`
|
|
28
|
+
}
|
|
29
|
+
const handleMouseup = e => {
|
|
30
|
+
canMove = false
|
|
31
|
+
}
|
|
32
|
+
on(triggerDom, 'mousedown', handleMousedown)
|
|
33
|
+
on(document, 'mousemove', handleMousemove)
|
|
34
|
+
on(document, 'mouseup', handleMouseup)
|
|
35
|
+
},
|
|
36
|
+
update: (el, binding, vnode) => {
|
|
37
|
+
if (!binding.value.recover) return
|
|
38
|
+
let bodyDom = document.querySelector(binding.value.body)
|
|
39
|
+
bodyDom.style.transform = ''
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Icon from 'iview/src/components/icon'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
export default {
|
|
4
|
+
bind: (el, binding, vnode, oldVnode) => {
|
|
5
|
+
let nodeClassName = vnode.elm.className
|
|
6
|
+
let selector = nodeClassName && nodeClassName.length ? nodeClassName.replaceAll(' ', '.') : ''
|
|
7
|
+
if (selector) {
|
|
8
|
+
selector = '.' + selector + '>'
|
|
9
|
+
}
|
|
10
|
+
let loddingNode = vnode.elm.querySelectorAll(selector + 'div.ivu-spin')
|
|
11
|
+
if (loddingNode[0]) {
|
|
12
|
+
const textWrapEle = loddingNode[0].querySelector('.ivu-spin-text')
|
|
13
|
+
const defaulIcon = loddingNode[0].querySelector('.ivu-spin-dot')
|
|
14
|
+
defaulIcon.style.display = 'none'
|
|
15
|
+
if (textWrapEle) {
|
|
16
|
+
let propsData = { type: '', size: 18 }
|
|
17
|
+
if (typeof binding.value == 'object') {
|
|
18
|
+
propsData = { ...binding.value }
|
|
19
|
+
} else {
|
|
20
|
+
propsData.type = binding.value
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let iconInstance = new (Vue.extend(Icon))({ propsData }).$mount()
|
|
24
|
+
console.log('---loading-icon------bind------', iconInstance)
|
|
25
|
+
iconInstance.$el.classList.add('spin-icon-loading')
|
|
26
|
+
const textEle = textWrapEle.querySelector('.loading-text')
|
|
27
|
+
if (textEle) {
|
|
28
|
+
textWrapEle.insertBefore(iconInstance.$el, textEle)
|
|
29
|
+
} else {
|
|
30
|
+
textWrapEle.appendChild(iconInstance.$el)
|
|
31
|
+
}
|
|
32
|
+
textWrapEle.style.display = 'block'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
update: function (el, binding, vnode, oldVnode) {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Spin from 'iview/src/components/spin'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
export default {
|
|
4
|
+
bind: (el, binding, vnode, oldVnode) => {
|
|
5
|
+
let nodeClassName = vnode.elm.className
|
|
6
|
+
let selector = nodeClassName && nodeClassName.length ? nodeClassName.replaceAll(' ', '.') : ''
|
|
7
|
+
if (selector) {
|
|
8
|
+
selector = '.' + selector + '>'
|
|
9
|
+
}
|
|
10
|
+
let loddingNode = vnode.elm.querySelectorAll(selector + 'div.ivu-spin')
|
|
11
|
+
if (loddingNode[0]) {
|
|
12
|
+
const textEle = loddingNode[0].querySelector('.ivu-spin-text')
|
|
13
|
+
if (textEle) {
|
|
14
|
+
textEle.style.display = 'block'
|
|
15
|
+
const div = document.createElement('div')
|
|
16
|
+
div.classList.add('loading-text')
|
|
17
|
+
div.innerText = binding.value
|
|
18
|
+
textEle.appendChild(div)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
update: function (el, binding, vnode, oldVnode) {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import Spin from 'iview/src/components/spin'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
export default {
|
|
4
|
+
inserted: (el, binding, vnode, oldVnode) => {
|
|
5
|
+
var style = window.getComputedStyle(el, null) // 获取计算后的样式对象
|
|
6
|
+
var value = style.getPropertyValue('position')
|
|
7
|
+
if (value && (value != 'absolute' || value != 'relative')) {
|
|
8
|
+
el.style.position = 'relative'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
bind: (el, binding, vnode, oldVnode) => {
|
|
12
|
+
let spinInstance = new (Vue.extend(Spin))({ propsData: { fix: true, show: false } }).$mount()
|
|
13
|
+
el.appendChild(spinInstance.$el)
|
|
14
|
+
spinInstance.$el.hidden = !binding.value
|
|
15
|
+
spinInstance.$el.style.zIndex = '1'
|
|
16
|
+
// vnode.elm.style = vnode.elm.style || '' + 'position: relative;'
|
|
17
|
+
// console.log('----------loading-------bind-----------')
|
|
18
|
+
},
|
|
19
|
+
update: function (el, binding, vnode, oldVnode) {
|
|
20
|
+
let nodeClassName = vnode.elm.className
|
|
21
|
+
let selector = nodeClassName && nodeClassName.length ? nodeClassName.replaceAll(' ', '.') : ''
|
|
22
|
+
if (selector) {
|
|
23
|
+
selector = '.' + selector + '>'
|
|
24
|
+
}
|
|
25
|
+
let loddingNode = vnode.elm.querySelectorAll(selector + 'div.ivu-spin')
|
|
26
|
+
// console.log('----------loading-------update-----------', binding)
|
|
27
|
+
// console.log('----------loading-------update-----loddingNode------', vnode)
|
|
28
|
+
// console.log('----------loading-------update-----loddingNode------', loddingNode)
|
|
29
|
+
if (loddingNode[0]) {
|
|
30
|
+
if (binding.value) {
|
|
31
|
+
loddingNode[0].hidden = false
|
|
32
|
+
} else {
|
|
33
|
+
loddingNode[0].hidden = true
|
|
34
|
+
}
|
|
35
|
+
if (el.scrollHeight > loddingNode[0].clientHeight) {
|
|
36
|
+
loddingNode[0].style.height = el.scrollHeight + 'px'
|
|
37
|
+
} else {
|
|
38
|
+
loddingNode[0].style.height = '100%'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (el.scrollWidth > loddingNode[0].clientWidth) {
|
|
42
|
+
loddingNode[0].style.width = el.scrollHeight + 'px'
|
|
43
|
+
} else {
|
|
44
|
+
loddingNode[0].style.width = '100%'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* eslint-disable no-extend-native */
|
|
2
|
+
/* eslint-disable no-unused-vars */
|
|
3
|
+
import Vue from 'vue'
|
|
4
|
+
const install = (vue, opts = {}) => {
|
|
5
|
+
vue.prototype.$groupBy = groupBy
|
|
6
|
+
vue.prototype.$findItem = findItem
|
|
7
|
+
vue.prototype.$findItemIndex = findItemIndex
|
|
8
|
+
vue.prototype.$getValueByKey = getValueByKey
|
|
9
|
+
vue.prototype.$groupToDic = groupToDic
|
|
10
|
+
vue.prototype.$toDictionary = toDictionary
|
|
11
|
+
Array.prototype.findItemIndex = function (fn) {
|
|
12
|
+
return findItemIndex(this, fn)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
install
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function findItem(array, fn) {
|
|
21
|
+
for (const index in array) {
|
|
22
|
+
if (fn(array[index])) {
|
|
23
|
+
return array[index]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function findItemIndex(array, fn) {
|
|
30
|
+
for (const index in array) {
|
|
31
|
+
if (fn(array[index])) {
|
|
32
|
+
return index
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return -1
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getValueByKey(array, key) {
|
|
39
|
+
const result = []
|
|
40
|
+
for (const index in array) {
|
|
41
|
+
if (array[index][key]) {
|
|
42
|
+
result.push(array[index][key])
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function toDictionary(array, mainKey) {
|
|
49
|
+
const groups = {}
|
|
50
|
+
array.forEach(function (o) {
|
|
51
|
+
const allKeys = Object.keys(o)
|
|
52
|
+
const dicItem = {}
|
|
53
|
+
allKeys.forEach(key => {
|
|
54
|
+
dicItem[key] = o[key]
|
|
55
|
+
})
|
|
56
|
+
groups[o[mainKey]] = dicItem
|
|
57
|
+
})
|
|
58
|
+
return groups
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function groupToDic(array, callback) {
|
|
62
|
+
const groups = {}
|
|
63
|
+
array.forEach(function (o) {
|
|
64
|
+
const group = callback(o)
|
|
65
|
+
groups[group] = groups[group] || []
|
|
66
|
+
groups[group].push(o)
|
|
67
|
+
})
|
|
68
|
+
return groups
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function groupBy(array, callback) {
|
|
72
|
+
const groups = {}
|
|
73
|
+
array.forEach(function (o) {
|
|
74
|
+
const group = JSON.stringify(callback(o))
|
|
75
|
+
groups[group] = groups[group] || []
|
|
76
|
+
groups[group].push(o)
|
|
77
|
+
})
|
|
78
|
+
return Object.keys(groups).map(function (group) {
|
|
79
|
+
return groups[group]
|
|
80
|
+
})
|
|
81
|
+
}
|