mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: bug fix
This commit is contained in:
1 parent
273a0563b3
commit
60820a3e5f
7 files changed
+15
-12
No files matched your search
+2
-2
@@ -41,14 +41,14 @@
|
|||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"esbuild": "0.15.2",
|
"esbuild": "0.15.2",
|
||||||
"eslint": "^8.27.0",
|
"eslint": "^8.28.0",
|
||||||
"eslint-config-airbnb": "^19.0.4",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
"eslint-config-airbnb-typescript": "^17.0.0",
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
||||||
"eslint-import-resolver-typescript": "^3.5.2",
|
"eslint-import-resolver-typescript": "^3.5.2",
|
||||||
"eslint-import-resolver-webpack": "^0.13.2",
|
"eslint-import-resolver-webpack": "^0.13.2",
|
||||||
"eslint-plugin-import": "2.26.0",
|
"eslint-plugin-import": "2.26.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.6.1",
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||||
"eslint-plugin-react": "^7.31.10",
|
"eslint-plugin-react": "^7.31.11",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-simple-import-sort": "8.0.0",
|
"eslint-plugin-simple-import-sort": "8.0.0",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"@aws-sdk/middleware-endpoint": "^3.212.0",
|
"@aws-sdk/middleware-endpoint": "^3.212.0",
|
||||||
"@aws-sdk/s3-presigned-post": "^3.212.0",
|
"@aws-sdk/s3-presigned-post": "^3.212.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.212.0",
|
"@aws-sdk/s3-request-presigner": "^3.212.0",
|
||||||
"@graphql-tools/schema": "^8.5.1",
|
"@graphql-tools/schema": "^9.0.10",
|
||||||
"@hydrooj/utils": "workspace:*",
|
"@hydrooj/utils": "workspace:*",
|
||||||
"adm-zip": "0.5.5",
|
"adm-zip": "0.5.5",
|
||||||
"cac": "^6.7.14",
|
"cac": "^6.7.14",
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"emojis-list": "2.1.0",
|
"emojis-list": "2.1.0",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"graphql": "^16.6.0",
|
"graphql": "^16.6.0",
|
||||||
"graphql-scalars": "1.18.0",
|
"graphql-scalars": "1.20.1",
|
||||||
"isbinaryfile": "^5.0.0",
|
"isbinaryfile": "^5.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"koa": "^2.13.4",
|
"koa": "^2.13.4",
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ class RecordDetailConnectionHandler extends ConnectionHandler {
|
|||||||
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.throttleSend = throttle(this.send, 1000);
|
this.throttleSend = throttle(this.sendUpdate, 1000);
|
||||||
this.rid = rid.toString();
|
this.rid = rid.toString();
|
||||||
this.cleanup = bus.on('record/change', this.onRecordChange.bind(this));
|
this.cleanup = bus.on('record/change', this.onRecordChange.bind(this));
|
||||||
this.onRecordChange(rdoc);
|
this.onRecordChange(rdoc);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const diagnosticsOptions: monaco.languages.typescript.DiagnosticsOptions = {
|
|||||||
noSyntaxValidation: false,
|
noSyntaxValidation: false,
|
||||||
noSuggestionDiagnostics: true,
|
noSuggestionDiagnostics: true,
|
||||||
};
|
};
|
||||||
const compilerOptions = {
|
const compilerOptions: monaco.languages.typescript.CompilerOptions = {
|
||||||
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
||||||
module: monaco.languages.typescript.ModuleKind.ESNext,
|
module: monaco.languages.typescript.ModuleKind.ESNext,
|
||||||
allowNonTsExtensions: true,
|
allowNonTsExtensions: true,
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export async function previewFile(ev, type = '') {
|
|||||||
if (ext === 'pdf') return previewPDF(`${link}${link.includes('?') ? '&' : '?'}noDisposition=1`);
|
if (ext === 'pdf') return previewPDF(`${link}${link.includes('?') ? '&' : '?'}noDisposition=1`);
|
||||||
Notification.info(i18n('Loading file...'));
|
Notification.info(i18n('Loading file...'));
|
||||||
try {
|
try {
|
||||||
const { url } = await request.get(link);
|
const { url } = await request.get(link, {}, { headers: { 'Do-Not-Cache': 'on' } });
|
||||||
if (/^(doc|xls|ppt)x?$/.test(ext)) return previewOffice(link, url);
|
if (/^(doc|xls|ppt)x?$/.test(ext)) return previewOffice(link, url);
|
||||||
content = await request.get(url, undefined, { dataType: 'text' });
|
content = await request.get(url, undefined, { dataType: 'text' });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ self.addEventListener('notificationclick', (event) => {
|
|||||||
const PRECACHE = `precache-${process.env.VERSION}`;
|
const PRECACHE = `precache-${process.env.VERSION}`;
|
||||||
const DO_NOT_CACHE = ['vditor', '.worker.js', 'fonts', 'i.monaco'];
|
const DO_NOT_CACHE = ['vditor', '.worker.js', 'fonts', 'i.monaco'];
|
||||||
|
|
||||||
function shouldCache(name: string) {
|
function shouldCache(name: string, request?: Request) {
|
||||||
if (!name.split('/').pop()) return false;
|
if (!name.split('/').pop()) return false;
|
||||||
if (!name.split('/').pop().includes('.')) return false;
|
if (!name.split('/').pop().includes('.')) return false;
|
||||||
|
// For files download, a response is formatted as string
|
||||||
|
if (request && request.headers.get('Do-Not-Cache')) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function shouldPreCache(name: string) {
|
function shouldPreCache(name: string) {
|
||||||
@@ -86,21 +88,22 @@ self.addEventListener('activate', (event) => {
|
|||||||
|
|
||||||
self.addEventListener('fetch', (event: FetchEvent) => {
|
self.addEventListener('fetch', (event: FetchEvent) => {
|
||||||
if (!['get', 'head'].includes(event.request.method.toLowerCase())) return;
|
if (!['get', 'head'].includes(event.request.method.toLowerCase())) return;
|
||||||
if (!shouldCache(event.request.url) && config?.base && config?.targets?.length) {
|
if (!shouldCache(event.request.url, event.request) && config?.base && config?.targets?.length) {
|
||||||
if (new URL(event.request.url).origin !== location.origin) return;
|
if (new URL(event.request.url).origin !== location.origin) return;
|
||||||
event.respondWith(get(event.request.url));
|
event.respondWith(get(event.request.url));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Only handle whitelisted origins;
|
// Only handle whitelisted origins;
|
||||||
if (!config?.hosts?.some((i) => event.request.url.startsWith(i))) return;
|
if (!config?.hosts?.some((i) => event.request.url.startsWith(i))) return;
|
||||||
if (process.env.NODE_ENV !== 'production' || !shouldCache(event.request.url)) return;
|
if (!shouldCache(event.request.url, event.request)) return;
|
||||||
|
const Accept = event.request.headers.get('Accept');
|
||||||
event.respondWith((async () => {
|
event.respondWith((async () => {
|
||||||
const cachedResponse = await caches.match(event.request.url);
|
const cachedResponse = await caches.match(event.request.url);
|
||||||
if (cachedResponse) return cachedResponse;
|
if (cachedResponse) return cachedResponse;
|
||||||
console.log(`Caching ${event.request.url}`);
|
console.log(`Caching ${event.request.url}`);
|
||||||
const [cache, response] = await Promise.all([
|
const [cache, response] = await Promise.all([
|
||||||
caches.open(PRECACHE),
|
caches.open(PRECACHE),
|
||||||
fetch(event.request.url), // Fetch from url to prevent opaque response
|
fetch(event.request.url, { headers: { Accept } }), // Fetch from url to prevent opaque response
|
||||||
]);
|
]);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
cache.put(event.request.url, response.clone());
|
cache.put(event.request.url, response.clone());
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"mongodb": "^3.7.3",
|
"mongodb": "^3.7.3",
|
||||||
"reggol": "^1.3.1",
|
"reggol": "^1.3.1",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"systeminformation": "^5.12.15"
|
"systeminformation": "^5.13.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
|
|||||||
Reference in new issue
Block a user