Skip to content

Commit

Permalink
chore: update dependencies, migrate from NextUI to HeroUI
Browse files Browse the repository at this point in the history
  • Loading branch information
pompurin404 committed Feb 3, 2025
1 parent 8210b47 commit 0c1d259
Show file tree
Hide file tree
Showing 73 changed files with 1,122 additions and 1,078 deletions.
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
shamefully-hoist=true
virtual-store-dir-max-length=80
public-hoist-pattern[]=*@nextui-org/*
public-hoist-pattern[]=*@heroui/*
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"checksum": "node scripts/checksum.mjs",
"telegram": "node scripts/telegram.mjs",
"artifact": "node scripts/artifact.mjs",
"migrate-ui": "tsx scripts/migrate-to-heroui.ts",
"dev": "electron-vite dev",
"postinstall": "electron-builder install-app-deps",
"build:win": "electron-vite build && electron-builder --publish never --win",
Expand All @@ -25,9 +26,9 @@
"dependencies": {
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
"@heroui/react": "^2.6.14",
"@mihomo-party/sysproxy": "^2.0.7",
"@mihomo-party/sysproxy-darwin-arm64": "^2.0.7",
"@nextui-org/react": "2.6.10",
"@types/crypto-js": "^4.2.2",
"adm-zip": "^0.5.16",
"axios": "^1.7.7",
Expand All @@ -51,15 +52,15 @@
"@electron-toolkit/tsconfig": "^1.0.1",
"@types/adm-zip": "^0.5.6",
"@types/express": "^5.0.0",
"@types/node": "^22.9.0",
"@types/node": "^22.13.0",
"@types/pubsub-js": "^1.8.6",
"@types/react": "^19.0.4",
"@types/react-dom": "^19.0.2",
"@types/ws": "^8.5.13",
"@vitejs/plugin-react": "^4.3.3",
"autoprefixer": "^10.4.20",
"cron-validator": "^1.3.1",
"driver.js": "^1.3.1",
"driver.js": "^1.3.5",
"electron": "^33.3.2",
"electron-builder": "25.0.4",
"electron-vite": "^2.3.0",
Expand All @@ -82,7 +83,7 @@
"react-icons": "^5.3.0",
"react-markdown": "^9.0.1",
"react-monaco-editor": "^0.56.2",
"react-router-dom": "^7.1.1",
"react-router-dom": "^7.1.5",
"react-virtuoso": "^4.12.0",
"recharts": "^2.13.3",
"swr": "^2.2.5",
Expand Down
1,953 changes: 954 additions & 999 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions scripts/migrate-to-heroui.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const srcDir = path.join(__dirname, '..', 'src')

function replaceInFile(filePath: string): void {
let content = fs.readFileSync(filePath, 'utf8')

// 替换导入语句
content = content.replace(
/@nextui-org\/react/g,
'@heroui/react'
)

// 替换 NextUIProvider
content = content.replace(
/NextUIProvider/g,
'HeroUIProvider'
)

fs.writeFileSync(filePath, content)
}

function walkDir(dir: string): void {
const files = fs.readdirSync(dir)

files.forEach(file => {
const filePath = path.join(dir, file)
const stat = fs.statSync(filePath)

if (stat.isDirectory()) {
walkDir(filePath)
} else if (file.endsWith('.tsx') || file.endsWith('.ts')) {
replaceInFile(filePath)
}
})
}

walkDir(srcDir)
console.log('Migration completed!')
44 changes: 44 additions & 0 deletions scripts/migrate-to-heroui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const srcDir = path.join(__dirname, '..', 'src')

function replaceInFile(filePath: string): void {
let content = fs.readFileSync(filePath, 'utf8')

// 替换导入语句
content = content.replace(
/@nextui-org\/react/g,
'@heroui/react'
)

// 替换 NextUIProvider
content = content.replace(
/NextUIProvider/g,
'HeroUIProvider'
)

fs.writeFileSync(filePath, content)
}

function walkDir(dir: string): void {
const files = fs.readdirSync(dir)

files.forEach(file => {
const filePath = path.join(dir, file)
const stat = fs.statSync(filePath)

if (stat.isDirectory()) {
walkDir(filePath)
} else if (file.endsWith('.tsx') || file.endsWith('.ts')) {
replaceInFile(filePath)
}
})
}

walkDir(srcDir)
console.log('Migration completed!')
2 changes: 1 addition & 1 deletion src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NavigateFunction, useLocation, useNavigate, useRoutes } from 'react-rou
import OutboundModeSwitcher from '@renderer/components/sider/outbound-mode-switcher'
import SysproxySwitcher from '@renderer/components/sider/sysproxy-switcher'
import TunSwitcher from '@renderer/components/sider/tun-switcher'
import { Button, Divider } from '@nextui-org/react'
import { Button, Divider } from '@heroui/react'
import { IoSettings } from 'react-icons/io5'
import routes from '@renderer/routes'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/base/base-error-boundary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button } from '@nextui-org/react'
import { Button } from '@heroui/react'
import { ReactNode } from 'react'
import { ErrorBoundary, FallbackProps } from 'react-error-boundary'
import { useTranslation } from 'react-i18next'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/base/base-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Divider } from '@nextui-org/react'
import { Button, Divider } from '@heroui/react'
import { useAppConfig } from '@renderer/hooks/use-app-config'
import { platform } from '@renderer/utils/init'
import { isAlwaysOnTop, setAlwaysOnTop } from '@renderer/utils/ipc'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/base/base-password-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ModalFooter,
Button,
Input
} from '@nextui-org/react'
} from '@heroui/react'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/base/base-setting-card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Accordion, AccordionItem, Card, CardBody } from '@nextui-org/react'
import { Accordion, AccordionItem, Card, CardBody } from '@heroui/react'

interface Props {
title?: string
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/base/base-setting-item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Divider } from '@nextui-org/react'
import { Divider } from '@heroui/react'

import React from 'react'

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/base/border-swtich.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { cn, Switch, SwitchProps } from '@nextui-org/react'
import { cn, Switch, SwitchProps } from '@heroui/react'
import './border-switch.css'

interface SiderSwitchProps extends SwitchProps {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/base/collapse-input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef } from 'react'
import { Input, InputProps } from '@nextui-org/react'
import { Input, InputProps } from '@heroui/react'
import { FaSearch } from 'react-icons/fa'

interface CollapseInputProps extends InputProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
DropdownTrigger,
DropdownMenu,
DropdownItem
} from '@nextui-org/react'
} from '@heroui/react'
import React from 'react'
import SettingItem from '../base/base-setting-item'
import { calcTraffic } from '@renderer/utils/calc'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Card, CardFooter, CardHeader, Chip } from '@nextui-org/react'
import { Button, Card, CardFooter, CardHeader, Chip } from '@heroui/react'
import { calcTraffic } from '@renderer/utils/calc'
import dayjs from '@renderer/utils/dayjs'
import React, { useEffect } from 'react'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/logs/log-item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, CardBody, CardHeader } from '@nextui-org/react'
import { Card, CardBody, CardHeader } from '@heroui/react'
import React from 'react'

const colorMap = {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/mihomo/interface-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ModalFooter,
Button,
Snippet
} from '@nextui-org/react'
} from '@heroui/react'
import React, { useEffect, useState } from 'react'
import { getInterfaces } from '@renderer/utils/ipc'
import { useTranslation } from 'react-i18next'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/override/edit-file-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react'
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@heroui/react'
import React, { useEffect, useState } from 'react'
import { BaseEditor } from '../base/base-editor'
import { getOverride, restartCore, setOverride } from '@renderer/utils/ipc'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/override/edit-info-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Button,
Input,
Switch
} from '@nextui-org/react'
} from '@heroui/react'
import React, { useState } from 'react'
import SettingItem from '../base/base-setting-item'
import { restartCore } from '@renderer/utils/ipc'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/override/exec-log-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ModalFooter,
Button,
Divider
} from '@nextui-org/react'
} from '@heroui/react'
import React, { useEffect, useState } from 'react'
import { getOverride } from '@renderer/utils/ipc'
import { useTranslation } from 'react-i18next'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/override/override-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DropdownItem,
DropdownMenu,
DropdownTrigger
} from '@nextui-org/react'
} from '@heroui/react'
import { IoMdMore, IoMdRefresh } from 'react-icons/io'
import dayjs from '@renderer/utils/dayjs'
import React, { Key, useEffect, useMemo, useState } from 'react'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/profiles/edit-file-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react'
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@heroui/react'
import React, { useEffect, useState } from 'react'
import { BaseEditor } from '../base/base-editor'
import { getProfileStr, setProfileStr } from '@renderer/utils/ipc'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/profiles/edit-info-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
DropdownTrigger,
DropdownMenu,
DropdownItem
} from '@nextui-org/react'
} from '@heroui/react'
import React, { useState } from 'react'
import SettingItem from '../base/base-setting-item'
import { useOverrideConfig } from '@renderer/hooks/use-override-config'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/profiles/profile-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
DropdownTrigger,
Progress,
Tooltip
} from '@nextui-org/react'
} from '@heroui/react'
import { calcPercent, calcTraffic } from '@renderer/utils/calc'
import { IoMdMore, IoMdRefresh } from 'react-icons/io'
import dayjs from '@renderer/utils/dayjs'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/proxies/proxy-item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Card, CardBody } from '@nextui-org/react'
import { Button, Card, CardBody } from '@heroui/react'
import { mihomoUnfixedProxy } from '@renderer/utils/ipc'
import React, { useMemo, useState } from 'react'
import { FaMapPin } from 'react-icons/fa6'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/resources/geo-data.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Input, Switch, Tab, Tabs } from '@nextui-org/react'
import { Button, Input, Switch, Tab, Tabs } from '@heroui/react'
import SettingCard from '@renderer/components/base/base-setting-card'
import SettingItem from '@renderer/components/base/base-setting-item'
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/resources/proxy-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Viewer from './viewer'
import useSWR from 'swr'
import SettingCard from '../base/base-setting-card'
import SettingItem from '../base/base-setting-item'
import { Button, Chip } from '@nextui-org/react'
import { Button, Chip } from '@heroui/react'
import { IoMdRefresh } from 'react-icons/io'
import { CgLoadbarDoc } from 'react-icons/cg'
import { MdEditDocument } from 'react-icons/md'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/resources/rule-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Fragment, useEffect, useMemo, useState } from 'react'
import useSWR from 'swr'
import SettingCard from '../base/base-setting-card'
import SettingItem from '../base/base-setting-item'
import { Button, Chip } from '@nextui-org/react'
import { Button, Chip } from '@heroui/react'
import { IoMdRefresh } from 'react-icons/io'
import { CgLoadbarDoc } from 'react-icons/cg'
import { MdEditDocument } from 'react-icons/md'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/resources/viewer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react'
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@heroui/react'
import React, { useEffect, useState } from 'react'
import { BaseEditor } from '../base/base-editor'
import { getFileStr, setFileStr } from '@renderer/utils/ipc'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/rules/rule-item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, CardBody } from '@nextui-org/react'
import { Card, CardBody } from '@heroui/react'
import React from 'react'

const RuleItem: React.FC<IMihomoRulesDetail & { index: number }> = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/actions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Tooltip } from '@nextui-org/react'
import { Button, Tooltip } from '@heroui/react'
import SettingCard from '../base/base-setting-card'
import SettingItem from '../base/base-setting-item'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/css-editor-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react'
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@heroui/react'
import { BaseEditor } from '@renderer/components/base/base-editor'
import { readTheme } from '@renderer/utils/ipc'
import React, { useEffect, useState } from 'react'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/general-config.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react'
import SettingCard from '../base/base-setting-card'
import SettingItem from '../base/base-setting-item'
import { Button, Input, Select, SelectItem, Switch, Tab, Tabs, Tooltip } from '@nextui-org/react'
import { Button, Input, Select, SelectItem, Switch, Tab, Tabs, Tooltip } from '@heroui/react'
import { BiCopy, BiSolidFileImport } from 'react-icons/bi'
import useSWR from 'swr'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/mihomo-config.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import SettingCard from '../base/base-setting-card'
import SettingItem from '../base/base-setting-item'
import { Button, Input, Select, SelectItem, Switch, Tooltip } from '@nextui-org/react'
import { Button, Input, Select, SelectItem, Switch, Tooltip } from '@heroui/react'
import { useAppConfig } from '@renderer/hooks/use-app-config'
import debounce from '@renderer/utils/debounce'
import { getGistUrl, patchControledMihomoConfig, restartCore } from '@renderer/utils/ipc'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/shortcut-config.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Input } from '@nextui-org/react'
import { Button, Input } from '@heroui/react'
import SettingCard from '../base/base-setting-card'
import SettingItem from '../base/base-setting-item'
import { useAppConfig } from '@renderer/hooks/use-app-config'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/sider-config.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SettingCard from '@renderer/components/base/base-setting-card'
import SettingItem from '@renderer/components/base/base-setting-item'
import { useAppConfig } from '@renderer/hooks/use-app-config'
import { Radio, RadioGroup } from '@nextui-org/react'
import { Radio, RadioGroup } from '@heroui/react'
import { useTranslation } from 'react-i18next'
import type { FC } from 'react'

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/substore-config.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import SettingCard from '@renderer/components/base/base-setting-card'
import SettingItem from '@renderer/components/base/base-setting-item'
import { Button, Input, Switch } from '@nextui-org/react'
import { Button, Input, Switch } from '@heroui/react'
import {
startSubStoreFrontendServer,
startSubStoreBackendServer,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/webdav-config.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import SettingCard from '../base/base-setting-card'
import SettingItem from '../base/base-setting-item'
import { Button, Input } from '@nextui-org/react'
import { Button, Input } from '@heroui/react'
import { listWebdavBackups, webdavBackup } from '@renderer/utils/ipc'
import WebdavRestoreModal from './webdav-restore-modal'
import debounce from '@renderer/utils/debounce'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react'
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@heroui/react'
import { relaunchApp, webdavDelete, webdavRestore } from '@renderer/utils/ipc'
import React, { useState } from 'react'
import { MdDeleteForever } from 'react-icons/md'
Expand Down
Loading

0 comments on commit 0c1d259

Please sign in to comment.