cache assemblies in IndexedDB on WebAssembly
This commit is contained in:
@ -1,6 +1,12 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Oqtane.UI
|
||||
{
|
||||
@ -307,5 +313,76 @@ namespace Oqtane.UI
|
||||
return new ValueTask<int>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public Task SetIndexedDBItem(string key, object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
_jsRuntime.InvokeVoidAsync(
|
||||
"Oqtane.Interop.setIndexedDBItem",
|
||||
key, value);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<T> GetIndexedDBItem<T>(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _jsRuntime.InvokeAsync<T>(
|
||||
"Oqtane.Interop.getIndexedDBItem",
|
||||
key);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetIndexedDBKeys()
|
||||
{
|
||||
return await GetIndexedDBKeys("");
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetIndexedDBKeys(string contains)
|
||||
{
|
||||
try
|
||||
{
|
||||
var items = await _jsRuntime.InvokeAsync<JsonDocument>(
|
||||
"Oqtane.Interop.getIndexedDBKeys");
|
||||
if (!string.IsNullOrEmpty(contains))
|
||||
{
|
||||
return items.Deserialize<List<string>>()
|
||||
.Where(item => item.Contains(contains)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return items.Deserialize<List<string>>();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
public Task RemoveIndexedDBItem(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
_jsRuntime.InvokeVoidAsync(
|
||||
"Oqtane.Interop.removeIndexedDBItem",
|
||||
key);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user