Skip to content

Commit

Permalink
Merge pull request #192 from caorushizi/dev-webview
Browse files Browse the repository at this point in the history
feat(settings): ✨  添加自动更新选项
  • Loading branch information
caorushizi authored Jun 22, 2024
2 parents 7a2f9fe + 77158aa commit cb2deb5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/main/src/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ declare interface AppStore {
machineId: string;
// 下载代理设置
downloadProxySwitch: boolean;
// 自动更新
autoUpgrade: boolean;
}

declare interface BrowserStore {
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/vendor/ElectronStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class StoreService extends Store<AppStore> implements Vendor {
privacy: false,
machineId: "",
downloadProxySwitch: false,
autoUpgrade: true,
},
});
}
Expand Down
9 changes: 8 additions & 1 deletion packages/main/src/vendor/ElectronUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ import { TYPES } from "../types.ts";
import isDev from "electron-is-dev";
import ElectronLogger from "./ElectronLogger.ts";
import { Vendor } from "../core/vendor.ts";
import ElectronStore from "electron-store";

@injectable()
export default class UpdateService implements Vendor {
constructor(
@inject(TYPES.ElectronLogger) private readonly logger: ElectronLogger,
@inject(TYPES.ElectronLogger)
private readonly logger: ElectronLogger,
@inject(TYPES.ElectronStore)
private readonly store: ElectronStore
) {}

async init() {
if (isDev) return;

const { autoUpgrade } = this.store.store;
if (!autoUpgrade) return;

try {
autoUpdater.disableWebInstaller = true;
autoUpdater.logger = this.logger.logger;
Expand Down
4 changes: 4 additions & 0 deletions packages/renderer/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ Referer: http://www.example.com`,
close: "Close",
exportLog: "Export Log",
showTerminal: "Show Console",
autoUpgrade: "Auto Upgrade",
autoUpgradeTooltip: "Take effect next time you start",
consoleOutput: "Console",
downloadNow: "Download",
addToDownloadList: "Confirm",
Expand Down Expand Up @@ -251,6 +253,8 @@ Referer: http://www.example.com`,
close: "关闭",
exportLog: "导出日志",
showTerminal: "显示控制台",
autoUpgrade: "自动更新",
autoUpgradeTooltip: "下次启动时生效",
consoleOutput: "控制台",
downloadNow: "下载",
addToDownloadList: "确认",
Expand Down
7 changes: 7 additions & 0 deletions packages/renderer/src/pages/SettingPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ const SettingPage: React.FC = () => {
<ProFormSwitch label={t("openInNewWindow")} name="openInNewWindow" />
<ProFormSwitch label={t("downloadPrompt")} name="promptTone" />
<ProFormSwitch label={t("showTerminal")} name="showTerminal" />
<ProFormSwitch
label={renderTooltipLabel(
t("autoUpgrade"),
t("autoUpgradeTooltip")
)}
name="autoUpgrade"
/>
{/* <ProFormSwitch label={t("privacy")} name="privacy" /> */}
</ProFormGroup>
<ProFormGroup title={t("browserSetting")} direction={"vertical"}>
Expand Down

0 comments on commit cb2deb5

Please sign in to comment.