Skip to content

Commit

Permalink
feat: 登录背景支持
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed May 9, 2024
1 parent a3997d9 commit cc4ace1
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"prettier.enable": false,
"editor.formatOnSave": false,

// "stylelint.enable": true,
// "stylelint.validate": ["css", "less"],
"stylelint.enable": true,
"stylelint.validate": ["css", "less"],

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
// "source.fixAll.stylelint": "explicit",
"source.fixAll.stylelint": "explicit",
"source.organizeImports": "never"
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"dependencies": {
"@arco-design/web-react": "^2.62.0",
"@pansy/classnames": "^1.0.1",
"@pansy/react-amap": "^2.20.1",
"@pansy/react-mapbox-gl": "^1.8.1",
"@rcuse/core": "^0.16.0",
Expand Down Expand Up @@ -89,7 +90,6 @@
"vite-plugin-pages": "^0.32.1",
"vite-plugin-pwa": "^0.20.0",
"vite-plugin-react-virtualized": "^1.0.4",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
},
"lint-staged": {
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/assets/svg/login-bg-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/assets/svg/login-bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/global.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#root {
width: 100%;
height: 100%;
}

html,
body {
width: 100%;
height: 100%;
}

.amap-container {
.amap-copyright, .amap-logo {
display: none !important;
Expand Down
4 changes: 3 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import ReactDOM from 'react-dom/client'
import { App } from './App.tsx'
import '@unocss/reset/tailwind.css'
import 'nprogress/nprogress.css'
import 'uno.css'
import 'virtual:uno.css'
// import 'virtual:unocss-devtools'
import './global.less'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<App />,
Expand Down
18 changes: 18 additions & 0 deletions src/pages/login/components/LoginPage/index.module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.login {
min-height: 100%;
overflow: hidden;

&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin-left: -48%;
background-image: url('@/assets/svg/login-bg.svg');
background-repeat: no-repeat;
background-position: 100%;
background-size: auto 100%;
}
}
4 changes: 3 additions & 1 deletion src/pages/login/components/LoginPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react'
import classnames from '@pansy/classnames'
import styles from './index.module.less'

interface LoginPageProps {
children?: React.ReactNode
}

export const LoginPage = (props: LoginPageProps) => {
return (
<div className="relative w-full h-full px-4">
<div className={classnames(styles.login, 'relative w-full h-full px-4')}>
登录页面
{props.children}
<div className="i-carbon:accessibility-alt" />
Expand Down
3 changes: 1 addition & 2 deletions src/pages/login/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Button } from '@arco-design/web-react'
import { LoginPage } from './components/LoginPage'

const Login = () => {
return (
<LoginPage>
<Button type="primary" long>登录</Button>

</LoginPage>
)
}
Expand Down
26 changes: 4 additions & 22 deletions src/routers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import { CSSTransition, TransitionGroup } from 'react-transition-group'
import { useNProgress } from '@rcuse/integrations/useNProgress';
import { useRoutes, useLocation, Navigate } from 'react-router-dom';
import { useRoutes, Navigate } from 'react-router-dom';
import Login from '@/pages/login';
import { BasicLayout } from '@/layouts/BasicLayout';
import { LazyLoad } from './LazyLoad';
Expand Down Expand Up @@ -52,26 +50,10 @@ export const rootRouter: RouteObject[] = [
];

const Router = () => {
const location = useLocation();
const { start, done } = useNProgress();

return (
<TransitionGroup>
<CSSTransition
classNames="fade"
key={location.key}
onEnter={() => {
start();
}}
onEntered={() => {
done()
}}
appear
timeout={500}
>
{useRoutes(rootRouter)}
</CSSTransition>
</TransitionGroup>
<>
{useRoutes(rootRouter)}
</>
)
};

Expand Down
14 changes: 12 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { defineConfig } from 'vite'
import Unocss from 'unocss/vite'
import { resolve } from 'node:path';
import { vitePluginForArco } from '@arco-plugins/vite-react'
import { virtualized } from 'vite-plugin-react-virtualized';
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import { visualizer } from 'rollup-plugin-visualizer'

const analyze = process.env.ANALYZE;

const root = process.cwd();
const pathResolve = (pathname: string) => resolve(root, '.', pathname);

// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
return {
Expand All @@ -19,6 +22,14 @@ export default defineConfig(({ command }) => {
},
},
},
resolve: {
alias: [
{
find: /@\//,
replacement: pathResolve('src') + '/',
},
],
},
plugins: [
react(),
vitePluginForArco({ }),
Expand All @@ -29,7 +40,6 @@ export default defineConfig(({ command }) => {
open: true,
}) as any,
Unocss(),
tsconfigPaths(),
virtualized(),
],
build: {
Expand Down

0 comments on commit cc4ace1

Please sign in to comment.