code refactoring
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
"@mui/icons-material": "^5.6.2",
|
"@mui/icons-material": "^5.6.2",
|
||||||
"@mui/material": "^5.6.4",
|
"@mui/material": "^5.6.4",
|
||||||
"@reduxjs/toolkit": "^1.8.1",
|
"@reduxjs/toolkit": "^1.8.1",
|
||||||
"radash": "^10.6.0",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-redux": "^8.0.1",
|
"react-redux": "^8.0.1",
|
||||||
@@ -32,8 +31,6 @@
|
|||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^8.3.4",
|
||||||
"@vitejs/plugin-react": "^1.3.2",
|
"@vitejs/plugin-react": "^1.3.2",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"path-browserify": "^1.0.1",
|
|
||||||
"process": "^0.11.10",
|
|
||||||
"typescript": "^4.6.4",
|
"typescript": "^4.6.4",
|
||||||
"vite": "^2.9.10"
|
"vite": "^2.9.10"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import i18n from "../../assets/i18n.yaml";
|
import i18n from "../../assets/i18n.yaml"
|
||||||
|
|
||||||
export default class I18nBuilder {
|
export default class I18nBuilder {
|
||||||
private language: string;
|
private language: string
|
||||||
private textMap = i18n.languages;
|
private textMap = i18n.languages
|
||||||
|
|
||||||
constructor(language: string) {
|
constructor(language: string) {
|
||||||
this.language = language;
|
this.language = language
|
||||||
}
|
}
|
||||||
|
|
||||||
getLanguage(): string {
|
getLanguage(): string {
|
||||||
return this.language;
|
return this.language
|
||||||
}
|
}
|
||||||
|
|
||||||
setLanguage(language: string): void {
|
setLanguage(language: string): void {
|
||||||
this.language = language;
|
this.language = language
|
||||||
}
|
}
|
||||||
|
|
||||||
t(key: string): string {
|
t(key: string): string {
|
||||||
const map = this.textMap[this.language]
|
const map = this.textMap[this.language]
|
||||||
if (map) {
|
if (map) {
|
||||||
const translation = map[key];
|
const translation = map[key]
|
||||||
return translation ?? 'caption not defined';
|
return translation ?? 'caption not defined'
|
||||||
}
|
}
|
||||||
return 'caption not defined';
|
return 'caption not defined'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,10 +20,13 @@ export class RPCClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private sendHTTP<T>(req: RPCRequest) {
|
private sendHTTP<T>(req: RPCRequest) {
|
||||||
return new Promise<RPCResponse<T>>((resolve, reject) => {
|
return new Promise<RPCResponse<T>>((resolve) => {
|
||||||
fetch(getHttpRPCEndpoint(), {
|
fetch(getHttpRPCEndpoint(), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(req)
|
body: JSON.stringify({
|
||||||
|
id: this.incrementSeq(),
|
||||||
|
...req
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => resolve(data))
|
.then(data => resolve(data))
|
||||||
@@ -59,6 +62,7 @@ export class RPCClient {
|
|||||||
|
|
||||||
public running() {
|
public running() {
|
||||||
this.send({
|
this.send({
|
||||||
|
id: this.incrementSeq(),
|
||||||
method: 'Service.Running',
|
method: 'Service.Running',
|
||||||
params: [],
|
params: [],
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user