zkqh-lagrange-utils 0.0.53 → 0.0.54
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.jsx → PluginLocalExport.vue} +80 -81
- package/src/service/export_plugin/index.js +2 -2
- package/src/service/export_plugin/internal/{create-folder-modal.jsx → create-folder-modal.vue} +33 -30
- package/src/service/export_plugin/internal/{plugin-dir-select.jsx → plugin-dir-select.vue} +72 -100
package/package.json
CHANGED
|
@@ -1,9 +1,72 @@
|
|
|
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
|
+
导 出
|
|
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
|
+
导 出
|
|
55
|
+
</span>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script>
|
|
1
63
|
import { defineComponent, ref, computed, toRefs, onMounted } from "vue"
|
|
2
|
-
import
|
|
64
|
+
import PluginDirSelect from "./internal/plugin-dir-select.vue"
|
|
3
65
|
import { usePluginHealth } from "./hooks/use-plugin-health.js"
|
|
4
66
|
import { isOverSizeLimit, isPreviewOverflowDisk } from "./utils/size.js"
|
|
67
|
+
/** 组件局部使用 lc iconfont(不依赖宿主全局引入) */
|
|
68
|
+
import "zkqh-lagrange-utils/assets/font/iconfont-lc.css"
|
|
5
69
|
import "./internal/styles/plugin-local-export.less"
|
|
6
|
-
import("./assets/font/iconfont-lc.css")
|
|
7
70
|
|
|
8
71
|
const DEFAULT_PREVIEW = {
|
|
9
72
|
show: false,
|
|
@@ -13,16 +76,10 @@ const DEFAULT_PREVIEW = {
|
|
|
13
76
|
|
|
14
77
|
/**
|
|
15
78
|
* 本地导出组合区:平台/应用小文件导出 + 插件目录导出 + 50MB 分流
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* <PluginLocalExport
|
|
19
|
-
* previewInfo={{ show, totalSize, exportDisabled }}
|
|
20
|
-
* downloadUrl={url}
|
|
21
|
-
* onSuccess={({ mode, dirname }) => {}}
|
|
22
|
-
* />
|
|
23
79
|
*/
|
|
24
|
-
export
|
|
80
|
+
export default defineComponent({
|
|
25
81
|
name: "PluginLocalExport",
|
|
82
|
+
components: { PluginDirSelect },
|
|
26
83
|
props: {
|
|
27
84
|
/**
|
|
28
85
|
* 预览与分流控制
|
|
@@ -57,7 +114,6 @@ export const PluginLocalExport = defineComponent({
|
|
|
57
114
|
|
|
58
115
|
/**
|
|
59
116
|
* 是否展示平台/应用导出区(≤50MB)
|
|
60
|
-
* show=true 且未禁用且有大小且未超 50MB
|
|
61
117
|
*/
|
|
62
118
|
const usePlatformExport = computed(() => {
|
|
63
119
|
const info = preview.value
|
|
@@ -130,76 +186,19 @@ export const PluginLocalExport = defineComponent({
|
|
|
130
186
|
emit("success", { mode: "plugin", dirname: dirname.value })
|
|
131
187
|
}
|
|
132
188
|
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<span class="__tip lc-fs-m">文件小于50MB,请直接导出!</span>
|
|
146
|
-
<span
|
|
147
|
-
class="__action lc_btn_primary lc_btn_m"
|
|
148
|
-
onClick={onPlatformExportClick}>
|
|
149
|
-
导 出
|
|
150
|
-
</span>
|
|
151
|
-
</div>
|
|
152
|
-
) : null}
|
|
153
|
-
|
|
154
|
-
{showPlugin ? (
|
|
155
|
-
<>
|
|
156
|
-
<div class="_ple_label lc-fs-m">选择本地目录</div>
|
|
157
|
-
{pluginReady.value && diskOverflow.value ? (
|
|
158
|
-
<div class="_ple_warn lc-fs-s">
|
|
159
|
-
<i class="lc lc-warning-circle-outlined"></i>
|
|
160
|
-
<span>预估大小超出本地目录剩余空间,请更换目录或缩小导出范围</span>
|
|
161
|
-
</div>
|
|
162
|
-
) : null}
|
|
163
|
-
|
|
164
|
-
{!pluginReady.value ? (
|
|
165
|
-
<div class="_ple_row">
|
|
166
|
-
<n-tree-select
|
|
167
|
-
size="small"
|
|
168
|
-
disabled
|
|
169
|
-
placeholder="安装插件后可选择导出文件"
|
|
170
|
-
options={[]}
|
|
171
|
-
/>
|
|
172
|
-
<span
|
|
173
|
-
class="lc_btn_primary lc_btn_m _ple_install"
|
|
174
|
-
onClick={onInstall}>
|
|
175
|
-
立即安装插件
|
|
176
|
-
</span>
|
|
177
|
-
</div>
|
|
178
|
-
) : (
|
|
179
|
-
<div class="_ple_row">
|
|
180
|
-
<PluginDirSelect
|
|
181
|
-
modelValue={dirname.value}
|
|
182
|
-
onUpdate:modelValue={(v) => {
|
|
183
|
-
dirname.value = v
|
|
184
|
-
}}
|
|
185
|
-
onUpdate:diskInfo={onDiskInfoUpdate}
|
|
186
|
-
/>
|
|
187
|
-
<div class="_ple_action">
|
|
188
|
-
<span
|
|
189
|
-
class={["lc_btn_primary", "lc_btn_m", pluginExportDisabled.value ? "_disabled" : ""]}
|
|
190
|
-
title={pluginButtonTitle.value}
|
|
191
|
-
onClick={onPluginExportClick}>
|
|
192
|
-
导 出
|
|
193
|
-
</span>
|
|
194
|
-
</div>
|
|
195
|
-
</div>
|
|
196
|
-
)}
|
|
197
|
-
</>
|
|
198
|
-
) : null}
|
|
199
|
-
</div>
|
|
200
|
-
)
|
|
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
201
|
}
|
|
202
202
|
},
|
|
203
203
|
})
|
|
204
|
-
|
|
205
|
-
export default PluginLocalExport
|
|
204
|
+
</script>
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export { pluginApi } from "./api/plugin.js"
|
|
14
|
-
export { PluginLocalExport } from "./PluginLocalExport.
|
|
15
|
-
export { default } from "./PluginLocalExport.
|
|
14
|
+
export { default as PluginLocalExport } from "./PluginLocalExport.vue"
|
|
15
|
+
export { default } from "./PluginLocalExport.vue"
|
package/src/service/export_plugin/internal/{create-folder-modal.jsx → create-folder-modal.vue}
RENAMED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<n-modal
|
|
3
|
+
:show="true"
|
|
4
|
+
preset="dialog"
|
|
5
|
+
title="新建文件夹"
|
|
6
|
+
positive-text="确认"
|
|
7
|
+
negative-text="取消"
|
|
8
|
+
:mask-closable="false"
|
|
9
|
+
@update:show="onShowUpdate"
|
|
10
|
+
@positive-click="onConfirm">
|
|
11
|
+
<div class="export_plugin_modals_hint lc-fs-s">将在以下目录下创建:{{ parentDisplay }}</div>
|
|
12
|
+
<n-input
|
|
13
|
+
v-model:value="folderName"
|
|
14
|
+
size="small"
|
|
15
|
+
placeholder="请输入文件夹名称"
|
|
16
|
+
class="mt-8"
|
|
17
|
+
@keyup.enter="onConfirm" />
|
|
18
|
+
</n-modal>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
1
22
|
import { defineComponent, ref, computed } from "vue"
|
|
2
23
|
import { pluginApi } from "../api/plugin.js"
|
|
3
24
|
import { formatPathDisplay, normalizeDir } from "../utils/plugin-dir.js"
|
|
@@ -6,7 +27,7 @@ import "./styles/export-plugin-modals.less"
|
|
|
6
27
|
/**
|
|
7
28
|
* 新建文件夹弹窗(由父级 v-if 控制挂载,内部组件不对外)
|
|
8
29
|
*/
|
|
9
|
-
export
|
|
30
|
+
export default defineComponent({
|
|
10
31
|
name: "CreateFolderModal",
|
|
11
32
|
props: {
|
|
12
33
|
/** 父目录路径 */
|
|
@@ -22,6 +43,10 @@ export const CreateFolderModal = defineComponent({
|
|
|
22
43
|
emit("close")
|
|
23
44
|
}
|
|
24
45
|
|
|
46
|
+
const onShowUpdate = (v) => {
|
|
47
|
+
if (!v) close()
|
|
48
|
+
}
|
|
49
|
+
|
|
25
50
|
/**
|
|
26
51
|
* 新建文件夹
|
|
27
52
|
* @param {string} name
|
|
@@ -69,34 +94,12 @@ export const CreateFolderModal = defineComponent({
|
|
|
69
94
|
return true
|
|
70
95
|
}
|
|
71
96
|
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
preset="dialog"
|
|
79
|
-
title="新建文件夹"
|
|
80
|
-
positiveText="确认"
|
|
81
|
-
negativeText="取消"
|
|
82
|
-
maskClosable={false}
|
|
83
|
-
onPositiveClick={onConfirm}>
|
|
84
|
-
<div class="export_plugin_modals_hint lc-fs-s">将在以下目录下创建:{parentDisplay.value}</div>
|
|
85
|
-
<n-input
|
|
86
|
-
value={folderName.value}
|
|
87
|
-
onUpdate:value={(v) => {
|
|
88
|
-
folderName.value = v
|
|
89
|
-
}}
|
|
90
|
-
size="small"
|
|
91
|
-
placeholder="请输入文件夹名称"
|
|
92
|
-
class="mt-8"
|
|
93
|
-
onKeyup={(e) => {
|
|
94
|
-
if (e.key === "Enter") onConfirm()
|
|
95
|
-
}}
|
|
96
|
-
/>
|
|
97
|
-
</n-modal>
|
|
98
|
-
)
|
|
97
|
+
return {
|
|
98
|
+
folderName,
|
|
99
|
+
parentDisplay,
|
|
100
|
+
onShowUpdate,
|
|
101
|
+
onConfirm,
|
|
102
|
+
}
|
|
99
103
|
},
|
|
100
104
|
})
|
|
101
|
-
|
|
102
|
-
export default CreateFolderModal
|
|
105
|
+
</script>
|
|
@@ -1,83 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
buildPathChain,
|
|
5
|
-
findNodeByKey,
|
|
6
|
-
formatDiskRemain,
|
|
7
|
-
isPathUnder,
|
|
8
|
-
mapDirNodes,
|
|
9
|
-
normalizeDir,
|
|
10
|
-
normalizePathKey,
|
|
11
|
-
toTreeKey,
|
|
12
|
-
} from "../utils/plugin-dir.js"
|
|
13
|
-
import { CreateFolderModal } from "./create-folder-modal.jsx"
|
|
14
|
-
import "./styles/plugin-dir-select.less"
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 目录树选择
|
|
18
|
-
* @param {object} ctx
|
|
19
|
-
*/
|
|
20
|
-
const renderDirTreeSelect = (ctx) => {
|
|
21
|
-
const {
|
|
22
|
-
treeSelectKey,
|
|
23
|
-
treeSelectValue,
|
|
24
|
-
treeOptions,
|
|
25
|
-
expandedKeys,
|
|
26
|
-
renderTreeLabel,
|
|
27
|
-
onLoadTreeNode,
|
|
28
|
-
onExpandedKeysUpdate,
|
|
29
|
-
onDirChange,
|
|
30
|
-
} = ctx
|
|
31
|
-
|
|
32
|
-
return (
|
|
1
|
+
<template>
|
|
2
|
+
<div class="plugin_dir_select">
|
|
33
3
|
<n-tree-select
|
|
34
|
-
key=
|
|
35
|
-
value=
|
|
4
|
+
:key="treeSelectKey"
|
|
5
|
+
:value="treeSelectValue"
|
|
36
6
|
size="small"
|
|
37
7
|
placeholder="请选择本地目录"
|
|
38
|
-
|
|
39
|
-
|
|
8
|
+
:consistent-menu-width="false"
|
|
9
|
+
show-path
|
|
40
10
|
separator="/"
|
|
41
11
|
filterable
|
|
42
12
|
clearable
|
|
43
|
-
options=
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 文件夹图标 + 磁盘占用
|
|
56
|
-
* @param {object} ctx
|
|
57
|
-
*/
|
|
58
|
-
const renderDirUsage = (ctx) => {
|
|
59
|
-
const { diskUsageText, usagePercent } = ctx
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<>
|
|
13
|
+
:options="treeOptions"
|
|
14
|
+
:expanded-keys="expandedKeys"
|
|
15
|
+
:menu-props="{ class: 'plugin_dir_select_tree' }"
|
|
16
|
+
:render-label="renderTreeLabel"
|
|
17
|
+
:on-load="onLoadTreeNode"
|
|
18
|
+
@update:expanded-keys="onExpandedKeysUpdate"
|
|
19
|
+
@update:value="onDirChange" />
|
|
20
|
+
<template v-if="diskUsageText">
|
|
63
21
|
<span class="_pds_folder_icon">
|
|
64
22
|
<i class="lc lc-tuxing1"></i>
|
|
65
23
|
</span>
|
|
66
24
|
<div class="_pds_usage">
|
|
67
25
|
<div class="__bar">
|
|
68
|
-
<span style={
|
|
26
|
+
<span :style="{ width: `${usagePercent}%` }"></span>
|
|
69
27
|
</div>
|
|
70
|
-
<span class="lc-fs-s">{diskUsageText
|
|
28
|
+
<span class="lc-fs-s">{{ diskUsageText }}</span>
|
|
71
29
|
</div>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
30
|
+
</template>
|
|
31
|
+
<CreateFolderModal
|
|
32
|
+
v-if="showCreateModal"
|
|
33
|
+
:parent-path="createParentPath"
|
|
34
|
+
@created="onFolderCreated"
|
|
35
|
+
@close="showCreateModal = false" />
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script>
|
|
40
|
+
import { defineComponent, ref, computed, toRefs, h } from "vue"
|
|
41
|
+
import { pluginApi } from "../api/plugin.js"
|
|
42
|
+
import {
|
|
43
|
+
buildPathChain,
|
|
44
|
+
findNodeByKey,
|
|
45
|
+
formatDiskRemain,
|
|
46
|
+
isPathUnder,
|
|
47
|
+
mapDirNodes,
|
|
48
|
+
normalizeDir,
|
|
49
|
+
normalizePathKey,
|
|
50
|
+
toTreeKey,
|
|
51
|
+
} from "../utils/plugin-dir.js"
|
|
52
|
+
import CreateFolderModal from "./create-folder-modal.vue"
|
|
53
|
+
import "./styles/plugin-dir-select.less"
|
|
75
54
|
|
|
76
55
|
/**
|
|
77
56
|
* 插件本地目录选择(树选择 + 占用展示 + 新建文件夹,内部组件)
|
|
78
57
|
*/
|
|
79
|
-
export
|
|
58
|
+
export default defineComponent({
|
|
80
59
|
name: "PluginDirSelect",
|
|
60
|
+
components: { CreateFolderModal },
|
|
81
61
|
props: {
|
|
82
62
|
/** 当前选中目录(v-model) */
|
|
83
63
|
modelValue: { type: String, default: "" },
|
|
@@ -126,18 +106,20 @@ export const PluginDirSelect = defineComponent({
|
|
|
126
106
|
}
|
|
127
107
|
|
|
128
108
|
/** 目录树节点:文件夹名 + 新建子目录 */
|
|
129
|
-
const renderTreeLabel = ({ option }) =>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
109
|
+
const renderTreeLabel = ({ option }) =>
|
|
110
|
+
h("span", { class: "_pds_tree_node" }, [
|
|
111
|
+
h("span", { class: "__name" }, option.label),
|
|
112
|
+
h(
|
|
113
|
+
"span",
|
|
114
|
+
{
|
|
115
|
+
class: "__add",
|
|
116
|
+
title: "新建子文件夹",
|
|
117
|
+
onMousedown: (e) => e.stopPropagation(),
|
|
118
|
+
onClick: (e) => openCreateFolder(option.key, e),
|
|
119
|
+
},
|
|
120
|
+
"+",
|
|
121
|
+
),
|
|
122
|
+
])
|
|
141
123
|
|
|
142
124
|
const loadNodeChildren = async (node) => {
|
|
143
125
|
if (Array.isArray(node.children)) return node.children
|
|
@@ -313,31 +295,21 @@ export const PluginDirSelect = defineComponent({
|
|
|
313
295
|
|
|
314
296
|
initDirectory()
|
|
315
297
|
|
|
316
|
-
return
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
parentPath={createParentPath.value}
|
|
332
|
-
onCreated={onFolderCreated}
|
|
333
|
-
onClose={() => {
|
|
334
|
-
showCreateModal.value = false
|
|
335
|
-
}}
|
|
336
|
-
/>
|
|
337
|
-
) : null}
|
|
338
|
-
</div>
|
|
339
|
-
)
|
|
298
|
+
return {
|
|
299
|
+
showCreateModal,
|
|
300
|
+
createParentPath,
|
|
301
|
+
treeOptions,
|
|
302
|
+
expandedKeys,
|
|
303
|
+
treeSelectKey,
|
|
304
|
+
treeSelectValue,
|
|
305
|
+
diskUsageText,
|
|
306
|
+
usagePercent,
|
|
307
|
+
renderTreeLabel,
|
|
308
|
+
onLoadTreeNode,
|
|
309
|
+
onExpandedKeysUpdate,
|
|
310
|
+
onDirChange,
|
|
311
|
+
onFolderCreated,
|
|
312
|
+
}
|
|
340
313
|
},
|
|
341
314
|
})
|
|
342
|
-
|
|
343
|
-
export default PluginDirSelect
|
|
315
|
+
</script>
|