mirror of
https://github.com/jaywcjlove/wxmp.git
synced 2026-01-10 15:28:47 +08:00
feat: add api request loading animation.
This commit is contained in:
29
src/assets/tail-spin.svg
Normal file
29
src/assets/tail-spin.svg
Normal file
@@ -0,0 +1,29 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 105 105" fill="currentColor">
|
||||
<circle cx="12.5" cy="12.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="0s" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="12.5" cy="52.5" r="12.5" fill-opacity=".5">
|
||||
<animate attributeName="fill-opacity" begin="100ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="52.5" cy="12.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="300ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="52.5" cy="52.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="600ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="92.5" cy="12.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="800ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="92.5" cy="52.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="400ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="12.5" cy="92.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="700ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="52.5" cy="92.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="500ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="92.5" cy="92.5" r="12.5">
|
||||
<animate attributeName="fill-opacity" begin="200ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -1,8 +1,11 @@
|
||||
import styled from 'styled-components';
|
||||
import { Outlet, NavLink } from 'react-router-dom';
|
||||
import '@wcj/dark-mode';
|
||||
import { useContext } from 'react';
|
||||
import { ReactComponent as LogoIcon } from '../assets/logo.svg';
|
||||
import { ReactComponent as GithubIcon } from '../assets/github.svg';
|
||||
import { ReactComponent as Loading } from '../assets/tail-spin.svg';
|
||||
import { Context } from '../store/context';
|
||||
|
||||
const Warpper = styled.div``;
|
||||
|
||||
@@ -75,6 +78,7 @@ const Section = styled.section`
|
||||
`;
|
||||
|
||||
export function Layout() {
|
||||
const { isLoading } = useContext(Context);
|
||||
return (
|
||||
<Warpper className="wmde-markdown-color">
|
||||
<Header>
|
||||
@@ -84,6 +88,7 @@ export function Layout() {
|
||||
微信公众号排版编辑器
|
||||
<sup> v{VERSION} </sup>
|
||||
</Title>
|
||||
{isLoading && <Loading />}
|
||||
</Article>
|
||||
<Section>
|
||||
<NavLink to="/">首页</NavLink>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import toast from 'react-hot-toast';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const Warpper = styled.div`
|
||||
font-size: 0.8rem;
|
||||
`;
|
||||
|
||||
export const useMdSource = (url: string | null) => {
|
||||
return useQuery(['database-list', url], () => {
|
||||
@@ -7,6 +13,13 @@ export const useMdSource = (url: string | null) => {
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
return data;
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(
|
||||
<Warpper>
|
||||
加载失败!<a href={url}>请检查你的URL</a>
|
||||
</Warpper>,
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user