@wp1001/ui 2.9.13

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.
Files changed (177) hide show
  1. package/.env +6 -0
  2. package/@vant-D4fmGxs6.js +3891 -0
  3. package/index.js +8419 -0
  4. package/package.json +59 -0
  5. package/packages/assets/devtools-detector.js +2 -0
  6. package/packages/components/xarray/index.js +64 -0
  7. package/packages/components/xarray/xarray.vue +57 -0
  8. package/packages/components/xautorows/index.js +35 -0
  9. package/packages/components/xautorows/xautorows.vue +29 -0
  10. package/packages/components/xbutton/mobile.js +3 -0
  11. package/packages/components/xbutton/mobile.vue +9 -0
  12. package/packages/components/xbutton/pc.js +3 -0
  13. package/packages/components/xbutton/pc.vue +9 -0
  14. package/packages/components/xbuttons/mobile.js +51 -0
  15. package/packages/components/xbuttons/mobile.vue +12 -0
  16. package/packages/components/xbuttons/pc.js +51 -0
  17. package/packages/components/xbuttons/pc.vue +16 -0
  18. package/packages/components/xchart/constants.js +58 -0
  19. package/packages/components/xchart/index.js +263 -0
  20. package/packages/components/xchart/utils.js +121 -0
  21. package/packages/components/xchart/xchart.vue +173 -0
  22. package/packages/components/xcheckboxs/mobile.js +58 -0
  23. package/packages/components/xcheckboxs/mobile.vue +38 -0
  24. package/packages/components/xcheckboxs/pc.js +49 -0
  25. package/packages/components/xcheckboxs/pc.vue +42 -0
  26. package/packages/components/xcol/mobile.js +10 -0
  27. package/packages/components/xcol/mobile.vue +9 -0
  28. package/packages/components/xcol/pc.js +10 -0
  29. package/packages/components/xcol/pc.vue +9 -0
  30. package/packages/components/xdatepicker/mobile.js +71 -0
  31. package/packages/components/xdatepicker/mobile.vue +44 -0
  32. package/packages/components/xdatepicker/pc.js +9 -0
  33. package/packages/components/xdatepicker/pc.vue +12 -0
  34. package/packages/components/xdialog/mobile.js +60 -0
  35. package/packages/components/xdialog/mobile.vue +43 -0
  36. package/packages/components/xdialog/pc.js +64 -0
  37. package/packages/components/xdialog/pc.vue +51 -0
  38. package/packages/components/xdict/index.js +47 -0
  39. package/packages/components/xdict/xdict.vue +9 -0
  40. package/packages/components/xdistrictselect/mobile.js +79 -0
  41. package/packages/components/xdistrictselect/mobile.vue +28 -0
  42. package/packages/components/xdistrictselect/pc.js +127 -0
  43. package/packages/components/xdistrictselect/pc.vue +32 -0
  44. package/packages/components/xform/mobile.js +29 -0
  45. package/packages/components/xform/mobile.vue +43 -0
  46. package/packages/components/xform/pc.js +42 -0
  47. package/packages/components/xform/pc.vue +76 -0
  48. package/packages/components/xform/utils.js +95 -0
  49. package/packages/components/xformitem/mobile.js +56 -0
  50. package/packages/components/xformitem/mobile.vue +3 -0
  51. package/packages/components/xformitem/pc.js +72 -0
  52. package/packages/components/xformitem/pc.vue +10 -0
  53. package/packages/components/xformitem/utils.jsx +181 -0
  54. package/packages/components/xicon/mobile.js +35 -0
  55. package/packages/components/xicon/mobile.vue +9 -0
  56. package/packages/components/xicon/pc.js +35 -0
  57. package/packages/components/xicon/pc.vue +11 -0
  58. package/packages/components/xinfo/index.js +100 -0
  59. package/packages/components/xinfo/xinfo.vue +140 -0
  60. package/packages/components/xlooper/index.js +7 -0
  61. package/packages/components/xlooper/xlooper.vue +20 -0
  62. package/packages/components/xpagination/mobile.js +21 -0
  63. package/packages/components/xpagination/mobile.vue +31 -0
  64. package/packages/components/xpagination/pc.js +21 -0
  65. package/packages/components/xpagination/pc.vue +16 -0
  66. package/packages/components/xpicker/index.js +38 -0
  67. package/packages/components/xpicker/xpicker.vue +29 -0
  68. package/packages/components/xradios/mobile.js +40 -0
  69. package/packages/components/xradios/mobile.vue +22 -0
  70. package/packages/components/xradios/pc.js +53 -0
  71. package/packages/components/xradios/pc.vue +43 -0
  72. package/packages/components/xrow/mobile.js +9 -0
  73. package/packages/components/xrow/mobile.vue +23 -0
  74. package/packages/components/xrow/pc.js +9 -0
  75. package/packages/components/xrow/pc.vue +22 -0
  76. package/packages/components/xscan/mobile.js +24 -0
  77. package/packages/components/xscan/mobile.vue +21 -0
  78. package/packages/components/xscan/pc.js +20 -0
  79. package/packages/components/xscan/pc.vue +18 -0
  80. package/packages/components/xsearcher/index.js +198 -0
  81. package/packages/components/xsearcher/xsearcher.vue +170 -0
  82. package/packages/components/xselect/mobile.js +86 -0
  83. package/packages/components/xselect/mobile.vue +24 -0
  84. package/packages/components/xselect/pc.js +114 -0
  85. package/packages/components/xselect/pc.vue +55 -0
  86. package/packages/components/xselect/util.js +66 -0
  87. package/packages/components/xselectv2/index.js +91 -0
  88. package/packages/components/xselectv2/xselectv2.vue +46 -0
  89. package/packages/components/xtable/mobile.js +108 -0
  90. package/packages/components/xtable/mobile.vue +246 -0
  91. package/packages/components/xtable/pc.js +143 -0
  92. package/packages/components/xtable/pc.vue +421 -0
  93. package/packages/components/xtable/searcher.js +477 -0
  94. package/packages/components/xtable/searcher.jsx +330 -0
  95. package/packages/components/xtable/searcher.vue +133 -0
  96. package/packages/components/xtable/settings.js +80 -0
  97. package/packages/components/xtable/settings.vue +77 -0
  98. package/packages/components/xtable/utils.js +692 -0
  99. package/packages/components/xtabletools/mobile.js +25 -0
  100. package/packages/components/xtabletools/mobile.vue +126 -0
  101. package/packages/components/xtabletools/pc.js +18 -0
  102. package/packages/components/xtabletools/pc.vue +135 -0
  103. package/packages/components/xtablev2/index.js +53 -0
  104. package/packages/components/xtablev2/utils.jsx +214 -0
  105. package/packages/components/xtablev2/xtablev2.vue +147 -0
  106. package/packages/components/xtags/mobile.js +17 -0
  107. package/packages/components/xtags/mobile.vue +21 -0
  108. package/packages/components/xtags/pc.js +17 -0
  109. package/packages/components/xtags/pc.vue +22 -0
  110. package/packages/components/xtinymce/index.js +71 -0
  111. package/packages/components/xtinymce/xtinymce.vue +9 -0
  112. package/packages/components/xuploader/xfileuploader.js +48 -0
  113. package/packages/components/xuploader/xfileuploader.vue +54 -0
  114. package/packages/components/xuploader/ximageuploader.js +53 -0
  115. package/packages/components/xuploader/ximageuploader.vue +52 -0
  116. package/packages/comps.js +108 -0
  117. package/packages/controllers/BaseController.js +125 -0
  118. package/packages/controllers/CrudController.js +907 -0
  119. package/packages/controllers/TempCrudController.js +32 -0
  120. package/packages/controllers/index.js +15 -0
  121. package/packages/directives/el-table-infinite-scroll.js +55 -0
  122. package/packages/directives/index.js +5 -0
  123. package/packages/index.js +81 -0
  124. package/packages/index.scss +4 -0
  125. package/packages/layout/breadcrumb/breadcrumb.vue +31 -0
  126. package/packages/layout/breadcrumb/index.js +41 -0
  127. package/packages/layout/header/header.vue +281 -0
  128. package/packages/layout/header/inner.js +11 -0
  129. package/packages/layout/header/inner.vue +3 -0
  130. package/packages/layout/mobile-menu.vue +83 -0
  131. package/packages/layout/mobile-tabs.vue +54 -0
  132. package/packages/layout/pc.vue +85 -0
  133. package/packages/layout/screenlock/index.js +129 -0
  134. package/packages/layout/screenlock/screenlock.vue +85 -0
  135. package/packages/layout/sidebar/item.js +16 -0
  136. package/packages/layout/sidebar/item.vue +16 -0
  137. package/packages/layout/sidebar/menu.js +72 -0
  138. package/packages/layout/sidebar/menu.vue +106 -0
  139. package/packages/layout/sidebar/sidebar.vue +147 -0
  140. package/packages/layout/tagsview/ScrollPane.js +65 -0
  141. package/packages/layout/tagsview/ScrollPane.vue +24 -0
  142. package/packages/layout/tagsview/index.js +169 -0
  143. package/packages/layout/tagsview/index.vue +124 -0
  144. package/packages/plop/actions/make-fill-admin-partials-action.js +95 -0
  145. package/packages/plop/generators/make-admin-page.js +39 -0
  146. package/packages/plop/generators/make-database-admin-pages.js +84 -0
  147. package/packages/plop/generators/make-page-generator.js +52 -0
  148. package/packages/plop/generators/make-simple-page.js +20 -0
  149. package/packages/plop/plopfile.js +24 -0
  150. package/packages/plop/templates/admin_page/controller.js +3 -0
  151. package/packages/plop/templates/admin_page/model.js +24 -0
  152. package/packages/plop/templates/admin_page/{{snakeCase pagename}}-scoped.scss +3 -0
  153. package/packages/plop/templates/admin_page/{{snakeCase pagename}}.vue +11 -0
  154. package/packages/plop/templates/simple_page/controller.js +3 -0
  155. package/packages/plop/templates/simple_page/model.js +6 -0
  156. package/packages/plop/templates/simple_page/{{snakeCase pagename}}-scoped.scss +3 -0
  157. package/packages/plop/templates/simple_page/{{snakeCase pagename}}.vue +7 -0
  158. package/packages/plop/utils/index.js +168 -0
  159. package/packages/plop/utils/plop-utils.js +86 -0
  160. package/packages/styles/common.scss +137 -0
  161. package/packages/styles/element-ui.scss +142 -0
  162. package/packages/styles/vant.scss +133 -0
  163. package/packages/styles/variables.scss +23 -0
  164. package/packages/utils/crypt.js +24 -0
  165. package/packages/utils/decorators.js +67 -0
  166. package/packages/utils/disallowDevtools.js +53 -0
  167. package/packages/utils/effects.js +173 -0
  168. package/packages/utils/funcs.js +78 -0
  169. package/packages/utils/index.js +95 -0
  170. package/packages/utils/message.js +110 -0
  171. package/packages/utils/middlewares.js +86 -0
  172. package/packages/utils/model.js +71 -0
  173. package/packages/utils/modelUtils.js +203 -0
  174. package/packages/utils/request.js +57 -0
  175. package/packages/utils/site.js +33 -0
  176. package/packages/vite-plugins.js +141 -0
  177. package/publish.sh +12 -0
