Skip to content

Commit

Permalink
feat(live-demo): 登录页添加版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer17x committed Jul 11, 2022
1 parent bda216b commit 492c31e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
21 changes: 15 additions & 6 deletions packages/live-demo/src/pages/login/index.module.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
.container {
display: flex;
width: 100vw;
height: 100vh;
align-items: center;
justify-content: center;
.page {
width: 100%;
height: 100%;
background-image: url("./bg-login.svg");
}

.card {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.version {
text-align: center;
padding: 16px 0;
}
27 changes: 15 additions & 12 deletions packages/live-demo/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const validateForm = (value: LoginData): string | null => {

interface LoginProps {
nextUrl: string;
version?: string | null;
}

/**
Expand All @@ -35,7 +36,7 @@ interface LoginProps {
*/
export const Login: React.FC<LoginProps> = (props) => {
const history = useHistory();
const { nextUrl } = props;
const { nextUrl, version } = props;
const { dispatch: dispatchUserStoreState } = useUserStore();
const { dispatch: dispatchIMStoreState } = useIMStore();

Expand Down Expand Up @@ -130,16 +131,18 @@ export const Login: React.FC<LoginProps> = (props) => {
});
};

return <div className={styles.container}>
<LoginForm
className={styles.form}
data={loginData}
onChange={onChange}
onSmsClick={onSmsClick}
onSubmit={onSubmit}
isSmsLoading={isSmsLoading}
isLoading={isLoading}
countdown={countdown}
/>
return <div className={styles.page}>
<div className={styles.card}>
<LoginForm
data={loginData}
onChange={onChange}
onSmsClick={onSmsClick}
onSubmit={onSubmit}
isSmsLoading={isSmsLoading}
isLoading={isLoading}
countdown={countdown}
/>
{version && <div className={styles.version}>当前版本:{version}</div>}
</div>
</div>;
};
3 changes: 2 additions & 1 deletion packages/live-demo/src/pages/login/login-form/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//height: 504px;
background: #FFFFFF;
box-shadow: 0 4px 18px 0 rgba(4, 90, 133, 0.50);
border-radius: 8px;
border-radius: 16px;
display: flex;
overflow: hidden;

Expand Down Expand Up @@ -52,6 +52,7 @@

.text {
margin: 0 20px;
white-space: nowrap;
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/live-demo/src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const changeDocumentTitle = (path: string) => {
if (path === '/') {
return '欢迎登录';
}
if (path === '/list') {
if (path === '/room-list') {
return '房间列表';
}
if (path.startsWith('/room')) {
Expand All @@ -30,7 +30,7 @@ const RootRouter = () => {
}, [location.pathname]);

return <Switch>
<Route exact path="/login" render={() => <Login nextUrl="/room-list"/>}/>
<Route exact path="/login" render={() => <Login nextUrl="/room-list" version={version}/>}/>
<Route
path="/"
render={() => {
Expand Down
1 change: 1 addition & 0 deletions packages/live-demo/src/version.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const version: string;
5 changes: 5 additions & 0 deletions packages/live-demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import * as path from 'path';

const packageJson = require('./package.json');

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return {
define: {
version: JSON.stringify(packageJson.version),
},
plugins: [react()],
resolve: {
alias: {
Expand Down

0 comments on commit 492c31e

Please sign in to comment.