Skip to content

Commit 550c8d3

Browse files
authored
Merge pull request #124 from DnsChanger/develop
Imporve UI
2 parents a7ae4f1 + 851fa89 commit 550c8d3

9 files changed

Lines changed: 284 additions & 247 deletions

File tree

src/main/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1+
import { release } from 'node:os'
2+
import os from 'node:os'
3+
import { join } from 'node:path'
4+
import Url from 'node:url'
5+
import { config } from 'dotenv'
16
import {
2-
app,
37
BrowserWindow,
4-
shell,
5-
ipcMain,
6-
Tray,
78
Menu,
9+
Tray,
10+
app,
11+
ipcMain,
812
nativeImage,
13+
shell,
914
} from 'electron'
10-
import { release } from 'node:os'
11-
import { join } from 'node:path'
12-
import { getIconPath } from './shared/getIconPath'
13-
import { update } from './update'
14-
import { config } from 'dotenv'
15-
import { store } from './store/store'
1615
import { EventsKeys } from '../shared/constants/eventsKeys.constant'
1716
import { getPublicFilePath } from './shared/file'
18-
import os from 'node:os'
19-
import Url from 'node:url'
17+
import { getIconPath } from './shared/getIconPath'
2018
import serve from './shared/serve'
19+
import { store } from './store/store'
20+
import { update } from './update'
2121

