@xmszm/core 0.0.1 → 0.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.
Files changed (77) hide show
  1. package/README.md +187 -0
  2. package/dist/index.cjs +2 -2
  3. package/dist/index.mjs +1431 -1170
  4. package/dist/plugin/vite/initRouteMeta.cjs +1 -0
  5. package/dist/plugin/vite/initRouteMeta.mjs +13 -0
  6. package/dist/style.css +1 -1
  7. package/docs/.vitepress/config.mjs +91 -0
  8. package/docs/components/config-options.md +125 -0
  9. package/docs/components/dataform.md +176 -23
  10. package/docs/components/datatable.md +58 -39
  11. package/docs/components/dialog.md +158 -19
  12. package/docs/components/options.md +44 -15
  13. package/docs/components/query.md +68 -14
  14. package/docs/components/utils.md +124 -16
  15. package/docs/guide/changelog.md +81 -0
  16. package/docs/guide/config.md +415 -0
  17. package/docs/guide/demo.md +2 -2
  18. package/docs/guide/local-development.md +109 -0
  19. package/docs/guide/quickstart.md +40 -11
  20. package/docs/index.md +3 -3
  21. package/docs/usage.md +30 -6
  22. package/examples/README.md +46 -0
  23. package/examples/index.html +14 -0
  24. package/examples/package.json +25 -0
  25. package/examples/pnpm-lock.yaml +1569 -0
  26. package/examples/pnpm-workspace.yaml +3 -0
  27. package/examples/src/AdminSystem.vue +870 -0
  28. package/examples/src/App.vue +330 -0
  29. package/examples/src/Introduction.vue +307 -0
  30. package/examples/src/main.js +22 -0
  31. package/examples/src/utils/permission.js +16 -0
  32. package/examples/src/utils/request.js +10 -0
  33. package/examples/vite.config.js +41 -0
  34. package/package.json +13 -4
  35. package/src/dialog/commonDialog.tsx +285 -0
  36. package/src/dialog/useCommonDialog.ts +41 -0
  37. package/src/dialog/utils/{dialog.js → dialog.ts} +2 -0
  38. package/src/directives/auto-register.ts +57 -0
  39. package/src/directives/permission.ts +67 -0
  40. package/src/enum/sort.tsx +45 -0
  41. package/src/form/DataForm.vue +34 -52
  42. package/src/index.ts +58 -0
  43. package/src/list/{useList.jsx → useList.tsx} +49 -14
  44. package/src/options/{Options.jsx → Options.tsx} +86 -72
  45. package/src/options/defaultOptions.tsx +656 -0
  46. package/src/plugin/index.ts +20 -0
  47. package/src/query/CommonQuery.vue +65 -90
  48. package/src/table/DataTable.vue +82 -95
  49. package/src/table/opr/{DataColumnCollet.jsx → DataColumnCollet.tsx} +18 -8
  50. package/src/table/opr/useDataColumn.tsx +226 -0
  51. package/src/table/opr/{useDataColumnButton.jsx → useDataColumnButton.tsx} +13 -6
  52. package/src/table/opr/{useDataColumnPop.jsx → useDataColumnPop.tsx} +13 -5
  53. package/src/table/opr/useQRCode.ts +40 -0
  54. package/src/utils/{array.js → array.ts} +4 -6
  55. package/src/utils/config.ts +192 -0
  56. package/src/utils/dialog.ts +110 -0
  57. package/src/utils/{object.js → object.ts} +1 -0
  58. package/src/utils/upload.ts +53 -0
  59. package/types/auto-imports.d.ts +78 -0
  60. package/types/components.d.ts +402 -0
  61. package/types/index.d.ts +145 -7
  62. package/types/plugin/vite/initRouteMeta.d.ts +23 -0
  63. package/types/src.d.ts +55 -0
  64. package/types/vue-shim.d.ts +9 -0
  65. package/examples/demo.vue +0 -224
  66. package/src/dialog/commonDialog.jsx +0 -230
  67. package/src/enum/sort.jsx +0 -31
  68. package/src/index.js +0 -46
  69. package/src/options/defaultOptions.jsx +0 -580
  70. package/src/table/opr/useDataColumn.jsx +0 -196
  71. package/src/utils/upload.js +0 -46
  72. /package/src/enum/{options.js → options.ts} +0 -0
  73. /package/src/plugin/vite/{initRouteMeta.js → initRouteMeta.ts} +0 -0
  74. /package/src/store/utils/{index.js → index.ts} +0 -0
  75. /package/src/table/utils/{ellipsis.js → ellipsis.ts} +0 -0
  76. /package/src/utils/{auth.js → auth.ts} +0 -0
  77. /package/src/utils/{time.js → time.ts} +0 -0
