Skip to content

Commit 185125d

Browse files
authored
Merge pull request #61 from 2skydev/dev
v0.0.12
2 parents d56becd + ecca925 commit 185125d

File tree

19 files changed

+686
-104
lines changed

19 files changed

+686
-104
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ yarn-error.log*
77
/resources/windows/chromium
88
chrome_data
99
out
10-
release
10+
release
11+
.env

electron.vite.config.ts

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
1-
import { defineConfig, externalizeDepsPlugin, swcPlugin } from 'electron-vite'
1+
import { defineConfig, externalizeDepsPlugin, loadEnv, swcPlugin } from 'electron-vite'
22

3+
import { sentryVitePlugin } from '@sentry/vite-plugin'
34
import react from '@vitejs/plugin-react'
45
import { resolve } from 'path'
56

6-
export default defineConfig({
7-
main: {
8-
plugins: [externalizeDepsPlugin(), swcPlugin()],
9-
build: {
10-
watch: {},
11-
},
12-
resolve: {
13-
alias: {
14-
'@main': resolve('src/main'),
7+
export default defineConfig(({ mode }) => {
8+
const isDev = mode === 'development'
9+
const env = loadEnv(mode, process.cwd(), '')
10+
11+
const sentryVitePluginArray = isDev
12+
? []
13+
: [
14+
sentryVitePlugin({
15+
org: '2skydev',
16+
project: 'lada',
17+
authToken: env.SENTRY_AUTH_TOKEN,
18+
}),
19+
]
20+
21+
return {
22+
main: {
23+
plugins: [externalizeDepsPlugin(), swcPlugin(), ...sentryVitePluginArray],
24+
build: {
25+
watch: {},
26+
sourcemap: true,
1527
},
16-
},
17-
},
18-
preload: {
19-
plugins: [externalizeDepsPlugin()],
20-
},
21-
renderer: {
22-
plugins: [react()],
23-
resolve: {
24-
alias: {
25-
'@main': resolve('src/main'),
26-
'@renderer': resolve('src/renderer/src'),
28+
resolve: {
29+
alias: {
30+
'@main': resolve('src/main'),
31+
},
2732
},
2833
},
29-
server: {
30-
port: 3000,
31-
strictPort: true,
34+
preload: {
35+
plugins: [externalizeDepsPlugin()],
36+
},
37+
renderer: {
38+
plugins: [react(), ...sentryVitePluginArray],
39+
resolve: {
40+
alias: {
41+
'@main': resolve('src/main'),
42+
'@renderer': resolve('src/renderer/src'),
43+
},
44+
},
45+
server: {
46+
port: 3000,
47+
strictPort: true,
48+
},
49+
build: {
50+
sourcemap: true,
51+
},
3252
},
33-
},
53+
}
3454
})

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"dependencies": {
2828
"@launchtray/tsyringe-async": "^4.3.3",
29+
"@sentry/electron": "^4.8.0",
2930
"auto-launch": "^5.0.5",
3031
"axios": "^1.2.3",
3132
"cheerio": "^1.0.0-rc.12",
@@ -43,6 +44,8 @@
4344
"ts-pattern": "^4.3.0"
4445
},
4546
"devDependencies": {
47+
"@sentry/react": "^7.58.1",
48+
"@sentry/vite-plugin": "^2.4.0",
4649
"@swc/core": "^1.3.51",
4750
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
4851
"@types/auto-launch": "^5.0.2",

src/main/env.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface ImportMetaEnv {
2+
readonly MAIN_VITE_SENTRY_DSN: string
3+
}
4+
5+
interface ImportMeta {
6+
readonly env: ImportMetaEnv
7+
}

src/main/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'reflect-metadata'
22

33
import { container } from '@launchtray/tsyringe-async'
4+
import * as Sentry from '@sentry/electron/main'
45

56
import { AppFactory } from '@main/core/factory'
67
import { AppModule } from '@main/modules/app/app.module'
@@ -11,6 +12,9 @@ import { MigrationModule } from '@main/modules/migration/migration.module'
1112
import { PSModule } from '@main/modules/ps/ps.module'
1213
import { UpdateModule } from '@main/modules/update/update.module'
1314

15+
Sentry.init({
16+
dsn: import.meta.env.MAIN_VITE_SENTRY_DSN,
17+
})
1418
;(async () => {
1519
const appModule = await AppFactory.create(AppModule, [
1620
MigrationModule,

src/main/modules/ps/ps.module.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,9 @@ export class PSModule {
4141
this.server.add('/summoner-ps-id/:summonerName', async ({ params }) => {
4242
const { summonerName } = params
4343

44-
const { data: html } = await axios.get(`https://lol.ps/summoner/${summonerName}`)
45-
const $ = cheerio.load(html)
44+
const summoner = await this.getSummoner(summonerName)
4645

47-
const [
48-
,
49-
,
50-
,
51-
{
52-
data: { summary },
53-
},
54-
] = JSON.parse($('script[sveltekit\\:data-type="server_data"]').text())
55-
56-
return summary._id
46+
return summoner?.summonerPsId ?? null
5747
})
5848

5949
this.server.add('/summoners', async ({ payload }) => {

src/renderer/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="ko">
33
<head>
44
<meta charset="UTF-8" />
5-
<meta http-equiv="Content-Security-Policy" content="script-src 'self';" />
5+
<meta http-equiv="Content-Security-Policy" content="script-src 'self'; worker-src blob:;" />
66
<link href="/fonts.css" rel="stylesheet" />
77
<link href="/fonts/Boxicons/css/boxicons.min.css" rel="stylesheet" />
88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
122 KB
Loading
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useState } from 'react'
2+
import { useLocation, useRouteError } from 'react-router-dom'
3+
4+
import { Button } from 'antd'
5+
6+
import errorImage from '@renderer/assets/images/error.webp'
7+
import Titlebar from '@renderer/components/Titlebar'
8+
9+
import { ErrorFallbackStyled } from './styled'
10+
11+
const ignorePaths = [/\/overlays\/.+/]
12+
13+
const ErrorFallback = () => {
14+
const [loading, setLoading] = useState(false)
15+
16+
const { message } = useRouteError() as any
17+
const { pathname } = useLocation()
18+
19+
const isIgnore = ignorePaths.some(path => path.test(pathname))
20+
21+
const handleReload = () => {
22+
setLoading(true)
23+
setTimeout(() => window.location.reload(), 500)
24+
}
25+
26+
if (isIgnore) return null
27+
28+
return (
29+
<ErrorFallbackStyled
30+
className="ErrorFallback"
31+
initial={{ opacity: 0 }}
32+
animate={{ opacity: 1 }}
33+
>
34+
<Titlebar />
35+
36+
<img src={errorImage} alt="error" />
37+
38+
<h1>알 수 없는 곳으로 와버린 거 같아요</h1>
39+
<p>원인은 저희가 찾아볼게요 여러분들은 다시 돌아가는 게 좋을 것 같아요</p>
40+
41+
<Button onClick={handleReload} loading={loading}>
42+
돌아가기
43+
</Button>
44+
45+
<div className="error">
46+
<div className="title">오류 내용</div>
47+
<div className="content">{message}</div>
48+
</div>
49+
</ErrorFallbackStyled>
50+
)
51+
}
52+
53+
export default ErrorFallback
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// === Automatically generated file. Don't edit it. ===
2+
export * from './ErrorFallback';
3+
export { default } from './ErrorFallback';

0 commit comments

Comments
 (0)