@@ -0,0 +1,133 @@
1
+ :root {
2
+ --van-dialog-max-height: 90vh;
3
+ --van-dialog-header-padding: 15px 0 10px;
4
+ --main-button-padding: 10px;
5
+ }
6
+
7
+ .van-dialog {
8
+ max-height: var(--var-dialog-max-height);
9
+ overflow-y: auto;
10
+ .van-dialog__header {
11
+ padding: var(--van-dialog-header-padding);
12
+ }
13
+ .van-dialog__content {
14
+ padding: 5px;
15
+ max-height: 80vh;
16
+ overflow-y: auto;
17
+ }
18
+ }
19
+
20
+ .mobile-x-table {
21
+ width: 100%;
22
+ }
23
+
24
+ .mobile-x-form {
25
+ width: 100%;
26
+ &.viewonly {
27
+ .van-field__control {
28
+ color: #909999;
29
+ }
30
+ }
31
+ .van-progress {
32
+ width: 100%;
33
+ }
34
+ .el-col {
35
+ .van-cell {
36
+ padding: 7px 0;
37
+ }
38
+ .van-field__control > * {
39
+ width: 100%;
40
+ }
41
+ }
42
+ }
43
+
44
+ .comp-html {
45
+ width: 100%;
46
+ }
47
+
48
+ .mobile-x-select {
49
+ width: 100%;
50
+ height: 20px;
51
+ line-height: 20px;
52
+ }
53
+
54
+ .mobile-x-paginaiton {
55
+ padding: var(--x-medium-padding);
56
+ }
57
+
58
+ .x-district-select {
59
+ &__placeholder {
60
+ color: #ccc;
61
+ }
62
+ &__value {
63
+ color: #555;
64
+ }
65
+ }
66
+
67
+ .x-picker {
68
+ position: fixed;
69
+ left: 0;
70
+ bottom: 0;
71
+ width: 100%;
72
+ &__placeholder {
73
+ color: #ccc;
74
+ }
75
+ &__value {
76
+ color: #555;
77
+ }
78
+ }
79
+
80
+ main {
81
+ .van-button--block {
82
+ width: calc(100% - var(--main-button-padding) * 2);
83
+ margin-left: var(--main-button-padding);
84
+ margin-right: var(--main-button-padding);
85
+ }
86
+ }
87
+
88
+ .mobile-x-dialog {
89
+ .van-action-sheet__content {
90
+ max-height: 60vh;
91
+ padding: 0 10px;
92
+ .van-cell {
93
+ padding-left: 0;
94
+ padding-right: 0;
95
+ }
96
+ }
97
+ .van-action-sheet__description {
98
+ padding: 14px 0;
99
+ color: var(--van-text-color);
100
+ font-size: 16px;
101
+ }
102
+ .van-action-sheet__cancel {
103
+ padding: 0;
104
+ .van-button {
105
+ margin: 0;
106
+ padding: 0;
107
+ width: 100%;
108
+ border: none;
109
+ }
110
+ }
111
+ .x-info {
112
+ .x-info__label {
113
+ padding-left: 0 !important;
114
+ }
115
+ .x-info__value {
116
+ padding-right: 0 !important;
117
+ }
118
+ }
119
+ }
120
+
121
+ .mobile-x-radios--plain {
122
+ .van-radio {
123
+ margin-right: 20px;
124
+ .van-radio__icon {
125
+ display: none;
126
+ }
127
+ }
128
+ }
129
+ .van-radio[aria-checked="true"] {
130
+ .van-radio__label {
131
+ color: var(--van-blue);
132
+ }
133
+ }
@@ -0,0 +1,23 @@
1
+ :root {
2
+ --x-sidebar-width: 270px;
3
+ --x-sidebar-collapse-width: 65px;
4
+ --x-head-height: 56px;
5
+ --x-header-height: 55px;
6
+ --x-tagsview-height: 38px;
7
+ --x-header-bg-color: #ffffff;
8
+ --x-sidebar-bg-color: #304156;
9
+ --x-sidebar-current-bg-color: #1a283a;
10
+ --x-sidebar-hover-bg-color: #17345a;
11
+ --x-sidebar-text-color: #a0aaaa;
12
+ --x-sidebar-current-text-color: #409eff;
13
+ --x-bg-color: #f5f7fa;
14
+
15
+ --x-font-size: 13px;
16
+ --x-text-color: #606666;
17
+ --x-label-color: #909999;
18
+ --x-small-padding: 5px;
19
+ --x-medium-padding: 10px;
20
+ --x-large-padding: 20px;
21
+ --x-default-border-color: #ddd;
22
+ --x-default-border: 1px dashed var(--x-default-border-color);
23
+ }
@@ -0,0 +1,24 @@
1
+ const simple = {
2
+ encrypt (text) {
3
+ text = encodeURIComponent(text)
4
+ text = btoa(text)
5
+ text = text.split('')
6
+ text = text.map(c => String.fromCharCode(c.charCodeAt(0) + 6))
7
+ text.reverse()
8
+ text = text.join('')
9
+ return text
10
+ },
11
+ decrypt (text) {
12
+ text = text.split('')
13
+ text.reverse()
14
+ text = text.map(c => String.fromCharCode(c.charCodeAt(0) - 6))
15
+ text = text.join('')
16
+ text = atob(text)
17
+ text = decodeURIComponent(text)
18
+ return text
19
+ }
20
+ }
21
+
22
+ export { simple }
23
+
24
+ export default { simple }
@@ -0,0 +1,67 @@
1
+ const { highdict } = StardustJs
2
+
3
+ const _checkOk = (self, key) => {
4
+ let ok = key
5
+ if (typeof key === 'string') {
6
+ ok = highdict.get(self, key)
7
+ } else if (typeof key === 'function') {
8
+ ok = key(self)
9
+ }
10
+ return !!ok
11
+ }
12
+
13
+ export const when = (key) => {
14
+ return (value, { name, addInitializer, ...others }) => {
15
+ addInitializer(function () {
16
+ const self = this
17
+ const func = self[name]
18
+ self[name] = function (...props) {
19
+ if (!_checkOk(self, key)) return
20
+ return func.apply(self, props)
21
+ }
22
+ })
23
+ }
24
+ }
25
+
26
+ export const not = (key) => {
27
+ return (value, { name, addInitializer, ...others }) => {
28
+ addInitializer(function () {
29
+ const self = this
30
+ const func = self[name]
31
+ self[name] = function (...props) {
32
+ if (_checkOk(self, key)) return
33
+ return func.apply(self, props)
34
+ }
35
+ })
36
+ }
37
+ }
38
+
39
+ export const loading = (key) => {
40
+ return (value, { name, addInitializer, ...others }) => {
41
+ addInitializer(function () {
42
+ const self = this
43
+ const func = self[name]
44
+ key ??= self.table && 'table.loading' || self.model && 'model.loading' || self.dialog && 'dialog.loading' || 'loading'
45
+ self[name] = function (...props) {
46
+ if (!key) throw 'invalid params for @loading'
47
+ if (highdict.get(self, key)) return
48
+ highdict.set(self, key, true)
49
+ const result = func.apply(self, props)
50
+ if (result instanceof Promise) {
51
+ return result.then((...res) => {
52
+ highdict.set(self, key, false)
53
+ return res
54
+ })
55
+ }
56
+ highdict.set(self, key, false)
57
+ return result
58
+ }
59
+ })
60
+ }
61
+ }
62
+
63
+ export default {
64
+ when,
65
+ not,
66
+ loading
67
+ }
@@ -0,0 +1,53 @@
1
+ import devtoolsDetector from '../assets/devtools-detector.js'
2
+
3
+ const { addListener, launch } = devtoolsDetector
4
+
5
+ const disallowDevtools = (env = {}, whiteList) => {
6
+ const onDevtools = isOpen => {
7
+ if (isOpen) {
8
+ // sessionStorage.clear()
9
+ // localStorage.clear()
10
+ // document.documentElement.innerHTML = '为了网站的安全,禁止调试'
11
+ document.documentElement.innerHTML = decodeURIComponent(atob('JUU0JUI4JUJBJUU0JUJBJTg2JUU3JUJEJTkxJUU3JUFCJTk5JUU3JTlBJTg0JUU1JUFFJTg5JUU1JTg1JUE4JUVGJUJDJThDJUU3JUE2JTgxJUU2JUFEJUEyJUU4JUIwJTgzJUU4JUFGJTk1'))
12
+ window.location.href = decodeURIComponent(atob('YWJvdXQlM0FibGFuaw=='))
13
+ }
14
+ }
15
+ addListener(onDevtools)
16
+ if (
17
+ !window.eval.name
18
+ || !console.clear.name
19
+ || !RegExp.toString.toString().includes('toString')
20
+ || !history.pushState.toString.toString().includes('toString')
21
+ ) {
22
+ onDevtools(true)
23
+ }
24
+ if (
25
+ !(
26
+ whiteList || JSON.parse(
27
+ env.PROD
28
+ ? env.VITE_PROD_DEBUGGERABLE_DOMAINS
29
+ : env.VITE_DEV_DEBUGGERABLE_DOMAINS
30
+ )
31
+ ).includes(window.location.hostname)
32
+ ) {
33
+ launch()
34
+ window.addEventListener('contextmenu', (e) => {
35
+ if (
36
+ !(e.target instanceof SVGElement)
37
+ && !['IMG', 'CANVAS', 'AUDIO', 'VIDEO', 'PICTURE', 'INPUT', 'TEXTAREA'].includes(e.target.nodeName)
38
+ ) {
39
+ e.preventDefault()
40
+ }
41
+ }, true)
42
+ window.addEventListener('keydown', (e) => {
43
+ if (
44
+ e.code === 'F12'
45
+ || (e.metaKey || e.ctrlKey) && (e.altKey || e.shiftKey) && ['KeyU', 'KeyI', 'KeyJ', 'KeyC'].indexOf(e.code) >= 0
46
+ ) {
47
+ e.preventDefault()
48
+ }
49
+ }, true)
50
+ }
51
+ }
52
+
53
+ export default disallowDevtools
@@ -0,0 +1,173 @@
1
+
2
+ export const pop = (canvas) => {
3
+ const { width, height } = canvas.getBoundingClientRect()
4
+ canvas.width = width
5
+ canvas.height = height
6
+ const ctx = canvas.getContext('2d')
7
+
8
+ class Circle {
9
+ constructor (x, y, radius, color, vx, vy, ctx) {
10
+ this.x = x
11
+ this.y = y
12
+ this.radius = radius
13
+ this.color = color
14
+ this.vx = vx
15
+ this.vy = vy
16
+ this.ctx = ctx
17
+ }
18
+
19
+ update () {
20
+ this.x += this.vx
21
+ this.y += this.vy
22
+ this.ctx.beginPath()
23
+ this.ctx.fillStyle = this.color
24
+ this.ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2)
25
+ this.ctx.fill()
26
+ this.detectWall()
27
+ }
28
+
29
+ detectWall () {
30
+ if (this.x < this.radius) {
31
+ this.x = this.radius
32
+ this.vx = -this.vx
33
+ } else if (this.x + this.radius > width) {
34
+ this.x = width - this.radius
35
+ this.vx = -this.vx
36
+ }
37
+ if (this.y < this.radius) {
38
+ this.y = this.radius
39
+ this.vy = -this.vy
40
+ } else if (this.y + this.radius > height) {
41
+ this.y = height - this.radius
42
+ this.vy = -this.vy
43
+ }
44
+ }
45
+ }
46
+
47
+ const clear = () => ctx.clearRect(0, 0, width, height)
48
+ const randint = max => Math.floor(Math.random() * max)
49
+
50
+ let stop = 0
51
+ let stopStep = 0.01
52
+ let sleep = 0
53
+ const drawBackground = () => {
54
+ const gradient = ctx.createLinearGradient(0, 0, width * 1.5, height * 1.5)
55
+ if (!sleep) {
56
+ stop += stopStep
57
+ if (stop <= 0) {
58
+ stop = 0
59
+ stopStep = -stopStep
60
+ sleep = fps * 30
61
+ }
62
+ if (stop >= 1) {
63
+ stop = 1
64
+ stopStep = -stopStep
65
+ sleep = fps * 30
66
+ }
67
+ } else {
68
+ sleep --
69
+ }
70
+ gradient.addColorStop(0, 'rgba(250, 220, 20, 0.5)')
71
+ gradient.addColorStop(stop, 'rgba(20, 20, 20, 0.5)')
72
+ ctx.fillStyle = gradient
73
+ ctx.fillRect(0, 0, width, height)
74
+ }
75
+ const vw = Math.floor(width / 100)
76
+ const vh = Math.floor(height / 100)
77
+
78
+ const fps = 20
79
+ const frameGap = Math.round(1000 / fps)
80
+
81
+ const circles = Array.from({ length: 52 }).map(() => {
82
+ const radius = Math.floor(randint(vw + vh) * 1.5 + randint(5))
83
+ let x = randint(width)
84
+ let y = randint(height)
85
+ x = Math.min(Math.max(radius, x), width - radius)
86
+ y = Math.min(Math.max(radius, y), height - radius)
87
+ let vx = randint(2) ? (randint(2) + 2) * vw : (randint(-1) - 2) * vw
88
+ let vy = randint(2) ? (randint(2) + 2) * vh : (randint(-1) - 2) * vh
89
+ vx = Math.floor(vx / fps)
90
+ vy = Math.floor(vy / fps)
91
+ return new Circle(
92
+ x,
93
+ y,
94
+ radius,
95
+ `rgba(${randint(256)}, ${randint(256)}, ${randint(256)}, ${(randint(5) + 5) / 10})`,
96
+ vx,
97
+ vy,
98
+ ctx
99
+ )
100
+ })
101
+
102
+ let lastX, lastY
103
+ canvas.addEventListener('mouseover', e => {
104
+ lastX = e.pageX
105
+ lastY = e.pageY
106
+ })
107
+ canvas.addEventListener('mousemove', e => {
108
+ if (lastX === undefined) {
109
+ lastX = e.pageX
110
+ lastY = e.pageY
111
+ return
112
+ }
113
+ const diffX = e.pageX - lastX
114
+ const diffY = e.pageY - lastY
115
+ circles.forEach(c => {
116
+ c.x += diffX / fps
117
+ c.y += diffY / fps
118
+ })
119
+ lastX = e.pageX
120
+ lastY = e.pageY
121
+ })
122
+
123
+ let lastTime = Date.now()
124
+ let anim = null
125
+
126
+ const update = () => {
127
+ if (Date.now() - lastTime >= frameGap) {
128
+ clear()
129
+ drawBackground()
130
+ circles.forEach(circle => circle.update())
131
+ lastTime = Date.now()
132
+ }
133
+ anim = requestAnimationFrame(update)
134
+ }
135
+
136
+ anim = requestAnimationFrame(update)
137
+
138
+ return () => cancelAnimationFrame(anim)
139
+ }
140
+
141
+ export const createWatermark = ({
142
+ text,
143
+ gap,
144
+ fontSize,
145
+ color,
146
+ width = window.innerWidth,
147
+ height = window.innerHeight,
148
+ drawMode = 'fill'
149
+ }) => {
150
+ const canvas = document.createElement('canvas')
151
+ canvas.width = width
152
+ canvas.height = height
153
+
154
+ const ctx = canvas.getContext('2d')
155
+ ctx.font = `${fontSize}px Arial`
156
+ ctx[drawMode + 'Style'] = color
157
+
158
+ const textWidth = ctx.measureText(text).width
159
+ const perWidth = textWidth + gap
160
+ const perHeight = fontSize + gap
161
+ for (let y = gap / 2; y < height; y += perHeight) {
162
+ for (let x = gap / 2; x < width; x += perWidth) {
163
+ ctx[drawMode + 'Text'](text, x, y)
164
+ }
165
+ }
166
+
167
+ return canvas
168
+ }
169
+
170
+ export default {
171
+ pop,
172
+ createWatermark
173
+ }
@@ -0,0 +1,78 @@
1
+ import { toRaw, markRaw } from 'vue'
2
+
3
+ export const validateForm = async (model) => {
4
+ const ok = await model.formRef?.validate().then(() => true).catch(() => false)
5
+ const oks = await Promise.all(model.formItems?.filter(it => {
6
+ return it.comp?.endsWith('XForm') || it.comp?.endsWith('x-form')
7
+ }).map(it => validateForm(it.form)))
8
+ return ok && oks.every(ok => ok)
9
+ }
10
+
11
+ export const formatPrecision = (number, precision) => {
12
+ if (typeof number !== 'number') {
13
+ const parsed = parseFloat(number) || null
14
+ if (typeof parsed !== 'number') {
15
+ return number
16
+ }
17
+ number = parsed
18
+ }
19
+ return number.toFixed(precision) * 1
20
+ }
21
+
22
+ export const formatOptions = (options, vm) => {
23
+ const opts = options.__v_isRef ? options.value : toRaw(options)
24
+ const { text = 'text', value = 'value' } = vm
25
+ const items = opts.map(op => {
26
+ if (typeof op === 'object') {
27
+ return { text: op[text], value: op[value], disabled: op.disabled, raw: markRaw(op) }
28
+ } else {
29
+ return { text: op, value: op }
30
+ }
31
+ })
32
+ if (!vm.sort) return items
33
+ const field = typeof vm.sort === 'string' ? vm.sort : (vm.text || 'text')
34
+ return items.sort((a, b) => {
35
+ return a[field].localeCompare(b[field])
36
+ })
37
+ }
38
+
39
+ export const injectVanFieldProvide = (vm) => {
40
+ const provides = vm._.provides
41
+ const keys = Object.getOwnPropertySymbols(provides)
42
+ if (!keys.length) return
43
+ vm.provide = provides[keys[0]]
44
+ if (!vm.provide?.customValue) {
45
+ return vm.provide = null
46
+ }
47
+ vm.provide.customValue.value = () => vm.modelValue
48
+ }
49
+
50
+ export const getUrlType = url => {
51
+ const extname = url?.split('.').pop().toLowerCase()
52
+ if (['png', 'jpg', 'jpeg', 'gif', 'webp'].includes(extname)) return 'image'
53
+ else if (['mp4', 'webm', 'ogg', '3gpp', 'avi', 'mov'].includes(extname)) return 'video'
54
+ else if (extname === 'pdf') return 'pdf'
55
+ else if (extname === 'doc' || extname === 'docx') return 'docx'
56
+ else if (extname === 'xls' || extname === 'xlsx') return 'xlsx'
57
+ else if (extname === 'ppt' || extname === 'pptx') return 'pptx'
58
+ else if (['zip', 'rar', '7z', 'tar', 'gzip'].includes(extname)) return 'zip'
59
+ return 'others'
60
+ }
61
+
62
+ export const getFiletypeIcon = type => {
63
+ if (type === 'pdf') return 'iwwa:file-pdf'
64
+ if (type === 'docx') return 'file-icons:microsoft-word'
65
+ if (type === 'xlsx') return 'file-icons:microsoft-excel'
66
+ if (type === 'pptx') return 'file-icons:microsoft-powerpoint'
67
+ if (type === 'zip') return 'formkit:zip'
68
+ return 'bi:file-pdf-fill'
69
+ }
70
+
71
+ export default {
72
+ validateForm,
73
+ formatPrecision,
74
+ formatOptions,
75
+ injectVanFieldProvide,
76
+ getUrlType,
77
+ getFiletypeIcon
78
+ }
@@ -0,0 +1,95 @@
1
+ import crypt from './crypt.js'
2
+ import decorators from './decorators.js'
3
+ import effects from './effects.js'
4
+
5
+ import {
6
+ validateForm,
7
+ formatPrecision,
8
+ formatOptions,
9
+ getUrlType,
10
+ getFiletypeIcon
11
+ } from './funcs.js'
12
+
13
+ import {
14
+ Message,
15
+ Notify,
16
+ Confirm,
17
+ Prompt
18
+ } from './message.js'
19
+
20
+ import middlewares from './middlewares.js'
21
+
22
+ import {
23
+ baseForm,
24
+ baseTable,
25
+ baseDialog,
26
+ baseModel
27
+ } from './model.js'
28
+
29
+ import {
30
+ initFields,
31
+ initModel,
32
+ initTable,
33
+ initDialog,
34
+ initForm,
35
+ initFormRules,
36
+ initDefaultForm,
37
+ isWhenMatched,
38
+ triggers
39
+ } from './modelUtils.js'
40
+
41
+ export {
42
+ crypt,
43
+ effects,
44
+ validateForm,
45
+ formatPrecision,
46
+ formatOptions,
47
+ getUrlType,
48
+ getFiletypeIcon,
49
+ Message,
50
+ Notify,
51
+ Confirm,
52
+ Prompt,
53
+ baseForm,
54
+ baseTable,
55
+ baseDialog,
56
+ baseModel,
57
+ initFields,
58
+ initModel,
59
+ initTable,
60
+ initDialog,
61
+ initForm,
62
+ initFormRules,
63
+ initDefaultForm,
64
+ isWhenMatched,
65
+ triggers
66
+ }
67
+
68
+ export default {
69
+ crypt,
70
+ decorators,
71
+ effects,
72
+ validateForm,
73
+ formatPrecision,
74
+ formatOptions,
75
+ getUrlType,
76
+ getFiletypeIcon,
77
+ Message,
78
+ Notify,
79
+ Confirm,
80
+ Prompt,
81
+ middlewares,
82
+ baseForm,
83
+ baseTable,
84
+ baseDialog,
85
+ baseModel,
86
+ initFields,
87
+ initModel,
88
+ initTable,
89
+ initDialog,
90
+ initForm,
91
+ initFormRules,
92
+ initDefaultForm,
93
+ isWhenMatched,
94
+ triggers
95
+ }