diff --git a/index.html b/index.html index f5926e82..e2b4a6f4 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,7 @@ // url: "https://cdn.dos.zone/custom/dos/QB45.jsdos", // qbasic // url: decodeURIComponent("https%3A%2F%2Fcdn.dos.zone%2Fcustom%2Fdos%2Fdoom_dm.jsdos"), // url: decodeURIComponent("https%3A%2F%2Fcdn.dos.zone%2Fcustom%2Fdos%2Fhomm2_netbios.jsdos"), - // url: "https://cdn.dos.zone/original/2X/2/24b00b14f118580763440ecaddcc948f8cb94f14.jsdos", // digger + url: "https://cdn.dos.zone/original/2X/2/24b00b14f118580763440ecaddcc948f8cb94f14.jsdos", // digger // url: "https://cdn.dos.zone/custom/dos/doom.jsdos", // url: "https://cdn.dos.zone/custom/dos/duke3d_ipx.jsdos", // url: "https://br.cdn.dos.zone/ipx/duke3d/duke3d_ipx.jsdos", diff --git a/src/frame/account-frame.tsx b/src/frame/account-frame.tsx deleted file mode 100644 index cbb4e0fe..00000000 --- a/src/frame/account-frame.tsx +++ /dev/null @@ -1,182 +0,0 @@ -import { useDispatch, useSelector } from "react-redux"; -import { useState } from "preact/hooks"; -import { uiSlice } from "../store/ui"; -import { authSlice } from "../store/auth"; -import { useT } from "../i18n"; -import { State } from "../store"; -import { linkToBuy, cancle as cancelSubscription } from "../v8/subscriptions"; -import { cancelSubscriptionPage } from "../v8/config"; - -export function AccountFrame(props: {}) { - const t = useT(); - const account = useSelector((state: State) => state.auth.account); - const dispatch = useDispatch(); - - if (account === null) { - return null; - } - - function logout() { - dispatch(authSlice.actions.logout({})); - dispatch(uiSlice.actions.frameNone()); - } - - return
- {account.picture !== null && - } -
- {account.picture === null && - - - } - {account.name ?? account.email} -
- - -
-
{t("features")}
-
- - - -
-
- -
; -} - -function PremiumPlan(props: {}) { - const t = useT(); - const lang = useSelector((state: State) => state.i18n.lang); - const account = useSelector((state: State) => state.auth.account); - const [locked, setLocked] = useState(false); - const dispatch = useDispatch(); - - if (account === null) { - return null; - } - - const token = account.token.access_token; - function onBuy() { - if (locked) { - return; - } - - if (location.host !== "js-dos.com") { - window.open("https://js-dos.com/subscription.html#subscribe", "_blank"); - return; - } - - setLocked(true); - linkToBuy(token) - .then((link) => { - if (link !== null) { - window.open(link, "_blank"); - } - }) - .catch(console.error) - .finally(() => setLocked(false)); - } - - async function cancle() { - const openPage = () => { - dispatch(uiSlice.actions.showToast({ - message: t("unable_to_cancle_subscription"), - intent: "error", - })); - window.open(cancelSubscriptionPage[lang] ?? cancelSubscriptionPage.en, "_blank"); - }; - if (!account) { - openPage(); - } else { - try { - if (await cancelSubscription(account.token.access_token)) { - dispatch(uiSlice.actions.showToast({ - message: t("subscription_cancelled"), - intent: "success", - })); - } else { - openPage(); - } - } catch (e) { - openPage(); - } - } - } - - return
-
- { account.premium && } -
{t("premium")}
-
- {account.premium && - } -
- {!account.premium && - <> -
-
- $3 -
-
-
USD / mo
-
5 {t("try_free")}
-
-
- - - } -
-
- -
{t("cloud_saves")}
-
-
- -
{t("experimental_features")}
-
-
- -
{t("writeable_fat32")}
-
- -
-
- -
{t("net_no_limits")}
-
-
- -
{t("unlock_options")}
-
-
-
; -} - -function PremiumCheck(props: {}) { - return - - ; -} - -function openPremiumPage() { - window.open("https://js-dos.com/cloud-overview.html", "_blank"); -} diff --git a/src/frame/editor/editor-conf-frame.tsx b/src/frame/editor/editor-conf-frame.tsx index 67ff2eec..54ce0cef 100644 --- a/src/frame/editor/editor-conf-frame.tsx +++ b/src/frame/editor/editor-conf-frame.tsx @@ -30,10 +30,10 @@ export function EditorConf() { const [myDrives, setMyDrives] = useState<{ name: string, owner: string }[]>([]); useEffect(() => { - if (!account || !account.token) { + if (!account) { setMyDrives([]); } else { - fetch(sockdriveEndpoint + "/list/drives/" + account.token.access_token) + fetch(sockdriveEndpoint + "/list/drives/" + account.token) .then((r) => r.json()) .then(setMyDrives) .catch(console.error); diff --git a/src/frame/fat-drives-frame.tsx b/src/frame/fat-drives-frame.tsx index 7d0a3aaf..17212464 100644 --- a/src/frame/fat-drives-frame.tsx +++ b/src/frame/fat-drives-frame.tsx @@ -87,7 +87,7 @@ export function FatDrivesFrame() { setBusy(false); } else { setBusy(true); - fetch(sockdriveEndpoint + "/list/drives/" + account.token.access_token) + fetch(sockdriveEndpoint + "/list/drives/" + account.token) .then((r) => r.json()) .then((drives: Drive[]) => { setMyDrives(drives.sort((a, b) => a.name.localeCompare(b.name))); @@ -179,7 +179,7 @@ export function FatDrivesFrame() { setDialogIndex(-1); setBusy(true); // eslint-disable-next-line max-len - fetch(`${sockdriveEndpoint}/fork/drive/${myDrives[dialogIndex].owner}/${myDrives[dialogIndex].name}/${forkName}/${account.token.access_token}`, { + fetch(`${sockdriveEndpoint}/fork/drive/${myDrives[dialogIndex].owner}/${myDrives[dialogIndex].name}/${forkName}/${account.token}`, { method: "POST", }) .then((r) => r.json()) @@ -220,7 +220,7 @@ export function FatDrivesFrame() { setDialogIndex(-1); setBusy(true); // eslint-disable-next-line max-len - fetch(`${sockdriveEndpoint}/fork/delete/${myDrives[dialogIndex].owner}/${myDrives[dialogIndex].name}/${account.token.access_token}`, { method: "POST" }) + fetch(`${sockdriveEndpoint}/fork/delete/${myDrives[dialogIndex].owner}/${myDrives[dialogIndex].name}/${account.token}`, { method: "POST" }) .then((r) => r.json()) .then((response) => { if (response.error) { diff --git a/src/frame/frame.css b/src/frame/frame.css index aa42fde4..fc586cc3 100644 --- a/src/frame/frame.css +++ b/src/frame/frame.css @@ -69,17 +69,6 @@ } } - .account-frame { - @apply px-6 mt-4; - .account-img { - @apply w-24 h-24 my-8 rounded-full; - } - - .account-email { - @apply text-xs mt-4; - } - } - .network-frame { @apply w-full; diff --git a/src/frame/frame.tsx b/src/frame/frame.tsx index 7e260ff6..0e3beeca 100644 --- a/src/frame/frame.tsx +++ b/src/frame/frame.tsx @@ -1,6 +1,5 @@ import { useSelector } from "react-redux"; import { State } from "../store"; -import { AccountFrame } from "./account-frame"; import { EditorConf } from "./editor/editor-conf-frame"; import { EditorFsFrame } from "./editor/editor-fs-frame"; import { FatDrivesFrame } from "./fat-drives-frame"; @@ -20,7 +19,6 @@ export function Frame(props: {}) { return
- { frame === "account" && } { frame === "settings" && } { frame === "editor-conf" && } { frame === "editor-fs" && } diff --git a/src/i18n.ts b/src/i18n.ts index d8ab38ae..540a2ae0 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -4,6 +4,8 @@ import { State } from "./store"; const translations: {[lang: string]: {[key: string]: string} } = { ru: { + hello: "Привет", + hello_guest: "Привет, гость!", mobile_controls: "Моибльное управление", mirrored_controls: "Отразить управление", scale_controls: "Масштаб управления", @@ -62,7 +64,6 @@ const translations: {[lang: string]: {[key: string]: string} } = { editor: "Редактор", download: "Скачать", changes: "Сохранения", - account_not_ready: "Пропустить загрузку сохранений", loading_saves: "Загрузка сохранений", success: "Успешно", success_save: "Сохранено в облаке", @@ -84,10 +85,13 @@ const translations: {[lang: string]: {[key: string]: string} } = { fat_write: "FAT запись", play: "Запустить", system_cursor: "Системный курсор", - no_cloud_access: "Войдите что бы использовать", - cloud_storage: "облачное хранилище", + no_cloud_access: "Введите", + no_cloud_access2: "что бы использовать облачное хранилище", + key: "Ваш ключ", }, en: { + hello: "Hello", + hello_guest: "Hello, guest!", play: "Start", system_cursor: "System cursor", mobile_controls: "Mobile controls", @@ -148,7 +152,6 @@ const translations: {[lang: string]: {[key: string]: string} } = { editor: "Editor", download: "Download", changes: "Saves", - account_not_ready: "Skip loading saves", loading_saves: "Loading saves", success: "Success", success_save: "Saved in cloud", @@ -168,8 +171,9 @@ const translations: {[lang: string]: {[key: string]: string} } = { hardware: "Hardware acceleration", net_drives: "Net drives", fat_write: "Writeable FAT", - no_cloud_access: "Please login to use", - cloud_storage: "cloud storage", + no_cloud_access: "Please enter", + no_cloud_access2: "to use cloud storage", + key: "your key", }, }; diff --git a/src/index.css b/src/index.css index dfd071a5..67041052 100644 --- a/src/index.css +++ b/src/index.css @@ -2,7 +2,6 @@ @import "./app.css"; @import "./components/components.css"; @import "./sidebar/sidebar.css"; -@import "./login/login.css"; @import "./window/window.css"; @import "./frame/frame.css"; @import "./layers/layers.css"; \ No newline at end of file diff --git a/src/login/login.css b/src/login/login.css deleted file mode 100644 index 5a3117fe..00000000 --- a/src/login/login.css +++ /dev/null @@ -1,9 +0,0 @@ -.jsdos-rso { - .login-widget { - @apply absolute z-40 left-12 top-0 bottom-0 right-0 bg-white; - - iframe { - @apply w-full h-full p-0 m-0 border-0; - } - } -} \ No newline at end of file diff --git a/src/login/login.tsx b/src/login/login.tsx deleted file mode 100644 index 05688e12..00000000 --- a/src/login/login.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import { Dispatch, useEffect, useRef } from "preact/hooks"; -import { useDispatch, useSelector } from "react-redux"; -import { State } from "../store"; -import { uiSlice } from "../store/ui"; -import { CloseButton } from "../components/close-button"; -import { authentificator } from "../v8/config"; -import { Account, authSlice, getRefreshToken } from "../store/auth"; -import { havePremium } from "../v8/subscriptions"; -import { AnyAction } from "@reduxjs/toolkit"; - -export function Login() { - const iframeRef = useRef(null); - const activeAccount = useSelector((state: State) => state.auth.account); - const visible = useSelector((state: State) => state.ui.modal) === "login"; - const loginUrl = useSelector((state: State) => state.auth.loginUrl); - const dispatch = useDispatch(); - - useEffect(() => { - if (activeAccount != null) { - return; - } - - const iframe = iframeRef.current; - if (iframe === null) { - dispatch(authSlice.actions.logout({})); - dispatch(authSlice.actions.ready()); - console.error("Unable to inialize authentificator!"); - return; - } - - async function onAuthMessage(e: any) { - if (e.data.action === "auth/ready") { - postAuthMessage("auth/authenicate", iframe as HTMLIFrameElement, dispatch); - } else if (e.data.action === "auth/authenicate") { - const account = e.data.account as Account | null; - if (account !== null) { - try { - account.premium = await havePremium(account.token.access_token); - } catch (e: any) { - console.error(e); - account.premium = false; - } - dispatch(authSlice.actions.login(e.data.account)); - } else { - dispatch(authSlice.actions.logout({})); - dispatch(authSlice.actions.ready()); - } - } - } - - window.addEventListener("message", onAuthMessage); - iframe.src = authentificator; - - return () => { - window.removeEventListener("message", onAuthMessage); - }; - }, []); - - useEffect(() => { - if (visible) { - const iframe = iframeRef.current; - if (iframe === null) { - return; - } - - postAuthMessage("auth/login", iframe, dispatch, loginUrl); - } - }, [visible, loginUrl]); - - return
-