diff --git a/package.json b/package.json index 875c1380..1f5e6f7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vocechat-web", - "version": "0.3.15", + "version": "0.3.17", "private": true, "homepage": "https://voce.chat", "dependencies": { diff --git a/src/app/config.ts b/src/app/config.ts index 4c34f774..120a23fe 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -65,7 +65,7 @@ export const KEY_TOKEN = "VOCECHAT_TOKEN"; export const KEY_EXPIRE = "VOCECHAT_TOKEN_EXPIRE"; export const KEY_REFRESH_TOKEN = "VOCECHAT_REFRESH_TOKEN"; export const KEY_UID = "VOCECHAT_CURR_UID"; -export const KEY_DEVICE_KEY = "VOCECHAT_DEVICE_KEY"; +export const KEY_DEVICE_ID = "VOCECHAT_DEVICE_KEY"; export const KEY_USERS_VERSION = "VOCECHAT_USERS_VERSION"; export const KEY_AFTER_MID = "VOCECHAT_AFTER_MID"; export const KEY_PWA_INSTALLED = "VOCECHAT_PWA_INSTALLED"; diff --git a/src/app/services/auth.ts b/src/app/services/auth.ts index 8abbb650..812e812d 100644 --- a/src/app/services/auth.ts +++ b/src/app/services/auth.ts @@ -2,7 +2,7 @@ import { createApi } from "@reduxjs/toolkit/query/react"; import { nanoid } from "@reduxjs/toolkit"; import baseQuery from "./base.query"; import { setAuthData, updateToken, resetAuthData, updateInitialized } from "../slices/auth.data"; -import BASE_URL, { KEY_DEVICE_KEY, KEY_LOCAL_MAGIC_TOKEN } from "../config"; +import BASE_URL, { KEY_DEVICE_ID, KEY_LOCAL_MAGIC_TOKEN } from "../config"; import { AuthData, CredentialResponse, @@ -12,10 +12,10 @@ import { } from "../../types/auth"; const getDeviceId = () => { - let d = localStorage.getItem(KEY_DEVICE_KEY); + let d = localStorage.getItem(KEY_DEVICE_ID); if (!d) { d = `web:${nanoid()}`; - localStorage.setItem(KEY_DEVICE_KEY, d); + localStorage.setItem(KEY_DEVICE_ID, d); } return d; }; diff --git a/src/common/component/BlankPlaceholder.tsx b/src/common/component/BlankPlaceholder.tsx index 4fb5e22d..37ae2df5 100644 --- a/src/common/component/BlankPlaceholder.tsx +++ b/src/common/component/BlankPlaceholder.tsx @@ -1,5 +1,4 @@ import { FC, useState } from "react"; -import styled from "styled-components"; import ChannelModal from "./ChannelModal"; import InviteModal from "./InviteModal"; import IconChat from "../../assets/icons/placeholder.chat.svg"; @@ -10,67 +9,15 @@ import UsersModal from "./UsersModal"; import usePWAInstallPrompt from "../hook/usePWAInstallPrompt"; import { useAppSelector } from "../../app/store"; -const Styled = styled.div` - margin-top: -50px; - display: flex; - flex-direction: column; - gap: 32px; - .head { - display: flex; - flex-direction: column; - align-items: center; - gap: 8px; - .title { - font-weight: 700; - font-size: 30px; - line-height: 38px; - color: #344054; - } - .desc { - text-align: center; - font-weight: 400; - font-size: 14px; - line-height: 20px; - color: #98a2b3; - max-width: 424px; - } - } - .boxes { - display: grid; - grid-template-columns: 1fr 1fr; - grid-template-rows: 1fr 1fr; - gap: 24px; - .box { - cursor: pointer; - width: 200px; - height: 200px; - background: #f9fafb; - border-radius: 20px; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - gap: 16px; - .icon { - width: 40px; - height: 40px; - } - .txt { - padding: 0 21px; - text-align: center; - font-weight: 700; - font-size: 14px; - line-height: 20px; - color: #475467; - } - } - } -`; interface Props { type?: "chat" | "user"; } - +const classes = { + box: "w-[200px] h-[200px] cursor-pointer bg-[#f9fafb] rounded-3xl flex flex-col justify-center items-center gap-4", + boxIcon: "w-10 h-10", + boxTip: "px-5 text-sm text-[#475467] font-bold text-center" +}; const BlankPlaceholder: FC = ({ type = "chat" }) => { const { showPrompt } = usePWAInstallPrompt(); const server = useAppSelector((store) => store.server); @@ -89,36 +36,35 @@ const BlankPlaceholder: FC = ({ type = "chat" }) => { const chatTip = type == "chat" ? "Create a Channel to Start a Conversation" : "Send a Direct Message"; const chatHandler = type == "chat" ? toggleChannelModalVisible : toggleUserListVisible; - return ( <> - -
-

