simple implementation for preview testing
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
////if ('serviceWorker' in navigator)
|
||||
////{
|
||||
//// window.addEventListener('load', () =>
|
||||
//// {
|
||||
//// navigator.serviceWorker.register('sw.js').then(
|
||||
//// registration =>
|
||||
//// {
|
||||
//// console.log('Service worker registered with scope: ', registration.scope);
|
||||
//// },
|
||||
//// err =>
|
||||
//// {
|
||||
//// console.log('ServiceWorker registration failed: ', err);
|
||||
//// });
|
||||
//// });
|
||||
////}
|
||||
|
||||
console.info('hi from worker');
|
||||
|
||||
self.addEventListener('fetch', event =>
|
||||
{
|
||||
console.info('fetch', event);
|
||||
event.request.headers.append("zero-preview", "true");
|
||||
event.respondWith(
|
||||
fetch(event.request)
|
||||
// intercept requests by handling event.request here
|
||||
);
|
||||
});
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
created()
|
||||
{
|
||||
this.src = 'http://localhost:2310' + this.$route.query.path + '?preview=true';
|
||||
this.src = 'http://localhost:2310' + this.$route.query.path + '?zero_preview=true';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -38,6 +38,11 @@
|
||||
height: 100%;
|
||||
position: relative;
|
||||
background: var(--color-bg);
|
||||
|
||||
.-text
|
||||
{
|
||||
color: var(--color-text);
|
||||
}
|
||||
}
|
||||
|
||||
iframe.app-preview-frame
|
||||
|
||||
@@ -80,6 +80,7 @@ let config = defineConfig({
|
||||
alias: {
|
||||
vue: path.resolve(__dirname, 'node_modules/@vue/compat'),
|
||||
zero: path.resolve(__dirname, 'app'),
|
||||
zeroworkers: path.resolve(__dirname, 'app/modules/preview'),
|
||||
...pluginAliases,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -40,6 +40,9 @@ public class ZeroContext : IZeroContext
|
||||
/// <inheritdoc />
|
||||
public ZeroContextScope Scope { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsPreview { get; private set; }
|
||||
|
||||
|
||||
protected IApplicationResolver AppResolver { get; private set; }
|
||||
|
||||
@@ -93,6 +96,9 @@ public class ZeroContext : IZeroContext
|
||||
|
||||
_resolved = true;
|
||||
|
||||
// check whether the current request is a preview request
|
||||
IsPreview = context.Request.Query.ContainsKey("zero_preview");
|
||||
|
||||
// check if the current request is a backoffice request
|
||||
IsBackofficeRequest = context.IsBackofficeRequest(Options.ZeroPath);
|
||||
|
||||
@@ -245,6 +251,11 @@ public interface IZeroContext
|
||||
/// </summary>
|
||||
bool IsLoggedIntoBackoffice { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the current request is a preview request
|
||||
/// </summary>
|
||||
bool IsPreview { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Global zero options
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user