2222
config()
2323
if (isDev)
@@ -60,7 +60,7 @@ async function createWindow() {
6060
win = new BrowserWindow({
6161
title: 'DNS Changer',
6262
icon: icon,
63-
height: 483,
63+
height: 500,
6464
width: 743,
6565
webPreferences: {
6666
preload,
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react'
22

3-
import { NavbarComponent } from '../component/head/navbar.component'
43
import { useI18nContext } from '../../i18n/i18n-react'
4+
import { NavbarComponent } from '../component/head/navbar.component'
55

66
interface Props {
77
children: JSX.Element
@@ -13,11 +13,7 @@ export function PageWrapper(prop: Props) {
1313
return (
1414
<div dir={locale == 'fa' ? 'rtl' : 'ltr'}>
1515
<NavbarComponent />
16-
<div className="lg:flex-row ">
17-
<main className=" rounded-3xl ">
18-
{React.cloneElement(prop.children, { currentPage })}
19-
</main>
20-
</div>
16+
{React.cloneElement(prop.children, { currentPage })}
2117
</div>
2218
)
2319
}

src/renderer/component/buttons/connect-btn.component.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ export function ConnectButtonComponent() {
7171
) {
7272
//disconnecting
7373
return (
74-
<div>
74+
<div className="flex flex-col justify-center pt-10 text-center">
75+
{' '}
7576
<div
76-
className="bg-[#BB3D3D] outline -outline-offset-2 outline-8 outline-[#8c37373b] rounded-[70px]"
77+
className="bg-[#BB3D3D] outline -outline-offset-2 outline-8 outline-[#8c37373b] rounded-[70px] flex items-center justify-center"
7778
style={{ width: 130, height: 130 }}
7879
>
79-
<AiOutlineLoading
80-
size={60}
81-
className={'absolute spinner bottom-20 left-9'}
82-
/>
80+
<AiOutlineLoading size={60} className={'spinner'} />
8381
</div>
8482
<div
8583
className={
@@ -94,15 +92,13 @@ export function ConnectButtonComponent() {
9492

9593
//connecting
9694
return (
97-
<div>
95+
<div className="flex flex-col justify-center pt-10 text-center">
96+
{' '}
9897
<div
99-
className="bg-[#63A76A] outline -outline-offset-2 outline-8 outline-[#378c4040] rounded-[70px]"
98+
className="bg-[#63A76A] outline -outline-offset-2 outline-8 outline-[#378c4040] rounded-[70px] flex items-center justify-center"
10099
style={{ width: 130, height: 130 }}
101100
>
102-
<AiOutlineLoading
103-
size={60}
104-
className={'absolute spinner bottom-20 left-9'}
105-
/>
101+
<AiOutlineLoading size={60} className={'spinner'} />
106102
</div>
107103
<div
108104
className={
@@ -121,7 +117,7 @@ export function ConnectButtonComponent() {
121117
) {
122118
//isConnect
123119
return (
124-
<div>
120+
<div className="flex flex-col justify-center pt-10 text-center">
125121
<Button
126122
onClick={() => clickHandler(statusStep.CONNECTED)}
127123
shape={'circle'}
@@ -143,15 +139,14 @@ export function ConnectButtonComponent() {
143139

144140
//disconnect Btn
145141
return (
146-
<div>
142+
<div className="flex flex-col justify-center pt-10 text-center">
147143
<Button
148144
onClick={() => clickHandler(statusStep.DISCONNECT)}
149145
shape={'circle'}
150-
className="relative disconnectedBtn dark:bg-white bg-[#AFAFAF] border-none
151-
outline -outline-offset-2 outline-8 outline-[#cfcfcf1a] hover:bg-[#AAA9A9] dark:hover:bg-gray-300 "
146+
className="disconnectedBtn dark:bg-white bg-[#AFAFAF] border-none
147+
outline -outline-offset-2 outline-8 outline-[#cfcfcf1a] hover:bg-[#AAA9A9] dark:hover:bg-gray-300 flex items-center justify-center"
152148
style={{ width: 130, height: 130 }}
153149
>
154-
<span className="absolute inset-0 outline-[#cfcfcf1a] outline-8 "></span>
155150
<CiPower
156151
size={60}
157152
style={{ transform: 'rotate(180deg)' }}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import axios from 'axios'
2+
import { useEffect, useState } from 'react'
3+
import { UrlsConstant } from '../../../shared/constants/urls.constant'
4+
import { Advertisement } from '../../../shared/interfaces/advertisement.interface'
5+
6+
export function AdvertisementCardComponent() {
7+
const [ad, setAd] = useState<Advertisement | null>(null)
8+
const [loading, setLoading] = useState<boolean>(true)
9+
const [error, setError] = useState<boolean>(false)
10+
useEffect(() => {
11+
async function fetchAd() {
12+
try {
13+
setLoading(true)
14+
setError(false)
15+
const response = await axios.get<Advertisement>(
16+
`${UrlsConstant.ADS_STORE}?t=${Date.now()}`,
17+
)
18+
if (!response.data || response.data.disabled) {
19+
setAd(null)
20+
setError(true)
21+
} else {
22+
setAd(response.data)
23+
}
24+
} catch (err) {
25+
console.error('Failed to load advertisement:', err)
26+
setError(true)
27+
} finally {
28+
setLoading(false)
29+
}
30+
}
31+
32+
fetchAd()
33+
}, [])
34+
35+
function handleAdClick() {
36+
if (ad?.url) {
37+
window.ipc.openBrowser(ad.url)
38+
} else {
39+
window.ipc.openBrowser('https://discord.gg/p9TZzEV39e')
40+
}
41+
}
42+
43+
if (loading) {
44+
return (
45+
<div
46+
className={
47+
'p-2 dark:bg-[#262626] bg-base-200 rounded-2xl shadow-sm h-[70px] max-h-[70px] flex items-center justify-center'
48+
}
49+
>
50+
<div className="flex flex-row items-center gap-2">
51+
<span className="loading loading-ring loading-xs"></span>
52+
<span className="text-xs text-gray-500 dark:text-gray-400">
53+
Loading advertisement...
54+
</span>
55+
</div>
56+
</div>
57+
)
58+
}
59+
if (error || !ad) {
60+
return (
61+
<div
62+
className={
63+
'p-2 dark:bg-[#262626] bg-base-200 rounded-2xl shadow-sm h-[70px] max-h-[70px] flex items-center justify-center overflow-hidden cursor-pointer'
64+
}
65+
onClick={handleAdClick}
66+
>
67+
<div className="text-sm font-medium text-gray-400 dark:text-gray-500">
68+
Ad
69+
</div>
70+
</div>
71+
)
72+
}
73+
return (
74+
<div
75+
className={
76+
'p-1 dark:bg-[#262626] bg-base-200 rounded-2xl shadow-sm h-[70px] max-h-[70px] overflow-hidden cursor-pointer w-[360px] max-w-[360px] relative'
77+
}
78+
onClick={handleAdClick}
79+
>
80+
<div className="flex items-center h-full">
81+
<img
82+
src={ad.banner}
83+
alt={ad.name}
84+
className="object-cover w-full h-full rounded-xl"
85+
onError={({ currentTarget }) => {
86+
currentTarget.onerror = null
87+
currentTarget.style.display = 'none'
88+
setError(true)
89+
}}
90+
/>
91+
</div>
92+
<div className="absolute top-0 right-0 bg-gray-500/30 text-white text-[10px] px-1.5 py-0.5 rounded-bl-lg rounded-tr-lg font-medium">
93+
Ad
94+
</div>
95+
</div>
96+
)
97+
}

0 commit comments

Comments
 (0)