oldj 2 роки тому
батько
коміт
6f2e60015f

+ 1 - 1
README.md

@@ -6,7 +6,7 @@
 Homepage: [https://switchhosts.vercel.app](https://switchhosts.vercel.app)
 
 SwitchHosts is an App for managing hosts file, it is based on [Electron](http://electron.atom.io/)
-, [React](https://facebook.github.io/react/), [UmiJS](https://umijs.org/)
+, [React](https://facebook.github.io/react/), [Jotai](https://jotai.org/)
 , [Chakra UI](https://chakra-ui.com/), [CodeMirror](http://codemirror.net/), etc.
 
 ## Screenshot

+ 1 - 1
README.zh_hans.md

@@ -6,7 +6,7 @@
 项目主页:[https://switchhosts.vercel.app](https://switchhosts.vercel.app)
 
 SwitchHosts 是一个管理 hosts 文件的应用,基于 [Electron](http://electron.atom.io/)
-、[React](https://facebook.github.io/react/)、[UmiJS](https://umijs.org/)
+、[React](https://facebook.github.io/react/)、[Jotai](https://jotai.org/)
 、[Chakra UI](https://chakra-ui.com/)、[CodeMirror](http://codemirror.net/) 等技术开发。
 
 ## 截图

+ 1 - 1
README.zh_hant.md

@@ -6,7 +6,7 @@
 項目主頁:[https://switchhosts.vercel.app](https://switchhosts.vercel.app)
 
 SwitchHosts 是一個管理 hosts 檔案的應用程式,基於 [Electron](http://electron.atom.io/)
-、[React](https://facebook.github.io/react/)、[UmiJS](https://umijs.org/)
+、[React](https://facebook.github.io/react/)、[Jotai](https://jotai.org/)
 、[Chakra UI](https://chakra-ui.com/)、[CodeMirror](http://codemirror.net/) 等技術開發。
 
 ## 螢幕截圖

+ 1 - 1
app/package.json

@@ -1,7 +1,7 @@
 {
   "name": "switchhosts",
   "productName": "SwitchHosts",
-  "version": "4.2.0.6098",
+  "version": "4.2.0.6099",
   "description": "Switch hosts quickly!",
   "main": "./main.js",
   "author": {

+ 8 - 1
src/common/types.d.ts

@@ -5,12 +5,19 @@
  */
 
 import { HostsType } from '@common/data'
-import { MenuItemConstructorOptions } from 'electron'
+import { MenuItemConstructorOptions, WebContents } from 'electron'
 import { default as lang } from './i18n/languages/en'
+import * as actions from '@main/actions'
 
 export type LanguageDict = typeof lang
 export type LanguageKey = keyof LanguageDict
 
+export interface IActionFunc {
+  sender: WebContents
+}
+
+export type Actions = typeof actions & IActionFunc
+
 export interface IMenuItemOption extends MenuItemConstructorOptions {
   // 参见:https://www.electronjs.org/docs/api/menu-item
 

+ 1 - 1
src/main/actions/cmd/changeDataDir.ts

@@ -7,7 +7,7 @@ import { app, BrowserWindow, dialog, OpenDialogOptions, OpenDialogReturnValue }
 import { localdb } from '@main/data'
 import getDataFolder, { getDefaultDataDir } from '@main/libs/getDataDir'
 import getI18N from '@main/core/getI18N'
-import { IActionFunc } from '@main/types'
+import { IActionFunc } from '@common/types'
 
 export default async function (
   this: IActionFunc,

+ 3 - 1
src/main/actions/trashcan/deleteItem.ts

@@ -10,7 +10,9 @@ import { flatten } from '@common/hostsFn'
 export default async (id: string): Promise<boolean> => {
   // Permanently delete the specified item with id.
 
-  let trashcan_item: ITrashcanListObject = await swhdb.list.trashcan.find((i) => i.data.id === id)
+  let trashcan_item: ITrashcanListObject | undefined = await swhdb.list.trashcan.find(
+    (i) => i.data.id === id,
+  )
 
   if (!trashcan_item) {
     console.log(`can't find trashcan_item with id #${id}.`)

+ 3 - 1
src/main/actions/trashcan/restoreItem.ts

@@ -9,7 +9,9 @@ import { getNodeById } from '@common/tree'
 import { IHostsListObject, ITrashcanListObject } from '@common/data'
 
 export default async (id: string): Promise<boolean> => {
-  let trashcan_item: ITrashcanListObject = await swhdb.list.trashcan.find((i) => i.data.id === id)
+  let trashcan_item: ITrashcanListObject | undefined = await swhdb.list.trashcan.find(
+    (i) => i.data.id === id,
+  )
 
   if (!trashcan_item) {
     console.log(`can't find trashcan_item with id #${id}.`)

+ 3 - 5
src/main/core/message.ts

@@ -5,9 +5,10 @@
  */
 
 import * as actions from '@main/actions'
-import { ActionData, IActionFunc } from '@main/types'
+import { ActionData } from '@main/types'
 import { ipcMain } from 'electron'
 import { EventEmitter } from 'events'
+import { IActionFunc } from '@common/types'
 
 const ee = new EventEmitter()
 const registered_clients: { [key: string]: any } = {}
@@ -32,10 +33,7 @@ ipcMain.on('x_unreg', (e, d) => {
     delete registered_clients[name]
   } else {
     for (let k in registered_clients) {
-      if (
-        registered_clients.hasOwnProperty(k) &&
-        registered_clients[k] === e.sender
-      ) {
+      if (registered_clients.hasOwnProperty(k) && registered_clients[k] === e.sender) {
         delete registered_clients[k]
         break
       }

+ 1 - 1
src/main/preload.ts

@@ -4,7 +4,7 @@
  * @homepage: https://oldj.net
  */
 
-import { Actions } from '@main/types'
+import { Actions } from '@common/types'
 import { IPopupMenuOption } from '@common/types'
 import { contextBridge, ipcRenderer } from 'electron'
 import { EventEmitter } from 'events'

+ 3 - 9
src/main/types.d.ts

@@ -7,13 +7,11 @@
 import Tracer from '@main/libs/tracer'
 import { LocaleName } from '@common/i18n'
 import SwhDb from 'potdb'
-import { BrowserWindow, WebContents } from 'electron'
-import * as actions from './actions'
-
-export type Actions = typeof actions
+import { BrowserWindow } from 'electron'
+import * as actions from '@main/actions'
 
 export interface ActionData {
-  action: keyof Actions
+  action: keyof typeof actions
   data?: any
   callback: string
 }
@@ -22,10 +20,6 @@ export interface IHostsWriteOptions {
   sudo_pswd?: string
 }
 
-export interface IActionFunc {
-  sender: WebContents
-}
-
 declare global {
   var data_dir: string | undefined
   var swhdb: SwhDb

+ 1 - 1
src/renderer/components/Pref/Advanced.tsx

@@ -1,5 +1,5 @@
 /**
- * General
+ * Advanced.tsx
  * @author: oldj
  * @homepage: https://oldj.net
  */

+ 1 - 1
src/renderer/components/Pref/Commands.tsx

@@ -1,5 +1,5 @@
 /**
- * General
+ * Commands.tsx
  * @author: oldj
  * @homepage: https://oldj.net
  */

+ 2 - 2
src/renderer/components/Pref/CommandsHistory.tsx

@@ -75,7 +75,7 @@ const CommandsHistory = (props: Props) => {
           >
             <AlertIcon />
             <Box flex="1">
-              <AlertTitle d="block">
+              <AlertTitle>
                 <HStack>
                   <span>#{item._id}</span>
                   <span style={{ fontWeight: 'normal' }}>
@@ -91,7 +91,7 @@ const CommandsHistory = (props: Props) => {
                   />
                 </HStack>
               </AlertTitle>
-              <AlertDescription d="block" spacing={3}>
+              <AlertDescription>
                 {item.stdout ? (
                   <>
                     <Box>

+ 1 - 1
src/renderer/components/Pref/Proxy.tsx

@@ -1,5 +1,5 @@
 /**
- * General
+ * Proxy.tsx
  * @author: oldj
  * @homepage: https://oldj.net
  */

+ 1 - 1
src/renderer/core/agent.ts

@@ -4,7 +4,7 @@
  * @homepage: https://oldj.net
  */
 
-import { Actions } from '@main/types'
+import { Actions } from '@common/types'
 
 export const actions: Actions = new Proxy(
   {},

+ 1 - 1
src/version.json

@@ -1 +1 @@
-[4, 2, 0, 6098]
+[4, 2, 0, 6099]