adtec-core-package 3.2.3 → 3.2.5
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/package.json +1 -1
- package/src/api/workflow/workflowInstApi.ts +2 -2
- package/src/components/upload/CustomElUpload.vue +14 -16
- package/src/components/upload/ElUploads.vue +14 -16
- package/src/components/workflow/components/SelectReturnActivityDialog.vue +5 -2
- package/src/config/VxeTableConfig.ts +29 -9
- package/src/interface/workflow/IWfTaskAskVo.ts +2 -0
- package/src/utils/AxiosConfig.ts +4 -7
- package/src/utils/buildUploadHeaders.ts +58 -0
- package/src/utils/uploadAccept.ts +3 -1
- package/vite/umoCjsVirtual.ts +32 -13
- package/vite/umoIntegration.js +51 -16
- package/vite/umoIntegration.ts +20 -1
package/package.json
CHANGED
|
@@ -34,8 +34,8 @@ export default {
|
|
|
34
34
|
return request.post<IWfTaskVo>(baseUrl + '/taskReject', task)
|
|
35
35
|
},
|
|
36
36
|
//查询可回退环节
|
|
37
|
-
findReturnTaskList(taskId: string) {
|
|
38
|
-
return request.post<IWfReturnNodeVo[]>(baseUrl + '/findReturnTaskList', { taskId })
|
|
37
|
+
findReturnTaskList(taskId: string, ignoreBackNodes = false) {
|
|
38
|
+
return request.post<IWfReturnNodeVo[]>(baseUrl + '/findReturnTaskList', { taskId, ignoreBackNodes })
|
|
39
39
|
},
|
|
40
40
|
//回退任务
|
|
41
41
|
taskReturn(activity: IWfTaskAskVo) {
|
|
@@ -44,15 +44,7 @@
|
|
|
44
44
|
:before-upload="beforeUpload"
|
|
45
45
|
drag
|
|
46
46
|
:accept="getAccept"
|
|
47
|
-
:action="
|
|
48
|
-
'/api/doc/uploadFile/' +
|
|
49
|
-
business +
|
|
50
|
-
'/' +
|
|
51
|
-
businessId +
|
|
52
|
-
'/' +
|
|
53
|
-
association +
|
|
54
|
-
(watermarkCode ? '?watermarkCode=' + watermarkCode : '')
|
|
55
|
-
"
|
|
47
|
+
:action="uploadAction"
|
|
56
48
|
multiple
|
|
57
49
|
:limit="limit"
|
|
58
50
|
:headers="uploadHeaders"
|
|
@@ -101,7 +93,7 @@
|
|
|
101
93
|
|
|
102
94
|
<script setup lang="ts">
|
|
103
95
|
import { UploadFilled } from '@element-plus/icons-vue'
|
|
104
|
-
import { computed,
|
|
96
|
+
import { computed, ref } from 'vue'
|
|
105
97
|
import {
|
|
106
98
|
ElMessage,
|
|
107
99
|
ElMessageBox,
|
|
@@ -116,11 +108,9 @@ import documentApi from '../../api/DocumentApi.ts'
|
|
|
116
108
|
import frameworkUtils from '../../utils/FrameworkUtils.ts'
|
|
117
109
|
import { userInfoStore } from '../../stores/userInfoStore'
|
|
118
110
|
import { getAcceptString } from '../../utils/uploadAccept.ts'
|
|
111
|
+
import { buildUploadHeaders } from '../../utils/buildUploadHeaders.ts'
|
|
119
112
|
|
|
120
113
|
const { fileView: fileView } = useFileView()
|
|
121
|
-
const uploadHeaders = ref({
|
|
122
|
-
Authorization: '',
|
|
123
|
-
})
|
|
124
114
|
const emit = defineEmits(['success'])
|
|
125
115
|
const userInfo = userInfoStore()
|
|
126
116
|
const ref_upload = ref()
|
|
@@ -217,6 +207,17 @@ const props = defineProps({
|
|
|
217
207
|
default: () => undefined,
|
|
218
208
|
},
|
|
219
209
|
})
|
|
210
|
+
const uploadAction = computed(
|
|
211
|
+
() =>
|
|
212
|
+
'/api/doc/uploadFile/' +
|
|
213
|
+
props.business +
|
|
214
|
+
'/' +
|
|
215
|
+
props.businessId +
|
|
216
|
+
'/' +
|
|
217
|
+
props.association +
|
|
218
|
+
(props.watermarkCode ? '?watermarkCode=' + props.watermarkCode : ''),
|
|
219
|
+
)
|
|
220
|
+
const uploadHeaders = computed(() => buildUploadHeaders(uploadAction.value))
|
|
220
221
|
/**
|
|
221
222
|
* 文件列表
|
|
222
223
|
*/
|
|
@@ -435,9 +436,6 @@ const confirm = async (autoDelete: boolean = true) => {
|
|
|
435
436
|
}
|
|
436
437
|
}
|
|
437
438
|
}
|
|
438
|
-
onMounted(() => {
|
|
439
|
-
uploadHeaders.value.Authorization = sessionStorage.getItem('Authorization') + ''
|
|
440
|
-
})
|
|
441
439
|
defineExpose({
|
|
442
440
|
remove,
|
|
443
441
|
confirm,
|
|
@@ -40,15 +40,7 @@
|
|
|
40
40
|
:before-upload="beforeUpload"
|
|
41
41
|
drag
|
|
42
42
|
:accept="getAccept"
|
|
43
|
-
:action="
|
|
44
|
-
'/api/doc/uploadFile/' +
|
|
45
|
-
business +
|
|
46
|
-
'/' +
|
|
47
|
-
businessId +
|
|
48
|
-
'/' +
|
|
49
|
-
association +
|
|
50
|
-
(watermarkCode ? '?watermarkCode=' + watermarkCode : '')
|
|
51
|
-
"
|
|
43
|
+
:action="uploadAction"
|
|
52
44
|
multiple
|
|
53
45
|
:limit="limit"
|
|
54
46
|
:headers="uploadHeaders"
|
|
@@ -97,7 +89,7 @@
|
|
|
97
89
|
|
|
98
90
|
<script setup lang="ts">
|
|
99
91
|
import { UploadFilled } from '@element-plus/icons-vue'
|
|
100
|
-
import { computed,
|
|
92
|
+
import { computed, ref, watch } from 'vue'
|
|
101
93
|
import {
|
|
102
94
|
ElMessage,
|
|
103
95
|
ElMessageBox,
|
|
@@ -112,11 +104,9 @@ import documentApi from '../../api/DocumentApi.ts'
|
|
|
112
104
|
import frameworkUtils from '../../utils/FrameworkUtils.ts'
|
|
113
105
|
import { userInfoStore } from '../../stores/userInfoStore'
|
|
114
106
|
import { getAcceptString } from '../../utils/uploadAccept.ts'
|
|
107
|
+
import { buildUploadHeaders } from '../../utils/buildUploadHeaders.ts'
|
|
115
108
|
|
|
116
109
|
const { fileView: fileView } = useFileView()
|
|
117
|
-
const uploadHeaders = ref({
|
|
118
|
-
Authorization: '',
|
|
119
|
-
})
|
|
120
110
|
const userInfo = userInfoStore()
|
|
121
111
|
const ref_upload = ref()
|
|
122
112
|
const hoverfileName = ref('')
|
|
@@ -201,6 +191,17 @@ const props = defineProps({
|
|
|
201
191
|
default: () => undefined,
|
|
202
192
|
},
|
|
203
193
|
})
|
|
194
|
+
const uploadAction = computed(
|
|
195
|
+
() =>
|
|
196
|
+
'/api/doc/uploadFile/' +
|
|
197
|
+
props.business +
|
|
198
|
+
'/' +
|
|
199
|
+
props.businessId +
|
|
200
|
+
'/' +
|
|
201
|
+
props.association +
|
|
202
|
+
(props.watermarkCode ? '?watermarkCode=' + props.watermarkCode : ''),
|
|
203
|
+
)
|
|
204
|
+
const uploadHeaders = computed(() => buildUploadHeaders(uploadAction.value))
|
|
204
205
|
const mousemove = (fileName: string) => {
|
|
205
206
|
hoverfileName.value = fileName
|
|
206
207
|
}
|
|
@@ -325,9 +326,6 @@ const remove = async (file: UploadFile) => {
|
|
|
325
326
|
}
|
|
326
327
|
// }
|
|
327
328
|
}
|
|
328
|
-
onMounted(() => {
|
|
329
|
-
uploadHeaders.value.Authorization = sessionStorage.getItem('Authorization') + ''
|
|
330
|
-
})
|
|
331
329
|
defineExpose({
|
|
332
330
|
remove,
|
|
333
331
|
})
|
|
@@ -49,14 +49,16 @@ const loading = ref(false)
|
|
|
49
49
|
const selectActivity = ref<string>('')
|
|
50
50
|
const taskId = ref<string>('')
|
|
51
51
|
const comment = ref<string>('')
|
|
52
|
-
const
|
|
52
|
+
const ignoreBackNodes = ref(false)
|
|
53
|
+
const open = async (tId: string, c: string, ignoreBackNodesFlag = false) => {
|
|
53
54
|
try {
|
|
54
55
|
selectActivity.value = ''
|
|
55
56
|
taskId.value = tId ?? ''
|
|
56
57
|
comment.value = c ?? ''
|
|
58
|
+
ignoreBackNodes.value = ignoreBackNodesFlag
|
|
57
59
|
dialogVisible.value = true
|
|
58
60
|
loading.value = true
|
|
59
|
-
data.value = await workflowInstApi.findReturnTaskList(tId)
|
|
61
|
+
data.value = await workflowInstApi.findReturnTaskList(tId, ignoreBackNodesFlag)
|
|
60
62
|
} catch (err: any) {
|
|
61
63
|
data.value = []
|
|
62
64
|
frameworkUtils.messageError(err)
|
|
@@ -76,6 +78,7 @@ const save = async () => {
|
|
|
76
78
|
userId: userInfoStore().getUserInfo.id,
|
|
77
79
|
comment: comment.value,
|
|
78
80
|
targetKey: selectActivity.value,
|
|
81
|
+
ignoreBackNodes: ignoreBackNodes.value,
|
|
79
82
|
})
|
|
80
83
|
ElMessage.success('回退成功')
|
|
81
84
|
emit('success')
|
|
@@ -4,14 +4,11 @@ import {
|
|
|
4
4
|
VxeUI,
|
|
5
5
|
VxeTooltip } from 'vxe-pc-ui'
|
|
6
6
|
|
|
7
|
-
import VxeUIPluginRenderElement from '@vxe-ui/plugin-render-element'
|
|
8
7
|
import '@vxe-ui/plugin-render-element/dist/style.css'
|
|
9
|
-
import VxeUIPluginExportXLSX from '@vxe-ui/plugin-export-xlsx'
|
|
10
8
|
import 'vxe-pc-ui/lib/style.css'
|
|
11
9
|
import '../css/vxeTableUI/all.scss'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
|
|
10
|
+
// 导入默认的语言(使用 es 构建,避免 lib CJS 在 Vite 下无 default 导出)
|
|
11
|
+
import zhCN from 'vxe-table/es/locale/lang/zh-CN'
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* 局部初始化 vxe-table 插件与配置
|
|
@@ -25,15 +22,38 @@ export function initVxeTableInPage(
|
|
|
25
22
|
VxeUI.setI18n('zh-CN', zhCN)
|
|
26
23
|
VxeUI.setLanguage('zh-CN')
|
|
27
24
|
VxeUI.component(VxeTooltip)
|
|
28
|
-
//
|
|
29
|
-
|
|
25
|
+
// 局部注册插件(CJS 包动态加载,避免 Vite 静态 import 无 default 导出)
|
|
26
|
+
if (enableElementPlus) {
|
|
27
|
+
void import('@vxe-ui/plugin-render-element').then((renderModule) => {
|
|
28
|
+
const VxeUIPluginRenderElement =
|
|
29
|
+
renderModule.default ??
|
|
30
|
+
(renderModule as { VxeUIPluginRenderElement?: typeof renderModule.default })
|
|
31
|
+
.VxeUIPluginRenderElement ??
|
|
32
|
+
renderModule
|
|
33
|
+
VxeUI.use(VxeUIPluginRenderElement)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
30
36
|
if (enableExcel) {
|
|
31
|
-
void
|
|
37
|
+
void Promise.all([
|
|
38
|
+
import('exceljs'),
|
|
39
|
+
import('@vxe-ui/plugin-export-xlsx'),
|
|
40
|
+
]).then(([{ default: ExcelJS }, xlsxModule]) => {
|
|
41
|
+
const VxeUIPluginExportXLSX =
|
|
42
|
+
xlsxModule.default ??
|
|
43
|
+
(xlsxModule as { VxeUIPluginExportXLSX?: typeof xlsxModule.default }).VxeUIPluginExportXLSX ??
|
|
44
|
+
xlsxModule
|
|
32
45
|
VxeUI.use(VxeUIPluginExportXLSX, { ExcelJS })
|
|
33
46
|
})
|
|
34
47
|
}
|
|
35
48
|
if (enablePdf) {
|
|
36
|
-
void
|
|
49
|
+
void Promise.all([
|
|
50
|
+
import('jspdf'),
|
|
51
|
+
import('@vxe-ui/plugin-export-pdf'),
|
|
52
|
+
]).then(([{ jsPDF }, pdfModule]) => {
|
|
53
|
+
const VxeUIPluginExportPDF =
|
|
54
|
+
pdfModule.default ??
|
|
55
|
+
(pdfModule as { VxeUIPluginExportPDF?: typeof pdfModule.default }).VxeUIPluginExportPDF ??
|
|
56
|
+
pdfModule
|
|
37
57
|
VxeUI.use(VxeUIPluginExportPDF, { jsPDF })
|
|
38
58
|
})
|
|
39
59
|
}
|
package/src/utils/AxiosConfig.ts
CHANGED
|
@@ -14,6 +14,7 @@ import encrypt from './encrypt'
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
15
|
|
|
16
16
|
import { Md5 } from 'ts-md5'
|
|
17
|
+
import { computeSigna, normalizeSignaPayload } from './buildUploadHeaders'
|
|
17
18
|
import { ElMessage } from 'element-plus'
|
|
18
19
|
import { useEventBus } from '@vueuse/core'
|
|
19
20
|
/** 是否正在刷新的标志 */
|
|
@@ -31,7 +32,6 @@ const request = axios.create({
|
|
|
31
32
|
function setHeaders(config: any) {
|
|
32
33
|
//数据防止篡改
|
|
33
34
|
const Authorization = config.skipAuthorization ? '' : sessionStorage.getItem('Authorization')
|
|
34
|
-
const signa = 'F2E49299-D0D2-4AA1-87A3-270272EA3D6A'
|
|
35
35
|
let dataJson: string = ''
|
|
36
36
|
if (config.method === 'get') {
|
|
37
37
|
if (config.params) {
|
|
@@ -52,14 +52,11 @@ function setHeaders(config: any) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
dataJson=dataJson.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '')
|
|
58
|
-
dataJson = dataJson.split('').sort().join('').trim()
|
|
55
|
+
const normalizedPayload = normalizeSignaPayload(dataJson)
|
|
59
56
|
config.headers.sessionId = config.skipAuthorization ? '' : sessionStorage.getItem('sessionId')
|
|
60
57
|
config.headers.Authorization = Authorization
|
|
61
|
-
config.headers.signa =
|
|
62
|
-
config.headers.antiShakeKey = Md5.hashStr(
|
|
58
|
+
config.headers.signa = computeSigna(Authorization || '', dataJson)
|
|
59
|
+
config.headers.antiShakeKey = Md5.hashStr(normalizedPayload)
|
|
63
60
|
//防止重放 GUID+当前时间+TOKEN 加密
|
|
64
61
|
const timeDifference = sessionStorage.getItem('timeDifference')
|
|
65
62
|
const id = uuidv4()
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Md5 } from 'ts-md5'
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
3
|
+
import encrypt from './encrypt'
|
|
4
|
+
|
|
5
|
+
/** 与后端 token.dataSigna / DataTamperingFilter 一致 */
|
|
6
|
+
export const SIGNA_KEY = 'F2E49299-D0D2-4AA1-87A3-270272EA3D6A'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 规范化 signa 参与签名的字符串(strip 非字母数字 → 字符排序)。
|
|
10
|
+
* multipart 上传使用完整 URL(含 query);JSON 接口使用序列化后的 body。
|
|
11
|
+
*/
|
|
12
|
+
export function normalizeSignaPayload(raw: string): string {
|
|
13
|
+
return raw
|
|
14
|
+
.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '')
|
|
15
|
+
.split('')
|
|
16
|
+
.sort()
|
|
17
|
+
.join('')
|
|
18
|
+
.trim()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function computeSigna(authorization: string, payload: string): string {
|
|
22
|
+
return Md5.hashStr(authorization + SIGNA_KEY + normalizeSignaPayload(payload))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BuildUploadHeadersOptions {
|
|
26
|
+
/** 上传 action 路径,如 /api/doc/uploadFile/biz/id/true?watermarkCode=xxx */
|
|
27
|
+
url: string
|
|
28
|
+
skipAuthorization?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* el-upload / uni.uploadFile 等不走 axios 拦截器的上传请求头。
|
|
33
|
+
* signa 按 URL 计算,与 DataTamperingFilter multipart 分支对齐。
|
|
34
|
+
*/
|
|
35
|
+
export function buildUploadHeaders(
|
|
36
|
+
options: BuildUploadHeadersOptions | string,
|
|
37
|
+
): Record<string, string> {
|
|
38
|
+
const url = typeof options === 'string' ? options : options.url
|
|
39
|
+
const skipAuthorization =
|
|
40
|
+
typeof options === 'string' ? false : (options.skipAuthorization ?? false)
|
|
41
|
+
|
|
42
|
+
const Authorization = skipAuthorization ? '' : sessionStorage.getItem('Authorization') || ''
|
|
43
|
+
const normalizedPayload = normalizeSignaPayload(url)
|
|
44
|
+
|
|
45
|
+
const timeDifference = sessionStorage.getItem('timeDifference')
|
|
46
|
+
const id = uuidv4()
|
|
47
|
+
const localTime = new Date().getTime()
|
|
48
|
+
const replayObj = { timeDifference, guid: id, localTime }
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
Authorization,
|
|
52
|
+
sessionId: skipAuthorization ? '' : sessionStorage.getItem('sessionId') || '',
|
|
53
|
+
signa: computeSigna(Authorization, url),
|
|
54
|
+
antiShakeKey: Md5.hashStr(normalizedPayload),
|
|
55
|
+
'Cache-Control': 'no-cache',
|
|
56
|
+
replayToken: encrypt.encrypt(JSON.stringify(replayObj)),
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -16,6 +16,8 @@ export function getAcceptString(accept: string): string | undefined {
|
|
|
16
16
|
return '.xls,.xlsx'
|
|
17
17
|
} else if (accept === 'ppt') {
|
|
18
18
|
return '.ppt,.pptx'
|
|
19
|
+
} else if (accept === 'zip') {
|
|
20
|
+
return '.zip'
|
|
19
21
|
}
|
|
20
22
|
return undefined
|
|
21
23
|
}
|
|
@@ -28,7 +30,7 @@ export function getAcceptSuffixes(accept: string): string[] | null {
|
|
|
28
30
|
return acceptStr.split(',').map((suffix) => suffix.slice(1).toLowerCase())
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
const ACCEPT_TYPES = ['images', 'document', 'txt', 'pdf', 'word', 'excel', 'ppt'] as const
|
|
33
|
+
const ACCEPT_TYPES = ['images', 'document', 'txt', 'pdf', 'word', 'excel', 'ppt', 'zip'] as const
|
|
32
34
|
|
|
33
35
|
const ALL_PREVIEW_SUFFIXES = new Set(
|
|
34
36
|
ACCEPT_TYPES.flatMap((accept) => getAcceptSuffixes(accept) ?? []),
|
package/vite/umoCjsVirtual.ts
CHANGED
|
@@ -23,15 +23,36 @@ const UMO_CJS_SPECS = [
|
|
|
23
23
|
'nzh/cn',
|
|
24
24
|
'jszip',
|
|
25
25
|
'exceljs',
|
|
26
|
+
'@vxe-ui/plugin-render-element',
|
|
27
|
+
'@vxe-ui/plugin-export-xlsx',
|
|
28
|
+
'@vxe-ui/plugin-export-pdf',
|
|
26
29
|
] as const
|
|
27
30
|
|
|
28
31
|
const UMO_CJS_NAMED_EXPORTS: Record<string, string[]> = {
|
|
29
32
|
'file-saver': ['saveAs'],
|
|
30
33
|
'pure-svg-code': ['qrcode', 'barcode', 'svg2url'],
|
|
34
|
+
'@vxe-ui/plugin-render-element': ['VxeUIPluginRenderElement'],
|
|
35
|
+
'@vxe-ui/plugin-export-xlsx': ['VxeUIPluginExportXLSX'],
|
|
36
|
+
'@vxe-ui/plugin-export-pdf': ['VxeUIPluginExportPDF'],
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
const VIRTUAL_UMO_CJS_PREFIX = '\0virtual:umo-cjs:'
|
|
34
40
|
|
|
41
|
+
function parseNpmSpec(spec: string): { pkgName: string; subPath: string | null } {
|
|
42
|
+
if (spec.startsWith('@')) {
|
|
43
|
+
const parts = spec.split('/')
|
|
44
|
+
if (parts.length >= 2) {
|
|
45
|
+
return {
|
|
46
|
+
pkgName: `${parts[0]}/${parts[1]}`,
|
|
47
|
+
subPath: parts.length > 2 ? parts.slice(2).join('/') : null,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const slashIndex = spec.indexOf('/')
|
|
52
|
+
if (slashIndex === -1) return { pkgName: spec, subPath: null }
|
|
53
|
+
return { pkgName: spec.slice(0, slashIndex), subPath: spec.slice(slashIndex + 1) }
|
|
54
|
+
}
|
|
55
|
+
|
|
35
56
|
function requireFromProjectRoot() {
|
|
36
57
|
return createRequire(path.join(getProjectRoot(), 'package.json'))
|
|
37
58
|
}
|
|
@@ -58,7 +79,7 @@ function resolvePackageMain(pkgDir: string): string | null {
|
|
|
58
79
|
|
|
59
80
|
function findUmoPackageDir(pkgName: string): string | null {
|
|
60
81
|
const projectRoot = getProjectRoot()
|
|
61
|
-
const hoisted = path.join(projectRoot, 'node_modules', pkgName)
|
|
82
|
+
const hoisted = path.join(projectRoot, 'node_modules', ...pkgName.split('/'))
|
|
62
83
|
if (fs.existsSync(path.join(hoisted, 'package.json'))) return hoisted
|
|
63
84
|
|
|
64
85
|
const pnpmDir = path.join(projectRoot, 'node_modules/.pnpm')
|
|
@@ -68,16 +89,16 @@ function findUmoPackageDir(pkgName: string): string | null {
|
|
|
68
89
|
const pkgDir = fs.readdirSync(pnpmDir).find((name) => name.startsWith(`${pnpmPrefix}@`))
|
|
69
90
|
if (!pkgDir) return null
|
|
70
91
|
|
|
71
|
-
const resolved = path.join(pnpmDir, pkgDir, 'node_modules', pkgName)
|
|
92
|
+
const resolved = path.join(pnpmDir, pkgDir, 'node_modules', ...pkgName.split('/'))
|
|
72
93
|
return fs.existsSync(path.join(resolved, 'package.json')) ? resolved : null
|
|
73
94
|
}
|
|
74
95
|
|
|
75
96
|
function findUmoPackageEntryForSpec(spec: string): string | null {
|
|
76
|
-
const
|
|
97
|
+
const { pkgName, subPath } = parseNpmSpec(spec)
|
|
77
98
|
const pkgDir = findUmoPackageDir(pkgName)
|
|
78
99
|
if (!pkgDir) return null
|
|
79
100
|
|
|
80
|
-
if (
|
|
101
|
+
if (!subPath) {
|
|
81
102
|
const override = UMO_CJS_ENTRY_OVERRIDES[pkgName]
|
|
82
103
|
if (override) {
|
|
83
104
|
const overridePath = path.join(pkgDir, override)
|
|
@@ -88,11 +109,10 @@ function findUmoPackageEntryForSpec(spec: string): string | null {
|
|
|
88
109
|
return resolvePackageMain(pkgDir)
|
|
89
110
|
}
|
|
90
111
|
|
|
91
|
-
const sub = subParts.join('/')
|
|
92
112
|
const candidates = [
|
|
93
|
-
path.join(pkgDir, `${
|
|
94
|
-
path.join(pkgDir,
|
|
95
|
-
path.join(pkgDir,
|
|
113
|
+
path.join(pkgDir, `${subPath}.js`),
|
|
114
|
+
path.join(pkgDir, subPath, 'index.js'),
|
|
115
|
+
path.join(pkgDir, subPath),
|
|
96
116
|
]
|
|
97
117
|
for (const candidate of candidates) {
|
|
98
118
|
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate
|
|
@@ -102,13 +122,12 @@ function findUmoPackageEntryForSpec(spec: string): string | null {
|
|
|
102
122
|
}
|
|
103
123
|
|
|
104
124
|
function matchesUmoCjsFile(source: string, spec: string): boolean {
|
|
105
|
-
const
|
|
106
|
-
if (!source.includes(`/${
|
|
107
|
-
if (
|
|
125
|
+
const { pkgName, subPath } = parseNpmSpec(spec)
|
|
126
|
+
if (!source.includes(`/${pkgName}/`)) return false
|
|
127
|
+
if (!subPath) {
|
|
108
128
|
return source.endsWith('.js') || source.includes('.js?')
|
|
109
129
|
}
|
|
110
|
-
|
|
111
|
-
return source.includes(`/${pkg}/${subPath}.js`) || source.includes(`/${pkg}/${subPath}?`)
|
|
130
|
+
return source.includes(`/${subPath}.js`) || source.includes(`/${subPath}?`)
|
|
112
131
|
}
|
|
113
132
|
|
|
114
133
|
function augmentUmoCjsNamedExports(code: string, spec: string): string {
|
package/vite/umoIntegration.js
CHANGED
|
@@ -448,13 +448,33 @@ var UMO_CJS_SPECS = [
|
|
|
448
448
|
"pure-svg-code",
|
|
449
449
|
"nzh/cn",
|
|
450
450
|
"jszip",
|
|
451
|
-
"exceljs"
|
|
451
|
+
"exceljs",
|
|
452
|
+
"@vxe-ui/plugin-render-element",
|
|
453
|
+
"@vxe-ui/plugin-export-xlsx",
|
|
454
|
+
"@vxe-ui/plugin-export-pdf"
|
|
452
455
|
];
|
|
453
456
|
var UMO_CJS_NAMED_EXPORTS = {
|
|
454
457
|
"file-saver": ["saveAs"],
|
|
455
|
-
"pure-svg-code": ["qrcode", "barcode", "svg2url"]
|
|
458
|
+
"pure-svg-code": ["qrcode", "barcode", "svg2url"],
|
|
459
|
+
"@vxe-ui/plugin-render-element": ["VxeUIPluginRenderElement"],
|
|
460
|
+
"@vxe-ui/plugin-export-xlsx": ["VxeUIPluginExportXLSX"],
|
|
461
|
+
"@vxe-ui/plugin-export-pdf": ["VxeUIPluginExportPDF"]
|
|
456
462
|
};
|
|
457
463
|
var VIRTUAL_UMO_CJS_PREFIX = "\0virtual:umo-cjs:";
|
|
464
|
+
function parseNpmSpec(spec) {
|
|
465
|
+
if (spec.startsWith("@")) {
|
|
466
|
+
const parts = spec.split("/");
|
|
467
|
+
if (parts.length >= 2) {
|
|
468
|
+
return {
|
|
469
|
+
pkgName: `${parts[0]}/${parts[1]}`,
|
|
470
|
+
subPath: parts.length > 2 ? parts.slice(2).join("/") : null
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const slashIndex = spec.indexOf("/");
|
|
475
|
+
if (slashIndex === -1) return { pkgName: spec, subPath: null };
|
|
476
|
+
return { pkgName: spec.slice(0, slashIndex), subPath: spec.slice(slashIndex + 1) };
|
|
477
|
+
}
|
|
458
478
|
function requireFromProjectRoot() {
|
|
459
479
|
return createRequire4(path4.join(getProjectRoot(), "package.json"));
|
|
460
480
|
}
|
|
@@ -475,21 +495,21 @@ function resolvePackageMain(pkgDir) {
|
|
|
475
495
|
}
|
|
476
496
|
function findUmoPackageDir(pkgName) {
|
|
477
497
|
const projectRoot2 = getProjectRoot();
|
|
478
|
-
const hoisted = path4.join(projectRoot2, "node_modules", pkgName);
|
|
498
|
+
const hoisted = path4.join(projectRoot2, "node_modules", ...pkgName.split("/"));
|
|
479
499
|
if (fs5.existsSync(path4.join(hoisted, "package.json"))) return hoisted;
|
|
480
500
|
const pnpmDir = path4.join(projectRoot2, "node_modules/.pnpm");
|
|
481
501
|
if (!fs5.existsSync(pnpmDir)) return null;
|
|
482
502
|
const pnpmPrefix = pkgName.replace("/", "+");
|
|
483
503
|
const pkgDir = fs5.readdirSync(pnpmDir).find((name) => name.startsWith(`${pnpmPrefix}@`));
|
|
484
504
|
if (!pkgDir) return null;
|
|
485
|
-
const resolved = path4.join(pnpmDir, pkgDir, "node_modules", pkgName);
|
|
505
|
+
const resolved = path4.join(pnpmDir, pkgDir, "node_modules", ...pkgName.split("/"));
|
|
486
506
|
return fs5.existsSync(path4.join(resolved, "package.json")) ? resolved : null;
|
|
487
507
|
}
|
|
488
508
|
function findUmoPackageEntryForSpec(spec) {
|
|
489
|
-
const
|
|
509
|
+
const { pkgName, subPath } = parseNpmSpec(spec);
|
|
490
510
|
const pkgDir = findUmoPackageDir(pkgName);
|
|
491
511
|
if (!pkgDir) return null;
|
|
492
|
-
if (
|
|
512
|
+
if (!subPath) {
|
|
493
513
|
const override = UMO_CJS_ENTRY_OVERRIDES[pkgName];
|
|
494
514
|
if (override) {
|
|
495
515
|
const overridePath = path4.join(pkgDir, override);
|
|
@@ -499,11 +519,10 @@ function findUmoPackageEntryForSpec(spec) {
|
|
|
499
519
|
}
|
|
500
520
|
return resolvePackageMain(pkgDir);
|
|
501
521
|
}
|
|
502
|
-
const sub = subParts.join("/");
|
|
503
522
|
const candidates = [
|
|
504
|
-
path4.join(pkgDir, `${
|
|
505
|
-
path4.join(pkgDir,
|
|
506
|
-
path4.join(pkgDir,
|
|
523
|
+
path4.join(pkgDir, `${subPath}.js`),
|
|
524
|
+
path4.join(pkgDir, subPath, "index.js"),
|
|
525
|
+
path4.join(pkgDir, subPath)
|
|
507
526
|
];
|
|
508
527
|
for (const candidate of candidates) {
|
|
509
528
|
if (fs5.existsSync(candidate) && fs5.statSync(candidate).isFile()) return candidate;
|
|
@@ -511,13 +530,12 @@ function findUmoPackageEntryForSpec(spec) {
|
|
|
511
530
|
return null;
|
|
512
531
|
}
|
|
513
532
|
function matchesUmoCjsFile(source, spec) {
|
|
514
|
-
const
|
|
515
|
-
if (!source.includes(`/${
|
|
516
|
-
if (
|
|
533
|
+
const { pkgName, subPath } = parseNpmSpec(spec);
|
|
534
|
+
if (!source.includes(`/${pkgName}/`)) return false;
|
|
535
|
+
if (!subPath) {
|
|
517
536
|
return source.endsWith(".js") || source.includes(".js?");
|
|
518
537
|
}
|
|
519
|
-
|
|
520
|
-
return source.includes(`/${pkg}/${subPath}.js`) || source.includes(`/${pkg}/${subPath}?`);
|
|
538
|
+
return source.includes(`/${subPath}.js`) || source.includes(`/${subPath}?`);
|
|
521
539
|
}
|
|
522
540
|
function augmentUmoCjsNamedExports(code, spec) {
|
|
523
541
|
const named = UMO_CJS_NAMED_EXPORTS[spec] ?? UMO_CJS_NAMED_EXPORTS[spec.split("/")[0] ?? ""];
|
|
@@ -653,8 +671,24 @@ function docxPreviewViteFix() {
|
|
|
653
671
|
}
|
|
654
672
|
};
|
|
655
673
|
}
|
|
674
|
+
function coreVxeTableViteFix() {
|
|
675
|
+
return {
|
|
676
|
+
name: "core-vxe-table-vite",
|
|
677
|
+
config() {
|
|
678
|
+
return {
|
|
679
|
+
optimizeDeps: {
|
|
680
|
+
exclude: [
|
|
681
|
+
"@vxe-ui/plugin-render-element",
|
|
682
|
+
"@vxe-ui/plugin-export-xlsx",
|
|
683
|
+
"@vxe-ui/plugin-export-pdf"
|
|
684
|
+
]
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
}
|
|
656
690
|
function coreOfficePreviewVitePlugins() {
|
|
657
|
-
return [createProjectRootPlugin(), umoCjsVirtual(), docxPreviewViteFix()];
|
|
691
|
+
return [createProjectRootPlugin(), umoCjsVirtual(), docxPreviewViteFix(), coreVxeTableViteFix()];
|
|
658
692
|
}
|
|
659
693
|
function coreUmoVitePlugins() {
|
|
660
694
|
return [
|
|
@@ -663,6 +697,7 @@ function coreUmoVitePlugins() {
|
|
|
663
697
|
highlightJsLibVirtual(),
|
|
664
698
|
umoCjsVirtual(),
|
|
665
699
|
docxPreviewViteFix(),
|
|
700
|
+
coreVxeTableViteFix(),
|
|
666
701
|
tiptapUmoResolve(),
|
|
667
702
|
yjsPeerResolve()
|
|
668
703
|
];
|
package/vite/umoIntegration.ts
CHANGED
|
@@ -23,12 +23,30 @@ function docxPreviewViteFix(): Plugin {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** vxe-ui 插件为 CJS,交由 umoCjsVirtual 转 ESM,避免 Vite 直接解析 index.common.js */
|
|
27
|
+
function coreVxeTableViteFix(): Plugin {
|
|
28
|
+
return {
|
|
29
|
+
name: 'core-vxe-table-vite',
|
|
30
|
+
config() {
|
|
31
|
+
return {
|
|
32
|
+
optimizeDeps: {
|
|
33
|
+
exclude: [
|
|
34
|
+
'@vxe-ui/plugin-render-element',
|
|
35
|
+
'@vxe-ui/plugin-export-xlsx',
|
|
36
|
+
'@vxe-ui/plugin-export-pdf',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
/**
|
|
27
45
|
* 核心包 CJS 兼容(附件预览 docx-preview/jszip、表格导出 exceljs 等)在宿主 Vite 中的插件。
|
|
28
46
|
* 前端系统框架等未接入完整 Umo 插件链的宿主也应引入。
|
|
29
47
|
*/
|
|
30
48
|
export function coreOfficePreviewVitePlugins(): Plugin[] {
|
|
31
|
-
return [createProjectRootPlugin(), umoCjsVirtual(), docxPreviewViteFix()]
|
|
49
|
+
return [createProjectRootPlugin(), umoCjsVirtual(), docxPreviewViteFix(), coreVxeTableViteFix()]
|
|
32
50
|
}
|
|
33
51
|
|
|
34
52
|
/**
|
|
@@ -42,6 +60,7 @@ export function coreUmoVitePlugins(): Plugin[] {
|
|
|
42
60
|
highlightJsLibVirtual(),
|
|
43
61
|
umoCjsVirtual(),
|
|
44
62
|
docxPreviewViteFix(),
|
|
63
|
+
coreVxeTableViteFix(),
|
|
45
64
|
tiptapUmoResolve(),
|
|
46
65
|
yjsPeerResolve(),
|
|
47
66
|
]
|