mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: problem_files: allow image preview
This commit is contained in:
1 parent
abec5fd3ec
commit
7151f71417
2 files changed
+16
-4
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.31.5",
|
"version": "4.31.6",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { NamedPage } from 'vj/misc/Page';
|
import { NamedPage } from 'vj/misc/Page';
|
||||||
import Notification from 'vj/components/notification';
|
import Notification from 'vj/components/notification';
|
||||||
import { ConfirmDialog, ActionDialog, Dialog } from 'vj/components/dialog/index';
|
import {
|
||||||
|
ConfirmDialog, ActionDialog, InfoDialog, Dialog,
|
||||||
|
} from 'vj/components/dialog/index';
|
||||||
import download from 'vj/components/zipDownloader';
|
import download from 'vj/components/zipDownloader';
|
||||||
import createHint from 'vj/components/hint';
|
import createHint from 'vj/components/hint';
|
||||||
import request from 'vj/utils/request';
|
import request from 'vj/utils/request';
|
||||||
@@ -217,8 +219,18 @@ const page = new NamedPage('problem_files', () => {
|
|||||||
if (ev) {
|
if (ev) {
|
||||||
const link = $(ev.currentTarget).find('a').attr('href');
|
const link = $(ev.currentTarget).find('a').attr('href');
|
||||||
if (!link) return;
|
if (!link) return;
|
||||||
if (filesize > 8 * 1024 * 1024) {
|
const ext = filename.split('.').pop();
|
||||||
Notification.error(i18n('file too large'));
|
if (['png', 'jpeg', 'jpg', 'gif', 'webp', 'bmp'].includes(ext)) {
|
||||||
|
await new InfoDialog({
|
||||||
|
$body: tpl`<div class="typo"><img src="${link}"></img></div>`,
|
||||||
|
}).open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (['zip', 'rar', '7z'].includes(ext) || filesize > 8 * 1024 * 1024) {
|
||||||
|
const action = await new ActionDialog({
|
||||||
|
$body: tpl.typoMsg(i18n('Cannot preview this file. Download now?')),
|
||||||
|
}).open();
|
||||||
|
if (action === 'ok') window.open(link);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Notification.info(i18n('Loading file...'));
|
Notification.info(i18n('Loading file...'));
|
||||||
|
|||||||
Reference in new issue
Block a user