zkqh-lagrange-utils 0.0.56 → 0.0.58
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/service/export_plugin/PluginLocalExport.vue +14 -41
- package/src/service/export_plugin/hooks/use-plugin-health.js +7 -4
- package/src/service/export_plugin/index.js +1 -3
- package/src/service/export_plugin/internal/create-folder-modal.vue +1 -1
- package/src/service/export_plugin/internal/export-task-modal.vue +5 -31
- package/src/service/export_plugin/internal/plugin-dir-select.vue +1 -1
- package/src/service/export_plugin/internal/styles/base.less +11 -0
- package/src/service/export_plugin/internal/styles/plugin-local-export.less +2 -1
- package/src/service/export_plugin/utils/export-task.js +11 -2
package/package.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
v-if="usePlatformExport || usePluginExport"
|
|
4
4
|
class="plugin_local_export"
|
|
5
5
|
:class="{ _platform: usePlatformExport }">
|
|
6
|
-
<!-- 平台 /
|
|
6
|
+
<!-- 平台 / 应用小文件导出区 -->
|
|
7
7
|
<template v-if="usePlatformExport">
|
|
8
|
-
<span class="_ple_tip
|
|
8
|
+
<span class="_ple_tip lc_fs_m">文件小于50MB,请直接导出!</span>
|
|
9
9
|
<span
|
|
10
10
|
class="_ple_action lc_btn_primary lc_btn_m"
|
|
11
11
|
@click="onPlatformExportClick">
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
|
|
16
16
|
<!-- 插件本地目录导出区 -->
|
|
17
17
|
<template v-if="usePluginExport">
|
|
18
|
-
<div class="_ple_label
|
|
18
|
+
<div class="_ple_label lc_fs_m">选择本地目录</div>
|
|
19
19
|
<div
|
|
20
20
|
v-if="pluginReady && diskOverflow"
|
|
21
|
-
class="_ple_warn
|
|
21
|
+
class="_ple_warn lc_fs_s">
|
|
22
22
|
<i class="lc lc-warning-circle-outlined"></i>
|
|
23
23
|
<span>预估大小超出本地目录剩余空间,请更换目录或缩小导出范围</span>
|
|
24
24
|
</div>
|
|
@@ -62,24 +62,21 @@
|
|
|
62
62
|
:kind="kind"
|
|
63
63
|
:args="args"
|
|
64
64
|
:dirname="dirname"
|
|
65
|
-
:get-token="getToken"
|
|
66
|
-
:get-url="getUrl"
|
|
67
|
-
:validate-args="validateArgs"
|
|
68
65
|
@success="onTaskModalSuccess"
|
|
69
66
|
@close="showTaskModal = false" />
|
|
70
67
|
</div>
|
|
71
68
|
</template>
|
|
72
69
|
|
|
73
70
|
<script>
|
|
71
|
+
/** 组件自带 token / 按钮 / 字号,不依赖宿主全局样式 */
|
|
72
|
+
import "./internal/styles/plugin-local-export.less"
|
|
73
|
+
import "zkqh-lagrange-utils/assets/font/iconfont-lc.css"
|
|
74
74
|
import { defineComponent, ref, computed, toRefs, onMounted } from "vue"
|
|
75
75
|
import PluginDirSelect from "./internal/plugin-dir-select.vue"
|
|
76
76
|
import ExportTaskModal from "./internal/export-task-modal.vue"
|
|
77
77
|
import { usePluginHealth } from "./hooks/use-plugin-health.js"
|
|
78
78
|
import { isOverSizeLimit, isPreviewOverflowDisk } from "./utils/size.js"
|
|
79
79
|
import { validateTimeRangeArgs } from "./utils/export-task.js"
|
|
80
|
-
/** 组件局部使用 lc iconfont(不依赖宿主全局引入) */
|
|
81
|
-
import "zkqh-lagrange-utils/assets/font/iconfont-lc.css"
|
|
82
|
-
import "./internal/styles/plugin-local-export.less"
|
|
83
80
|
|
|
84
81
|
const DEFAULT_PREVIEW = {
|
|
85
82
|
show: false,
|
|
@@ -89,6 +86,7 @@ const DEFAULT_PREVIEW = {
|
|
|
89
86
|
|
|
90
87
|
/**
|
|
91
88
|
* 本地导出组合区:平台/应用小文件导出 + 插件目录导出 + 50MB 分流 + 任务弹窗
|
|
89
|
+
* token / url / 校验 / 安装包地址均内置,宿主无需传入
|
|
92
90
|
*/
|
|
93
91
|
export default defineComponent({
|
|
94
92
|
name: "PluginLocalExport",
|
|
@@ -102,39 +100,19 @@ export default defineComponent({
|
|
|
102
100
|
type: Object,
|
|
103
101
|
default: () => ({ ...DEFAULT_PREVIEW }),
|
|
104
102
|
},
|
|
105
|
-
/**
|
|
106
|
-
downloadUrl: { type: String, default: "" },
|
|
107
|
-
/** 导出 kind(插件创建任务用) */
|
|
103
|
+
/** 导出 kind(插件 createExport 用) */
|
|
108
104
|
kind: { type: String, default: "event" },
|
|
109
|
-
/**
|
|
105
|
+
/** 筛选参数(插件 createExport 用) */
|
|
110
106
|
args: { type: Object, default: () => ({}) },
|
|
111
|
-
/**
|
|
112
|
-
* 获取登录 token;不传则读 localStorage.token
|
|
113
|
-
* @type {(() => string) | string}
|
|
114
|
-
*/
|
|
115
|
-
getToken: { type: [Function, String], default: null },
|
|
116
|
-
/**
|
|
117
|
-
* 获取平台根 URL;不传则读 window.sys_con.baseURL
|
|
118
|
-
* @type {(() => string) | string}
|
|
119
|
-
*/
|
|
120
|
-
getUrl: { type: [Function, String], default: null },
|
|
121
|
-
/**
|
|
122
|
-
* 导出前校验 args;不传则校验时间范围
|
|
123
|
-
* @type {(args: object) => boolean}
|
|
124
|
-
*/
|
|
125
|
-
validateArgs: { type: Function, default: null },
|
|
126
107
|
},
|
|
127
108
|
emits: ["success"],
|
|
128
109
|
setup(props, { emit }) {
|
|
129
|
-
const { previewInfo,
|
|
110
|
+
const { previewInfo, kind, args } = toRefs(props)
|
|
130
111
|
const dirname = ref("")
|
|
131
112
|
const diskInfo = ref({ total_size: 0, used_size: 0 })
|
|
132
113
|
const showTaskModal = ref(false)
|
|
133
114
|
|
|
134
|
-
const
|
|
135
|
-
downloadUrl: () => downloadUrl.value,
|
|
136
|
-
})
|
|
137
|
-
const { pluginReady, checkHealth, triggerInstall } = health
|
|
115
|
+
const { pluginReady, checkHealth, triggerInstall } = usePluginHealth()
|
|
138
116
|
|
|
139
117
|
onMounted(() => {
|
|
140
118
|
checkHealth()
|
|
@@ -145,8 +123,6 @@ export default defineComponent({
|
|
|
145
123
|
...(previewInfo.value || {}),
|
|
146
124
|
}))
|
|
147
125
|
|
|
148
|
-
const resolveValidate = () => validateArgs.value || validateTimeRangeArgs
|
|
149
|
-
|
|
150
126
|
/**
|
|
151
127
|
* 是否展示平台/应用导出区(≤50MB)
|
|
152
128
|
*/
|
|
@@ -205,7 +181,7 @@ export default defineComponent({
|
|
|
205
181
|
/** 平台/应用路径:确认后回调 */
|
|
206
182
|
const onPlatformExportClick = () => {
|
|
207
183
|
const exportArgs = { ...(args.value || {}) }
|
|
208
|
-
if (!
|
|
184
|
+
if (!validateTimeRangeArgs(exportArgs)) return
|
|
209
185
|
|
|
210
186
|
window.$dialog?.warning?.({
|
|
211
187
|
title: "确认导出",
|
|
@@ -222,7 +198,7 @@ export default defineComponent({
|
|
|
222
198
|
const onPluginExportClick = () => {
|
|
223
199
|
if (pluginExportDisabled.value) return
|
|
224
200
|
const exportArgs = { ...(args.value || {}) }
|
|
225
|
-
if (!
|
|
201
|
+
if (!validateTimeRangeArgs(exportArgs)) return
|
|
226
202
|
showTaskModal.value = true
|
|
227
203
|
}
|
|
228
204
|
|
|
@@ -236,9 +212,6 @@ export default defineComponent({
|
|
|
236
212
|
dirname,
|
|
237
213
|
kind,
|
|
238
214
|
args,
|
|
239
|
-
getToken,
|
|
240
|
-
getUrl,
|
|
241
|
-
validateArgs,
|
|
242
215
|
showTaskModal,
|
|
243
216
|
pluginReady,
|
|
244
217
|
usePlatformExport,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ref, onBeforeUnmount, unref } from "vue"
|
|
2
2
|
import { pluginApi } from "../api/plugin.js"
|
|
3
3
|
import { PLUGIN_HEALTH_INTERVAL } from "../utils/size.js"
|
|
4
|
+
import { getDefaultDownloadUrl } from "../utils/export-task.js"
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* 触发导出插件安装包下载
|
|
@@ -21,6 +22,7 @@ function _downloadPlugin(url = "") {
|
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* 导出插件 health:单次检测 + 安装后轮询,就绪后自动停止
|
|
25
|
+
* downloadUrl 可不传,默认当前域名 /plugins.main.exe
|
|
24
26
|
* @param {{ interval?: number, downloadUrl?: string | import('vue').Ref<string> | (() => string) }} [options]
|
|
25
27
|
* @returns {{
|
|
26
28
|
* pluginReady: import('vue').Ref<boolean>,
|
|
@@ -39,8 +41,9 @@ export function usePluginHealth(options = {}) {
|
|
|
39
41
|
|
|
40
42
|
const resolveDownloadUrl = () => {
|
|
41
43
|
const raw = options.downloadUrl
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
+
if (raw == null) return getDefaultDownloadUrl()
|
|
45
|
+
if (typeof raw === "function") return raw() || getDefaultDownloadUrl()
|
|
46
|
+
return unref(raw) || getDefaultDownloadUrl()
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
const stopPoll = () => {
|
|
@@ -81,8 +84,8 @@ export function usePluginHealth(options = {}) {
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
/**
|
|
84
|
-
* 下载安装包并启动 health
|
|
85
|
-
* @param {string} [url] 优先使用入参,否则取 options.downloadUrl
|
|
87
|
+
* 下载安装包并启动 health 轮询(默认当前域名 /plugins.main.exe)
|
|
88
|
+
* @param {string} [url] 优先使用入参,否则取 options.downloadUrl 或默认地址
|
|
86
89
|
*/
|
|
87
90
|
const triggerInstall = (url) => {
|
|
88
91
|
_downloadPlugin(url || resolveDownloadUrl())
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 对外:
|
|
5
5
|
* - pluginApi:可独立引用
|
|
6
|
-
* - PluginLocalExport
|
|
7
|
-
* - ExportTaskModal:也可单独使用
|
|
6
|
+
* - PluginLocalExport:平台/插件导出区组合组件(任务名称弹窗内置,不对外)
|
|
8
7
|
* - usePluginHealth:插件存活检测 / 安装轮询
|
|
9
8
|
*
|
|
10
9
|
* @example
|
|
@@ -13,6 +12,5 @@
|
|
|
13
12
|
|
|
14
13
|
export { pluginApi } from "./api/plugin.js"
|
|
15
14
|
export { default as PluginLocalExport } from "./PluginLocalExport.vue"
|
|
16
|
-
export { default as ExportTaskModal } from "./internal/export-task-modal.vue"
|
|
17
15
|
export { usePluginHealth } from "./hooks/use-plugin-health.js"
|
|
18
16
|
export { default } from "./PluginLocalExport.vue"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
:mask-closable="false"
|
|
9
9
|
@update:show="onShowUpdate"
|
|
10
10
|
@positive-click="onConfirm">
|
|
11
|
-
<div class="export_plugin_modals_hint
|
|
11
|
+
<div class="export_plugin_modals_hint lc_fs_s">将在以下目录下创建:{{ parentDisplay }}</div>
|
|
12
12
|
<n-input
|
|
13
13
|
v-model:value="folderName"
|
|
14
14
|
size="small"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
:loading="exporting"
|
|
10
10
|
@update:show="onShowUpdate"
|
|
11
11
|
@positive-click="onConfirm">
|
|
12
|
-
<div class="export_plugin_modals_hint
|
|
12
|
+
<div class="export_plugin_modals_hint lc_fs_s">请填写导出任务名称,任务可在「导出进度」中查看。</div>
|
|
13
13
|
<n-input
|
|
14
14
|
v-model:value="taskName"
|
|
15
15
|
size="small"
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
import "./styles/export-plugin-modals.less"
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 导出任务名称弹窗(创建插件导出作业,token/url/校验内置)
|
|
35
35
|
*/
|
|
36
36
|
export default defineComponent({
|
|
37
37
|
name: "ExportTaskModal",
|
|
@@ -42,37 +42,12 @@ export default defineComponent({
|
|
|
42
42
|
args: { type: Object, default: () => ({}) },
|
|
43
43
|
/** 本地导出目录 */
|
|
44
44
|
dirname: { type: String, default: "" },
|
|
45
|
-
/**
|
|
46
|
-
* 获取登录 token;不传则读 localStorage.token
|
|
47
|
-
* @type {(() => string) | string}
|
|
48
|
-
*/
|
|
49
|
-
getToken: { type: [Function, String], default: null },
|
|
50
|
-
/**
|
|
51
|
-
* 获取平台根 URL;不传则读 window.sys_con.baseURL
|
|
52
|
-
* @type {(() => string) | string}
|
|
53
|
-
*/
|
|
54
|
-
getUrl: { type: [Function, String], default: null },
|
|
55
|
-
/**
|
|
56
|
-
* 导出前校验 args;不传则校验时间范围
|
|
57
|
-
* @type {(args: object) => boolean}
|
|
58
|
-
*/
|
|
59
|
-
validateArgs: { type: Function, default: null },
|
|
60
45
|
},
|
|
61
46
|
emits: ["close", "success"],
|
|
62
47
|
setup(props, { emit }) {
|
|
63
48
|
const taskName = ref(buildTaskName())
|
|
64
49
|
const exporting = ref(false)
|
|
65
50
|
|
|
66
|
-
const resolveToken = () => {
|
|
67
|
-
if (props.getToken == null) return getDefaultToken()
|
|
68
|
-
return typeof props.getToken === "function" ? props.getToken() : String(props.getToken || "")
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const resolveUrl = () => {
|
|
72
|
-
if (props.getUrl == null) return getDefaultUrl()
|
|
73
|
-
return typeof props.getUrl === "function" ? props.getUrl() : String(props.getUrl || "")
|
|
74
|
-
}
|
|
75
|
-
|
|
76
51
|
const close = () => {
|
|
77
52
|
emit("close")
|
|
78
53
|
}
|
|
@@ -88,11 +63,10 @@ export default defineComponent({
|
|
|
88
63
|
*/
|
|
89
64
|
const createExport = async (name) => {
|
|
90
65
|
const exportArgs = { ...(props.args || {}) }
|
|
91
|
-
|
|
92
|
-
if (!validate(exportArgs)) return false
|
|
66
|
+
if (!validateTimeRangeArgs(exportArgs)) return false
|
|
93
67
|
|
|
94
|
-
const token =
|
|
95
|
-
const url =
|
|
68
|
+
const token = getDefaultToken()
|
|
69
|
+
const url = getDefaultUrl()
|
|
96
70
|
if (!token) {
|
|
97
71
|
window.$message?.error?.("登录态失效,请重新登录")
|
|
98
72
|
return false
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* export_plugin 自带 token / 按钮类,不依赖宿主注入全局样式 */
|
|
2
|
+
@import "zkqh-lagrange-utils/assets/css/common/color.less";
|
|
3
|
+
@import "zkqh-lagrange-utils/assets/css/common/button.less";
|
|
4
|
+
|
|
5
|
+
.lc_fs_s {
|
|
6
|
+
font-size: @lc_font_size_s;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.lc_fs_m {
|
|
10
|
+
font-size: @lc_font_size_m;
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 默认读取平台登录 token
|
|
2
|
+
* 默认读取平台登录 token
|
|
3
3
|
* @returns {string}
|
|
4
4
|
*/
|
|
5
5
|
export const getDefaultToken = () => {
|
|
@@ -13,7 +13,7 @@ export const getDefaultToken = () => {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* 默认平台根地址(当前页 origin,或 sys_con.baseURL)
|
|
17
17
|
* @returns {string}
|
|
18
18
|
*/
|
|
19
19
|
export const getDefaultUrl = () => {
|
|
@@ -23,6 +23,15 @@ export const getDefaultUrl = () => {
|
|
|
23
23
|
return String(base).replace(/\/$/, "")
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* 默认插件安装包地址:当前域名端口 + /plugins/main.exe(对应前端 public/plugins/main.exe)
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
export const getDefaultDownloadUrl = () => {
|
|
31
|
+
if (typeof window === "undefined" || !window.location) return "/plugins/main.exe"
|
|
32
|
+
return `${window.location.origin}/plugins/main.exe`
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
/**
|
|
27
36
|
* 默认校验:导出 args 需含完整时间范围
|
|
28
37
|
* @param {Record<string, any>} args
|