zkqh-lagrange-utils 0.0.55 → 0.0.57

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 CHANGED
@@ -1,74 +1,74 @@
1
- {
2
- "name": "zkqh-lagrange-utils",
3
- "private": false,
4
- "version": "0.0.55",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "gen-style": "node ./scripts/generate-naiveui-common-style.mjs"
10
- },
11
- "main": "dist/lagrange-utils.umd.cjs",
12
- "module": "dist/lagrange-utils.js",
13
- "sideEffects": [
14
- "*.css"
15
- ],
16
- "exports": {
17
- ".": {
18
- "import": "./dist/lagrange-utils.js",
19
- "require": "./dist/lagrange-utils.umd.cjs"
20
- },
21
- "./export_plugin": {
22
- "import": "./src/service/export_plugin/index.js",
23
- "default": "./src/service/export_plugin/index.js"
24
- },
25
- "./export_plugin/api": {
26
- "import": "./src/service/export_plugin/api/index.js",
27
- "default": "./src/service/export_plugin/api/index.js"
28
- },
29
- "./style.css": {
30
- "default": "./dist/style.css"
31
- },
32
- "./assets/*": "./dist/assets/*",
33
- "./assets/css/*": "./dist/assets/css/*",
34
- "./assets/font/*": "./dist/assets/font/*",
35
- "./assets/image/*": "./dist/assets/image/*",
36
- "./postcss.config.js": {
37
- "import": "./postcss.config.js",
38
- "require": "./postcss.config.cjs",
39
- "default": "./postcss.config.js"
40
- }
41
- },
42
- "files": [
43
- "dist",
44
- "assets",
45
- "src/service",
46
- "postcss.config.js",
47
- "postcss.config.cjs"
48
- ],
49
- "dependencies": {
50
- "autoprefixer": "^10.4.22",
51
- "axios": "^1.18.1",
52
- "postcss-pxtorem": "^6.1.0",
53
- "vue": "^3.3.0"
54
- },
55
- "peerDependencies": {
56
- "naive-ui": "^2.40.0",
57
- "vue": "^3.3.0"
58
- },
59
- "peerDependenciesMeta": {
60
- "naive-ui": {
61
- "optional": true
62
- }
63
- },
64
- "devDependencies": {
65
- "@vitejs/plugin-vue": "^5.0.4",
66
- "@vitejs/plugin-vue-jsx": "^3.0.2",
67
- "less": "^4.4.2",
68
- "naive-ui": "2.43.1",
69
- "vite": "^5.4.10",
70
- "vite-plugin-static-copy": "^0.17.0"
71
- },
72
- "author": "zkqh-ddh",
73
- "license": "MIT"
74
- }
1
+ {
2
+ "name": "zkqh-lagrange-utils",
3
+ "private": false,
4
+ "version": "0.0.57",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "gen-style": "node ./scripts/generate-naiveui-common-style.mjs"
10
+ },
11
+ "main": "dist/lagrange-utils.umd.cjs",
12
+ "module": "dist/lagrange-utils.js",
13
+ "sideEffects": [
14
+ "*.css"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/lagrange-utils.js",
19
+ "require": "./dist/lagrange-utils.umd.cjs"
20
+ },
21
+ "./export_plugin": {
22
+ "import": "./src/service/export_plugin/index.js",
23
+ "default": "./src/service/export_plugin/index.js"
24
+ },
25
+ "./export_plugin/api": {
26
+ "import": "./src/service/export_plugin/api/index.js",
27
+ "default": "./src/service/export_plugin/api/index.js"
28
+ },
29
+ "./style.css": {
30
+ "default": "./dist/style.css"
31
+ },
32
+ "./assets/*": "./dist/assets/*",
33
+ "./assets/css/*": "./dist/assets/css/*",
34
+ "./assets/font/*": "./dist/assets/font/*",
35
+ "./assets/image/*": "./dist/assets/image/*",
36
+ "./postcss.config.js": {
37
+ "import": "./postcss.config.js",
38
+ "require": "./postcss.config.cjs",
39
+ "default": "./postcss.config.js"
40
+ }
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "assets",
45
+ "src/service",
46
+ "postcss.config.js",
47
+ "postcss.config.cjs"
48
+ ],
49
+ "dependencies": {
50
+ "autoprefixer": "^10.4.22",
51
+ "axios": "^1.18.1",
52
+ "postcss-pxtorem": "^6.1.0",
53
+ "vue": "^3.3.0"
54
+ },
55
+ "peerDependencies": {
56
+ "naive-ui": "^2.40.0",
57
+ "vue": "^3.3.0"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "naive-ui": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "devDependencies": {
65
+ "@vitejs/plugin-vue": "^5.0.4",
66
+ "@vitejs/plugin-vue-jsx": "^3.0.2",
67
+ "less": "^4.4.2",
68
+ "naive-ui": "2.43.1",
69
+ "vite": "^5.4.10",
70
+ "vite-plugin-static-copy": "^0.17.0"
71
+ },
72
+ "author": "zkqh-ddh",
73
+ "license": "MIT"
74
+ }
@@ -1,258 +1,230 @@
1
- <template>
2
- <div
3
- v-if="usePlatformExport || usePluginExport"
4
- class="plugin_local_export">
5
- <!-- 平台 / 应用小文件导出区 -->
6
- <div
7
- v-if="usePlatformExport"
8
- class="_ple_platform">
9
- <span class="__tip lc-fs-m">文件小于50MB,请直接导出!</span>
10
- <span
11
- class="__action lc_btn_primary lc_btn_m"
12
- @click="onPlatformExportClick">
13
- 导&nbsp;&nbsp;出
14
- </span>
15
- </div>
16
-
17
- <!-- 插件本地目录导出区 -->
18
- <template v-if="usePluginExport">
19
- <div class="_ple_label lc-fs-m">选择本地目录</div>
20
- <div
21
- v-if="pluginReady && diskOverflow"
22
- class="_ple_warn lc-fs-s">
23
- <i class="lc lc-warning-circle-outlined"></i>
24
- <span>预估大小超出本地目录剩余空间,请更换目录或缩小导出范围</span>
25
- </div>
26
-
27
- <div
28
- v-if="!pluginReady"
29
- class="_ple_row">
30
- <n-tree-select
31
- size="small"
32
- disabled
33
- placeholder="安装插件后可选择导出文件"
34
- :options="[]" />
35
- <span
36
- class="lc_btn_primary lc_btn_m _ple_install"
37
- @click="onInstall">
38
- 立即安装插件
39
- </span>
40
- </div>
41
-
42
- <div
43
- v-else
44
- class="_ple_row">
45
- <PluginDirSelect
46
- v-model="dirname"
47
- @update:disk-info="onDiskInfoUpdate" />
48
- <div class="_ple_action">
49
- <span
50
- class="lc_btn_primary lc_btn_m"
51
- :class="{ _disabled: pluginExportDisabled }"
52
- :title="pluginButtonTitle"
53
- @click="onPluginExportClick">
54
- 导&nbsp;&nbsp;出
55
- </span>
56
- </div>
57
- </div>
58
- </template>
59
-
60
- <!-- 插件导出:任务名称弹窗(内置) -->
61
- <ExportTaskModal
62
- v-if="showTaskModal"
63
- :kind="kind"
64
- :args="args"
65
- :dirname="dirname"
66
- :get-token="getToken"
67
- :get-url="getUrl"
68
- :validate-args="validateArgs"
69
- @success="onTaskModalSuccess"
70
- @close="showTaskModal = false" />
71
- </div>
72
- </template>
73
-
74
- <script>
75
- import { defineComponent, ref, computed, toRefs, onMounted } from "vue"
76
- import PluginDirSelect from "./internal/plugin-dir-select.vue"
77
- import ExportTaskModal from "./internal/export-task-modal.vue"
78
- import { usePluginHealth } from "./hooks/use-plugin-health.js"
79
- import { isOverSizeLimit, isPreviewOverflowDisk } from "./utils/size.js"
80
- import { validateTimeRangeArgs } from "./utils/export-task.js"
81
- /** 组件局部使用 lc iconfont(不依赖宿主全局引入) */
82
- import "zkqh-lagrange-utils/assets/font/iconfont-lc.css"
83
- import "./internal/styles/plugin-local-export.less"
84
-
85
- const DEFAULT_PREVIEW = {
86
- show: false,
87
- totalSize: 0,
88
- exportDisabled: false,
89
- }
90
-
91
- /**
92
- * 本地导出组合区:平台/应用小文件导出 + 插件目录导出 + 50MB 分流 + 任务弹窗
93
- */
94
- export default defineComponent({
95
- name: "PluginLocalExport",
96
- components: { PluginDirSelect, ExportTaskModal },
97
- props: {
98
- /**
99
- * 预览与分流控制
100
- * @type {{ show?: boolean, totalSize?: number, exportDisabled?: boolean }}
101
- */
102
- previewInfo: {
103
- type: Object,
104
- default: () => ({ ...DEFAULT_PREVIEW }),
105
- },
106
- /** 插件安装包下载地址 */
107
- downloadUrl: { type: String, default: "" },
108
- /** 导出 kind(插件创建任务用) */
109
- kind: { type: String, default: "event" },
110
- /** 筛选参数(插件创建任务用) */
111
- args: { type: Object, default: () => ({}) },
112
- /**
113
- * 获取登录 token;不传则读 localStorage.token
114
- * @type {(() => string) | string}
115
- */
116
- getToken: { type: [Function, String], default: null },
117
- /**
118
- * 获取平台根 URL;不传则读 window.sys_con.baseURL
119
- * @type {(() => string) | string}
120
- */
121
- getUrl: { type: [Function, String], default: null },
122
- /**
123
- * 导出前校验 args;不传则校验时间范围
124
- * @type {(args: object) => boolean}
125
- */
126
- validateArgs: { type: Function, default: null },
127
- },
128
- emits: ["success"],
129
- setup(props, { emit }) {
130
- const { previewInfo, downloadUrl, kind, args, getToken, getUrl, validateArgs } = toRefs(props)
131
- const dirname = ref("")
132
- const diskInfo = ref({ total_size: 0, used_size: 0 })
133
- const showTaskModal = ref(false)
134
-
135
- const health = usePluginHealth({
136
- downloadUrl: () => downloadUrl.value,
137
- })
138
- const { pluginReady, checkHealth, triggerInstall } = health
139
-
140
- onMounted(() => {
141
- checkHealth()
142
- })
143
-
144
- const preview = computed(() => ({
145
- ...DEFAULT_PREVIEW,
146
- ...(previewInfo.value || {}),
147
- }))
148
-
149
- const resolveValidate = () => validateArgs.value || validateTimeRangeArgs
150
-
151
- /**
152
- * 是否展示平台/应用导出区(≤50MB)
153
- */
154
- const usePlatformExport = computed(() => {
155
- const info = preview.value
156
- if (!info.show || info.exportDisabled) return false
157
- const size = Number(info.totalSize) || 0
158
- if (size <= 0) return false
159
- return !isOverSizeLimit(size)
160
- })
161
-
162
- /**
163
- * 是否展示插件导出区
164
- * - show=false:始终插件
165
- * - show=true:已可导出且 >50MB
166
- */
167
- const usePluginExport = computed(() => {
168
- const info = preview.value
169
- if (!info.show) return true
170
- if (info.exportDisabled) return false
171
- const size = Number(info.totalSize) || 0
172
- if (size <= 0) return false
173
- return isOverSizeLimit(size)
174
- })
175
-
176
- /** 插件路径:预览大小是否超出当前目录剩余空间 */
177
- const diskOverflow = computed(() => {
178
- if (!pluginReady.value || !usePluginExport.value) return false
179
- const info = preview.value
180
- if (!info.show) return false
181
- return isPreviewOverflowDisk(info.totalSize, diskInfo.value)
182
- })
183
-
184
- const pluginExportDisabled = computed(() => {
185
- if (!pluginReady.value) return true
186
- if (!dirname.value) return true
187
- if (diskOverflow.value) return true
188
- return false
189
- })
190
-
191
- const pluginButtonTitle = computed(() => {
192
- if (!pluginReady.value) return "请先安装并启动导出插件"
193
- if (!dirname.value) return "请选择本地导出目录"
194
- if (diskOverflow.value) return "预估大小超出本地目录剩余空间,无法导出"
195
- return ""
196
- })
197
-
198
- const onDiskInfoUpdate = (info) => {
199
- diskInfo.value = info || { total_size: 0, used_size: 0 }
200
- }
201
-
202
- const onInstall = () => {
203
- triggerInstall()
204
- }
205
-
206
- /** 平台/应用路径:确认后回调 */
207
- const onPlatformExportClick = () => {
208
- const exportArgs = { ...(args.value || {}) }
209
- if (!resolveValidate()(exportArgs)) return
210
-
211
- window.$dialog?.warning?.({
212
- title: "确认导出",
213
- content: "确认按当前筛选条件通过平台打包下载?",
214
- positiveText: "确认",
215
- negativeText: "取消",
216
- onPositiveClick: () => {
217
- emit("success", { mode: "platform" })
218
- },
219
- })
220
- }
221
-
222
- /** 插件路径:打开任务名称弹窗 */
223
- const onPluginExportClick = () => {
224
- if (pluginExportDisabled.value) return
225
- const exportArgs = { ...(args.value || {}) }
226
- if (!resolveValidate()(exportArgs)) return
227
- showTaskModal.value = true
228
- }
229
-
230
- /** 插件任务创建成功 */
231
- const onTaskModalSuccess = () => {
232
- showTaskModal.value = false
233
- emit("success", { mode: "plugin", dirname: dirname.value })
234
- }
235
-
236
- return {
237
- dirname,
238
- kind,
239
- args,
240
- getToken,
241
- getUrl,
242
- validateArgs,
243
- showTaskModal,
244
- pluginReady,
245
- usePlatformExport,
246
- usePluginExport,
247
- diskOverflow,
248
- pluginExportDisabled,
249
- pluginButtonTitle,
250
- onDiskInfoUpdate,
251
- onInstall,
252
- onPlatformExportClick,
253
- onPluginExportClick,
254
- onTaskModalSuccess,
255
- }
256
- },
257
- })
258
- </script>
1
+ <template>
2
+ <div
3
+ v-if="usePlatformExport || usePluginExport"
4
+ class="plugin_local_export"
5
+ :class="{ _platform: usePlatformExport }">
6
+ <!-- 平台 / 应用小文件导出区 -->
7
+ <template v-if="usePlatformExport">
8
+ <span class="_ple_tip lc_fs_m">文件小于50MB,请直接导出!</span>
9
+ <span
10
+ class="_ple_action lc_btn_primary lc_btn_m"
11
+ @click="onPlatformExportClick">
12
+ 导&nbsp;&nbsp;出
13
+ </span>
14
+ </template>
15
+
16
+ <!-- 插件本地目录导出区 -->
17
+ <template v-if="usePluginExport">
18
+ <div class="_ple_label lc_fs_m">选择本地目录</div>
19
+ <div
20
+ v-if="pluginReady && diskOverflow"
21
+ class="_ple_warn lc_fs_s">
22
+ <i class="lc lc-warning-circle-outlined"></i>
23
+ <span>预估大小超出本地目录剩余空间,请更换目录或缩小导出范围</span>
24
+ </div>
25
+
26
+ <div
27
+ v-if="!pluginReady"
28
+ class="_ple_row">
29
+ <n-tree-select
30
+ size="small"
31
+ disabled
32
+ placeholder="安装插件后可选择导出文件"
33
+ :options="[]" />
34
+ <span
35
+ class="lc_btn_primary lc_btn_m _ple_install"
36
+ @click="onInstall">
37
+ 立即安装插件
38
+ </span>
39
+ </div>
40
+
41
+ <div
42
+ v-else
43
+ class="_ple_row">
44
+ <PluginDirSelect
45
+ v-model="dirname"
46
+ @update:disk-info="onDiskInfoUpdate" />
47
+ <div class="_ple_action">
48
+ <span
49
+ class="lc_btn_primary lc_btn_m"
50
+ :class="{ _disabled: pluginExportDisabled }"
51
+ :title="pluginButtonTitle"
52
+ @click="onPluginExportClick">
53
+ 导&nbsp;&nbsp;出
54
+ </span>
55
+ </div>
56
+ </div>
57
+ </template>
58
+
59
+ <!-- 插件导出:任务名称弹窗(内置) -->
60
+ <ExportTaskModal
61
+ v-if="showTaskModal"
62
+ :kind="kind"
63
+ :args="args"
64
+ :dirname="dirname"
65
+ @success="onTaskModalSuccess"
66
+ @close="showTaskModal = false" />
67
+ </div>
68
+ </template>
69
+
70
+ <script>
71
+ /** 组件自带 token / 按钮 / 字号,不依赖宿主全局样式 */
72
+ import "./internal/styles/plugin-local-export.less"
73
+ import "zkqh-lagrange-utils/assets/font/iconfont-lc.css"
74
+ import { defineComponent, ref, computed, toRefs, onMounted } from "vue"
75
+ import PluginDirSelect from "./internal/plugin-dir-select.vue"
76
+ import ExportTaskModal from "./internal/export-task-modal.vue"
77
+ import { usePluginHealth } from "./hooks/use-plugin-health.js"
78
+ import { isOverSizeLimit, isPreviewOverflowDisk } from "./utils/size.js"
79
+ import { validateTimeRangeArgs } from "./utils/export-task.js"
80
+
81
+ const DEFAULT_PREVIEW = {
82
+ show: false,
83
+ totalSize: 0,
84
+ exportDisabled: false,
85
+ }
86
+
87
+ /**
88
+ * 本地导出组合区:平台/应用小文件导出 + 插件目录导出 + 50MB 分流 + 任务弹窗
89
+ * token / url / 校验 / 安装包地址均内置,宿主无需传入
90
+ */
91
+ export default defineComponent({
92
+ name: "PluginLocalExport",
93
+ components: { PluginDirSelect, ExportTaskModal },
94
+ props: {
95
+ /**
96
+ * 预览与分流控制
97
+ * @type {{ show?: boolean, totalSize?: number, exportDisabled?: boolean }}
98
+ */
99
+ previewInfo: {
100
+ type: Object,
101
+ default: () => ({ ...DEFAULT_PREVIEW }),
102
+ },
103
+ /** 导出 kind(插件 createExport 用) */
104
+ kind: { type: String, default: "event" },
105
+ /** 筛选参数(插件 createExport 用) */
106
+ args: { type: Object, default: () => ({}) },
107
+ },
108
+ emits: ["success"],
109
+ setup(props, { emit }) {
110
+ const { previewInfo, kind, args } = toRefs(props)
111
+ const dirname = ref("")
112
+ const diskInfo = ref({ total_size: 0, used_size: 0 })
113
+ const showTaskModal = ref(false)
114
+
115
+ const { pluginReady, checkHealth, triggerInstall } = usePluginHealth()
116
+
117
+ onMounted(() => {
118
+ checkHealth()
119
+ })
120
+
121
+ const preview = computed(() => ({
122
+ ...DEFAULT_PREVIEW,
123
+ ...(previewInfo.value || {}),
124
+ }))
125
+
126
+ /**
127
+ * 是否展示平台/应用导出区(≤50MB)
128
+ */
129
+ const usePlatformExport = computed(() => {
130
+ const info = preview.value
131
+ if (!info.show || info.exportDisabled) return false
132
+ const size = Number(info.totalSize) || 0
133
+ if (size <= 0) return false
134
+ return !isOverSizeLimit(size)
135
+ })
136
+
137
+ /**
138
+ * 是否展示插件导出区
139
+ * - show=false:始终插件
140
+ * - show=true:已可导出且 >50MB
141
+ */
142
+ const usePluginExport = computed(() => {
143
+ const info = preview.value
144
+ if (!info.show) return true
145
+ if (info.exportDisabled) return false
146
+ const size = Number(info.totalSize) || 0
147
+ if (size <= 0) return false
148
+ return isOverSizeLimit(size)
149
+ })
150
+
151
+ /** 插件路径:预览大小是否超出当前目录剩余空间 */
152
+ const diskOverflow = computed(() => {
153
+ if (!pluginReady.value || !usePluginExport.value) return false
154
+ const info = preview.value
155
+ if (!info.show) return false
156
+ return isPreviewOverflowDisk(info.totalSize, diskInfo.value)
157
+ })
158
+
159
+ const pluginExportDisabled = computed(() => {
160
+ if (!pluginReady.value) return true
161
+ if (!dirname.value) return true
162
+ if (diskOverflow.value) return true
163
+ return false
164
+ })
165
+
166
+ const pluginButtonTitle = computed(() => {
167
+ if (!pluginReady.value) return "请先安装并启动导出插件"
168
+ if (!dirname.value) return "请选择本地导出目录"
169
+ if (diskOverflow.value) return "预估大小超出本地目录剩余空间,无法导出"
170
+ return ""
171
+ })
172
+
173
+ const onDiskInfoUpdate = (info) => {
174
+ diskInfo.value = info || { total_size: 0, used_size: 0 }
175
+ }
176
+
177
+ const onInstall = () => {
178
+ triggerInstall()
179
+ }
180
+
181
+ /** 平台/应用路径:确认后回调 */
182
+ const onPlatformExportClick = () => {
183
+ const exportArgs = { ...(args.value || {}) }
184
+ if (!validateTimeRangeArgs(exportArgs)) return
185
+
186
+ window.$dialog?.warning?.({
187
+ title: "确认导出",
188
+ content: "确认按当前筛选条件通过平台打包下载?",
189
+ positiveText: "确认",
190
+ negativeText: "取消",
191
+ onPositiveClick: () => {
192
+ emit("success", { mode: "platform" })
193
+ },
194
+ })
195
+ }
196
+
197
+ /** 插件路径:打开任务名称弹窗 */
198
+ const onPluginExportClick = () => {
199
+ if (pluginExportDisabled.value) return
200
+ const exportArgs = { ...(args.value || {}) }
201
+ if (!validateTimeRangeArgs(exportArgs)) return
202
+ showTaskModal.value = true
203
+ }
204
+
205
+ /** 插件任务创建成功 */
206
+ const onTaskModalSuccess = () => {
207
+ showTaskModal.value = false
208
+ emit("success", { mode: "plugin", dirname: dirname.value })
209
+ }
210
+
211
+ return {
212
+ dirname,
213
+ kind,
214
+ args,
215
+ showTaskModal,
216
+ pluginReady,
217
+ usePlatformExport,
218
+ usePluginExport,
219
+ diskOverflow,
220
+ pluginExportDisabled,
221
+ pluginButtonTitle,
222
+ onDiskInfoUpdate,
223
+ onInstall,
224
+ onPlatformExportClick,
225
+ onPluginExportClick,
226
+ onTaskModalSuccess,
227
+ }
228
+ },
229
+ })
230
+ </script>
@@ -1,6 +1,6 @@
1
- /**
2
- * 导出插件 API 独立入口(可不挂载 UI)
3
- * @example
4
- * import { pluginApi } from "zkqh-lagrange-utils/export_plugin/api"
5
- */
6
- export { pluginApi } from "./plugin.js"
1
+ /**
2
+ * 导出插件 API 独立入口(可不挂载 UI)
3
+ * @example
4
+ * import { pluginApi } from "zkqh-lagrange-utils/export_plugin/api"
5
+ */
6
+ export { pluginApi } from "./plugin.js"