default white bg for websites with no bg (#355)

This commit is contained in:
Red J Adaya 2024-09-11 03:16:34 +08:00 committed by GitHub
parent 62eb04090a
commit a9486852f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@ import clsx from "clsx";
import { WebviewTag } from "electron"; import { WebviewTag } from "electron";
import * as jotai from "jotai"; import * as jotai from "jotai";
import React, { memo, useEffect, useState } from "react"; import React, { memo, useEffect, useState } from "react";
import { debounce } from "throttle-debounce";
import "./webview.less"; import "./webview.less";
export class WebViewModel implements ViewModel { export class WebViewModel implements ViewModel {
@ -385,10 +386,14 @@ const WebView = memo(({ model }: WebViewProps) => {
const startLoadingHandler = () => { const startLoadingHandler = () => {
model.setRefreshIcon("xmark-large"); model.setRefreshIcon("xmark-large");
model.setIsLoading(true); model.setIsLoading(true);
webview.style.backgroundColor = "transparent";
}; };
const stopLoadingHandler = () => { const stopLoadingHandler = () => {
model.setRefreshIcon("rotate-right"); model.setRefreshIcon("rotate-right");
model.setIsLoading(false); model.setIsLoading(false);
debounce(1000, () => {
webview.style.backgroundColor = "white";
})();
}; };
const failLoadHandler = (e: any) => { const failLoadHandler = (e: any) => {
if (e.errorCode === -3) { if (e.errorCode === -3) {