mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
ui: fix resource cache in dev mode
This commit is contained in:
1 parent
d069fe127b
commit
d20bf5b1e7
3 files changed
+3
-3
No files matched your search
@@ -133,7 +133,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, {}, { headers: { 'Do-Not-Cache': 'on' } });
|
||||
const { url } = await request.get(link, {}, { headers: { Pragma: 'no-cache' } });
|
||||
if (/^(doc|xls|ppt)x?$/.test(ext)) return previewOffice(link, url);
|
||||
content = await request.get(url, undefined, { dataType: 'text' });
|
||||
} catch (e) {
|
||||
|
||||
@@ -26,7 +26,7 @@ function shouldCache(name: string, request?: Request) {
|
||||
if (!name.split('/').pop().includes('.')) return false;
|
||||
if (process.env.NODE_ENV !== 'production' && (name.includes('.hot-update.') || name.includes('?version='))) return false;
|
||||
// For files download, a response is formatted as string
|
||||
if (request && request.headers.get('Do-Not-Cache')) return false;
|
||||
if (request && request.headers.get('Pragma') === 'no-cache') return false;
|
||||
return true;
|
||||
}
|
||||
function shouldPreCache(name: string) {
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<script type="text/javascript" src="{{ UiContext.cdn_prefix }}l/{{ _('__id') }}"></script>
|
||||
<script src="{{ UiContext.cdn_prefix }}default.theme.js?version={{ global.Hydro.version['ui-default'] }}"></script>
|
||||
{% if process.env.DEV %}
|
||||
<script type="text/javascript" src="/hydro.js"></script>
|
||||
<script type="text/javascript" src="/hydro.js?version={{ global.Hydro.version['ui-default'] }}"></script>
|
||||
{% else %}
|
||||
<script type="text/javascript" src="{{ UiContext.cdn_prefix }}hydro-{{ global.Hydro.version['ui-default'] }}.js"></script>
|
||||
{% endif %}
|
||||
|
||||
Reference in new issue
Block a user