parent
50f76e3947
commit
0fb853a1bd
|
|
@ -2,9 +2,10 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="src/favicon.svg" />
|
<link rel="icon" href="/src/images/icon.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Vite App</title>
|
<title>保罗 API Next</title>
|
||||||
|
<link href="https://fastly.jsdelivr.net/gh/FortAwesome/Font-Awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,13 @@
|
||||||
"@midwayjs/hooks-kit": "^3.0.0",
|
"@midwayjs/hooks-kit": "^3.0.0",
|
||||||
"@midwayjs/koa": "^3.3.0",
|
"@midwayjs/koa": "^3.3.0",
|
||||||
"@midwayjs/rpc": "^3.0.0",
|
"@midwayjs/rpc": "^3.0.0",
|
||||||
|
"@prisma/client": "^3.12.0",
|
||||||
"ahooks": "^3.3.0",
|
"ahooks": "^3.3.0",
|
||||||
"isomorphic-unfetch": "^3.1.0",
|
"isomorphic-unfetch": "^3.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
|
"react-router-dom": "^6.3.0",
|
||||||
"redis": "^4.0.6"
|
"redis": "^4.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -25,6 +27,10 @@
|
||||||
"@types/react": "^17.0.44",
|
"@types/react": "^17.0.44",
|
||||||
"@types/react-dom": "^17.0.15",
|
"@types/react-dom": "^17.0.15",
|
||||||
"@vitejs/plugin-react": "^1.3.0",
|
"@vitejs/plugin-react": "^1.3.0",
|
||||||
|
"prisma": "^3.12.0",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3"
|
||||||
|
},
|
||||||
|
"prisma": {
|
||||||
|
"seed": "ts-node prisma/seed.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
// React
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
|
||||||
|
// UI
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
|
import Avatar from "../../images/avatar.jpg";
|
||||||
|
|
||||||
|
|
||||||
|
// Components
|
||||||
|
function Aside() {
|
||||||
|
|
||||||
|
const [sideOpen, setSideOpen] = useState(false);
|
||||||
|
|
||||||
|
const toggleClick = () => {
|
||||||
|
setSideOpen(!sideOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<aside className={sideOpen ? "sidebar active" : "sidebar"}>
|
||||||
|
<div className="toggle" onClick={toggleClick}></div>
|
||||||
|
<div className="wrapper">
|
||||||
|
<div className="header">
|
||||||
|
<h1>保罗|API</h1>
|
||||||
|
</div>
|
||||||
|
<nav className="menu">
|
||||||
|
<a href="https://paul.ren" title="保罗的小窝"><i className="fa fa-home"></i>首页</a>
|
||||||
|
<a href="https://paugram.com" target="_blank" title="保罗的博客"><i className="fa fa-book"></i>博客</a>
|
||||||
|
<a href="https://paul.ren/project" title="保罗的项目"><i className="fa fa-magic"></i>项目</a>
|
||||||
|
<nav className="has-child">
|
||||||
|
<Link to="/" title="保罗的 API"><i className="fa fa-gears"></i>API</Link>
|
||||||
|
<nav className="sub-menu">
|
||||||
|
<Link to="/netease">网易云解析</Link>
|
||||||
|
<Link to="/wallpaper">随机动漫壁纸</Link>
|
||||||
|
<Link to="/acgm">随机动漫音乐</Link>
|
||||||
|
{/* <Link to="/acgm">Gravatar 解析</Link> */}
|
||||||
|
<Link to="/bing">必应每日壁纸</Link>
|
||||||
|
</nav>
|
||||||
|
</nav>
|
||||||
|
</nav>
|
||||||
|
<div className="user-area no-login">
|
||||||
|
<img src={Avatar} alt="头像" />
|
||||||
|
<span className="username">未登录</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Aside;
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 178 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 200 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
343
src/index.css
343
src/index.css
|
|
@ -1,39 +1,320 @@
|
||||||
body {
|
@charset "UTF-8";
|
||||||
|
|
||||||
|
/* ----
|
||||||
|
|
||||||
|
# Paul API
|
||||||
|
# By: Dreamer-Paul
|
||||||
|
# Last Update: 2021.12.16
|
||||||
|
|
||||||
|
保罗的首页、作品和 API 页通用模板
|
||||||
|
|
||||||
|
本代码为奇趣保罗原创,并遵守 MIT 开源协议。欢迎访问我的博客:https://paugram.com
|
||||||
|
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/* 0 - 全局
|
||||||
|
-------------------------------- */
|
||||||
|
:root{
|
||||||
|
--primary: #009688;
|
||||||
|
--secondly: #2ecc71;
|
||||||
|
}
|
||||||
|
|
||||||
|
body{
|
||||||
|
margin-left: 10em;
|
||||||
|
padding: 1em 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3{ font-weight: lighter }
|
||||||
|
|
||||||
|
button{
|
||||||
|
padding: 0;
|
||||||
|
font: inherit;
|
||||||
|
outline: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radius-full{ border-radius: 100% }
|
||||||
|
|
||||||
|
/* 1 - 页眉
|
||||||
|
-------------------------------- */
|
||||||
|
.sidebar{
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 2;
|
||||||
|
color: #fff;
|
||||||
|
width: 10em;
|
||||||
|
position: fixed;
|
||||||
|
background-color: #3498db;
|
||||||
|
background-color: var(--primary);
|
||||||
|
transition: transform .3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .header{
|
||||||
|
padding: 1em;
|
||||||
|
background: rgba(255, 255, 255, .2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar h1{
|
||||||
|
font-size: 1.3em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.sidebar i{
|
||||||
|
width: 1em;
|
||||||
|
margin-right: .75em;
|
||||||
|
}
|
||||||
|
.sidebar hr{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: 'Avenir', Helvetica, Arial, -apple-system, BlinkMacSystemFont,
|
border-color: rgba(0, 0, 0, .15);
|
||||||
'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
|
|
||||||
'Droid Sans', 'Helvetica Neue', sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
.sidebar .wrapper{
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
height: 100%;
|
||||||
monospace;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app {
|
|
||||||
min-height: 100vh;
|
|
||||||
margin: 6rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
width: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
overflow-y: auto;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
}
|
||||||
|
.sidebar .wrapper::-webkit-scrollbar{ width: 0 }
|
||||||
|
|
||||||
|
.sidebar nav a{
|
||||||
|
padding: 1em;
|
||||||
|
display: block;
|
||||||
|
color: rgba(255, 255, 255, .9);
|
||||||
|
}
|
||||||
|
.sidebar nav i{
|
||||||
|
opacity: .8;
|
||||||
|
transition: transform .3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lambda {
|
.sidebar nav a:hover{ background: rgba(0, 0, 0, .2) }
|
||||||
display: inline-block;
|
.sidebar nav a:hover i{ transform: scale(1.2); }
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 4px 8px;
|
.sidebar a.active, .sidebar .has-child > a{
|
||||||
background-color: #e3e3e3;
|
position: relative;
|
||||||
border-radius: 4px;
|
background: rgba(0, 0, 0, .1);
|
||||||
margin-right: 8px;
|
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
||||||
monospace;
|
|
||||||
}
|
}
|
||||||
|
.sidebar a.active:before ,.sidebar .has-child > a:before{
|
||||||
|
right: 0;
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
border: .75em solid transparent;
|
||||||
|
border-right-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .sub-menu a{ padding: .75em 1em }
|
||||||
|
|
||||||
|
@media screen and (max-width: 600px){
|
||||||
|
body{ margin-left: 0 }
|
||||||
|
|
||||||
|
.sidebar{
|
||||||
|
transform: translateX(-10em);
|
||||||
|
}
|
||||||
|
.sidebar.active{
|
||||||
|
transform: translateX(0);
|
||||||
|
box-shadow: .25em 0 .5em rgba(0, 0, 0, .2);
|
||||||
|
}
|
||||||
|
|
||||||
|
aside .toggle{
|
||||||
|
top: 0;
|
||||||
|
left: 10em;
|
||||||
|
z-index: 3;
|
||||||
|
color: #fff;
|
||||||
|
width: 2.5em;
|
||||||
|
height: 2.5em;
|
||||||
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
background-color: var(--primary);
|
||||||
|
box-shadow: .25em 0 .5em rgba(0, 0, 0, .2);
|
||||||
|
}
|
||||||
|
aside .toggle:before{
|
||||||
|
content: "\f0c9";
|
||||||
|
line-height: 2.5em;
|
||||||
|
font-family: "FontAwesome";
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar.active .toggle{
|
||||||
|
background-color: #2ecc71;
|
||||||
|
background-color: var(--secondly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .menu{
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .user-area{
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
padding: .75em 1em;
|
||||||
|
transition: background .3s;
|
||||||
|
border-top: 1px solid rgba(0, 0, 0, .15);
|
||||||
|
}
|
||||||
|
.sidebar .user-area:hover{ background: rgba(0, 0, 0, .2) }
|
||||||
|
.sidebar .user-area img{
|
||||||
|
width: 2em;
|
||||||
|
border-radius: 66%;
|
||||||
|
border: 2px solid #fff;
|
||||||
|
}
|
||||||
|
.sidebar .user-area .username{
|
||||||
|
margin-left: .5em;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2 - 正文
|
||||||
|
-------------------------------- */
|
||||||
|
main, footer{
|
||||||
|
margin: auto;
|
||||||
|
max-width: 45em;
|
||||||
|
}
|
||||||
|
|
||||||
|
main .header{
|
||||||
|
padding: 1em;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 3em;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
main .header h1{ font-size: 2em }
|
||||||
|
main .header h2{ color: #666; font-size: 1.25em }
|
||||||
|
|
||||||
|
main .post{
|
||||||
|
margin-bottom: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
main .post a{
|
||||||
|
text-decoration: 1px dashed underline;
|
||||||
|
text-underline-offset: 0.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
main .post h3{
|
||||||
|
margin-top: 3em;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
main .post > h3:after{
|
||||||
|
content: "";
|
||||||
|
width: 1.5em;
|
||||||
|
height: 2px;
|
||||||
|
display: block;
|
||||||
|
margin-top: .25em;
|
||||||
|
background-color: #2ecc71;
|
||||||
|
background-color: var(--secondly);
|
||||||
|
}
|
||||||
|
main .post h3:first-child{ margin-top: 0 }
|
||||||
|
|
||||||
|
main .post img{ border-radius: .5em }
|
||||||
|
|
||||||
|
main .box{
|
||||||
|
height: 100%;
|
||||||
|
color: #fff;
|
||||||
|
display: block;
|
||||||
|
padding: 2em 1em;
|
||||||
|
text-align: center;
|
||||||
|
transition: background .3s;
|
||||||
|
animation: fade-in-top .3s backwards;
|
||||||
|
}
|
||||||
|
main .box.first{
|
||||||
|
background: #2ecc71;
|
||||||
|
animation-delay: .2s;
|
||||||
|
}
|
||||||
|
main .box.first:hover{ background: #27ae60 }
|
||||||
|
|
||||||
|
main .box.second{
|
||||||
|
background: #3498db;
|
||||||
|
animation-delay: .4s;
|
||||||
|
}
|
||||||
|
main .box.second:hover{ background: #2980b9 }
|
||||||
|
|
||||||
|
main .box.third{
|
||||||
|
background: #f1c40f;
|
||||||
|
animation-delay: .6s;
|
||||||
|
}
|
||||||
|
main .box.third:hover{ background: #f39c12 }
|
||||||
|
|
||||||
|
main .box.fourth{
|
||||||
|
background: #e74c3c;
|
||||||
|
animation-delay: .8s;
|
||||||
|
}
|
||||||
|
main .box.fourth:hover{ background: #c0392b }
|
||||||
|
|
||||||
|
main .box.fifth{
|
||||||
|
background: #9b59b6;
|
||||||
|
animation-delay: 1s;
|
||||||
|
}
|
||||||
|
main .box.fifth:hover{ background: #8e44ad }
|
||||||
|
|
||||||
|
main .box.sixth{
|
||||||
|
background: #1abc9c;
|
||||||
|
animation-delay: 1.2s;
|
||||||
|
}
|
||||||
|
main .box.sixth:hover{ background: #16a085 }
|
||||||
|
|
||||||
|
main .box.seventh{
|
||||||
|
background: #e67e22;
|
||||||
|
animation-delay: 1.4s;
|
||||||
|
}
|
||||||
|
main .box.seventh:hover{ background: #d35400 }
|
||||||
|
|
||||||
|
main .box.eighth{
|
||||||
|
background: #95a5a6;
|
||||||
|
animation-delay: 1.6s;
|
||||||
|
}
|
||||||
|
main .box.eighth:hover{ background: #7f8c8d }
|
||||||
|
|
||||||
|
main .box i{ margin-right: .5em }
|
||||||
|
main .box h3:before{ content: normal }
|
||||||
|
|
||||||
|
main kplayer{ margin-bottom: 1em; }
|
||||||
|
|
||||||
|
main .comments{
|
||||||
|
margin-bottom: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3 - 页尾
|
||||||
|
------------------------------ */
|
||||||
|
footer{
|
||||||
|
color: #666;
|
||||||
|
padding: 1em 0;
|
||||||
|
text-align: center;
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-flag{
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 6;
|
||||||
|
color: #fff;
|
||||||
|
cursor: help;
|
||||||
|
position: fixed;
|
||||||
|
background: orangered;
|
||||||
|
padding: 2em 5em .5em 5em;
|
||||||
|
transform-origin: top right;
|
||||||
|
transform: rotate(45deg) translateX(50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 4 - 附加
|
||||||
|
------------------------------ */
|
||||||
|
.gt-meta{
|
||||||
|
margin-top: 0;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gt-copyright{ display: none }
|
||||||
|
|
||||||
|
.token.comment, .token.block-comment, .token.prolog, .token.doctype, .token.cdata{ color: slategray }
|
||||||
|
.token.punctuation{ color: #f8f8f2 }
|
||||||
|
.token.namespace { opacity: .7 }
|
||||||
|
.token.property, .token.tag, .token.function-name, .token.constant, .token.symbol, .token.deleted{ color: #f92672 }
|
||||||
|
.token.boolean, .token.number { color: #ae81ff }
|
||||||
|
.token.selector, .token.attr-name, .token.string, .token.char, .token.function, .token.builtin, .token.inserted{ color: #a6e22e }
|
||||||
|
|
||||||
|
.token.operator, .token.entity, .token.url, .token.variable{ color: #f8f8f2 }
|
||||||
|
.token.atrule, .token.attr-value, .token.class-name{ color: #e6db74 }
|
||||||
|
.token.keyword { color: #66d9ef }
|
||||||
|
.token.regex, .token.important{ color: #fd971f }
|
||||||
|
|
||||||
|
.language-css .token.string, .style .token.string { color: #28b9be }
|
||||||
|
|
||||||
|
.token.important, .token.bold { font-weight: bold }
|
||||||
|
.token.italic { font-style: italic }
|
||||||
|
.token.entity { cursor: help }
|
||||||
|
.token.important { font-weight: normal }
|
||||||
|
|
|
||||||
|
|
@ -1,60 +1,28 @@
|
||||||
import React from 'react';
|
import React from "react";
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from "react-dom";
|
||||||
import { useRequest } from 'ahooks';
|
|
||||||
import { getDate } from './api/date';
|
import "./kico.css";
|
||||||
import fetchGithubStars from './api/star';
|
import "./index.css";
|
||||||
import { getBookByParams, getBookByQuery } from './api/book';
|
|
||||||
import './index.css';
|
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
||||||
|
|
||||||
|
import Aside from "./components/Layout/Aside";
|
||||||
|
import Home from "./pages/index";
|
||||||
|
import Wallpaper from "./pages/wallpaper";
|
||||||
|
import Bing from "./pages/bing";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { data: date } = useRequest(() => getDate());
|
|
||||||
const { data: repo, loading } = useRequest(() =>
|
|
||||||
fetchGithubStars('midwayjs/midway')
|
|
||||||
);
|
|
||||||
const { data: book } = useRequest(() =>
|
|
||||||
getBookByParams({ params: { id: '1' } })
|
|
||||||
);
|
|
||||||
const { data: book2 } = useRequest(() =>
|
|
||||||
getBookByQuery({ query: { id: '2' } })
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app">
|
<Router>
|
||||||
<img src="/logo.png" className="logo" />
|
<Aside />
|
||||||
<h2>Hello Midway Hooks</h2>
|
<Routes>
|
||||||
<p style={{ textAlign: 'center' }}>
|
<Route path="/" element={<Home />} />
|
||||||
Edit <code>src/api/*.ts</code> and watch it change.
|
<Route path="/wallpaper" element={<Wallpaper />} />
|
||||||
<br />
|
<Route path="/bing" element={<Bing />} />
|
||||||
You can also open Devtools to see the request details.
|
<Route path="*" element={<div>404</div>} />
|
||||||
</p>
|
</Routes>
|
||||||
<div>
|
</Router>
|
||||||
<p>
|
|
||||||
<span className="lambda">λ GET</span>
|
|
||||||
<span className="lambda">getDate()</span>
|
|
||||||
<span>Server Date: {date}</span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<span className="lambda">λ POST</span>
|
|
||||||
<span className="lambda">fetchStars('midwayjs/midway')</span>
|
|
||||||
<span>Github Stars: {loading ? 'Fetching...' : repo.stars}</span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<span className="lambda">λ GET</span>
|
|
||||||
<span className="lambda">
|
|
||||||
{`getBookByParams({ params: { id: '1' } })`}
|
|
||||||
</span>
|
|
||||||
<span>Book title: {book?.title}</span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<span className="lambda">λ GET</span>
|
|
||||||
<span className="lambda">
|
|
||||||
{`getBookByQuery({ query: { id: '2' } })`}
|
|
||||||
</span>
|
|
||||||
<span>Book title: {book2?.title}</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(<App />, document.getElementById('root'));
|
ReactDOM.render(<App />, document.getElementById("root"));
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,81 @@
|
||||||
|
// React
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
|
||||||
|
// Components
|
||||||
|
function Bing() {
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<section className="header">
|
||||||
|
<h1>必应每日壁纸</h1>
|
||||||
|
<h2>每日更新,尽享乐趣</h2>
|
||||||
|
</section>
|
||||||
|
<article className="post">
|
||||||
|
<h3>使用方法:</h3>
|
||||||
|
<p>调用地址 <code>https://api.paugram.com/bing/</code> 可自动跳转到对应的壁纸</p>
|
||||||
|
<p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p>
|
||||||
|
<p>图片版权归原作者所有,本站不为滥用本 API 进行违规操作者承担责任。</p>
|
||||||
|
|
||||||
|
<h3>参数:</h3>
|
||||||
|
<div className="ks-table text-nowrap">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>参数</td>
|
||||||
|
<td>描述</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>info</td>
|
||||||
|
<td>返回 JSON 数据,包含图片来源及版权资料</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>示例:</h3>
|
||||||
|
<p>调用一张当天的图片</p>
|
||||||
|
<pre><code>https://api.paugram.com/bing</code></pre>
|
||||||
|
<p>调用一张当天的图片,并使用 JSON 形式返回资料</p>
|
||||||
|
<pre className="language-javascript"><code>{`https://api.paugram.com/bing/?info
|
||||||
|
|
||||||
|
// 返回的是:
|
||||||
|
|
||||||
|
{
|
||||||
|
"link":"https://cn.bing.com/th?id=OHR.QatarMuseum_EN-US2624327100_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
|
||||||
|
"copyright":"National Museum of Qatar in Doha, Qatar (© Hasan Zaidi/Shutterstock)",
|
||||||
|
}</code></pre>
|
||||||
|
<p>在网页背景上使用本 API</p>
|
||||||
|
<pre className="language-css"><code>body{
|
||||||
|
background: url("https://api.paugram.com/bing/") center/cover no-repeat;
|
||||||
|
}`}
|
||||||
|
</code></pre>
|
||||||
|
<p>在网页背景上使用本 API(伪元素半透明版)</p>
|
||||||
|
<pre className="language-css"><code>{`body:before{
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
opacity: .3;
|
||||||
|
z-index: -1;
|
||||||
|
content: "";
|
||||||
|
position: fixed;
|
||||||
|
background: url(https://api.paugram.com/bing/) center/cover;
|
||||||
|
}`}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3>测试:</h3>
|
||||||
|
<p>使用 <code>img</code> 标签引用图片</p>
|
||||||
|
<p><img src={`//${location.host}/api/bing`} /></p>
|
||||||
|
|
||||||
|
<h3>感谢:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://bing.com" rel="nofollow" target="_blank">Bing</a></li>
|
||||||
|
</ul>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Bing;
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { useRequest } from 'ahooks';
|
||||||
|
import { getDate } from '../api/date';
|
||||||
|
import fetchGithubStars from '../api/star';
|
||||||
|
import { getBookByParams, getBookByQuery } from '../api/book';
|
||||||
|
import getStat from "../api/stat";
|
||||||
|
|
||||||
|
function Index() {
|
||||||
|
|
||||||
|
const { data: date } = useRequest(() => getDate());
|
||||||
|
// const { data: repo, loading } = useRequest(() =>
|
||||||
|
// fetchGithubStars('midwayjs/midway')
|
||||||
|
// );
|
||||||
|
const { data: book } = useRequest(() =>
|
||||||
|
getBookByParams({ params: { id: '1' } })
|
||||||
|
);
|
||||||
|
const { data: book2 } = useRequest(() =>
|
||||||
|
getBookByQuery({ query: { id: '2' } })
|
||||||
|
);
|
||||||
|
|
||||||
|
const { data: stat } = useRequest(() => getStat());
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<img src="/logo.png" className="logo" />
|
||||||
|
<h2>Hello Midway Hooks</h2>
|
||||||
|
<p style={{ textAlign: 'center' }}>
|
||||||
|
Edit <code>src/api/*.ts</code> and watch it change.
|
||||||
|
<br />
|
||||||
|
You can also open Devtools to see the request details.
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<span className="lambda">λ GET</span>
|
||||||
|
<span className="lambda">getDate()</span>
|
||||||
|
<span>Server Date: {date}</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="lambda">λ POST</span>
|
||||||
|
<span className="lambda">fetchStars('midwayjs/midway')</span>
|
||||||
|
{/* <span>Github Stars: {loading ? 'Fetching...' : repo.stars}</span> */}
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
{
|
||||||
|
stat?.data && Object.keys(stat.data).map((item) => (
|
||||||
|
<p key={item}>{item}: {stat.data[item]}</p>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<span className="lambda">λ GET</span>
|
||||||
|
<span className="lambda">
|
||||||
|
{`getBookByParams({ params: { id: '1' } })`}
|
||||||
|
</span>
|
||||||
|
<span>Book title: {book?.title}</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="lambda">λ GET</span>
|
||||||
|
<span className="lambda">
|
||||||
|
{`getBookByQuery({ query: { id: '2' } })`}
|
||||||
|
</span>
|
||||||
|
<span>Book title: {book2?.title}</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Index;
|
||||||
|
|
@ -0,0 +1,173 @@
|
||||||
|
// React
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
|
||||||
|
// UI
|
||||||
|
import HelpExample from "../images/help/wallpaper-pr-example.jpg";
|
||||||
|
import HelpRequire from "../images/help/wallpaper-pr-require.jpg";
|
||||||
|
|
||||||
|
|
||||||
|
// Components
|
||||||
|
function Wallpaper() {
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<section className="header">
|
||||||
|
<h1>随机动漫壁纸</h1>
|
||||||
|
<h2>生成适合 Single 主题的白底动漫壁纸</h2>
|
||||||
|
</section>
|
||||||
|
<article className="post">
|
||||||
|
<h3>说明:</h3>
|
||||||
|
<p>本 API 的所有图片均进行了公开,欢迎前往仓库 <a href="https://github.com/Dreamer-Paul/Anime-Wallpaper" target="_blank">Anime-Wallpaper</a> 提交 PR,完善资源。Commit 的说明上最好带上对应角色的来源~</p>
|
||||||
|
<blockquote>你既可以将仓库图片下载自用或创建自己的随机图片 API,也可以直接使用本 API 提供的链接插入到自己的网页上,也顺带让你学会了用 Git 提交代码,不是很有意思嘛。</blockquote>
|
||||||
|
<p>提 PR 增加资源需要注意一些细节问题,先做了解,会让你的提交过程更加顺利呢!本仓库不接受存在以下问题的提交,保罗有拒绝合并的权限哦(当然,你也可以重新修改后再次提交)</p>
|
||||||
|
<ul>
|
||||||
|
<li>动作/衣着等尺度较大的图片</li>
|
||||||
|
<li>尽可能以日漫女或无性角色为主(暂时没有作品上的限制)</li>
|
||||||
|
<li>人物主体占画面主体的比例偏高(应小于 50%)</li>
|
||||||
|
<li>人物主体离画面顶部、左右侧或底部太靠近(网站顶部有菜单栏就会被“切掉”了)</li>
|
||||||
|
<li>可参考以下图片示例,画布尺寸需为 <code>1920 x 1080</code> 像素,<code>.jpg</code> 格式。</li>
|
||||||
|
</ul>
|
||||||
|
<p><img src={HelpExample} style={{ border: "1px solid #ddd" }} alt="提交须知" /></p>
|
||||||
|
<p><img src={HelpRequire} alt="提交须知" /></p>
|
||||||
|
<p>Commit 说明可参考以下示例:</p>
|
||||||
|
<pre><code>Add 5 Images
|
||||||
|
|
||||||
|
增加了《轻音少女》阿梓喵、《原神》可莉的图片
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3>使用方法:</h3>
|
||||||
|
<p>调用地址 <code>https://api.paugram.com/wallpaper/</code> 可自动跳转到对应的壁纸(由于运营成本限制,目前本 API 借助 图床/CDN 等平台托管图片。欢迎给予资源赞助~)</p>
|
||||||
|
<p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p>
|
||||||
|
<p>图片版权归原作者所有,本站不为滥用本 API 进行违规操作者承担责任。</p>
|
||||||
|
|
||||||
|
<h3>参数:</h3>
|
||||||
|
<div className="ks-table text-nowrap">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>参数</td>
|
||||||
|
<td>可选值</td>
|
||||||
|
<td>描述</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>source</td>
|
||||||
|
<td><code>sm</code> <code>cp</code> <code>sina</code> <code>paul</code></td>
|
||||||
|
<td>图片源,如留空则默认采用 sm.ms 源</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>category(施工中)</td>
|
||||||
|
<td><code>us</code> <code>jp</code> <code>cn</code></td>
|
||||||
|
<td>图片分类,可按不同国家和类别选择</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>图片源:</h3>
|
||||||
|
<div className="ks-table text-nowrap">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>参数名称</td>
|
||||||
|
<td>状态</td>
|
||||||
|
<td>图片源描述</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>sm</td>
|
||||||
|
<td><em className="green">可用</em></td>
|
||||||
|
<td>资源较少!sm.ms 图床,国外速度较快,部分浏览器会阻止访问</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>gt</td>
|
||||||
|
<td><em className="green">可用</em></td>
|
||||||
|
<td>Gitee Pages 服务托管,服务器位于国内,速度稳定</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>sina</td>
|
||||||
|
<td><em className="green">可用</em></td>
|
||||||
|
<td>资源较少!新浪微博相册,国内速度较快,已更换新地址</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>gh</td>
|
||||||
|
<td><em className="green">可用</em></td>
|
||||||
|
<td>存放在 GitHub 上的图片资源,基于 JSDelivr 托管,速度非常理想</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>图片分类(施工中):</h3>
|
||||||
|
<div className="ks-table text-nowrap">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>参数名称</td>
|
||||||
|
<td>状态</td>
|
||||||
|
<td>分类描述</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>1</td>
|
||||||
|
<td><em className="red">不可用</em></td>
|
||||||
|
<td>白底动漫插图</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>2</td>
|
||||||
|
<td><em className="red">不可用</em></td>
|
||||||
|
<td>透明底动漫插图</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>3</td>
|
||||||
|
<td><em className="red">不可用</em></td>
|
||||||
|
<td>随机底动漫壁纸</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>示例:</h3>
|
||||||
|
<p>使用 sm.ms 图片源</p>
|
||||||
|
<pre><code>https://api.paugram.com/wallpaper/?source=sm</code></pre>
|
||||||
|
<p>使用新浪图片源,并选择美漫图片分类</p>
|
||||||
|
<pre><code>https://api.paugram.com/wallpaper/?source=sina&category=us</code></pre>
|
||||||
|
<p>在网页背景上使用本 API</p>
|
||||||
|
<pre className="language-css"><code>{`body{
|
||||||
|
background: url("https://api.paugram.com/wallpaper/") center/cover no-repeat;
|
||||||
|
}`}
|
||||||
|
</code></pre>
|
||||||
|
<p>在网页背景上使用本 API(伪元素半透明版)</p>
|
||||||
|
<pre className="language-css"><code>{`body:before{
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
opacity: .3;
|
||||||
|
z-index: -1;
|
||||||
|
content: "";
|
||||||
|
position: fixed;
|
||||||
|
background: url(https://api.paugram.com/wallpaper/) center/cover;
|
||||||
|
}`}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3>测试:</h3>
|
||||||
|
<p>使用 <code>img</code> 标签引用图片</p>
|
||||||
|
<p><img src={`//${location.host}/api/wallpaper`} style={{ border: "1px solid #ddd" }} alt="示例" /></p>
|
||||||
|
|
||||||
|
<h3>感谢:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://sm.ms" rel="nofollow" target="_blank">SM.MS</a></li>
|
||||||
|
<li><a href="https://github.com/Dreamer-Paul/Anime-Wallpaper" rel="nofollow" target="_blank">GitHub</a></li>
|
||||||
|
<li><a href="https://www.jsdelivr.com" rel="nofollow" target="_blank">JSDelivr</a></li>
|
||||||
|
<li><a href="https://gitee.com" rel="nofollow" target="_blank">Gitee Pages</a></li>
|
||||||
|
</ul>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Wallpaper;
|
||||||
Loading…
Reference in New Issue