@xcanwin/manyoyo 5.8.1 → 5.8.2
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.
|
@@ -165,12 +165,7 @@
|
|
|
165
165
|
</div>
|
|
166
166
|
</label>
|
|
167
167
|
<label>containerName<input id="createContainerName" placeholder="my-dev 或 my-{now}" /></label>
|
|
168
|
-
<label>containerPath
|
|
169
|
-
<div class="field-inline">
|
|
170
|
-
<input id="createContainerPath" placeholder="/workspace" />
|
|
171
|
-
<button type="button" id="pickContainerPathBtn" class="secondary field-picker-btn">选择</button>
|
|
172
|
-
</div>
|
|
173
|
-
</label>
|
|
168
|
+
<label>containerPath<input id="createContainerPath" placeholder="/workspace" /></label>
|
|
174
169
|
<label>imageName<input id="createImageName" placeholder="localhost/xcanwin/manyoyo" /></label>
|
|
175
170
|
<label>imageVersion<input id="createImageVersion" placeholder="1.7.4-common" /></label>
|
|
176
171
|
<label>containerMode
|
|
@@ -285,7 +280,6 @@
|
|
|
285
280
|
<script src="/app/vendor/xterm-addon-fit.js"></script>
|
|
286
281
|
<script src="/app/vendor/marked.min.js"></script>
|
|
287
282
|
<script src="/app/frontend/markdown-renderer.js"></script>
|
|
288
|
-
<script src="/app/frontend/path-picker-utils.js"></script>
|
|
289
283
|
<script src="/app/frontend/app.js"></script>
|
|
290
284
|
</body>
|
|
291
285
|
</html>
|
package/lib/web/frontend/app.js
CHANGED
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
sessionDetailRequestId: 0,
|
|
63
63
|
agentTemplateError: '',
|
|
64
64
|
createAgentPromptAuto: false,
|
|
65
|
-
createContainerPathBase: '',
|
|
66
65
|
createDefaults: null,
|
|
67
66
|
createRuns: {},
|
|
68
67
|
sessionNodeMap: new Map(),
|
|
@@ -80,8 +79,6 @@
|
|
|
80
79
|
title: '',
|
|
81
80
|
tip: '',
|
|
82
81
|
currentPath: '',
|
|
83
|
-
basePath: '',
|
|
84
|
-
baseContainerPath: '',
|
|
85
82
|
entries: [],
|
|
86
83
|
error: ''
|
|
87
84
|
},
|
|
@@ -145,7 +142,6 @@
|
|
|
145
142
|
const createHostPath = document.getElementById('createHostPath');
|
|
146
143
|
const createContainerPath = document.getElementById('createContainerPath');
|
|
147
144
|
const pickHostPathBtn = document.getElementById('pickHostPathBtn');
|
|
148
|
-
const pickContainerPathBtn = document.getElementById('pickContainerPathBtn');
|
|
149
145
|
const createImageName = document.getElementById('createImageName');
|
|
150
146
|
const createImageVersion = document.getElementById('createImageVersion');
|
|
151
147
|
const createContainerMode = document.getElementById('createContainerMode');
|
|
@@ -244,10 +240,6 @@
|
|
|
244
240
|
&& typeof window.ManyoyoMarkdown.render === 'function'
|
|
245
241
|
? window.ManyoyoMarkdown
|
|
246
242
|
: null;
|
|
247
|
-
const pathPickerUtils = window.ManyoyoPathPickerUtils && typeof window.ManyoyoPathPickerUtils === 'object'
|
|
248
|
-
? window.ManyoyoPathPickerUtils
|
|
249
|
-
: {};
|
|
250
|
-
|
|
251
243
|
function normalizeBooleanMap(source) {
|
|
252
244
|
const result = {};
|
|
253
245
|
if (!source || typeof source !== 'object' || Array.isArray(source)) {
|
|
@@ -704,41 +696,6 @@
|
|
|
704
696
|
return false;
|
|
705
697
|
}
|
|
706
698
|
|
|
707
|
-
function normalizeSlashPath(value) {
|
|
708
|
-
if (typeof pathPickerUtils.normalizeSlashPath === 'function') {
|
|
709
|
-
return pathPickerUtils.normalizeSlashPath(value);
|
|
710
|
-
}
|
|
711
|
-
return String(value || '').replace(/\\/g, '/');
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
function isChildPath(basePath, targetPath) {
|
|
715
|
-
if (typeof pathPickerUtils.isChildPath === 'function') {
|
|
716
|
-
return pathPickerUtils.isChildPath(basePath, targetPath);
|
|
717
|
-
}
|
|
718
|
-
const normalizedBase = normalizeSlashPath(basePath).replace(/\/+$/, '');
|
|
719
|
-
const normalizedTarget = normalizeSlashPath(targetPath).replace(/\/+$/, '');
|
|
720
|
-
if (!normalizedBase) {
|
|
721
|
-
return false;
|
|
722
|
-
}
|
|
723
|
-
return normalizedTarget === normalizedBase || normalizedTarget.startsWith(normalizedBase + '/');
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
function buildContainerPathFromHostSelection(baseHostPath, baseContainerPath, selectedHostPath) {
|
|
727
|
-
if (typeof pathPickerUtils.buildContainerPathFromHostSelection === 'function') {
|
|
728
|
-
return pathPickerUtils.buildContainerPathFromHostSelection(baseHostPath, baseContainerPath, selectedHostPath);
|
|
729
|
-
}
|
|
730
|
-
const normalizedBaseHost = normalizeSlashPath(baseHostPath).replace(/\/+$/, '');
|
|
731
|
-
const normalizedContainer = normalizeSlashPath(baseContainerPath).replace(/\/+$/, '') || '/workspace';
|
|
732
|
-
const normalizedSelected = normalizeSlashPath(selectedHostPath).replace(/\/+$/, '');
|
|
733
|
-
if (!normalizedBaseHost || !isChildPath(normalizedBaseHost, normalizedSelected)) {
|
|
734
|
-
return normalizedContainer;
|
|
735
|
-
}
|
|
736
|
-
const relative = normalizedSelected === normalizedBaseHost
|
|
737
|
-
? ''
|
|
738
|
-
: normalizedSelected.slice(normalizedBaseHost.length + 1);
|
|
739
|
-
return relative ? `${normalizedContainer}/${relative}`.replace(/\/+/g, '/') : normalizedContainer;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
699
|
function setModalVisible(modalNode, visible) {
|
|
743
700
|
if (!modalNode) return;
|
|
744
701
|
modalNode.hidden = !visible;
|
|
@@ -947,7 +904,6 @@
|
|
|
947
904
|
createContainerName.value = value.containerName || '';
|
|
948
905
|
createHostPath.value = value.hostPath || '';
|
|
949
906
|
createContainerPath.value = value.containerPath || '';
|
|
950
|
-
state.createContainerPathBase = String(value.containerPath || '').trim();
|
|
951
907
|
createImageName.value = value.imageName || '';
|
|
952
908
|
createImageVersion.value = value.imageVersion || '';
|
|
953
909
|
createContainerMode.value = value.containerMode || '';
|
|
@@ -2411,12 +2367,8 @@
|
|
|
2411
2367
|
try {
|
|
2412
2368
|
const params = new URLSearchParams();
|
|
2413
2369
|
params.set('path', picker.currentPath || '/');
|
|
2414
|
-
if (picker.basePath) {
|
|
2415
|
-
params.set('basePath', picker.basePath);
|
|
2416
|
-
}
|
|
2417
2370
|
const data = await api('/api/fs/directories?' + params.toString());
|
|
2418
2371
|
picker.currentPath = data.currentPath || picker.currentPath;
|
|
2419
|
-
picker.basePath = data.basePath || picker.basePath || '';
|
|
2420
2372
|
picker.parentPath = data.parentPath || '';
|
|
2421
2373
|
picker.entries = Array.isArray(data.entries) ? data.entries : [];
|
|
2422
2374
|
} catch (e) {
|
|
@@ -2435,8 +2387,6 @@
|
|
|
2435
2387
|
state.directoryPicker.title = '';
|
|
2436
2388
|
state.directoryPicker.tip = '';
|
|
2437
2389
|
state.directoryPicker.currentPath = '';
|
|
2438
|
-
state.directoryPicker.basePath = '';
|
|
2439
|
-
state.directoryPicker.baseContainerPath = '';
|
|
2440
2390
|
state.directoryPicker.parentPath = '';
|
|
2441
2391
|
state.directoryPicker.entries = [];
|
|
2442
2392
|
state.directoryPicker.error = '';
|
|
@@ -2448,54 +2398,22 @@
|
|
|
2448
2398
|
if (!picker.currentPath) {
|
|
2449
2399
|
return;
|
|
2450
2400
|
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
if (!(createContainerPath.value || '').trim()) {
|
|
2454
|
-
createContainerPath.value = '/workspace';
|
|
2455
|
-
state.createContainerPathBase = '/workspace';
|
|
2456
|
-
}
|
|
2457
|
-
} else if (picker.mode === 'container') {
|
|
2458
|
-
const mapped = buildContainerPathFromHostSelection(
|
|
2459
|
-
picker.basePath,
|
|
2460
|
-
picker.baseContainerPath || '/workspace',
|
|
2461
|
-
picker.currentPath
|
|
2462
|
-
);
|
|
2463
|
-
createContainerPath.value = mapped;
|
|
2464
|
-
}
|
|
2401
|
+
createHostPath.value = picker.currentPath;
|
|
2402
|
+
createContainerPath.value = picker.currentPath;
|
|
2465
2403
|
closeDirectoryPicker();
|
|
2466
2404
|
}
|
|
2467
2405
|
|
|
2468
|
-
function openDirectoryPicker(
|
|
2406
|
+
function openDirectoryPicker() {
|
|
2469
2407
|
const picker = state.directoryPicker;
|
|
2470
2408
|
picker.open = true;
|
|
2471
2409
|
picker.loading = false;
|
|
2472
2410
|
picker.error = '';
|
|
2473
2411
|
picker.entries = [];
|
|
2474
2412
|
picker.parentPath = '';
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
picker.open = false;
|
|
2480
|
-
renderDirectoryPicker();
|
|
2481
|
-
return;
|
|
2482
|
-
}
|
|
2483
|
-
picker.mode = 'container';
|
|
2484
|
-
picker.title = '选择 containerPath 对应目录';
|
|
2485
|
-
picker.tip = '从 hostPath 下选择子目录,结果会映射到容器路径。';
|
|
2486
|
-
picker.basePath = baseHostPath;
|
|
2487
|
-
picker.baseContainerPath = typeof pathPickerUtils.resolveContainerPickerBase === 'function'
|
|
2488
|
-
? pathPickerUtils.resolveContainerPickerBase(state.createContainerPathBase, createContainerPath.value)
|
|
2489
|
-
: (String(state.createContainerPathBase || '').trim() || String(createContainerPath.value || '').trim() || '/workspace');
|
|
2490
|
-
picker.currentPath = baseHostPath;
|
|
2491
|
-
} else {
|
|
2492
|
-
picker.mode = 'host';
|
|
2493
|
-
picker.title = '选择 hostPath';
|
|
2494
|
-
picker.tip = '浏览宿主机目录,选中后会回填 create 表单。';
|
|
2495
|
-
picker.basePath = '';
|
|
2496
|
-
picker.baseContainerPath = '';
|
|
2497
|
-
picker.currentPath = (createHostPath.value || '').trim() || '/';
|
|
2498
|
-
}
|
|
2413
|
+
picker.mode = 'host';
|
|
2414
|
+
picker.title = '选择 hostPath';
|
|
2415
|
+
picker.tip = '浏览宿主机目录,选中后会回填 create 表单。';
|
|
2416
|
+
picker.currentPath = (createHostPath.value || '').trim() || '/';
|
|
2499
2417
|
renderDirectoryPicker();
|
|
2500
2418
|
loadDirectoryPicker(picker.currentPath);
|
|
2501
2419
|
}
|
|
@@ -3659,13 +3577,7 @@
|
|
|
3659
3577
|
|
|
3660
3578
|
if (pickHostPathBtn) {
|
|
3661
3579
|
pickHostPathBtn.addEventListener('click', function () {
|
|
3662
|
-
openDirectoryPicker(
|
|
3663
|
-
});
|
|
3664
|
-
}
|
|
3665
|
-
|
|
3666
|
-
if (pickContainerPathBtn) {
|
|
3667
|
-
pickContainerPathBtn.addEventListener('click', function () {
|
|
3668
|
-
openDirectoryPicker('container');
|
|
3580
|
+
openDirectoryPicker();
|
|
3669
3581
|
});
|
|
3670
3582
|
}
|
|
3671
3583
|
|
|
@@ -3762,12 +3674,6 @@
|
|
|
3762
3674
|
});
|
|
3763
3675
|
}
|
|
3764
3676
|
|
|
3765
|
-
if (createContainerPath) {
|
|
3766
|
-
createContainerPath.addEventListener('input', function () {
|
|
3767
|
-
state.createContainerPathBase = String(createContainerPath.value || '').trim();
|
|
3768
|
-
});
|
|
3769
|
-
}
|
|
3770
|
-
|
|
3771
3677
|
if (createForm) {
|
|
3772
3678
|
createForm.addEventListener('submit', async function (event) {
|
|
3773
3679
|
event.preventDefault();
|
package/lib/web/server.js
CHANGED
|
@@ -3767,7 +3767,7 @@ async function startWebServer(options) {
|
|
|
3767
3767
|
const appFrontendMatch = pathname.match(/^\/app\/frontend\/([A-Za-z0-9._-]+)$/);
|
|
3768
3768
|
if (req.method === 'GET' && appFrontendMatch) {
|
|
3769
3769
|
const assetName = appFrontendMatch[1];
|
|
3770
|
-
if (!(assetName === 'app.css' || assetName === 'app.js' || assetName === 'markdown.css' || assetName === 'markdown-renderer.js'
|
|
3770
|
+
if (!(assetName === 'app.css' || assetName === 'app.js' || assetName === 'markdown.css' || assetName === 'markdown-renderer.js')) {
|
|
3771
3771
|
sendHtml(res, 404, '<h1>404 Not Found</h1>');
|
|
3772
3772
|
return;
|
|
3773
3773
|
}
|
package/package.json
CHANGED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
(function (root, factory) {
|
|
2
|
-
const api = factory();
|
|
3
|
-
if (typeof module === 'object' && module.exports) {
|
|
4
|
-
module.exports = api;
|
|
5
|
-
}
|
|
6
|
-
if (root && typeof root === 'object') {
|
|
7
|
-
root.ManyoyoPathPickerUtils = api;
|
|
8
|
-
}
|
|
9
|
-
}(typeof globalThis !== 'undefined' ? globalThis : this, function () {
|
|
10
|
-
function normalizeSlashPath(value) {
|
|
11
|
-
return String(value || '').replace(/\\/g, '/');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function isChildPath(basePath, targetPath) {
|
|
15
|
-
const normalizedBase = normalizeSlashPath(basePath).replace(/\/+$/, '');
|
|
16
|
-
const normalizedTarget = normalizeSlashPath(targetPath).replace(/\/+$/, '');
|
|
17
|
-
if (!normalizedBase) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return normalizedTarget === normalizedBase || normalizedTarget.startsWith(normalizedBase + '/');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function resolveContainerPickerBase(baseContainerPath, currentContainerPath) {
|
|
24
|
-
return String(baseContainerPath || '').trim()
|
|
25
|
-
|| String(currentContainerPath || '').trim()
|
|
26
|
-
|| '/workspace';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function buildContainerPathFromHostSelection(baseHostPath, baseContainerPath, selectedHostPath) {
|
|
30
|
-
const normalizedBaseHost = normalizeSlashPath(baseHostPath).replace(/\/+$/, '');
|
|
31
|
-
const normalizedContainer = normalizeSlashPath(baseContainerPath).replace(/\/+$/, '') || '/workspace';
|
|
32
|
-
const normalizedSelected = normalizeSlashPath(selectedHostPath).replace(/\/+$/, '');
|
|
33
|
-
if (!normalizedBaseHost || !isChildPath(normalizedBaseHost, normalizedSelected)) {
|
|
34
|
-
return normalizedContainer;
|
|
35
|
-
}
|
|
36
|
-
const relative = normalizedSelected === normalizedBaseHost
|
|
37
|
-
? ''
|
|
38
|
-
: normalizedSelected.slice(normalizedBaseHost.length + 1);
|
|
39
|
-
return relative ? `${normalizedContainer}/${relative}`.replace(/\/+/g, '/') : normalizedContainer;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function applyContainerPathSelection(baseHostPath, baseContainerPath, currentContainerPath, selectedHostPath) {
|
|
43
|
-
return buildContainerPathFromHostSelection(
|
|
44
|
-
baseHostPath,
|
|
45
|
-
resolveContainerPickerBase(baseContainerPath, currentContainerPath),
|
|
46
|
-
selectedHostPath
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
normalizeSlashPath,
|
|
52
|
-
isChildPath,
|
|
53
|
-
resolveContainerPickerBase,
|
|
54
|
-
buildContainerPathFromHostSelection,
|
|
55
|
-
applyContainerPathSelection
|
|
56
|
-
};
|
|
57
|
-
}));
|