zkqh-lagrange-utils 0.0.54 → 0.0.56

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.54",
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.56",
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,204 +1,257 @@
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
- </div>
60
- </template>
61
-
62
- <script>
63
- import { defineComponent, ref, computed, toRefs, onMounted } from "vue"
64
- import PluginDirSelect from "./internal/plugin-dir-select.vue"
65
- import { usePluginHealth } from "./hooks/use-plugin-health.js"
66
- import { isOverSizeLimit, isPreviewOverflowDisk } from "./utils/size.js"
67
- /** 组件局部使用 lc iconfont(不依赖宿主全局引入) */
68
- import "zkqh-lagrange-utils/assets/font/iconfont-lc.css"
69
- import "./internal/styles/plugin-local-export.less"
70
-
71
- const DEFAULT_PREVIEW = {
72
- show: false,
73
- totalSize: 0,
74
- exportDisabled: false,
75
- }
76
-
77
- /**
78
- * 本地导出组合区:平台/应用小文件导出 + 插件目录导出 + 50MB 分流
79
- */
80
- export default defineComponent({
81
- name: "PluginLocalExport",
82
- components: { PluginDirSelect },
83
- props: {
84
- /**
85
- * 预览与分流控制
86
- * @type {{ show?: boolean, totalSize?: number, exportDisabled?: boolean }}
87
- */
88
- previewInfo: {
89
- type: Object,
90
- default: () => ({ ...DEFAULT_PREVIEW }),
91
- },
92
- /** 插件安装包下载地址 */
93
- downloadUrl: { type: String, default: "" },
94
- },
95
- emits: ["success"],
96
- setup(props, { emit }) {
97
- const { previewInfo, downloadUrl } = toRefs(props)
98
- const dirname = ref("")
99
- const diskInfo = ref({ total_size: 0, used_size: 0 })
100
-
101
- const health = usePluginHealth({
102
- downloadUrl: () => downloadUrl.value,
103
- })
104
- const { pluginReady, checkHealth, triggerInstall } = health
105
-
106
- onMounted(() => {
107
- checkHealth()
108
- })
109
-
110
- const preview = computed(() => ({
111
- ...DEFAULT_PREVIEW,
112
- ...(previewInfo.value || {}),
113
- }))
114
-
115
- /**
116
- * 是否展示平台/应用导出区(≤50MB)
117
- */
118
- const usePlatformExport = computed(() => {
119
- const info = preview.value
120
- if (!info.show || info.exportDisabled) return false
121
- const size = Number(info.totalSize) || 0
122
- if (size <= 0) return false
123
- return !isOverSizeLimit(size)
124
- })
125
-
126
- /**
127
- * 是否展示插件导出区
128
- * - show=false:始终插件
129
- * - show=true:已可导出且 >50MB
130
- */
131
- const usePluginExport = computed(() => {
132
- const info = preview.value
133
- if (!info.show) return true
134
- if (info.exportDisabled) return false
135
- const size = Number(info.totalSize) || 0
136
- if (size <= 0) return false
137
- return isOverSizeLimit(size)
138
- })
139
-
140
- /** 插件路径:预览大小是否超出当前目录剩余空间 */
141
- const diskOverflow = computed(() => {
142
- if (!pluginReady.value || !usePluginExport.value) return false
143
- const info = preview.value
144
- if (!info.show) return false
145
- return isPreviewOverflowDisk(info.totalSize, diskInfo.value)
146
- })
147
-
148
- const pluginExportDisabled = computed(() => {
149
- if (!pluginReady.value) return true
150
- if (!dirname.value) return true
151
- if (diskOverflow.value) return true
152
- return false
153
- })
154
-
155
- const pluginButtonTitle = computed(() => {
156
- if (!pluginReady.value) return "请先安装并启动导出插件"
157
- if (!dirname.value) return "请选择本地导出目录"
158
- if (diskOverflow.value) return "预估大小超出本地目录剩余空间,无法导出"
159
- return ""
160
- })
161
-
162
- const onDiskInfoUpdate = (info) => {
163
- diskInfo.value = info || { total_size: 0, used_size: 0 }
164
- }
165
-
166
- const onInstall = () => {
167
- triggerInstall()
168
- }
169
-
170
- /** 平台/应用路径:确认后回调 */
171
- const onPlatformExportClick = () => {
172
- window.$dialog?.warning?.({
173
- title: "确认导出",
174
- content: "确认按当前筛选条件通过平台打包下载?",
175
- positiveText: "确认",
176
- negativeText: "取消",
177
- onPositiveClick: () => {
178
- emit("success", { mode: "platform" })
179
- },
180
- })
181
- }
182
-
183
- /** 插件路径:校验后回调(含 dirname) */
184
- const onPluginExportClick = () => {
185
- if (pluginExportDisabled.value) return
186
- emit("success", { mode: "plugin", dirname: dirname.value })
187
- }
188
-
189
- return {
190
- dirname,
191
- pluginReady,
192
- usePlatformExport,
193
- usePluginExport,
194
- diskOverflow,
195
- pluginExportDisabled,
196
- pluginButtonTitle,
197
- onDiskInfoUpdate,
198
- onInstall,
199
- onPlatformExportClick,
200
- onPluginExportClick,
201
- }
202
- },
203
- })
204
- </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
+ :get-token="getToken"
66
+ :get-url="getUrl"
67
+ :validate-args="validateArgs"
68
+ @success="onTaskModalSuccess"
69
+ @close="showTaskModal = false" />
70
+ </div>
71
+ </template>
72
+
73
+ <script>
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
+ /** 组件局部使用 lc iconfont(不依赖宿主全局引入) */
81
+ import "zkqh-lagrange-utils/assets/font/iconfont-lc.css"
82
+ import "./internal/styles/plugin-local-export.less"
83
+
84
+ const DEFAULT_PREVIEW = {
85
+ show: false,
86
+ totalSize: 0,
87
+ exportDisabled: false,
88
+ }
89
+
90
+ /**
91
+ * 本地导出组合区:平台/应用小文件导出 + 插件目录导出 + 50MB 分流 + 任务弹窗
92
+ */
93
+ export default defineComponent({
94
+ name: "PluginLocalExport",
95
+ components: { PluginDirSelect, ExportTaskModal },
96
+ props: {
97
+ /**
98
+ * 预览与分流控制
99
+ * @type {{ show?: boolean, totalSize?: number, exportDisabled?: boolean }}
100
+ */
101
+ previewInfo: {
102
+ type: Object,
103
+ default: () => ({ ...DEFAULT_PREVIEW }),
104
+ },
105
+ /** 插件安装包下载地址 */
106
+ downloadUrl: { type: String, default: "" },
107
+ /** 导出 kind(插件创建任务用) */
108
+ kind: { type: String, default: "event" },
109
+ /** 筛选参数(插件创建任务用) */
110
+ 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
+ },
127
+ emits: ["success"],
128
+ setup(props, { emit }) {
129
+ const { previewInfo, downloadUrl, kind, args, getToken, getUrl, validateArgs } = toRefs(props)
130
+ const dirname = ref("")
131
+ const diskInfo = ref({ total_size: 0, used_size: 0 })
132
+ const showTaskModal = ref(false)
133
+
134
+ const health = usePluginHealth({
135
+ downloadUrl: () => downloadUrl.value,
136
+ })
137
+ const { pluginReady, checkHealth, triggerInstall } = health
138
+
139
+ onMounted(() => {
140
+ checkHealth()
141
+ })
142
+
143
+ const preview = computed(() => ({
144
+ ...DEFAULT_PREVIEW,
145
+ ...(previewInfo.value || {}),
146
+ }))
147
+
148
+ const resolveValidate = () => validateArgs.value || validateTimeRangeArgs
149
+
150
+ /**
151
+ * 是否展示平台/应用导出区(≤50MB)
152
+ */
153
+ const usePlatformExport = computed(() => {
154
+ const info = preview.value
155
+ if (!info.show || info.exportDisabled) return false
156
+ const size = Number(info.totalSize) || 0
157
+ if (size <= 0) return false
158
+ return !isOverSizeLimit(size)
159
+ })
160
+
161
+ /**
162
+ * 是否展示插件导出区
163
+ * - show=false:始终插件
164
+ * - show=true:已可导出且 >50MB
165
+ */
166
+ const usePluginExport = computed(() => {
167
+ const info = preview.value
168
+ if (!info.show) return true
169
+ if (info.exportDisabled) return false
170
+ const size = Number(info.totalSize) || 0
171
+ if (size <= 0) return false
172
+ return isOverSizeLimit(size)
173
+ })
174
+
175
+ /** 插件路径:预览大小是否超出当前目录剩余空间 */
176
+ const diskOverflow = computed(() => {
177
+ if (!pluginReady.value || !usePluginExport.value) return false
178
+ const info = preview.value
179
+ if (!info.show) return false
180
+ return isPreviewOverflowDisk(info.totalSize, diskInfo.value)
181
+ })
182
+
183
+ const pluginExportDisabled = computed(() => {
184
+ if (!pluginReady.value) return true
185
+ if (!dirname.value) return true
186
+ if (diskOverflow.value) return true
187
+ return false
188
+ })
189
+
190
+ const pluginButtonTitle = computed(() => {
191
+ if (!pluginReady.value) return "请先安装并启动导出插件"
192
+ if (!dirname.value) return "请选择本地导出目录"
193
+ if (diskOverflow.value) return "预估大小超出本地目录剩余空间,无法导出"
194
+ return ""
195
+ })
196
+
197
+ const onDiskInfoUpdate = (info) => {
198
+ diskInfo.value = info || { total_size: 0, used_size: 0 }
199
+ }
200
+
201
+ const onInstall = () => {
202
+ triggerInstall()
203
+ }
204
+
205
+ /** 平台/应用路径:确认后回调 */
206
+ const onPlatformExportClick = () => {
207
+ const exportArgs = { ...(args.value || {}) }
208
+ if (!resolveValidate()(exportArgs)) return
209
+
210
+ window.$dialog?.warning?.({
211
+ title: "确认导出",
212
+ content: "确认按当前筛选条件通过平台打包下载?",
213
+ positiveText: "确认",
214
+ negativeText: "取消",
215
+ onPositiveClick: () => {
216
+ emit("success", { mode: "platform" })
217
+ },
218
+ })
219
+ }
220
+
221
+ /** 插件路径:打开任务名称弹窗 */
222
+ const onPluginExportClick = () => {
223
+ if (pluginExportDisabled.value) return
224
+ const exportArgs = { ...(args.value || {}) }
225
+ if (!resolveValidate()(exportArgs)) return
226
+ showTaskModal.value = true
227
+ }
228
+
229
+ /** 插件任务创建成功 */
230
+ const onTaskModalSuccess = () => {
231
+ showTaskModal.value = false
232
+ emit("success", { mode: "plugin", dirname: dirname.value })
233
+ }
234
+
235
+ return {
236
+ dirname,
237
+ kind,
238
+ args,
239
+ getToken,
240
+ getUrl,
241
+ validateArgs,
242
+ showTaskModal,
243
+ pluginReady,
244
+ usePlatformExport,
245
+ usePluginExport,
246
+ diskOverflow,
247
+ pluginExportDisabled,
248
+ pluginButtonTitle,
249
+ onDiskInfoUpdate,
250
+ onInstall,
251
+ onPlatformExportClick,
252
+ onPluginExportClick,
253
+ onTaskModalSuccess,
254
+ }
255
+ },
256
+ })
257
+ </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"