Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zila-itc committed Oct 31, 2024
1 parent 48503ee commit 80cc8f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 82 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ const Page = () => {
## Reference and Credit

<https://github.com/dieharders/ai-text-server>
<https://github.com/cba85/electron-webview>
<https://github.com/hokein/electron-sample-apps>
1 change: 1 addition & 0 deletions src/main/main-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async function createMainWindow() {
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
sandbox: false,
webviewTag: true,
},
});
context.mainWindow = mainWindow;
Expand Down
97 changes: 15 additions & 82 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
ProCard,
ProForm,
ProFormCheckbox,
ProFormText,
} from '@ant-design/pro-components';
import { ProCard } from '@ant-design/pro-components';
import { useLocalStorageState } from 'ahooks';
import { Button, notification } from 'antd';

Expand Down Expand Up @@ -44,97 +39,35 @@ const handleSync = (opts = {} as any) => {
});
};

const SyncForm = () => {
const [formState, setFormState] = useLocalStorageState('formState', {
defaultValue: {
i18nUrl: '',
isScanAll: true,
isForceOverwrite: true,
},
});

const WeView = () => {
return (
<ProForm
onFinish={async (values: any) => {
console.log('formState', values);

const nextValues = {
...values,
isForceOverwrite: true,
isScanAll: true,
};

setFormState(nextValues);
handleSync(nextValues);
}}
initialValues={{
...formState,
}}
>
<ProFormCheckbox
name="isForceOverwrite"
width={'md'}
label={translate('Force Overwrite')}
tooltip={translate('Overwrite file')}
/>

<ProFormCheckbox
name="isScanAll"
width={'md'}
label={translate('Scan All')}
tooltip={translate(
'Scan all will include dynamic params or server translate',
)}
/>

<ProFormText
name="i18nUrl"
rules={[
{
type: 'url',
message: translate('Must be valid full API URL'),
},
]}
label={translate('API URL')}
/>
<ProFormText
rules={[
{
whitespace: true,
message: translate('Whitespace are not allowed'),
},
{
required: true,
message: translate(
'Must be a absolute path eg. D:\\projects\\test\\project\\src',
),
},
]}
name="scanPath"
label={translate('Full Path')}
<div className="">
<webview
src={'http://localhost/'}
style={{
width: '100%',
height: '69vh',
minHeight: '100%',
display: 'flex',
}}
/>
</ProForm>
</div>
);
};

export default function HomePage() {
return (
<ProCard
title={translate('I18n Management')}
title={translate('Configs')}
bordered
headerBordered
tabs={{
destroyInactiveTabPane: true,
items: [
{
key: '1',
label: translate('I18N SYNC'),
children: <SyncForm />,
},
{
key: '2',
label: translate('I18N SYNC'),
children: <SyncForm />,
label: translate('SERVER'),
children: <WeView />,
},
],
}}
Expand Down

0 comments on commit 80cc8f7

Please sign in to comment.