Skip to content

Commit

Permalink
impr: 优化canvas代码
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft authored and jianbing.chen committed Dec 18, 2024
1 parent f776c1e commit 0778aff
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 170 deletions.
10 changes: 6 additions & 4 deletions packages/editor/src/pages/welcome/Welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import { Button } from 'antd';
import { setNebulaCanvas } from '@/utils/canvas';
import { initStarCanvas } from '@/utils/canvas';
import CountUp from 'react-countup';
import style from './index.module.less';
export default function Welcome() {
const [isShadow, setShadow] = useState(false);

useEffect(() => {
setNebulaCanvas();
const el = document.getElementById('welcome') as HTMLDivElement;
initStarCanvas();
const el: HTMLElement | null = document.getElementById('welcome');
if (!el) return;
el.onscroll = () => {
if (el.scrollTop > 0) {
setShadow(true);
Expand Down
5 changes: 3 additions & 2 deletions packages/editor/src/router/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default function Root() {
const saveUserInfo = usePageStore((state) => state.saveUserInfo);

useEffect(() => {
if (!loaderData) return;
saveUserInfo(loaderData as UserInfoStore);
if (loaderData) {
saveUserInfo(loaderData as UserInfoStore);
}
}, []);

return (
Expand Down
4 changes: 0 additions & 4 deletions packages/editor/src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ declare module 'css';
declare module 'lodash-es';
declare module 'prettier';
declare module 'prettier/parser-babel';
declare module '@/utils/canvas' {
export function setNebulaCanvas();
export function setStarryCanvas();
}
interface Window {
[key: string]: any;
}
Loading

0 comments on commit 0778aff

Please sign in to comment.