refactor: rename isWindows to isWin for consistency across main/renderer (#7530)

refactor: rename isWindows to isWin for consistency across components
This commit is contained in:
fullex 2025-06-25 19:59:47 +08:00 committed by GitHub
parent 04e6f2c1ad
commit 0001bc60a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 25 additions and 25 deletions

View File

@ -10,7 +10,7 @@ import {
PushpinOutlined,
ReloadOutlined
} from '@ant-design/icons'
import { isLinux, isMac, isWindows } from '@renderer/config/constant'
import { isLinux, isMac, isWin } from '@renderer/config/constant'
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
import { useBridge } from '@renderer/hooks/useBridge'
import { useMinappPopup } from '@renderer/hooks/useMinappPopup'
@ -303,7 +303,7 @@ const MinappPopupContainer: React.FC = () => {
</Tooltip>
)}
<Spacer />
<ButtonsGroup className={isWindows || isLinux ? 'windows' : ''}>
<ButtonsGroup className={isWin || isLinux ? 'windows' : ''}>
<Tooltip title={t('minapp.popup.goBack')} mouseEnterDelay={0.8} placement="bottom">
<Button onClick={() => handleGoBack(appInfo.id)}>
<ArrowLeftOutlined />
@ -452,7 +452,7 @@ const ButtonsGroup = styled.div`
gap: 5px;
-webkit-app-region: no-drag;
&.windows {
margin-right: ${isWindows ? '130px' : isLinux ? '100px' : 0};
margin-right: ${isWin ? '130px' : isLinux ? '100px' : 0};
background-color: var(--color-background-mute);
border-radius: 50px;
padding: 0 3px;

View File

@ -1,4 +1,4 @@
import { isLinux, isMac, isWindows } from '@renderer/config/constant'
import { isLinux, isMac, isWin } from '@renderer/config/constant'
import { useFullscreen } from '@renderer/hooks/useFullscreen'
import useNavBackgroundColor from '@renderer/hooks/useNavBackgroundColor'
import type { FC, PropsWithChildren } from 'react'
@ -78,7 +78,7 @@ const NavbarRightContainer = styled.div<{ $isFullscreen: boolean }>`
display: flex;
align-items: center;
padding: 0 12px;
padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWindows ? '140px' : isLinux ? '120px' : '12px')};
padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWin ? '140px' : isLinux ? '120px' : '12px')};
justify-content: flex-end;
`
@ -91,5 +91,5 @@ const NavbarMainContainer = styled.div<{ $isFullscreen: boolean }>`
padding: 0 ${isMac ? '20px' : 0};
font-weight: bold;
color: var(--color-text-1);
padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWindows ? '140px' : isLinux ? '120px' : '12px')};
padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWin ? '140px' : isLinux ? '120px' : '12px')};
`

View File

@ -6,7 +6,7 @@ export const DEFAULT_KNOWLEDGE_THRESHOLD = 0.0
export const platform = window.electron?.process?.platform
export const isMac = platform === 'darwin'
export const isWindows = platform === 'win32' || platform === 'win64'
export const isWin = platform === 'win32' || platform === 'win64'
export const isLinux = platform === 'linux'
export const SILICON_CLIENT_ID = 'SFaJLLq0y6CAMoyDm81aMu'

View File

@ -1,4 +1,4 @@
import { isWindows } from '@renderer/config/constant'
import { isWin } from '@renderer/config/constant'
import { IpcChannel } from '@shared/IpcChannel'
import { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
@ -8,7 +8,7 @@ export function useFullScreenNotice() {
useEffect(() => {
const cleanup = window.electron.ipcRenderer.on(IpcChannel.FullscreenStatusChanged, (_, isFullscreen) => {
if (isWindows && isFullscreen) {
if (isWin && isFullscreen) {
window.message.info({
content: t('common.fullscreen'),
duration: 3,

View File

@ -1,4 +1,4 @@
import { isMac, isWindows } from '@renderer/config/constant'
import { isMac, isWin } from '@renderer/config/constant'
import { useAppSelector } from '@renderer/store'
import { orderBy } from 'lodash'
import { useCallback } from 'react'
@ -72,7 +72,7 @@ export function useShortcutDisplay(key: string) {
case 'ctrl':
return isMac ? '⌃' : 'Ctrl'
case 'command':
return isMac ? '⌘' : isWindows ? 'Win' : 'Super'
return isMac ? '⌘' : isWin ? 'Win' : 'Super'
case 'alt':
return isMac ? '⌥' : 'Alt'
case 'shift':

View File

@ -1,6 +1,6 @@
import { NavbarRight } from '@renderer/components/app/Navbar'
import { HStack } from '@renderer/components/Layout'
import { isLinux, isWindows } from '@renderer/config/constant'
import { isLinux, isWin } from '@renderer/config/constant'
import { useFullscreen } from '@renderer/hooks/useFullscreen'
import { Button, Dropdown, Menu, type MenuProps } from 'antd'
import { ChevronDown, Search } from 'lucide-react'
@ -74,7 +74,7 @@ export const McpSettingsNavbar = () => {
}))
return (
<NavbarRight style={{ paddingRight: useFullscreen() ? '12px' : isWindows ? 150 : isLinux ? 120 : 12 }}>
<NavbarRight style={{ paddingRight: useFullscreen() ? '12px' : isWin ? 150 : isLinux ? 120 : 12 }}>
<HStack alignItems="center" gap={5}>
<Button
size="small"

View File

@ -1,4 +1,4 @@
import { isWindows } from '@renderer/config/constant'
import { isWin } from '@renderer/config/constant'
import { useTheme } from '@renderer/context/ThemeProvider'
import { useSelectionAssistant } from '@renderer/hooks/useSelectionAssistant'
import { FilterMode, TriggerMode } from '@renderer/types/selectionTypes'
@ -53,7 +53,7 @@ const SelectionAssistantSettings: FC = () => {
// force disable selection assistant on non-windows systems
useEffect(() => {
if (!isWindows && selectionEnabled) {
if (!isWin && selectionEnabled) {
setSelectionEnabled(false)
}
}, [selectionEnabled, setSelectionEnabled])
@ -76,12 +76,12 @@ const SelectionAssistantSettings: FC = () => {
<SettingRow>
<SettingLabel>
<SettingRowTitle>{t('selection.settings.enable.title')}</SettingRowTitle>
{!isWindows && <SettingDescription>{t('selection.settings.enable.description')}</SettingDescription>}
{!isWin && <SettingDescription>{t('selection.settings.enable.description')}</SettingDescription>}
</SettingLabel>
<Switch
checked={isWindows && selectionEnabled}
checked={isWin && selectionEnabled}
onChange={(checked) => setSelectionEnabled(checked)}
disabled={!isWindows}
disabled={!isWin}
/>
</SettingRow>

View File

@ -1,6 +1,6 @@
import { ClearOutlined, UndoOutlined } from '@ant-design/icons'
import { HStack } from '@renderer/components/Layout'
import { isMac, isWindows } from '@renderer/config/constant'
import { isMac, isWin } from '@renderer/config/constant'
import { useTheme } from '@renderer/context/ThemeProvider'
import { useShortcuts } from '@renderer/hooks/useShortcuts'
import { useAppDispatch } from '@renderer/store'
@ -24,7 +24,7 @@ const ShortcutSettings: FC = () => {
//if shortcut is not available on all the platforms, block the shortcut here
let shortcuts = originalShortcuts
if (!isWindows) {
if (!isWin) {
//Selection Assistant only available on Windows now
const excludedShortcuts = ['selection_assistant_toggle', 'selection_assistant_select_text']
shortcuts = shortcuts.filter((s) => !excludedShortcuts.includes(s.key))
@ -86,7 +86,7 @@ const ShortcutSettings: FC = () => {
case 'Ctrl':
return isMac ? '⌃' : 'Ctrl'
case 'Command':
return isMac ? '⌘' : isWindows ? 'Win' : 'Super'
return isMac ? '⌘' : isWin ? 'Win' : 'Super'
case 'Alt':
return isMac ? '⌥' : 'Alt'
case 'Shift':

View File

@ -546,13 +546,13 @@ export const exportMarkdownToObsidian = async (attributes: any) => {
*/
function transformObsidianFileName(fileName: string): string {
const platform = window.navigator.userAgent
const isWindows = /win/i.test(platform)
const isWin = /win/i.test(platform)
const isMac = /mac/i.test(platform)
// 删除Obsidian 全平台无效字符
let sanitized = fileName.replace(/[#|\\^\\[\]]/g, '')
if (isWindows) {
if (isWin) {
// Windows 的清理
sanitized = sanitized
.replace(/[<>:"\\/\\|?*]/g, '') // 移除无效字符

View File

@ -1,4 +1,4 @@
import { isMac, isWindows } from '@renderer/config/constant'
import { isMac, isWin } from '@renderer/config/constant'
import Logger from '@renderer/config/logger'
import type { SendMessageShortcut } from '@renderer/store/settings'
import { FileType } from '@renderer/types'
@ -71,7 +71,7 @@ export const getSendMessageShortcutLabel = (shortcut: SendMessageShortcut) => {
case 'Alt+Enter':
return `${isMac ? '⌥' : 'Alt'} + Enter`
case 'Command+Enter':
return `${isMac ? '⌘' : isWindows ? 'Win' : 'Super'} + Enter`
return `${isMac ? '⌘' : isWin ? 'Win' : 'Super'} + Enter`
case 'Shift+Enter':
return 'Shift + Enter'
default: