mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix file create
This commit is contained in:
1 parent
70d836da59
commit
25ab36b2e6
1 file changed
+3
-3
@@ -105,7 +105,7 @@ async function previewOffice(link, src) {
|
|||||||
if (action === 'download') window.open(link);
|
if (action === 'download') window.open(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function previewFile(ev, type = '') {
|
export async function previewFile(ev?, type = '') {
|
||||||
if (ev?.metaKey || ev?.ctrlKey || ev?.shiftKey) return null;
|
if (ev?.metaKey || ev?.ctrlKey || ev?.shiftKey) return null;
|
||||||
if (ev) ev.preventDefault();
|
if (ev) ev.preventDefault();
|
||||||
const filename = ev
|
const filename = ev
|
||||||
@@ -146,8 +146,8 @@ export async function previewFile(ev, type = '') {
|
|||||||
const file = new File([val], filename, { type: 'text/plain' });
|
const file = new File([val], filename, { type: 'text/plain' });
|
||||||
const endpoint = new URL(!window.location.href.endsWith('/files')
|
const endpoint = new URL(!window.location.href.endsWith('/files')
|
||||||
? `${window.location.href.substring(0, window.location.href.lastIndexOf('/'))}/files` : '', window.location.href);
|
? `${window.location.href.substring(0, window.location.href.lastIndexOf('/'))}/files` : '', window.location.href);
|
||||||
const sidebarType = $(ev.currentTarget).closest('[data-fragment-id]').data('type');
|
const sidebarType = type || $(ev.currentTarget).closest('[data-fragment-id]').data('type');
|
||||||
const sidebar = $(ev.currentTarget).closest('[data-fragment-id]').data('sidebar') !== undefined;
|
const sidebar = ev && $(ev.currentTarget).closest('[data-fragment-id]').data('sidebar') !== undefined;
|
||||||
await uploadFiles(endpoint.toString(), [file], {
|
await uploadFiles(endpoint.toString(), [file], {
|
||||||
type: sidebarType || type,
|
type: sidebarType || type,
|
||||||
sidebar,
|
sidebar,
|
||||||
|
|||||||
Reference in new issue
Block a user