作者 韩昌

登录页

正在显示 71 个修改的文件 包含 1344 行增加0 行删除
  1 +# http://editorconfig.org
  2 +
  3 +root = true
  4 +
  5 +[*] # 表示所有文件适用
  6 +charset = utf-8 # 设置文件字符集为 utf-8
  7 +indent_style = space # 缩进风格(tab | space)
  8 +indent_size = 2 # 缩进大小
  9 +end_of_line = lf # 控制换行类型(lf | cr | crlf)
  10 +trim_trailing_whitespace = true # 去除行尾的任意空白字符
  11 +insert_final_newline = true # 始终在文件末尾插入一个新行
  12 +
  13 +[*.md] # 表示仅 md 文件适用以下规则
  14 +max_line_length = off
  15 +trim_trailing_whitespace = false
  1 +REACT_APP_NAME=why
  2 +REACT_APP_AGE=18
  1 +REACT_APP_NAME=kobe
  2 +REACT_APP_AGE=30
  1 +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
  2 +
  3 +# dependencies
  4 +/node_modules
  5 +/.pnp
  6 +.pnp.js
  7 +
  8 +# testing
  9 +/coverage
  10 +
  11 +# production
  12 +/build
  13 +
  14 +# misc
  15 +.DS_Store
  16 +.env.local
  17 +.env.development.local
  18 +.env.test.local
  19 +.env.production.local
  20 +
  21 +npm-debug.log*
  22 +yarn-debug.log*
  23 +yarn-error.log*
  1 +# /build/*
  2 +# .local
  3 +# .output.js
  4 +# /node_modules/**
  5 +
  6 +# **/*.svg
  7 +# **/*.sh
  8 +
  9 +# /public/*
  1 +{
  2 + "useTabs": false,
  3 + "tabWidth": 2,
  4 + "printWidth": 160,
  5 + "singleQuote": true,
  6 + "trailingComma": "none",
  7 + "semi": false
  8 +}
  1 +# Getting Started with Create React App
  2 +
  3 +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
  4 +
  5 +## Available Scripts
  6 +
  7 +In the project directory, you can run:
  8 +
  9 +### `npm start`
  10 +
  11 +Runs the app in the development mode.\
  12 +Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
  13 +
  14 +The page will reload if you make edits.\
  15 +You will also see any lint errors in the console.
  16 +
  17 +### `npm test`
  18 +
  19 +Launches the test runner in the interactive watch mode.\
  20 +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
  21 +
  22 +### `npm run build`
  23 +
  24 +Builds the app for production to the `build` folder.\
  25 +It correctly bundles React in production mode and optimizes the build for the best performance.
  26 +
  27 +The build is minified and the filenames include the hashes.\
  28 +Your app is ready to be deployed!
  29 +
  30 +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
  31 +
  32 +### `npm run eject`
  33 +
  34 +**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
  35 +
  36 +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
  37 +
  38 +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
  39 +
  40 +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
  41 +
  42 +## Learn More
  43 +
  44 +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
  45 +
  46 +To learn React, check out the [React documentation](https://reactjs.org/).
  1 +const path = require('path')
  2 +const CracoLessPlugin = require('craco-less')
  3 +
  4 +const resolve = (dir) => path.resolve(__dirname, dir)
  5 +
  6 +module.exports = {
  7 + plugins: [{ plugin: CracoLessPlugin }],
  8 + webpack: {
  9 + alias: {
  10 + '@': resolve('src')
  11 + }
  12 + }
  13 +}
此 diff 太大无法显示。
  1 +{
  2 + "name": "react18-tsx-neteasemusic",
  3 + "version": "0.1.0",
  4 + "private": true,
  5 + "dependencies": {
  6 + "@reduxjs/toolkit": "^1.9.5",
  7 + "@testing-library/jest-dom": "^5.17.0",
  8 + "@testing-library/react": "^13.4.0",
  9 + "@testing-library/user-event": "^13.5.0",
  10 + "@types/jest": "^27.5.2",
  11 + "@types/node": "^16.18.41",
  12 + "@types/react": "^18.2.20",
  13 + "@types/react-dom": "^18.2.7",
  14 + "antd": "^5.9.3",
  15 + "axios": "^1.4.0",
  16 + "craco-less": "^3.0.1",
  17 + "normalize.css": "^8.0.1",
  18 + "react": "^18.2.0",
  19 + "react-dom": "^18.2.0",
  20 + "react-redux": "^8.1.2",
  21 + "react-router-dom": "^6.15.0",
  22 + "react-scripts": "5.0.1",
  23 + "typescript": "^4.9.5",
  24 + "web-vitals": "^2.1.4"
  25 + },
  26 + "scripts": {
  27 + "start": "craco start",
  28 + "build": "craco build",
  29 + "test": "craco test",
  30 + "eject": "react-scripts eject"
  31 + },
  32 + "browserslist": {
  33 + "production": [
  34 + ">0.2%",
  35 + "not dead",
  36 + "not op_mini all"
  37 + ],
  38 + "development": [
  39 + "last 1 chrome version",
  40 + "last 1 firefox version",
  41 + "last 1 safari version"
  42 + ]
  43 + },
  44 + "devDependencies": {
  45 + "@craco/craco": "^7.0.0-alpha.9",
  46 + "styled-components": "^6.0.7"
  47 + }
  48 +}
不能预览此文件类型
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 + <head>
  4 + <meta charset="utf-8" />
  5 + <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
  6 + <meta name="viewport" content="width=device-width, initial-scale=1" />
  7 + <meta name="theme-color" content="#000000" />
  8 + <meta
  9 + name="description"
  10 + content="Web site created using create-react-app"
  11 + />
  12 + <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
  13 + <!--
  14 + manifest.json provides metadata used when your web app is installed on a
  15 + user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
  16 + -->
  17 + <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
  18 + <!--
  19 + Notice the use of %PUBLIC_URL% in the tags above.
  20 + It will be replaced with the URL of the `public` folder during the build.
  21 + Only files inside the `public` folder can be referenced from the HTML.
  22 +
  23 + Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
  24 + work correctly both with client-side routing and a non-root public URL.
  25 + Learn how to configure a non-root public URL by running `npm run build`.
  26 + -->
  27 + <title>React App</title>
  28 + </head>
  29 + <body>
  30 + <noscript>You need to enable JavaScript to run this app.</noscript>
  31 + <div id="root"></div>
  32 + <!--
  33 + This HTML file is a template.
  34 + If you open it directly in the browser, you will see an empty page.
  35 +
  36 + You can add webfonts, meta tags, or analytics to this file.
  37 + The build step will place the bundled scripts into the <body> tag.
  38 +
  39 + To begin the development, run `npm start` or `yarn start`.
  40 + To create a production bundle, use `npm run build` or `yarn build`.
  41 + -->
  42 + </body>
  43 +</html>
  1 +{
  2 + "short_name": "React App",
  3 + "name": "Create React App Sample",
  4 + "icons": [
  5 + {
  6 + "src": "favicon.ico",
  7 + "sizes": "64x64 32x32 24x24 16x16",
  8 + "type": "image/x-icon"
  9 + },
  10 + {
  11 + "src": "logo192.png",
  12 + "type": "image/png",
  13 + "sizes": "192x192"
  14 + },
  15 + {
  16 + "src": "logo512.png",
  17 + "type": "image/png",
  18 + "sizes": "512x512"
  19 + }
  20 + ],
  21 + "start_url": ".",
  22 + "display": "standalone",
  23 + "theme_color": "#000000",
  24 + "background_color": "#ffffff"
  25 +}
  1 +# https://www.robotstxt.org/robotstxt.html
  2 +User-agent: *
  3 +Disallow:
  1 +import React, { Suspense } from 'react'
  2 +import { useRoutes } from 'react-router-dom'
  3 +import routes from './router'
  4 +import { useAppSelector, useAppDispatch, shallowEqualApp } from './store'
  5 +import { changeMessage } from './store/modules/counter'
  6 +import AppHeader from './components/appHeader'
  7 +
  8 +function App() {
  9 + const { counter } = useAppSelector((state) => state, shallowEqualApp)
  10 + const dispatch = useAppDispatch()
  11 + function changeMessageHandler() {
  12 + dispatch(changeMessage('hahah'))
  13 + }
  14 + return (
  15 + <>
  16 + <AppHeader />
  17 + <Suspense fallback="loading...">
  18 + <div className="App">{useRoutes(routes)}</div>
  19 + </Suspense>
  20 +
  21 + {/* <div>当前计数{counter.count}</div>
  22 + <div>message: {counter.message}</div>
  23 + <button onClick={changeMessageHandler}>修改message</button> */}
  24 + </>
  25 + )
  26 +}
  27 +
  28 +export default App
  1 +body, textarea, select, input, button {
  2 + font-size: 12px;
  3 + color: #333;
  4 + font-family: Arial, Helvetica, sans-serif;
  5 + background-color: #f5f5f5;
  6 +}
  7 +
  8 +.wrap-v1 {
  9 + width: 1100px;
  10 + margin: 0 auto;
  11 +}
  12 +
  13 +.wrap-v2 {
  14 + width: 980px;
  15 + margin: 0 auto;
  16 +}
  17 +
  18 +.sprite_01 {
  19 + background: url(../img/sprite_01.png) no-repeat 0 9999px;
  20 +}
  21 +
  22 +.sprite_02 {
  23 + background: url(../img/sprite_02.png) no-repeat 0 9999px;
  24 +}
  25 +
  26 +.sprite_cover {
  27 + background: url(../img/sprite_cover.png) no-repeat 0 9999px;
  28 +}
  29 +
  30 +.sprite_icon {
  31 + background: url(../img/sprite_icon.png) no-repeat 0 9999px;
  32 +}
  33 +
  34 +.sprite_icon2 {
  35 + background: url(../img/sprite_icon2.png) no-repeat 0 9999px;
  36 +}
  37 +
  38 +.sprite_icon3 {
  39 + background: url(../img/sprite_icon3.png) no-repeat 0 9999px;
  40 +}
  41 +
  42 +.sprite_button {
  43 + background: url(../img/sprite_button.png) no-repeat 0 9999px;
  44 +}
  45 +
  46 +.sprite_button2 {
  47 + background: url(../img/sprite_button2.png) no-repeat 0 9999px;
  48 +}
  49 +
  50 +.sprite_table {
  51 + background: url(../img/sprite_table.png) no-repeat 0 9999px;
  52 +}
  53 +
  54 +.sprite_playbar {
  55 + background: url(../img/playbar_sprite.png) no-repeat 0 9999px;
  56 +}
  57 +
  58 +.sprite_playlist {
  59 + background: url(../img/playlist_sprite.png) no-repeat 0 9999px;
  60 +}
  61 +
  62 +.ant-message .ant-message-notice-content {
  63 + position: fixed;
  64 + left: 50%;
  65 + transform: translateX(-50%);
  66 + bottom: 60px;
  67 + background-color: rgba(0, 0, 0, .7);
  68 + color: #fff;
  69 +}
  1 +// @import '~antd/dist/antd.less';
  2 +@import './reset.less';
  3 +@import './common.less';
  4 +@import './main.less';
  1 +
  2 +
  3 +.flexJ {
  4 + display: flex;
  5 + justify-content: space-between;
  6 + align-items: center;
  7 +}
  8 +
  9 +.flexC {
  10 + display: flex;
  11 + justify-content: center;
  12 + align-items: center;
  13 +}
  14 +
  15 +.flexCCol {
  16 + display: flex;
  17 + justify-content: center;
  18 + align-items: center;
  19 + flex-direction: column;
  20 +}
  21 +
  22 +.flexD {
  23 + display: flex;
  24 + align-items: center;
  25 + justify-content: flex-end;
  26 +}
  27 +
  28 +.flexA {
  29 + display: flex;
  30 + align-items: center;
  31 +}
  32 +
  33 +.flexACol {
  34 + display: flex;
  35 + align-items: center;
  36 + flex-direction: column;
  37 +}
  38 +
  39 +.flexW {
  40 + display: flex;
  41 + align-items: center;
  42 + flex-wrap: wrap;
  43 +}
  44 +
  45 +.flex1 {
  46 + flex: 1;
  47 +}
  48 +
  49 +.Alltitle {
  50 + overflow: hidden;
  51 + text-overflow: ellipsis;
  52 + display: -webkit-box;
  53 + -webkit-line-clamp: 2; // 控制多行的行数
  54 + -webkit-box-orient: vertical;
  55 +}
  56 +
  57 +.zidx {
  58 + position: relative;
  59 + z-index: 1000;
  60 +}
  61 +
  62 +.iosPadding {
  63 + padding-bottom: constant(safe-area-inset-bottom);
  64 + padding-bottom: env(safe-area-inset-bottom);
  65 +}
  66 +
  67 +.bluetext {
  68 + color: #05b8d2;
  69 +}
  70 +
  71 +.graytext {
  72 + color: #666666;
  73 +}
  74 +
  75 +.Zindex {
  76 + z-index: 9999 !important;
  77 + position: relative;
  78 +}
  79 +
  80 +.ffftext {
  81 + color: #fff;
  82 +}
  83 +
  84 +.blueTag {
  85 + border: 2rpx solid #05b8d2;
  86 + background: #ebfdff;
  87 + color: #05b8d2;
  88 + border-radius: 8rpx;
  89 +}
  90 +
  91 +.grayLine {
  92 + margin: 0 auto;
  93 + background-color: #f5f9fa;
  94 + width: calc(100% + 64rpx);
  95 + height: 20rpx;
  96 + margin-left: -32rpx;
  97 +}
  98 +.flexJA{
  99 + display: flex;
  100 + align-items: center;
  101 + justify-content: space-around;
  102 +}
  103 +.fixed-bottom {
  104 + z-index: 999999;
  105 + width: 100%;
  106 + padding: 16rpx;
  107 + box-sizing: border-box;
  108 + bottom: 0;
  109 + left: 0;
  110 + position: fixed;
  111 + z-index: 99;
  112 + background: rgba(255, 255, 255, 1);
  113 + border-top: 1rpx solid #F0F2F5;
  114 +
  115 + .form-btns {
  116 + display: flex;
  117 + flex-direction: row;
  118 + align-items: center;
  119 + justify-content: space-between;
  120 + }
  121 +}
  1 +body,
  2 +html,
  3 +h1,
  4 +h2,
  5 +h3,
  6 +h4,
  7 +h5,
  8 +h6,
  9 +ul,
  10 +ol,
  11 +li,
  12 +dl,
  13 +dt,
  14 +dd,
  15 +header,
  16 +menu,
  17 +section,
  18 +p,
  19 +input,
  20 +td,
  21 +th,
  22 +ins {
  23 + padding: 0;
  24 + margin: 0;
  25 +}
  26 +
  27 +a {
  28 + color: #333;
  29 + text-decoration: none;
  30 + // display: block;
  31 +}
  32 +
  33 +img {
  34 + vertical-align: top;
  35 +}
  36 +
  37 +input, textarea, button, select, a {
  38 + outline: none;
  39 + border: none;
  40 +}
  41 +
  42 +li, ul {
  43 + list-style: none;
  44 +}
  1 +[
  2 + {
  3 + "title": "发现音乐",
  4 + "type": "path",
  5 + "link": "/discover"
  6 + },
  7 + {
  8 + "title": "我的音乐",
  9 + "type": "path",
  10 + "link": "/mine"
  11 + },
  12 + {
  13 + "title": "关注",
  14 + "type": "path",
  15 + "link": "/focus"
  16 + },
  17 + {
  18 + "title": "商城",
  19 + "type": "link",
  20 + "link": "https://music.163.com/store/product"
  21 + },
  22 + {
  23 + "title": "音乐人",
  24 + "type": "link",
  25 + "link": "https://music.163.com/st/musician"
  26 + },
  27 + {
  28 + "title": "下载客户端",
  29 + "type": "path",
  30 + "link": "/download"
  31 + }
  32 +]
  1 +export const headerLinks = [
  2 + {
  3 + title: '发现音乐',
  4 + link: '/discover'
  5 + },
  6 + {
  7 + title: '我的音乐',
  8 + link: '/mine'
  9 + },
  10 + {
  11 + title: '朋友',
  12 + link: '/friend'
  13 + },
  14 + {
  15 + title: '商城',
  16 + link: 'https://music.163.com/store/product'
  17 + },
  18 + {
  19 + title: '音乐人',
  20 + link: 'https://music.163.com/nmusician/web/index#/'
  21 + },
  22 + {
  23 + title: '下载客户端',
  24 + link: 'https://music.163.com/#/download'
  25 + }
  26 +]
  27 +
  28 +export const footerLinks = [
  29 + {
  30 + title: '服务条款',
  31 + link: 'https://st.music.163.com/official-terms/service'
  32 + },
  33 + {
  34 + title: '隐私政策',
  35 + link: 'https://st.music.163.com/official-terms/privacy'
  36 + },
  37 + {
  38 + title: '儿童隐私政策',
  39 + link: 'https://st.music.163.com/official-terms/children'
  40 + },
  41 + {
  42 + title: '版权投诉指引',
  43 + link: 'https://music.163.com/st/staticdeal/complaints.html'
  44 + },
  45 + {
  46 + title: '意见反馈',
  47 + link: '#'
  48 + }
  49 +]
  50 +
  51 +export const footerImages = [
  52 + {
  53 + link: 'https://music.163.com/st/userbasic#/auth'
  54 + },
  55 + {
  56 + link: 'https://music.163.com/recruit'
  57 + },
  58 + {
  59 + link: 'https://music.163.com/web/reward'
  60 + },
  61 + {
  62 + link: 'https://music.163.com/uservideo#/plan'
  63 + }
  64 +]
  65 +
  66 +// discover中的数据
  67 +export const discoverMenu = [
  68 + {
  69 + title: '推荐',
  70 + link: '/discover/recommend'
  71 + },
  72 + {
  73 + title: '排行榜',
  74 + link: '/discover/ranking'
  75 + },
  76 + {
  77 + title: '歌单',
  78 + link: '/discover/songs'
  79 + },
  80 + {
  81 + title: '主播电台',
  82 + link: '/discover/djradio'
  83 + },
  84 + {
  85 + title: '歌手',
  86 + link: '/discover/artist'
  87 + },
  88 + {
  89 + title: '新碟上架',
  90 + link: '/discover/album'
  91 + }
  92 +]
  93 +
  94 +// 热门主播
  95 +export const hotRadios = [
  96 + {
  97 + picUrl:
  98 + 'http://p1.music.126.net/H3QxWdf0eUiwmhJvA4vrMQ==/1407374893913311.jpg',
  99 + name: '陈立',
  100 + position: '心理学家、美食家陈立教授',
  101 + url: '/user/home?id=278438485'
  102 + },
  103 + {
  104 + picUrl:
  105 + 'http://p1.music.126.net/y5-sM7tjnxnu_V9LWKgZlw==/7942872001461517.jpg',
  106 + name: 'DJ艳秋',
  107 + position: '著名音乐节目主持人',
  108 + url: '/user/home?id=91239965'
  109 + },
  110 + {
  111 + picUrl:
  112 + 'http://p1.music.126.net/6cc6lgOfQTo6ovNnTHPyJg==/3427177769086282.jpg',
  113 + name: '国家大剧院古典音乐频道',
  114 + position: '国家大剧院古典音乐官方',
  115 + url: '/user/home?id=324314596'
  116 + },
  117 + {
  118 + picUrl:
  119 + 'http://p1.music.126.net/xa1Uxrrn4J0pm_PJwkGYvw==/3130309604335651.jpg',
  120 + name: '谢谢收听',
  121 + position: '南京电台主持人王馨',
  122 + url: '/user/home?id=1611157'
  123 + },
  124 + {
  125 + picUrl:
  126 + 'http://p1.music.126.net/slpd09Tf5Ju82Mv-h8MP4w==/3440371884651965.jpg',
  127 + name: 'DJ晓苏',
  128 + position: '独立DJ,CRI环球旅游广播特邀DJ',
  129 + url: '/user/home?id=2313954'
  130 + }
  131 +]
  132 +
  133 +// 歌手类别
  134 +export const artistCategories = [
  135 + {
  136 + title: '推荐',
  137 + area: -1,
  138 + artists: [
  139 + {
  140 + name: '推荐歌手',
  141 + type: 1,
  142 + url: '/discover/artist',
  143 + id: 0
  144 + },
  145 + {
  146 + name: '入驻歌手',
  147 + type: 2,
  148 + url: '/discover/artist?cat=5001',
  149 + dataPath: '/artist/list?cat=5001'
  150 + }
  151 + ]
  152 + },
  153 + {
  154 + title: '华语',
  155 + area: 7,
  156 + artists: [
  157 + {
  158 + name: '华语男歌手',
  159 + url: '/discover/artist?id=1001',
  160 + type: 1
  161 + },
  162 + {
  163 + name: '华语女歌手',
  164 + url: '/discover/artist?id=1002',
  165 + type: 2
  166 + },
  167 + {
  168 + name: '华语组合/乐队',
  169 + url: '/discover/artist?id=1003',
  170 + type: 3
  171 + }
  172 + ]
  173 + },
  174 + {
  175 + title: '欧美',
  176 + area: 96,
  177 + artists: [
  178 + {
  179 + name: '欧美男歌手',
  180 + url: '/discover/artist?id=2001',
  181 + type: 1
  182 + },
  183 + {
  184 + name: '欧美女歌手',
  185 + url: '/discover/artist?id=2002',
  186 + type: 2
  187 + },
  188 + {
  189 + name: '欧美组合乐队',
  190 + url: '/discover/artist?id=2003',
  191 + type: 3
  192 + }
  193 + ]
  194 + },
  195 + {
  196 + title: '日本',
  197 + area: 8,
  198 + artists: [
  199 + {
  200 + name: '日本男歌手',
  201 + url: '/discover/artist?id=6001',
  202 + type: 1
  203 + },
  204 + {
  205 + name: '日本女歌手',
  206 + url: '/discover/artist?id=6002',
  207 + type: 2
  208 + },
  209 + {
  210 + name: '日本组合/乐队',
  211 + url: '/discover/artist?id=6003',
  212 + type: 3
  213 + }
  214 + ]
  215 + },
  216 + {
  217 + title: '韩国',
  218 + area: 16,
  219 + artists: [
  220 + {
  221 + name: '韩国男歌手',
  222 + url: '/discover/artist?id=7001',
  223 + type: 1
  224 + },
  225 + {
  226 + name: '韩国女歌手',
  227 + url: '/discover/artist?id=7002',
  228 + type: 2
  229 + },
  230 + {
  231 + name: '韩国组合/乐队',
  232 + url: '/discover/artist?id=7003',
  233 + type: 3
  234 + }
  235 + ]
  236 + },
  237 + {
  238 + title: '其他',
  239 + area: 0,
  240 + artists: [
  241 + {
  242 + name: '其他男歌手',
  243 + url: '/discover/artist?id=4001',
  244 + type: 1
  245 + },
  246 + {
  247 + name: '其他女歌手',
  248 + url: '/discover/artist?id=4002',
  249 + type: 2
  250 + },
  251 + {
  252 + name: '其他组合乐队',
  253 + url: '/discover/artist?id=4003',
  254 + type: 3
  255 + }
  256 + ]
  257 + }
  258 +]
不能预览此文件类型
  1 +const theme = {
  2 + color: {
  3 + primary: '#C20C0C',
  4 + secondary: '#C10D0C'
  5 + },
  6 + mixin: {
  7 + wrapv1: `
  8 + width: 1100px;
  9 + margin: 0 auto;
  10 + `
  11 + }
  12 +}
  13 +
  14 +export default theme
  1 +import React, { memo } from 'react'
  2 +import type { FC, ReactNode } from 'react'
  3 +import { AppHeaderWrapper } from './styled'
  4 +import { useNavigate } from 'react-router-dom'
  5 +
  6 +interface IProps {
  7 + children?: ReactNode
  8 +}
  9 +
  10 +const AppHeader: FC<IProps> = memo(() => {
  11 + const navigate = useNavigate()
  12 +
  13 + const loginOutHandler = () => {
  14 + localStorage.clear()
  15 + navigate('/login')
  16 + }
  17 +
  18 + return (
  19 + <AppHeaderWrapper>
  20 + <div className="flexJ box">
  21 + <div className="title flexA">宠物问诊</div>
  22 + <div className="flexA">
  23 + <img className="avatar" src="https://tupian.qqw21.com/article/UploadPic/2020-4/20204421535275855.jpg" alt="" />
  24 + <div className="username">HachimanC</div>
  25 + <div className="loginout" onClick={loginOutHandler}>
  26 + 退出登录
  27 + </div>
  28 + </div>
  29 + </div>
  30 + </AppHeaderWrapper>
  31 + )
  32 +})
  33 +
  34 +export default AppHeader
  1 +import styled from 'styled-components'
  2 +
  3 +export const AppHeaderWrapper = styled.div`
  4 + height: 65px;
  5 + background-color: #05B8D2;
  6 + font-size: 14px;
  7 + box-sizing: border-box;
  8 + padding: 20px 32px;
  9 + .title{
  10 + color: #fff;
  11 + font-size: 22px;
  12 + }
  13 + .avatar{
  14 + border-radius: 50%;
  15 + width: 40px;
  16 + height: 40px;
  17 + margin-right: 16px;
  18 + }
  19 + .username{
  20 + font-size: 20px;
  21 + color: #fff;
  22 + margin-right: 16px;
  23 + font-weight: 700;
  24 + }
  25 + .loginout{
  26 + font-size: 18px;
  27 + color: #fff;
  28 + }
  29 +`
  1 +import React from 'react'
  2 +import ReactDOM from 'react-dom/client'
  3 +import 'normalize.css'
  4 +import '@/assets/css/index.less'
  5 +import { Provider } from 'react-redux'
  6 +import { HashRouter } from 'react-router-dom'
  7 +import App from '@/App'
  8 +import store from './store'
  9 +
  10 +const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
  11 +root.render(
  12 + <Provider store={store}>
  13 + <HashRouter>
  14 + <App />
  15 + </HashRouter>
  16 + </Provider>
  17 +)
  18 +
  19 +// react-tsx 360
  20 +
  21 +// craco => create-react-app-config 配置@别名 用于配置的运行config 需要修改package (npm install @craco/craco@alpha -D)
  22 +/*
  23 + "start": "react-scripts start",
  24 + "build": "react-scripts build",
  25 + "test": "react-scripts test",
  26 + ↓替换为
  27 + "start": "craco start",
  28 + "build": "craco build",
  29 + "test": "craco test",
  30 +*/
  31 +// npm install normalize.css => 全局重置样式
  32 +// npm install craco-less => 配置 craco.config.js 来使用less
  33 +// npm install react-router-dom => react 路由
  34 +// npm install @reduxjs/toolkit react-redux => 状态管理工具
  35 +// npm install styled-components -D => 写样式
  1 +/// <reference types="react-scripts" />
  1 +import React, { lazy } from 'react'
  2 +import { Navigate } from 'react-router-dom'
  3 +import type { RouteObject } from 'react-router-dom'
  4 +
  5 +// 路由懒加载
  6 +const Discover = lazy(() => import('@/views/discover'))
  7 +const Recommend = lazy(() => import('@/views/discover/view/recommend'))
  8 +const Login = lazy(() => import('@/views/login'))
  9 +
  10 +const routes: RouteObject[] = [
  11 + { path: '/', element: <Navigate to={'/login'} /> },
  12 + { path: '/login', element: <Login /> },
  13 + {
  14 + path: '/discover',
  15 + element: <Discover />,
  16 + children: [
  17 + { path: '/discover', element: <Navigate to={'/discover/recommend'} /> },
  18 + { path: '/discover/recommend', element: <Recommend /> },
  19 + ]
  20 + },
  21 +]
  22 +
  23 +export default routes
  1 +// service统一出口
  2 +import HYRequest from './request'
  3 +import { BASE_URL, TIME_OUT } from './request/config'
  4 +
  5 +const hyRequest = new HYRequest({
  6 + baseURL: BASE_URL,
  7 + timeout: TIME_OUT,
  8 + headers: {},
  9 + interceptors: {
  10 + requestInterceptor: (config) => {
  11 + return config
  12 + },
  13 + requestInterceptorCatch: (err) => {
  14 + return err
  15 + },
  16 + responseInterceptor: (res) => {
  17 + return res
  18 + },
  19 + responseInterceptorCatch: (err) => {
  20 + return err
  21 + }
  22 + }
  23 +})
  24 +
  25 +export default hyRequest
  1 +const BASE_URL = 'http://codercba.com:9002/'
  2 +const TIME_OUT = 10000
  3 +
  4 +console.log(process.env)
  5 +console.log(process.env.REACT_APP_AGE)
  6 +
  7 +export { BASE_URL, TIME_OUT }
  1 +import axios from 'axios'
  2 +import type { AxiosInstance } from 'axios'
  3 +import type { HYRequestInterceptors, HYRequestConfig } from './type'
  4 +
  5 +const DEAFULT_LOADING = true
  6 +
  7 +class HYRequest {
  8 + instance: AxiosInstance
  9 + interceptors?: HYRequestInterceptors
  10 + showLoading: boolean
  11 +
  12 + constructor(config: HYRequestConfig) {
  13 + // 创建axios实例
  14 + this.instance = axios.create(config)
  15 +
  16 + // 保存基本信息
  17 + this.showLoading = config.showLoading ?? DEAFULT_LOADING
  18 + this.interceptors = config.interceptors
  19 +
  20 + // 使用拦截器
  21 + // 1.从config中取出的拦截器是对应的实例的拦截器
  22 + this.instance.interceptors.request.use(
  23 + // this.interceptors?.requestInterceptor,
  24 + this.interceptors?.requestInterceptorCatch
  25 + )
  26 + this.instance.interceptors.response.use(
  27 + this.interceptors?.responseInterceptor,
  28 + this.interceptors?.responseInterceptorCatch
  29 + )
  30 +
  31 + // 2.添加所有的实例都有的拦截器
  32 + this.instance.interceptors.request.use(
  33 + (config) => {
  34 + return config
  35 + },
  36 + (err) => {
  37 + return err
  38 + }
  39 + )
  40 +
  41 + this.instance.interceptors.response.use(
  42 + (res) => {
  43 + const data = res.data
  44 + if (data.returnCode === '-1001') {
  45 + console.log('请求失败~, 错误信息')
  46 + } else {
  47 + return data
  48 + }
  49 + },
  50 + (err) => {
  51 + // 例子: 判断不同的HttpErrorCode显示不同的错误信息
  52 + if (err.response.status === 404) {
  53 + console.log('404的错误~')
  54 + }
  55 + return err
  56 + }
  57 + )
  58 + }
  59 +
  60 + request<T = any>(config: HYRequestConfig<T>): Promise<T> {
  61 + return new Promise((resolve, reject) => {
  62 + // 1.单个请求对请求config的处理
  63 + if (config.interceptors?.requestInterceptor) {
  64 + config = config.interceptors.requestInterceptor(config)
  65 + }
  66 +
  67 + // 2.判断是否需要显示loading
  68 + if (config.showLoading === false) {
  69 + this.showLoading = config.showLoading
  70 + }
  71 +
  72 + this.instance
  73 + .request<any, T>(config)
  74 + .then((res) => {
  75 + // 1.单个请求对数据的处理
  76 + if (config.interceptors?.responseInterceptor) {
  77 + res = config.interceptors.responseInterceptor(res)
  78 + }
  79 + // 2.将showLoading设置true, 这样不会影响下一个请求
  80 + this.showLoading = DEAFULT_LOADING
  81 +
  82 + // 3.将结果resolve返回出去
  83 + resolve(res)
  84 + })
  85 + .catch((err) => {
  86 + // 将showLoading设置true, 这样不会影响下一个请求
  87 + this.showLoading = DEAFULT_LOADING
  88 + reject(err)
  89 + return err
  90 + })
  91 + })
  92 + }
  93 +
  94 + get<T = any>(config: HYRequestConfig<T>): Promise<T> {
  95 + return this.request<T>({ ...config, method: 'GET' })
  96 + }
  97 +
  98 + post<T = any>(config: HYRequestConfig<T>): Promise<T> {
  99 + return this.request<T>({ ...config, method: 'POST' })
  100 + }
  101 +
  102 + delete<T = any>(config: HYRequestConfig<T>): Promise<T> {
  103 + return this.request<T>({ ...config, method: 'DELETE' })
  104 + }
  105 +
  106 + patch<T = any>(config: HYRequestConfig<T>): Promise<T> {
  107 + return this.request<T>({ ...config, method: 'PATCH' })
  108 + }
  109 +}
  110 +
  111 +export default HYRequest
  1 +import type { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
  2 +
  3 +export interface HYRequestInterceptors<T = AxiosResponse> {
  4 + requestInterceptor?: (config: AxiosRequestConfig) => AxiosRequestConfig
  5 + requestInterceptorCatch?: (error: any) => any
  6 + responseInterceptor?: (res: T) => T
  7 + responseInterceptorCatch?: (error: any) => any
  8 +}
  9 +
  10 +export interface HYRequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  11 + interceptors?: HYRequestInterceptors<T>
  12 + showLoading?: boolean
  13 +}
  1 +import { configureStore } from "@reduxjs/toolkit";
  2 +import { useSelector, useDispatch, TypedUseSelectorHook, shallowEqual } from 'react-redux'
  3 +import counterReducer from './modules/counter'
  4 +
  5 +const store = configureStore({
  6 + reducer: {
  7 + counter: counterReducer
  8 + }
  9 +})
  10 +
  11 +type GetStateFnType = typeof store.getState
  12 +type RootState = ReturnType<GetStateFnType>
  13 +type DispatchType = typeof store.dispatch
  14 +
  15 +// 拿到 redux 内定义的变量的类型
  16 +export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
  17 +export const useAppDispatch: () => DispatchType = useDispatch
  18 +export const shallowEqualApp = shallowEqual
  19 +
  20 +export default store
  1 +import { createSlice } from '@reduxjs/toolkit'
  2 +
  3 +const counterSlice = createSlice({
  4 + name: 'counter',
  5 + initialState: {
  6 + count: 100,
  7 + message: 'hello Redux',
  8 + name: 'HachimanC'
  9 + },
  10 + reducers: {
  11 + changeMessage(state, { payload }) {
  12 + state.message = payload
  13 + }
  14 + }
  15 +})
  16 +
  17 +export default counterSlice.reducer
  18 +
  19 +export const { changeMessage } = counterSlice.actions
  1 +import React, { Suspense, memo } from 'react'
  2 +import type { FC, ReactNode } from 'react'
  3 +import { NavLink, Outlet } from 'react-router-dom'
  4 +import { DiscoverWrapper } from './style'
  5 +import { discoverMenu } from '@/assets/data/local-data'
  6 +
  7 +interface IProps {
  8 + children?: ReactNode
  9 +}
  10 +
  11 +const Discover: FC<IProps> = memo(() => {
  12 + return (
  13 + <DiscoverWrapper>
  14 + <Suspense fallback="二级路由渲染">
  15 + <Outlet />
  16 + </Suspense>
  17 + </DiscoverWrapper>
  18 + )
  19 +})
  20 +
  21 +export default Discover
  1 +import styled from 'styled-components'
  2 +
  3 +export const DiscoverWrapper = styled.div`
  4 + .top {
  5 + height: 30px;
  6 + background-color: #c20c0c;
  7 + }
  8 +
  9 + .nav {
  10 + display: flex;
  11 + padding-left: 180px;
  12 + position: relative;
  13 + top: -4px;
  14 +
  15 + .item {
  16 + a {
  17 + display: inline-block;
  18 + height: 20px;
  19 + line-height: 20px;
  20 + padding: 0 13px;
  21 + margin: 7px 17px 0;
  22 + color: #fff;
  23 + font-size: 12px;
  24 +
  25 + &:hover,
  26 + &.active {
  27 + text-decoration: none;
  28 + background-color: #9b0909;
  29 + border-radius: 20px;
  30 + }
  31 + }
  32 + }
  33 + }
  34 +`
  1 +import hyRequest from '@/service'
  2 +import React, { memo, useEffect } from 'react'
  3 +import type { FC, ReactNode } from 'react'
  4 +
  5 +interface IProps {
  6 + children?: ReactNode
  7 +}
  8 +
  9 +const Recommend: FC<IProps> = memo(() => {
  10 + useEffect(() => {
  11 + hyRequest.get({ url: '/banner' }).then((res) => {
  12 + console.log(res, 'banner')
  13 + })
  14 + }, [])
  15 +
  16 + return <div>Recommend</div>
  17 +})
  18 +
  19 +export default Recommend
  1 +import React, { memo, useState } from 'react'
  2 +import type { FC, ReactNode } from 'react'
  3 +import { LoginWrapper } from './style'
  4 +import { Input, Button } from 'antd'
  5 +import { useNavigate } from 'react-router-dom'
  6 +
  7 +interface IProps {
  8 + children?: ReactNode
  9 +}
  10 +
  11 +const Login: FC<IProps> = memo(() => {
  12 + const naviate = useNavigate()
  13 +
  14 + const loginHandler = () => {
  15 + setLoadingState(true)
  16 +
  17 + setTimeout(() => {
  18 + setLoadingState(false)
  19 +
  20 + naviate('/discover')
  21 + }, 2000)
  22 + }
  23 +
  24 + const [loadingState, setLoadingState] = useState<boolean>(false)
  25 +
  26 + return (
  27 + <LoginWrapper>
  28 + <div className="loginBox">
  29 + <div className="title flexC">宠物问诊-兽医端</div>
  30 + <div className="subtitle">账号</div>
  31 + <Input placeholder="请输入手机号" className="inputbox" />
  32 + <div className="subtitle">验证码</div>
  33 + <Input placeholder="请输入密码" className="inputbox" suffix={<div style={{ color: '#05b8d2', fontSize: '17px' }}>获取验证码</div>} />
  34 + <Button className="loginbtn" onClick={loginHandler} loading={loadingState}>
  35 + 登录
  36 + </Button>
  37 + </div>
  38 + </LoginWrapper>
  39 + )
  40 +})
  41 +
  42 +export default Login
  1 +import styled from "styled-components";
  2 +
  3 +export const LoginWrapper = styled.div`
  4 + width: 100vw;
  5 + height: 100vh;
  6 + background-image: url('https://ts1.cn.mm.bing.net/th/id/R-C.8f9f83c84d633dc5d17a781d738fe59b?rik=4ibUxRtKgf1BvQ&riu=http%3a%2f%2fsc.68design.net%2fqita7%2fXCBJ%2fimages%2fwcxg_7003.jpg&ehk=7xSC12DDLVz37SiFWtnCtnxu8aIFD3MS9XZ9sShACEc%3d&risl=&pid=ImgRaw&r=0');
  7 + background-position: center center;
  8 + background-repeat: no-repeat;
  9 + background-attachment: fixed;
  10 + background-size: cover;
  11 + .ant-input{
  12 + background: #F7F8FA;
  13 + }
  14 +
  15 + .loginBox{
  16 + position: fixed;
  17 + top: 20%;
  18 + left: 50%;
  19 + transform: translate(-50%);
  20 + padding: 65px 83px;
  21 + border-radius: 12px;
  22 + background: #FFF;
  23 + box-shadow: 0 15px 54px 0 #1a4fa70d;
  24 + .title{
  25 + color: #000000e6;
  26 + font-size: 32px;
  27 + font-weight: 700;
  28 + margin-bottom: 50px;
  29 + }
  30 + .inputbox{
  31 + background: #F7F8FA;
  32 + margin-bottom: 24px;
  33 + border: none;
  34 +
  35 + }
  36 + .subtitle{
  37 + color: #000000e6;
  38 + font-size: 20px;
  39 + font-weight: 700;
  40 + margin-bottom: 12px;
  41 + }
  42 + .loginbtn{
  43 + background: '#05B8D2' !important;
  44 + width: 100%;
  45 + height: 58px;
  46 + border-radius: 8px;
  47 + background: #05B8D2;
  48 + color: #ffffff;
  49 + font-size: 18px;
  50 + font-weight: 700;
  51 + }
  52 + }
  53 +`
  1 +// 定义函数的调用签名
  2 +interface IFnCall<IRoot> {
  3 + <T>(fn: (num: IRoot) => T, age: number): T
  4 +}
  5 +
  6 +// 定义函数对象
  7 +const foo: IFnCall<number> = function (fn, age) {
  8 + return fn(111)
  9 +}
  10 +
  11 +// 调用函数
  12 +foo<string>(() => {
  13 + return '123'
  14 +}, 18)
  15 +
  16 +// 不传入明确的调用时的泛型,类型推荐
  17 +const res = foo((aaa) => {
  18 + return '123'
  19 +}, 18)
  1 +{
  2 + "compilerOptions": {
  3 + "target": "es5",
  4 + "lib": [
  5 + "dom",
  6 + "dom.iterable",
  7 + "esnext"
  8 + ],
  9 + "allowJs": true,
  10 + "skipLibCheck": true,
  11 + "esModuleInterop": true,
  12 + "allowSyntheticDefaultImports": true,
  13 + "strict": true,
  14 + "forceConsistentCasingInFileNames": true,
  15 + "noFallthroughCasesInSwitch": true,
  16 + "module": "esnext",
  17 + "moduleResolution": "node",
  18 + "resolveJsonModule": true,
  19 + "isolatedModules": true,
  20 + "noEmit": true,
  21 + "jsx": "react-jsx",
  22 + "baseUrl": ".",
  23 + "paths": {
  24 + "@/*": [
  25 + "src/*"
  26 + ]
  27 + }
  28 + },
  29 + "include": [
  30 + "src"
  31 + ]
  32 +}