Skip to content

Commit

Permalink
Merge pull request #49 from zmzimpl/dev
Browse files Browse the repository at this point in the history
code style prettier
  • Loading branch information
zmzimpl authored Feb 19, 2025
2 parents 312cddd + 3dc87fc commit 1ca9616
Show file tree
Hide file tree
Showing 15 changed files with 754 additions and 662 deletions.
6 changes: 3 additions & 3 deletions .electron-builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module.exports = async function () {
// macOS 基础配置(本地构建使用)
mac: {
icon: 'buildResources/icon.icns',
identity: null, // 本地构建不签名
identity: null, // 本地构建不签名
target: [
{
target: 'dmg',
Expand Down Expand Up @@ -139,8 +139,8 @@ module.exports = async function () {
// CI 环境特定配置(GitHub Actions 使用)
if (process.env.CI && process.platform === 'darwin') {
config.mac = {
...config.mac, // 保留基础配置
identity: process.env.APPLE_IDENTITY, // CI 环境使用签名
...config.mac, // 保留基础配置
identity: process.env.APPLE_IDENTITY, // CI 环境使用签名
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: 'buildResources/entitlements.mac.plist',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chrome-power",
"description": "The first open source multi-chrome manager tool.",
"version": "1.1.8",
"version": "1.1.9",
"private": true,
"author": {
"email": "zmzimpl@gmail.com",
Expand Down
6 changes: 3 additions & 3 deletions packages/main/src/fingerprint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const getAvailablePort = async () => {
const waitForChromeReady = async (chromePort: number, maxAttempts = 30) => {
const timeout = 500; // 每次尝试等待 500ms
let attempts = 0;

while (attempts < maxAttempts) {
try {
// 尝试连接 CDP
Expand All @@ -124,11 +124,11 @@ const waitForChromeReady = async (chromePort: number, maxAttempts = 30) => {
} catch (error) {
// 连接失败,继续等待
}

attempts++;
await sleep(timeout);
}

throw new Error('Chrome instance failed to start within the timeout period');
};

Expand Down
5 changes: 1 addition & 4 deletions packages/main/src/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {createLogger} from '../../shared/utils/logger';
import {MAIN_LOGGER_LABEL} from './constants';
import {existsSync} from 'fs';


const logger = createLogger(MAIN_LOGGER_LABEL);
const server = express();
const isDev = import.meta.env.DEV;
Expand Down Expand Up @@ -83,9 +82,7 @@ async function createWindow() {
browserWindow.setIcon(icon);
// 设置应用 ID,这对任务栏图标很重要
// 设置应用 ID
const appId = app.isPackaged
? 'com.chromepower.app'
: process.execPath;
const appId = app.isPackaged ? 'com.chromepower.app' : process.execPath;
app.setAppUserModelId(appId);

browserWindow.setThumbarButtons([]);
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/services/tag-service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ipcMain} from 'electron';
import type {DB} from '../../../shared/types/db';
import {TagDB} from '../db/tag';
import { WindowDB } from '../db/window';
import {WindowDB} from '../db/window';

export const initTagService = () => {
ipcMain.handle('tag-create', async (_, tag: DB.Tag) => {
Expand Down
1 change: 0 additions & 1 deletion packages/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const App = () => {
const [isVisible, setIsVisible] = useState(false);
const [messageApi, contextHolder] = message.useMessage(MESSAGE_CONFIG);


useEffect(() => {
setTimeout(() => setIsVisible(true), 100); // 延迟显示组件
}, []);
Expand Down
31 changes: 17 additions & 14 deletions packages/renderer/src/components/addable-select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState, useRef } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import { Divider, Input, Select, Space, Button, Tag, Row, Col, Typography } from 'antd';
import type { InputRef } from 'antd';
import type { CustomTagProps } from 'rc-select/lib/BaseSelect';
import React, {useState, useRef} from 'react';
import {PlusOutlined} from '@ant-design/icons';
import {Divider, Input, Select, Space, Button, Tag, Row, Col, Typography} from 'antd';
import type {InputRef} from 'antd';
import type {CustomTagProps} from 'rc-select/lib/BaseSelect';
import './index.css';
import type { DB } from '../../../../shared/types/db';
import { DeleteOutlined } from '@ant-design/icons';
import type {DB} from '../../../../shared/types/db';
import {DeleteOutlined} from '@ant-design/icons';
interface AddableSelectOptions {
options: DB.Group[] | DB.Tag[];
value?: number | string[] | number[] | undefined | string;
Expand All @@ -31,8 +31,8 @@ const AddableSelect: React.FC<AddableSelectOptions> = ({
}) => {
const [name, setName] = useState('');
const inputRef = useRef<InputRef>(null);
const fieldNames = { label: 'name', value: 'id' };
const { Text } = Typography;
const fieldNames = {label: 'name', value: 'id'};
const {Text} = Typography;
const onNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setName(event.target.value);
};
Expand All @@ -55,7 +55,7 @@ const AddableSelect: React.FC<AddableSelectOptions> = ({
};

const tagRender = (props: CustomTagProps) => {
const { label, value, closable, onClose } = props;
const {label, value, closable, onClose} = props;
const onPreventMouseDown = (event: React.MouseEvent<HTMLSpanElement>) => {
event.preventDefault();
event.stopPropagation();
Expand All @@ -69,7 +69,7 @@ const AddableSelect: React.FC<AddableSelectOptions> = ({
closable={closable}
bordered={false}
onClose={onClose}
style={{ marginRight: 3 }}
style={{marginRight: 3}}
>
{label}
</Tag>
Expand Down Expand Up @@ -97,8 +97,8 @@ const AddableSelect: React.FC<AddableSelectOptions> = ({
dropdownRender={menu => (
<>
{menu}
<Divider style={{ margin: '8px 0' }} />
<Space style={{ padding: '0 8px 4px' }}>
<Divider style={{margin: '8px 0'}} />
<Space style={{padding: '0 8px 4px'}}>
<Input
placeholder="Please enter item"
ref={inputRef}
Expand Down Expand Up @@ -128,7 +128,10 @@ const AddableSelect: React.FC<AddableSelectOptions> = ({
<Col span={21}>
<Text ellipsis>{option.label}</Text>
</Col>
<Col span={3} title="Remove">
<Col
span={3}
title="Remove"
>
<span
onClick={e => {
e.stopPropagation();
Expand Down
18 changes: 13 additions & 5 deletions packages/renderer/src/pages/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ const Api = () => {
</Link>
</Title>

<Paragraph type="secondary">
{t('api_description')}
</Paragraph>
<Paragraph type="secondary">{t('api_description')}</Paragraph>
<Divider />

<Form
Expand Down Expand Up @@ -89,7 +87,12 @@ const Api = () => {
GET /profiles/close?windowId=xxx
</Paragraph>
<Title level={4}>{t('api_windows')}</Title>
<Paragraph code copyable={{text: 'https://documenter.getpostman.com/view/25586363/2sA3BkdZ61#9734dfc0-2879-4cae-b4e4-029c411fafa2'}}>
<Paragraph
code
copyable={{
text: 'https://documenter.getpostman.com/view/25586363/2sA3BkdZ61#9734dfc0-2879-4cae-b4e4-029c411fafa2',
}}
>
<Link
href="https://documenter.getpostman.com/view/25586363/2sA3BkdZ61#9734dfc0-2879-4cae-b4e4-029c411fafa2"
target="_blank"
Expand All @@ -98,7 +101,12 @@ const Api = () => {
</Link>
</Paragraph>
<Title level={4}>{t('api.proxy')}</Title>
<Paragraph code copyable={{text: 'https://documenter.getpostman.com/view/25586363/2sA3BkdZ61#b8af2d09-618a-4e27-9ce7-35094efee212'}}>
<Paragraph
code
copyable={{
text: 'https://documenter.getpostman.com/view/25586363/2sA3BkdZ61#b8af2d09-618a-4e27-9ce7-35094efee212',
}}
>
<Link
href="https://documenter.getpostman.com/view/25586363/2sA3BkdZ61#b8af2d09-618a-4e27-9ce7-35094efee212"
target="_blank"
Expand Down
Loading

0 comments on commit 1ca9616

Please sign in to comment.