Welcome to {server.name} server

-

+

+
+

Welcome to {server.name} server

+

Here are some steps to help you get started. For more, check out our Getting Started guide

-
-
- -
Invite your friends or teammates
+
+
+ +
Invite your friends or teammates
-
- -
{chatTip}
-
- - - -
Got questions? Visit our help center
+ +
+ +
Got questions? Visit our help center
- +
{createChannelVisible && ( )} diff --git a/src/common/component/FAQ.tsx b/src/common/component/FAQ.tsx index 33a56b1c..d61ffedd 100644 --- a/src/common/component/FAQ.tsx +++ b/src/common/component/FAQ.tsx @@ -1,21 +1,14 @@ import { FC } from "react"; -import styled from "styled-components"; import { useGetServerVersionQuery } from "../../app/services/server"; - -const Styled = styled.div` - display: flex; - flex-direction: column; - gap: 12px; -`; type Props = {}; const FAQ: FC = () => { const { data: serverVersion } = useGetServerVersionQuery(); return ( - +
Client Version: {process.env.VERSION}
Server Version: {serverVersion}
Build Timestamp: {process.env.REACT_APP_BUILD_TIME}
- +
); }; export default FAQ; diff --git a/src/common/component/GithubLoginButton.tsx b/src/common/component/GithubLoginButton.tsx index e2130c13..efa95727 100644 --- a/src/common/component/GithubLoginButton.tsx +++ b/src/common/component/GithubLoginButton.tsx @@ -49,8 +49,12 @@ const GithubLoginButton: FC = ({ type = "login", source = "webapp", clien }, [source]); const handleGithubLogin = () => { - window.open(`https://github.com/login/oauth/authorize?client_id=${client_id}&redirect_uri=${location.origin}/github/cb/${source}.html`); - // location.href = `https://github.com/login/oauth/authorize?client_id=${client_id}`; + const redirectUrl = `https://github.com/login/oauth/authorize?client_id=${client_id}&redirect_uri=${location.origin}/github/cb/${source}.html`; + if (source == "webapp") { + location.href = redirectUrl; + } else { + window.open(redirectUrl); + } }; return ( diff --git a/src/common/component/NewVersion.tsx b/src/common/component/NewVersion.tsx index 5ce20a29..b5d5bb2f 100644 --- a/src/common/component/NewVersion.tsx +++ b/src/common/component/NewVersion.tsx @@ -1,22 +1,7 @@ import { FC } from "react"; import toast from "react-hot-toast"; -import styled from "styled-components"; import Button from "./styled/Button"; -const Styled = styled.span` - display: flex; - align-items: center; - gap: 8px; - strong { - white-space: nowrap; - font-weight: bold; - } - .btns { - gap: 5px; - display: flex; - } -`; - interface Props { id: string; handleUpdate: () => void; @@ -24,9 +9,9 @@ interface Props { const Index: FC = ({ id, handleUpdate }) => { return ( - - New Version Available -
+
+ New Version Available +
@@ -34,7 +19,7 @@ const Index: FC = ({ id, handleUpdate }) => { Dismiss
- +
); }; diff --git a/src/common/component/Profile/index.tsx b/src/common/component/Profile/index.tsx index f9aa9c30..58bf450a 100644 --- a/src/common/component/Profile/index.tsx +++ b/src/common/component/Profile/index.tsx @@ -48,9 +48,9 @@ const Profile: FC = ({ uid, type = "embed", cid }) => { return ( - -

{name}

- {email} + +

{name}

+ {email} {/*

{introduction}

*/}
    diff --git a/src/common/component/Profile/styled.tsx b/src/common/component/Profile/styled.tsx index 2f1855ee..a2d37ebf 100644 --- a/src/common/component/Profile/styled.tsx +++ b/src/common/component/Profile/styled.tsx @@ -9,33 +9,6 @@ const StyledWrapper = styled.div` margin-top: 80px; width: 432px; gap: 4px; - .avatar { - width: 80px; - height: 80px; - border-radius: 50%; - object-fit: cover; - } - .name { - user-select: text; - font-weight: bold; - font-size: 18px; - line-height: 100%; - color: #1c1c1e; - } - .email { - user-select: text; - font-weight: normal; - font-size: 14px; - line-height: 20px; - color: #98a2b3; - } - .intro { - color: #344054; - font-style: normal; - font-weight: 400; - font-size: 14px; - line-height: 20px; - } .icons { margin-top: 24px; display: flex; @@ -76,12 +49,6 @@ const StyledWrapper = styled.div` } } } - .line { - width: 100%; - height: 1px; - border: none; - background-color: rgba(0, 0, 0, 0.1); - } &.card { padding: 16px; width: 280px; diff --git a/src/routes/callback/GithubCallback.tsx b/src/routes/callback/GithubCallback.tsx index 01cbe666..eb3d54b2 100644 --- a/src/routes/callback/GithubCallback.tsx +++ b/src/routes/callback/GithubCallback.tsx @@ -1,22 +1,9 @@ import { useEffect, FC } from 'react'; -import styled from 'styled-components'; import { KEY_LOCAL_MAGIC_TOKEN } from "../../app/config"; import { useLoginMutation } from "../../app/services/auth"; import toast from "react-hot-toast"; import { FetchBaseQueryError } from "@reduxjs/toolkit/dist/query"; -const Styled = styled.section` - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - gap: 10px; - .success{ - font-size: 30px; - font-weight: bold; - color: green; - } -`; export type GithubLoginSource = "widget" | "webapp" type Props = { code: string, from?: GithubLoginSource @@ -41,6 +28,10 @@ const GithubCallback: FC = ({ code, from = "webapp" }) => { if (from == 'widget') { localStorage.setItem("widget", `${new Date().getTime()}`); } + // webapp 跳回首页 + if (from == 'webapp') { + location.href = "/"; + } } }, [isSuccess, from]); useEffect(() => { @@ -60,10 +51,10 @@ const GithubCallback: FC = ({ code, from = "webapp" }) => { } }, [error]); if (error) return Something Error; - return + return
    {isSuccess && from == 'widget' &&

    Please close this window and return widget window

    } - {isLoading ? "Github Logging in..." : "Github Login Success!"} - ; + {isLoading ? "Github Logging in..." : "Github Login Success!"} +
    ; }; export default GithubCallback; \ No newline at end of file diff --git a/src/routes/login/SignUpLink.tsx b/src/routes/login/SignUpLink.tsx index edeca3d4..4946d1e3 100644 --- a/src/routes/login/SignUpLink.tsx +++ b/src/routes/login/SignUpLink.tsx @@ -1,26 +1,5 @@ -import styled from "styled-components"; import { useNavigate } from "react-router-dom"; -const StyledSignUpLink = styled.p` - text-align: center; - margin: 24px 0 8px; - - > span { - font-weight: 400; - font-size: 14px; - line-height: 20px; - color: #667085; - margin-right: 4px; - } - - > a { - font-weight: 500; - font-size: 14px; - line-height: 20px; - color: #22d3ee; - cursor: pointer; - } -`; export default function MagicLinkLogin() { const navigate = useNavigate(); @@ -29,9 +8,9 @@ export default function MagicLinkLogin() { }; return ( - +
    Don’t have an account? - Sign up - + Sign up +
    ); } diff --git a/src/routes/reg/Register.tsx b/src/routes/reg/Register.tsx index 58c25dbf..7d41a504 100644 --- a/src/routes/reg/Register.tsx +++ b/src/routes/reg/Register.tsx @@ -148,10 +148,12 @@ export default function Reg() {
    - {googleLogin && } - {enableGithubLogin && ( - - )} +
    + {googleLogin && } + {enableGithubLogin && ( + + )} +
    ); diff --git a/src/routes/reg/SignInLink.tsx b/src/routes/reg/SignInLink.tsx index 4bc29c50..2ce133e7 100644 --- a/src/routes/reg/SignInLink.tsx +++ b/src/routes/reg/SignInLink.tsx @@ -1,30 +1,4 @@ import { useEffect } from 'react'; -import styled from "styled-components"; - -const StyledSignInLink = styled.ul` - display: flex; - flex-direction: column; - gap: 8px; - margin-top: 30px; - >.item{ - text-align: center; - margin: 0; - > span { - font-weight: 400; - font-size: 14px; - line-height: 20px; - color: #667085; - margin-right: 4px; - } - > a { - font-weight: 500; - font-size: 14px; - line-height: 20px; - color: #22d3ee; - cursor: pointer; - } -} -`; export default function SignInLink({ token }: { token?: string }) { const handleSignIn = () => { @@ -39,11 +13,9 @@ export default function SignInLink({ token }: { token?: string }) { }, [token]); return ( - -
  • - Have an account? - Sign In -
  • -
    +
    + Have an account? + Sign In +
    ); }