internal JSObjectReference(JSRuntime jsRuntime, long id) { _jsRuntime = jsRuntime; Id = id; }
public ValueTask Reload(bool forceGet = false) => JSRuntime.InvokeVoidAsync("location.reload", forceGet);
public ValueTask Print() => JSRuntime.InvokeVoidAsync("print");
public ValueTask Close() => JSRuntime.InvokeVoidAsync("close");
public ValueTask Alert(string message) => JSRuntime.InvokeVoidAsync("alert", message);
public ValueTask <bool> Confirm(string message) => JSRuntime.InvokeAsync <bool>("confirm", message);
/// <summary> /// 通过JS互操作直接写入document.cookie属性 /// </summary> /// <param name="cookie">要写入的Cookie文本</param> /// <returns></returns> private ValueTask SetCookie(string cookie) => JSRuntime.SetProperty("document.cookie", cookie);
/// <summary> /// 通过JS互操作直接读取document.cookie属性 /// </summary> /// <returns></returns> private ValueTask <string> GetCookie() => JSRuntime.GetProperty <string>("document.cookie");
public async Task <(bool Exist, string?Value)> TryGetValueAsync(string key) { var value = await JSRuntime.InvokeAsync <string?>("localStorage.getItem", key); return(value is { }, value);