@@ -1,196 +0,0 @@
1
- import { hasPermission } from '@/utils/permission'
2
- import { NButton, NImage, NSpace, NSpin } from 'naive-ui'
3
- import { ref } from 'vue'
4
- import DataColumnCollet from './DataColumnCollet.jsx'
5
- import OprButton from './useDataColumnButton.jsx'
6
- import Pop from './useDataColumnPop.jsx'
7
-
8
- export const rowIndexKey = (row, index) => (row ? JSON.stringify(row) : index)
9
-
10
- export function createActionColumnJsx(
11
- defaultOption,
12
- oprParams = null,
13
- collectParams,
14
- ) {
15
- // 粗滤计算操作栏占用宽度
16
- // 粗滤计算操作栏占用宽度
17
- const defaultCollectParams = {
18
- max: 4,
19
- width: 80,
20
- }
21
- let collect = false
22
- if (typeof collectParams === 'boolean')
23
- collect = defaultCollectParams
24
- else if (typeof collectParams === 'object')
25
- collect = { ...defaultCollectParams, ...collectParams }
26
-
27
- console.log('collect', collect)
28
- console.log(Array.isArray(defaultOption))
29
- if (!Array.isArray(defaultOption)) {
30
- throw new TypeError('需要配置数组')
31
- }
32
- console.log('ddd')
33
- let actions = []
34
- let width = 0
35
- const filterAction = []
36
- const isLoading = false
37
-
38
- if (Array.isArray(defaultOption)) {
39
- actions = defaultOption
40
- actions.forEach((itm, idx) => {
41
- if (itm.permission) {
42
- if (hasPermission(itm.permission)) {
43
- if (!collectParams || idx < collect.max)
44
- width += itm?.label?.length * 12 + 36
45
-
46
- filterAction.push(itm)
47
- }
48
- }
49
- else {
50
- if (!collectParams || idx < collect.max)
51
- width += itm?.label?.length * 12 + 36
52
- filterAction.push(itm)
53
- }
54
- })
55
-
56
- // for (const item of actions) {
57
- // if (!isLoading && item?.loading) isLoading = true
58
- // if (item.permission && item?.label) {
59
- // if (hasPermission(item.permission)) {
60
- // width += item?.label?.length * 12 + 36
61
- // filterAction.push(item)
62
- // }
63
- // } else if (item?.label) {
64
- // width += item?.label?.length * 12 + 36
65
- // filterAction.push(item)
66
- // }
67
- // }
68
- }
69
-
70
- width = Math.max(80, width)
71
- // return filterAction.length
72
- // ?
73
- width += isLoading ? 20 : 0
74
-
75
- if (collect)
76
- width += 2
77
-
78
- return filterAction.length
79
- ? {
80
- title: '操作',
81
- key: 'opr',
82
- fixed: 'right',
83
- align: 'left',
84
- width,
85
- ...oprParams,
86
- render(row, index) {
87
- const vNodes = collect
88
- ? (
89
- <DataColumnCollet
90
- data={row}
91
- index={index}
92
- max={collect.max}
93
- options={filterAction}
94
- />
95
- )
96
- : (
97
- filterAction
98
- .map(
99
- (
100
- {
101
- isRender = () => true,
102
- onClick = null,
103
- mode = null,
104
- disabled = false,
105
- type = 'primary',
106
- ...action
107
- },
108
- i,
109
- ) => {
110
- return isRender?.(row)
111
- ? (
112
- mode === 'pop'
113
- ? (
114
- <Pop
115
- onClick={onClick}
116
- row={row}
117
- index={index}
118
- action={action}
119
- key={rowIndexKey(row, index) + i}
120
- >
121
- <NButton
122
- text
123
- disabled={disabled && disabled(row)}
124
- type={disabled && disabled(row) ? 'default' : type}
125
- {...action}
126
- >
127
- {typeof action?.label === 'function'
128
- ? action?.label(row)
129
- : action?.label}
130
- </NButton>
131
- </Pop>
132
- )
133
- : (
134
- <OprButton
135
- row={row}
136
- action={{
137
- ...action,
138
- disabled,
139
- onClick,
140
- type,
141
- }}
142
- index={index}
143
- key={rowIndexKey(row, index) + i}
144
- />
145
- )
146
- )
147
- : undefined
148
- },
149
- )
150
- .filter(v => v)
151
- )
152
- return oprParams?.isRender
153
- ? (
154
- oprParams?.render(row)
155
- )
156
- : (
157
- <NSpace
158
- align="center"
159
- wrap-item={false}
160
- size={18}
161
- key={rowIndexKey(row, index)}
162
- >
163
- {vNodes}
164
- </NSpace>
165
- )
166
- },
167
- }
168
- : undefined
169
- }
170
-
171
- export async function createQRCode(row, fn = null) {
172
- const code = ref(null)
173
- const loading = ref(false)
174
- $dialog.info({
175
- showIcon: false,
176
- style: {
177
- width: '350px',
178
- height: '350px',
179
- },
180
- content: () => (
181
- <div className="qr-box">
182
- {loading.value ? <NSpin class="qr-spin" show /> : ''}
183
- <div className="qr-img">
184
- <NImage src={code.value} style={{ width: '100%' }} />
185
- </div>
186
- <div className="qr-title">{loading.value ? '' : row.name}</div>
187
- </div>
188
- ),
189
- })
190
- if (fn) {
191
- loading.value = true
192
- code.value = await fn()
193
- loading.value = false
194
- }
195
- return true
196
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * 上传数据类型
3
- * @import {AxiosRequestConfig} 'axios'
4
- * @typedef {object} UploadData
5
- * @property {string} url - 文件上传后的访问地址
6
- * // 可根据实际需求扩展更多字段
7
- * @typedef {Promise<import('axios').AxiosResponse<UploadData>>} UploadDataPromise
8
- */
9
-
10
- import { BASE_URL } from '@/utils/request'
11
-
12
- /**
13
- * 实际的上传实现函数
14
- * @type {null | ((AxiosRequestConfig) => UploadDataPromise)}
15
- */
16
- let uploadMethod = null
17
-
18
- /**
19
- * 注册上传方法
20
- * @param {function(AxiosRequestConfig): UploadDataPromise} fn - 实际的上传实现函数
21
- */
22
- export function registryUpload(fn) {
23
- uploadMethod = fn
24
- }
25
-
26
- /**
27
- * 自定义上传方法,调用已注册的上传实现
28
- * @param {AxiosRequestConfig} args - 上传参数
29
- * @returns {UploadDataPromise} 上传结果Promise
30
- */
31
- export function customUpload(...args) {
32
- if (typeof uploadMethod !== 'function') {
33
- throw new TypeError('请先通过 registryUpload(fn) 注册上传实现')
34
- }
35
- return uploadMethod(...args)
36
- }
37
-
38
- export function getFileUrl(url, ossSize = null) {
39
- if (url && !url?.startsWith('http')) {
40
- return !ossSize
41
- ? `${BASE_URL}${url}`
42
- : `${BASE_URL}${url}?x-oss-process=style/w${ossSize}`
43
- }
44
- return url
45
- }
46
-
File without changes
File without changes
File without changes
File without changes
File without changes