mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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-spawn": "^7.0.3",
|
||||
"esbuild": "0.15.2",
|
||||
"eslint": "^8.27.0",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-typescript": "^17.0.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.2",
|
||||
"eslint-import-resolver-webpack": "^0.13.2",
|
||||
"eslint-plugin-import": "2.26.0",
|
||||
"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-simple-import-sort": "8.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"@aws-sdk/middleware-endpoint": "^3.212.0",
|
||||
"@aws-sdk/s3-presigned-post": "^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:*",
|
||||
"adm-zip": "0.5.5",
|
||||
"cac": "^6.7.14",
|
||||
@@ -27,7 +27,7 @@
|
||||
"emojis-list": "2.1.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"graphql": "^16.6.0",
|
||||
"graphql-scalars": "1.18.0",
|
||||
"graphql-scalars": "1.20.1",
|
||||
"isbinaryfile": "^5.0.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"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);
|
||||
}
|
||||
|
||||
this.throttleSend = throttle(this.send, 1000);
|
||||
this.throttleSend = throttle(this.sendUpdate, 1000);
|
||||
this.rid = rid.toString();
|
||||
this.cleanup = bus.on('record/change', this.onRecordChange.bind(this));
|
||||
this.onRecordChange(rdoc);
|
||||
|
||||
@@ -7,7 +7,7 @@ const diagnosticsOptions: monaco.languages.typescript.DiagnosticsOptions = {
|
||||
noSyntaxValidation: false,
|
||||
noSuggestionDiagnostics: true,
|
||||
};
|
||||
const compilerOptions = {
|
||||
const compilerOptions: monaco.languages.typescript.CompilerOptions = {
|
||||
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
||||
module: monaco.languages.typescript.ModuleKind.ESNext,
|
||||
allowNonTsExtensions: true,
|
||||
|
||||
@@ -135,7 +135,7 @@ export async function previewFile(ev, type = '') {
|
||||
if (ext === 'pdf') return previewPDF(`${link}${link.includes('?') ? '&' : '?'}noDisposition=1`);
|
||||
Notification.info(i18n('Loading file...'));
|
||||
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);
|
||||
content = await request.get(url, undefined, { dataType: 'text' });
|
||||
} catch (e) {
|
||||
|
||||
@@ -21,9 +21,11 @@ self.addEventListener('notificationclick', (event) => {
|
||||
const PRECACHE = `precache-${process.env.VERSION}`;
|
||||
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().includes('.')) return false;
|
||||
// For files download, a response is formatted as string
|
||||
if (request && request.headers.get('Do-Not-Cache')) return false;
|
||||
return true;
|
||||
}
|
||||
function shouldPreCache(name: string) {
|
||||
@@ -86,21 +88,22 @@ self.addEventListener('activate', (event) => {
|
||||
|
||||
self.addEventListener('fetch', (event: FetchEvent) => {
|
||||
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;
|
||||
event.respondWith(get(event.request.url));
|
||||
return;
|
||||
}
|
||||
// Only handle whitelisted origins;
|
||||
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 () => {
|
||||
const cachedResponse = await caches.match(event.request.url);
|
||||
if (cachedResponse) return cachedResponse;
|
||||
console.log(`Caching ${event.request.url}`);
|
||||
const [cache, response] = await Promise.all([
|
||||
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) {
|
||||
cache.put(event.request.url, response.clone());
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"mongodb": "^3.7.3",
|
||||
"reggol": "^1.3.1",
|
||||
"source-map-support": "^0.5.21",
|
||||
"systeminformation": "^5.12.15"
|
||||
"systeminformation": "^5.13.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
|
||||
Reference in new issue
Block a user