odant-work 1.0.103 → 1.0.104
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/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +11 -1
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +11 -1
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/settings/$handler/class.js +292 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js +11 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +14 -11
- package/$server/$folder/$file/$html/handlers/preview/$handler/preview.js +7 -0
- package/$server/$folder/$file/$image/handlers/preview/$handler/preview.js +11 -0
- package/$server/$folder/$file/$md/handlers/preview/$handler/preview.js +29 -8
- package/$server/$folder/$file/$office/handlers/preview/$handler/preview.js +6 -0
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +34 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js +14 -11
- package/$server/$folder/$file/$task/handlers/preview/$handler/preview.js +1 -0
- package/$server/$folder/$file/$txt/handlers/preview/$handler/preview.js +9 -0
- package/$server/$folder/$file/$video/handlers/preview/$handler/preview.js +15 -0
- package/$server/$folder/handlers/pages/form/$handler/class.js +10 -2
- package/$server/$folder/handlers/pages/form/folder/$handler/class.js +523 -25
- package/$server/$folder/lib/explorer/explorer.js +63 -0
- package/$server/$folder/lib/tree/tree.js +45 -14
- package/NODES/$node/handlers/pages/form/network/$handler/class.js +552 -36
- package/oda/components/icon/icon.js +20 -7
- package/package.json +1 -1
- package/sources/client.js +24 -0
- package/sources/host/websocket.js +17 -0
- package/sources/modules/agent/index.js +25 -6
- package/sources/modules/agent/permissions.js +4 -2
- package/sources/modules/agent/scope.js +72 -5
- package/sources/modules/agent/session.js +59 -6
- package/sources/modules/agent/tools/work/classes.js +16 -1
- package/sources/modules/license/index.js +120 -0
- package/sources/modules/nodes/registry.js +57 -7
- package/sources/modules/trainer/local-engine.js +22 -9
- package/sources/modules/user-profile/user-profile.js +0 -129
- package/sources/modules/user-profile/user-tokens.js +426 -85
- package/sources/server/access/gateway.js +1 -0
- package/sources/server/folder.js +5 -1
- package/sources/server/node.js +16 -0
- package/sources/server/server.js +14 -5
- package/sources/server/user.js +3 -0
|
@@ -36,6 +36,7 @@ export default {
|
|
|
36
36
|
template: /*html*/ `
|
|
37
37
|
<style>
|
|
38
38
|
:host { @apply --vertical; gap: 6px; padding: 8px 10px; min-width: 0; overflow: hidden; }
|
|
39
|
+
:host([full-height]) { height: 100%; overflow: auto; box-sizing: border-box; }
|
|
39
40
|
.bar {
|
|
40
41
|
@apply --horizontal; align-items: center; gap: 8px; font-size: small; min-width: 0;
|
|
41
42
|
padding: 6px 10px; border-radius: var(--radius-m, 8px); position: relative; overflow: hidden;
|
|
@@ -5,6 +5,12 @@ export default{
|
|
|
5
5
|
@apply --vertical;
|
|
6
6
|
padding: 4px 16px;
|
|
7
7
|
}
|
|
8
|
+
:host([full-height]) {
|
|
9
|
+
height: 100%;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
padding: 10px 16px;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
8
14
|
div {
|
|
9
15
|
white-space: break-spaces;
|
|
10
16
|
padding-top: 4px;
|
|
@@ -15,6 +21,9 @@ export default{
|
|
|
15
21
|
-ms-user-select: text; /* Для старых версий Internet Explorer */
|
|
16
22
|
user-select: text; /* Стандартное свойство */
|
|
17
23
|
}
|
|
24
|
+
:host([full-height]) div {
|
|
25
|
+
overflow: visible;
|
|
26
|
+
}
|
|
18
27
|
</style>
|
|
19
28
|
<div flex ~html="value"></div>
|
|
20
29
|
`,
|
|
@@ -5,6 +5,21 @@ export default {
|
|
|
5
5
|
:host {
|
|
6
6
|
background-color: black;
|
|
7
7
|
}
|
|
8
|
+
:host([full-height]) {
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
:host([full-height]) video {
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
max-height: 100%;
|
|
21
|
+
object-fit: contain;
|
|
22
|
+
}
|
|
8
23
|
</style>
|
|
9
24
|
<video :src width="300" height="200" muted controls style="align-self: center;"></video>
|
|
10
25
|
`,
|
|
@@ -1217,8 +1217,16 @@ ODA({is: 'work-form',
|
|
|
1217
1217
|
return localCons;
|
|
1218
1218
|
},
|
|
1219
1219
|
openView(e) {
|
|
1220
|
-
if (e.button === 0 && this.view)
|
|
1221
|
-
|
|
1220
|
+
if (e.button === 0 && this.view) {
|
|
1221
|
+
const target = this.currentItem || this.$item;
|
|
1222
|
+
const short = String(target?.short || target?.path || '').replace(/\/+$/, '');
|
|
1223
|
+
const base = short === '/' ? '' : short;
|
|
1224
|
+
const sub = (this.view_control?.localName === 'work-subview-container' && this.view_control?.activeId)
|
|
1225
|
+
? '/' + this.view_control.activeId
|
|
1226
|
+
: '';
|
|
1227
|
+
const viewSeg = this.view.id ? ('/' + this.view.id + sub) : '';
|
|
1228
|
+
window.open(encodeURI(base + '/~/handlers/pages/form' + viewSeg + '/index.html'));
|
|
1229
|
+
}
|
|
1222
1230
|
},
|
|
1223
1231
|
back(e) {
|
|
1224
1232
|
alert('надо скрыть')
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
const TEXT_PREVIEW_EXTS = new Set([
|
|
2
|
+
'js', 'mjs', 'cjs', 'ts', 'tsx', 'jsx', 'json', 'json5',
|
|
3
|
+
'css', 'scss', 'less', 'xml', 'yml', 'yaml', 'toml', 'ini',
|
|
4
|
+
'conf', 'env', 'sh', 'bash', 'ps1', 'cmd', 'bat', 'py', 'rb',
|
|
5
|
+
'go', 'rs', 'java', 'c', 'cpp', 'h', 'hpp', 'sql', 'log',
|
|
6
|
+
'csv', 'tsv', 'txt', 'md', 'gitignore', 'editorconfig', 'npmrc', 'lock',
|
|
7
|
+
]);
|
|
8
|
+
const TEXT_PREVIEW_NAMES = new Set(['dockerfile', 'makefile', 'license', 'readme', 'changelog']);
|
|
9
|
+
const MAX_TEXT_PREVIEW_CHARS = 512 * 1024;
|
|
10
|
+
|
|
1
11
|
export default {
|
|
2
12
|
icon: 'fontawesome:r-folder-open',
|
|
3
13
|
label: 'Файлы',
|
|
4
14
|
order: 10,
|
|
5
15
|
default: true,
|
|
6
16
|
component: {
|
|
7
|
-
imports: '~/lib//tree.js',
|
|
17
|
+
imports: '~/lib//tree.js, oda//splitter, oda//button, oda//icon',
|
|
8
18
|
template: /* html */`
|
|
9
19
|
<style>
|
|
10
20
|
:host {
|
|
@@ -12,58 +22,341 @@ export default {
|
|
|
12
22
|
overflow: hidden;
|
|
13
23
|
@apply --content;
|
|
14
24
|
min-height: 0;
|
|
25
|
+
min-width: 0;
|
|
15
26
|
}
|
|
16
27
|
.folder-bar {
|
|
17
28
|
@apply --horizontal;
|
|
18
29
|
align-items: center;
|
|
19
|
-
justify-content: flex-end;
|
|
20
30
|
gap: 10px;
|
|
21
|
-
padding: 6px
|
|
22
|
-
border-bottom: 1px solid var(--subtle-border, var(--border-color));
|
|
23
|
-
background: var(--subtle-background, var(--content-background));
|
|
31
|
+
padding: 6px 10px;
|
|
24
32
|
flex-shrink: 0;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
.search-wrap {
|
|
36
|
+
@apply --horizontal;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 4px;
|
|
39
|
+
flex: 1;
|
|
40
|
+
min-width: 0;
|
|
41
|
+
max-width: 560px;
|
|
42
|
+
background: color-mix(in oklch, var(--content-background) 94%, transparent);
|
|
43
|
+
color: var(--content-color);
|
|
44
|
+
border-radius: 6px;
|
|
45
|
+
padding: 2px 8px;
|
|
46
|
+
border: 1px solid color-mix(in oklch, var(--content-color) 18%, transparent);
|
|
47
|
+
}
|
|
48
|
+
.search-wrap:focus-within {
|
|
49
|
+
background: var(--content-background);
|
|
50
|
+
box-shadow: 0 0 0 2px color-mix(in oklch, var(--accent-back, #fff) 35%, transparent);
|
|
51
|
+
}
|
|
52
|
+
.search-input {
|
|
53
|
+
flex: 1;
|
|
54
|
+
min-width: 0;
|
|
55
|
+
border: none;
|
|
56
|
+
outline: none;
|
|
57
|
+
background: transparent;
|
|
58
|
+
color: var(--content-color);
|
|
59
|
+
font: inherit;
|
|
60
|
+
font-size: 13px;
|
|
61
|
+
padding: 3px 2px;
|
|
62
|
+
}
|
|
63
|
+
.search-action {
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
opacity: 0.72;
|
|
66
|
+
color: var(--content-color);
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
}
|
|
69
|
+
.search-action:hover {
|
|
70
|
+
opacity: 1;
|
|
25
71
|
}
|
|
26
72
|
.sys-toggle {
|
|
27
73
|
@apply --horizontal;
|
|
28
74
|
align-items: center;
|
|
29
75
|
gap: 6px;
|
|
30
76
|
font-size: 12.5px;
|
|
31
|
-
color:
|
|
77
|
+
color: inherit;
|
|
32
78
|
cursor: pointer;
|
|
33
79
|
user-select: none;
|
|
80
|
+
white-space: nowrap;
|
|
81
|
+
flex-shrink: 0;
|
|
82
|
+
margin-left: auto;
|
|
34
83
|
}
|
|
35
84
|
.sys-toggle input {
|
|
36
85
|
margin: 0;
|
|
37
86
|
cursor: pointer;
|
|
38
|
-
accent-color: var(--
|
|
87
|
+
accent-color: var(--content-background);
|
|
88
|
+
}
|
|
89
|
+
.folder-body {
|
|
90
|
+
@apply --horizontal;
|
|
91
|
+
flex: 1;
|
|
92
|
+
min-height: 0;
|
|
93
|
+
min-width: 0;
|
|
94
|
+
overflow: hidden;
|
|
95
|
+
}
|
|
96
|
+
.tree-pane {
|
|
97
|
+
@apply --vertical;
|
|
98
|
+
flex: 1;
|
|
99
|
+
min-width: 220px;
|
|
100
|
+
min-height: 0;
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
}
|
|
103
|
+
oda-splitter {
|
|
104
|
+
background: var(--subtle-border, var(--border-color));
|
|
105
|
+
flex-shrink: 0;
|
|
106
|
+
}
|
|
107
|
+
.preview-pane {
|
|
108
|
+
@apply --vertical;
|
|
109
|
+
flex-shrink: 0;
|
|
110
|
+
min-width: 240px;
|
|
111
|
+
min-height: 0;
|
|
112
|
+
overflow: hidden;
|
|
113
|
+
background: var(--content-background);
|
|
114
|
+
color: var(--content-color);
|
|
115
|
+
}
|
|
116
|
+
.preview-head {
|
|
117
|
+
@apply --horizontal;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: 8px;
|
|
120
|
+
padding: 6px 10px;
|
|
121
|
+
border-bottom: 1px solid var(--subtle-border, var(--border-color));
|
|
122
|
+
background: var(--subtle-background, var(--content-background));
|
|
123
|
+
flex-shrink: 0;
|
|
124
|
+
min-width: 0;
|
|
125
|
+
}
|
|
126
|
+
.preview-title-wrap {
|
|
127
|
+
@apply --vertical;
|
|
128
|
+
min-width: 0;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
}
|
|
131
|
+
.preview-title {
|
|
132
|
+
font-size: 13px;
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
white-space: nowrap;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
text-overflow: ellipsis;
|
|
137
|
+
}
|
|
138
|
+
.preview-sub {
|
|
139
|
+
font-size: 11px;
|
|
140
|
+
color: var(--muted-color);
|
|
141
|
+
white-space: nowrap;
|
|
142
|
+
overflow: hidden;
|
|
143
|
+
text-overflow: ellipsis;
|
|
144
|
+
}
|
|
145
|
+
.preview-size {
|
|
146
|
+
font-size: 11.5px;
|
|
147
|
+
color: var(--muted-color);
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
flex-shrink: 0;
|
|
150
|
+
}
|
|
151
|
+
.preview-head oda-button {
|
|
152
|
+
flex-shrink: 0;
|
|
153
|
+
border-radius: 6px;
|
|
154
|
+
padding: 3px 8px;
|
|
155
|
+
font-size: 12px;
|
|
156
|
+
border: 1px solid var(--subtle-border, var(--border-color));
|
|
157
|
+
}
|
|
158
|
+
.preview-stage {
|
|
159
|
+
@apply --vertical;
|
|
160
|
+
flex: 1;
|
|
161
|
+
min-height: 0;
|
|
162
|
+
min-width: 0;
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
position: relative;
|
|
165
|
+
}
|
|
166
|
+
.preview-comp-wrap {
|
|
167
|
+
@apply --vertical;
|
|
168
|
+
flex: 1;
|
|
169
|
+
min-height: 0;
|
|
170
|
+
min-width: 0;
|
|
171
|
+
overflow: auto;
|
|
172
|
+
}
|
|
173
|
+
.preview-code {
|
|
174
|
+
margin: 0;
|
|
175
|
+
padding: 12px 14px;
|
|
176
|
+
flex: 1;
|
|
177
|
+
min-height: 0;
|
|
178
|
+
overflow: auto;
|
|
179
|
+
font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
|
|
180
|
+
font-size: 12.5px;
|
|
181
|
+
line-height: 1.5;
|
|
182
|
+
tab-size: 4;
|
|
183
|
+
white-space: pre;
|
|
184
|
+
user-select: text;
|
|
185
|
+
background: var(--content-background);
|
|
186
|
+
color: var(--content-color);
|
|
187
|
+
}
|
|
188
|
+
.preview-trunc {
|
|
189
|
+
padding: 6px 12px;
|
|
190
|
+
font-size: 12px;
|
|
191
|
+
color: var(--muted-color);
|
|
192
|
+
background: var(--subtle-background);
|
|
193
|
+
border-bottom: 1px solid var(--subtle-border, var(--border-color));
|
|
194
|
+
flex-shrink: 0;
|
|
195
|
+
}
|
|
196
|
+
.preview-pdf {
|
|
197
|
+
flex: 1;
|
|
198
|
+
width: 100%;
|
|
199
|
+
height: 100%;
|
|
200
|
+
border: none;
|
|
201
|
+
min-height: 0;
|
|
202
|
+
background: #fff;
|
|
203
|
+
}
|
|
204
|
+
.preview-empty {
|
|
205
|
+
@apply --vertical;
|
|
206
|
+
align-items: center;
|
|
207
|
+
justify-content: center;
|
|
208
|
+
text-align: center;
|
|
209
|
+
gap: 8px;
|
|
210
|
+
flex: 1;
|
|
211
|
+
padding: 24px;
|
|
212
|
+
min-height: 0;
|
|
213
|
+
overflow: auto;
|
|
214
|
+
}
|
|
215
|
+
.empty-title {
|
|
216
|
+
font-size: 14px;
|
|
217
|
+
font-weight: 600;
|
|
218
|
+
word-break: break-word;
|
|
219
|
+
}
|
|
220
|
+
.empty-sub {
|
|
221
|
+
font-size: 12.5px;
|
|
222
|
+
color: var(--muted-color);
|
|
223
|
+
}
|
|
224
|
+
.empty-hint {
|
|
225
|
+
font-size: 12.5px;
|
|
226
|
+
color: var(--muted-color);
|
|
227
|
+
max-width: 360px;
|
|
228
|
+
line-height: 1.45;
|
|
229
|
+
}
|
|
230
|
+
@media (max-width: 560px) {
|
|
231
|
+
.folder-bar {
|
|
232
|
+
flex-wrap: wrap;
|
|
233
|
+
gap: 6px;
|
|
234
|
+
}
|
|
235
|
+
.search-wrap {
|
|
236
|
+
max-width: none;
|
|
237
|
+
}
|
|
238
|
+
.folder-body {
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
}
|
|
241
|
+
.tree-pane {
|
|
242
|
+
min-width: 0;
|
|
243
|
+
min-height: 140px;
|
|
244
|
+
}
|
|
245
|
+
.preview-pane {
|
|
246
|
+
width: 100% !important;
|
|
247
|
+
max-width: 100% !important;
|
|
248
|
+
min-width: 0;
|
|
249
|
+
height: 55%;
|
|
250
|
+
border-top: 1px solid var(--subtle-border, var(--border-color));
|
|
251
|
+
}
|
|
39
252
|
}
|
|
40
253
|
</style>
|
|
41
|
-
<div
|
|
42
|
-
<
|
|
254
|
+
<div class="folder-bar" accent-invert>
|
|
255
|
+
<div class="search-wrap">
|
|
256
|
+
<input class="search-input" type="search"
|
|
257
|
+
placeholder="Поиск в дереве (Enter — глобальный)…"
|
|
258
|
+
:value="searchFilter"
|
|
259
|
+
@input="onSearchInput($event)"
|
|
260
|
+
@keydown="onSearchKey($event)">
|
|
261
|
+
<oda-icon ~if="searchFilter" icon="icons:close" :icon-size="15" class="search-action" title="Сбросить фильтр" @tap="clearSearch()"></oda-icon>
|
|
262
|
+
<oda-icon icon="icons:search" :icon-size="17" class="search-action" title="Глобальный поиск (Enter)" @tap="runGlobalSearch()"></oda-icon>
|
|
263
|
+
</div>
|
|
264
|
+
<label ~if="isBoss" class="sys-toggle">
|
|
43
265
|
<input type="checkbox" :checked="showSystem" @change="onShowSystemChange($event)">
|
|
44
266
|
<span>Показать системные</span>
|
|
45
267
|
</label>
|
|
46
268
|
</div>
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
269
|
+
<div class="folder-body">
|
|
270
|
+
<div class="tree-pane">
|
|
271
|
+
<item-tree id="folderTree" flex
|
|
272
|
+
:$item="storage"
|
|
273
|
+
:filter="searchFilter"
|
|
274
|
+
:hide-system="!effectiveShowSystem"
|
|
275
|
+
:restore-state="false"
|
|
276
|
+
:auto-run="false"
|
|
277
|
+
show-size
|
|
278
|
+
allow-focus
|
|
279
|
+
show-tools
|
|
280
|
+
menu-mode="both"
|
|
281
|
+
items-selector="entries"
|
|
282
|
+
hide-tops="1"
|
|
283
|
+
hide-roots="1"
|
|
284
|
+
:execute="openEntry"
|
|
285
|
+
@focused-item-changed="onTreeFocusChanged($event)">
|
|
286
|
+
</item-tree>
|
|
287
|
+
</div>
|
|
288
|
+
<oda-splitter ~if="showPreviewPane && !isMobile" left ::width="previewWidth" :min="240" :size="4"></oda-splitter>
|
|
289
|
+
<div ~if="showPreviewPane" class="preview-pane" :style="previewPaneStyle">
|
|
290
|
+
<div class="preview-head" ~if="previewTarget">
|
|
291
|
+
<oda-icon :icon="previewTarget.icon || (isPreviewFile ? 'files:document' : 'fontawesome:r-folder')" :icon-size="18"></oda-icon>
|
|
292
|
+
<div class="preview-title-wrap" flex>
|
|
293
|
+
<div class="preview-title" :title="previewTitle">{{previewTitle}}</div>
|
|
294
|
+
<div class="preview-sub" ~if="previewRelPath" :title="previewRelPath">{{previewRelPath}}</div>
|
|
295
|
+
</div>
|
|
296
|
+
<span class="preview-size" ~if="previewSizeText">{{previewSizeText}}</span>
|
|
297
|
+
<oda-button ~if="canOpenPreviewTarget" icon="icons:open-in-new" :icon-size="15" label="Открыть" title="Открыть в отдельной вкладке" @tap="openPreviewTarget()"></oda-button>
|
|
298
|
+
<oda-button ~if="isPreviewFile" icon="icons:file-download" :icon-size="15" label="Скачать" title="Скачать файл" @tap="downloadPreviewTarget()"></oda-button>
|
|
299
|
+
<oda-button ~if="isMobile" icon="icons:close" :icon-size="16" title="Закрыть предпросмотр" @tap="closeMobilePreview()"></oda-button>
|
|
300
|
+
</div>
|
|
301
|
+
<div class="preview-stage">
|
|
302
|
+
<div ~if="!previewTarget" class="preview-empty">
|
|
303
|
+
<oda-icon icon="fontawesome:r-folder-open" :icon-size="40" style="opacity: 0.35;"></oda-icon>
|
|
304
|
+
<div class="empty-title">{{storageTitle}}</div>
|
|
305
|
+
<div class="empty-hint">Выберите файл в дереве слева для предпросмотра. Двойной клик или Enter открывает элемент в отдельной вкладке.</div>
|
|
306
|
+
</div>
|
|
307
|
+
<div ~if="previewTarget && !isPreviewFile" class="preview-empty">
|
|
308
|
+
<oda-icon :icon="previewTarget.icon || 'fontawesome:r-folder'" :icon-size="40" style="opacity: 0.45;"></oda-icon>
|
|
309
|
+
<div class="empty-title">{{previewTitle}}</div>
|
|
310
|
+
<div class="empty-sub" ~if="previewSizeText">Размер: {{previewSizeText}}</div>
|
|
311
|
+
<div class="empty-hint">Это папка. Выберите файл внутри для предпросмотра или откройте двойным кликом.</div>
|
|
312
|
+
</div>
|
|
313
|
+
<div ~if="isPreviewFile && previewMode === 'loading'" class="preview-empty">
|
|
314
|
+
<oda-icon icon="spinners:8-dots-rotate" :icon-size="28"></oda-icon>
|
|
315
|
+
<div class="empty-hint">Загрузка предпросмотра…</div>
|
|
316
|
+
</div>
|
|
317
|
+
<div ~if="isPreviewFile && previewMode === 'component' && previewTag" class="preview-comp-wrap">
|
|
318
|
+
<div ~is="previewTag" full-height flex :$item="previewTarget"></div>
|
|
319
|
+
</div>
|
|
320
|
+
<div ~if="isPreviewFile && previewMode === 'text' && previewTruncated" class="preview-trunc">
|
|
321
|
+
Показаны первые 512 КБ файла. Нажмите «Открыть» или «Скачать» для полного просмотра.
|
|
322
|
+
</div>
|
|
323
|
+
<pre ~if="isPreviewFile && previewMode === 'text'" class="preview-code">{{previewText}}</pre>
|
|
324
|
+
<iframe ~if="isPreviewFile && previewMode === 'pdf'" class="preview-pdf" :src="previewPdfUrl"></iframe>
|
|
325
|
+
<div ~if="isPreviewFile && previewMode === 'error'" class="preview-empty">
|
|
326
|
+
<oda-icon icon="icons:warning" :icon-size="32" style="color: var(--error-color);"></oda-icon>
|
|
327
|
+
<div class="empty-title">Не удалось загрузить предпросмотр</div>
|
|
328
|
+
<div class="empty-hint">{{previewError}}</div>
|
|
329
|
+
</div>
|
|
330
|
+
<div ~if="isPreviewFile && previewMode === 'binary'" class="preview-empty">
|
|
331
|
+
<oda-icon :icon="previewTarget.icon || 'files:document'" :icon-size="40" style="opacity: 0.45;"></oda-icon>
|
|
332
|
+
<div class="empty-title">{{previewTitle}}</div>
|
|
333
|
+
<div class="empty-sub" ~if="previewExt">Формат: .{{previewExt}}<span ~if="previewSizeText"> · {{previewSizeText}}</span></div>
|
|
334
|
+
<div class="empty-hint">Предпросмотр для этого типа файлов недоступен. Используйте кнопки «Открыть» или «Скачать» выше.</div>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
61
339
|
`,
|
|
62
340
|
showSystem: false,
|
|
341
|
+
searchFilter: '',
|
|
63
342
|
_isBoss: false,
|
|
343
|
+
focusedItem: null,
|
|
344
|
+
previewWidth: {
|
|
345
|
+
$def: 480,
|
|
346
|
+
$save: true,
|
|
347
|
+
},
|
|
348
|
+
previewMode: 'empty',
|
|
349
|
+
previewTag: '',
|
|
350
|
+
previewText: '',
|
|
351
|
+
previewTruncated: false,
|
|
352
|
+
previewPdfUrl: '',
|
|
353
|
+
previewError: '',
|
|
354
|
+
previewSizeText: '',
|
|
64
355
|
$item: {
|
|
65
356
|
$def: null,
|
|
66
357
|
set(n) {
|
|
358
|
+
this.focusedItem = null;
|
|
359
|
+
this._clearPreview();
|
|
67
360
|
this._syncIsBoss(n);
|
|
68
361
|
},
|
|
69
362
|
},
|
|
@@ -97,12 +390,217 @@ export default {
|
|
|
97
390
|
get effectiveShowSystem() {
|
|
98
391
|
return Boolean(this._isBoss && this.showSystem);
|
|
99
392
|
},
|
|
100
|
-
|
|
101
|
-
|
|
393
|
+
get isMobile() {
|
|
394
|
+
const topW = typeof top !== 'undefined' ? top.innerWidth : (typeof window !== 'undefined' ? window.innerWidth : 1280);
|
|
395
|
+
const selfW = this.clientWidth || (typeof window !== 'undefined' ? window.innerWidth : 1280);
|
|
396
|
+
return Boolean((ODA.states?.mobileMode && topW <= 768) || selfW < 560);
|
|
102
397
|
},
|
|
103
398
|
get storage() {
|
|
104
399
|
return this.$item?.storage_folder;
|
|
105
400
|
},
|
|
401
|
+
get storageTitle() {
|
|
402
|
+
return this.$item?.DATA?.label || this.$item?.label || this.$item?.id || 'Файлы';
|
|
403
|
+
},
|
|
404
|
+
get previewTarget() {
|
|
405
|
+
return this.focusedItem || null;
|
|
406
|
+
},
|
|
407
|
+
get isPreviewFile() {
|
|
408
|
+
const it = this.previewTarget;
|
|
409
|
+
if (!it)
|
|
410
|
+
return false;
|
|
411
|
+
return (typeof CORE !== 'undefined' && CORE.$file && it instanceof CORE.$file) || it.type === '$file';
|
|
412
|
+
},
|
|
413
|
+
get previewTitle() {
|
|
414
|
+
const it = this.previewTarget;
|
|
415
|
+
return it?.label || it?.DATA?.label || it?.id || '';
|
|
416
|
+
},
|
|
417
|
+
get previewExt() {
|
|
418
|
+
const it = this.previewTarget;
|
|
419
|
+
if (!it)
|
|
420
|
+
return '';
|
|
421
|
+
const id = String(it.id || it.path || '');
|
|
422
|
+
const idx = id.lastIndexOf('.');
|
|
423
|
+
return idx > -1 ? id.slice(idx + 1).toLowerCase() : '';
|
|
424
|
+
},
|
|
425
|
+
get previewRelPath() {
|
|
426
|
+
const it = this.previewTarget;
|
|
427
|
+
if (!it)
|
|
428
|
+
return '';
|
|
429
|
+
const full = String(it.path || it.short || '');
|
|
430
|
+
const root = String(this.storage?.path || '');
|
|
431
|
+
if (root && full.startsWith(root + '/'))
|
|
432
|
+
return full.slice(root.length + 1);
|
|
433
|
+
return full;
|
|
434
|
+
},
|
|
435
|
+
get canOpenPreviewTarget() {
|
|
436
|
+
const it = this.previewTarget;
|
|
437
|
+
if (!it)
|
|
438
|
+
return false;
|
|
439
|
+
return this.isPreviewFile || it.type !== '$folder';
|
|
440
|
+
},
|
|
441
|
+
get showPreviewPane() {
|
|
442
|
+
if (this.isMobile)
|
|
443
|
+
return this.isPreviewFile;
|
|
444
|
+
return true;
|
|
445
|
+
},
|
|
446
|
+
get previewPaneStyle() {
|
|
447
|
+
if (this.isMobile)
|
|
448
|
+
return '';
|
|
449
|
+
const w = Math.max(240, Number(this.previewWidth) || 480);
|
|
450
|
+
return `width: ${w}px; max-width: 72%;`;
|
|
451
|
+
},
|
|
452
|
+
onSearchInput(e) {
|
|
453
|
+
this.searchFilter = e?.target?.value ?? '';
|
|
454
|
+
},
|
|
455
|
+
onSearchKey(e) {
|
|
456
|
+
if (e.key === 'Enter') {
|
|
457
|
+
e.preventDefault();
|
|
458
|
+
e.stopPropagation();
|
|
459
|
+
this.runGlobalSearch();
|
|
460
|
+
}
|
|
461
|
+
else if (e.key === 'Escape' && this.searchFilter) {
|
|
462
|
+
e.preventDefault();
|
|
463
|
+
e.stopPropagation();
|
|
464
|
+
this.clearSearch();
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
clearSearch() {
|
|
468
|
+
this.searchFilter = '';
|
|
469
|
+
},
|
|
470
|
+
runGlobalSearch() {
|
|
471
|
+
this.$('#folderTree')?.runGlobalSearch?.();
|
|
472
|
+
},
|
|
473
|
+
onShowSystemChange(e) {
|
|
474
|
+
const next = Boolean(e?.target?.checked);
|
|
475
|
+
if (next) {
|
|
476
|
+
const entries = this.storage?.[R]?.cache?.entries;
|
|
477
|
+
if (Array.isArray(entries)) {
|
|
478
|
+
for (const ent of entries) {
|
|
479
|
+
const id = String(ent?.id || '');
|
|
480
|
+
if (id.startsWith('$') || id.startsWith('#'))
|
|
481
|
+
ent.expanded = false;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
this.showSystem = next;
|
|
486
|
+
if (!next && this.focusedItem) {
|
|
487
|
+
const id = String(this.focusedItem.id || '');
|
|
488
|
+
const p = String(this.focusedItem.path || '');
|
|
489
|
+
if (id.startsWith('$') || id.startsWith('#') || p.includes('/$') || p.includes('/#')) {
|
|
490
|
+
const tree = this.$('#folderTree');
|
|
491
|
+
if (tree)
|
|
492
|
+
tree.focusedItem = null;
|
|
493
|
+
this.focusedItem = null;
|
|
494
|
+
this._clearPreview();
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
onTreeFocusChanged(e) {
|
|
499
|
+
const next = (e?.detail && 'value' in e.detail) ? e.detail.value : this.$('#folderTree')?.focusedItem;
|
|
500
|
+
const item = next || null;
|
|
501
|
+
this.focusedItem = item;
|
|
502
|
+
this._syncPreview(item);
|
|
503
|
+
},
|
|
504
|
+
closeMobilePreview() {
|
|
505
|
+
const tree = this.$('#folderTree');
|
|
506
|
+
if (tree)
|
|
507
|
+
tree.focusedItem = null;
|
|
508
|
+
this.focusedItem = null;
|
|
509
|
+
this._clearPreview();
|
|
510
|
+
},
|
|
511
|
+
openPreviewTarget() {
|
|
512
|
+
if (this.previewTarget)
|
|
513
|
+
this.openEntry(this.previewTarget);
|
|
514
|
+
},
|
|
515
|
+
downloadPreviewTarget() {
|
|
516
|
+
this.previewTarget?.download?.();
|
|
517
|
+
},
|
|
518
|
+
_clearPreview() {
|
|
519
|
+
this._previewSeq = (this._previewSeq || 0) + 1;
|
|
520
|
+
this.previewMode = 'empty';
|
|
521
|
+
this.previewTag = '';
|
|
522
|
+
this.previewText = '';
|
|
523
|
+
this.previewTruncated = false;
|
|
524
|
+
this.previewPdfUrl = '';
|
|
525
|
+
this.previewError = '';
|
|
526
|
+
this.previewSizeText = '';
|
|
527
|
+
},
|
|
528
|
+
async _syncPreview(item) {
|
|
529
|
+
const seq = (this._previewSeq = (this._previewSeq || 0) + 1);
|
|
530
|
+
this.previewTag = '';
|
|
531
|
+
this.previewText = '';
|
|
532
|
+
this.previewTruncated = false;
|
|
533
|
+
this.previewPdfUrl = '';
|
|
534
|
+
this.previewError = '';
|
|
535
|
+
this.previewSizeText = '';
|
|
536
|
+
if (!item) {
|
|
537
|
+
this.previewMode = 'empty';
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (item.size !== undefined) {
|
|
541
|
+
Promise.resolve(item.size).then(sz => {
|
|
542
|
+
if (seq === this._previewSeq && sz)
|
|
543
|
+
this.previewSizeText = String(sz);
|
|
544
|
+
}).catch(() => {});
|
|
545
|
+
}
|
|
546
|
+
const isFile = (typeof CORE !== 'undefined' && CORE.$file && item instanceof CORE.$file) || item.type === '$file';
|
|
547
|
+
if (!isFile) {
|
|
548
|
+
this.previewMode = 'folder';
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
this.previewMode = 'loading';
|
|
552
|
+
try {
|
|
553
|
+
const hasPreview = typeof CORE?.$file?.loadPreview === 'function'
|
|
554
|
+
? await CORE.$file.loadPreview(item)
|
|
555
|
+
: false;
|
|
556
|
+
if (seq !== this._previewSeq)
|
|
557
|
+
return;
|
|
558
|
+
if (hasPreview && item.ext) {
|
|
559
|
+
this.previewTag = item.ext + '-preview';
|
|
560
|
+
this.previewMode = 'component';
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const ext = this.previewExt;
|
|
564
|
+
if (ext === 'pdf' && item.url) {
|
|
565
|
+
this.previewPdfUrl = item.url;
|
|
566
|
+
this.previewMode = 'pdf';
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const nameLower = String(item.id || '').toLowerCase();
|
|
570
|
+
if ((TEXT_PREVIEW_EXTS.has(ext) || TEXT_PREVIEW_NAMES.has(nameLower)) && typeof item.load === 'function') {
|
|
571
|
+
const raw = await item.load();
|
|
572
|
+
if (seq !== this._previewSeq)
|
|
573
|
+
return;
|
|
574
|
+
let txt;
|
|
575
|
+
if (raw?.DATA instanceof Blob)
|
|
576
|
+
txt = await raw.DATA.text();
|
|
577
|
+
else if (raw instanceof Blob)
|
|
578
|
+
txt = await raw.text();
|
|
579
|
+
else if (raw && typeof raw === 'object')
|
|
580
|
+
txt = JSON.stringify(raw, null, 2);
|
|
581
|
+
else
|
|
582
|
+
txt = String(raw ?? '');
|
|
583
|
+
if (seq !== this._previewSeq)
|
|
584
|
+
return;
|
|
585
|
+
if (txt.length > MAX_TEXT_PREVIEW_CHARS) {
|
|
586
|
+
this.previewTruncated = true;
|
|
587
|
+
this.previewText = txt.slice(0, MAX_TEXT_PREVIEW_CHARS);
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
this.previewText = txt;
|
|
591
|
+
}
|
|
592
|
+
this.previewMode = 'text';
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
this.previewMode = 'binary';
|
|
596
|
+
}
|
|
597
|
+
catch (err) {
|
|
598
|
+
if (seq !== this._previewSeq)
|
|
599
|
+
return;
|
|
600
|
+
this.previewError = String(err?.message || err || 'Ошибка загрузки');
|
|
601
|
+
this.previewMode = 'error';
|
|
602
|
+
}
|
|
603
|
+
},
|
|
106
604
|
openEntry(item) {
|
|
107
605
|
if (!item)
|
|
108
606
|
return;
|