Egg + React 全栈开发记账本---前端页面代码

Overview

Egg + React 全栈开发记账本---前端页面代码

前端页面使用Vite 2.0 + React + ZarmUI 搭建 H5 开发环境

后台服务代码https://github.com/Willmind/cash_book-server

项目启动

# 进入项目文件夹
cd react-vite-h5

# 安装依赖
cnpm install

# 项目运行
npm run dev
使用浏览器打开http://localhost:3000/,默认账号密码是nick/1

# 前端项目打包
npm run build

项目预览

image image

项目结构树

└── react-vite-h5
    ├── dist
    │   └── assets
    └── src
        ├── components  # 组件
        │   ├── BillItem  # 账单列
        │   ├── CustomIcon	# 图标
        │   ├── Empty	# 空状态
        │   ├── Header	# 头部烂
        │   ├── NavBar	# 底部栏
        │   ├── PopupAddBill	# 添加账单弹框
        │   ├── PopupDate	# 时间选择弹框
        │   └── PopupType	# 类型选择弹框
        ├── config
        ├── container
        │   ├── Account  # 个人中心
        │   ├── Data	# 数据
        │   ├── Detail	# 数据详情
        │   ├── Home	# 首页
        │   ├── Login	# 登录
        │   ├── User	# 用户
        │   └── UserInfo	# 用户信息
        ├── router	# 路由
        └── utils	 # 常用状态和工具

项目知识点

  • 单页面应用实践
  • 前端构建工具 Vite
  • 前端框架 React 和路由 react-router-dom
  • React Hooks 钩子函数
  • CSS 预加载器 Less
  • HTTP 请求库 axios
  • 组件设计封装
  • 跨域代理
  • 移动端适配 lib-flexible、postcss-pxtorem

React Hooks

React 早期的写法以 Class 类组件为主,附带一些纯用于展示的函数组件,但是函数组件是不能控制自身的状态的. 引入全新的 Hooks 写法,如 useEffect、useState、useRef、useCallback、useMemo、useReducer 等等,通过这些钩子函数来管理函数组件的各自状态

vite 构建工具

下一代前端开发与构建工具

  • 快速启动,Vite 会在本地启动一个开发服务器,来管理开发环境的资源请求
  • 相比 Webpack 的开发环境打包构建,它在开发环境下是无需打包的,热更新相比 Webpack 会快很多
  • 原生 ES Module,要什么就当场给你什么。而 Webpack 则是先将资源构建好之后,再根据你的需要,分配给你想要的资源

CSS 预处理器 Less

项目中采用的 Less 作为 CSS 预处理器,它能设置变量以及一些嵌套逻辑,便于项目的样式编写。

移动端项目适配 rem

使用lib-flexible,当我们手机变成其他尺寸的时候,这个 font-size 的值也会变化,这是 flexible 起到的作用
然后再安装一个 postcss-pxtorem,它的作用是在你编写完 css 后,将你的单位自动转化为 rem 单位。
动态的变化 html 的 font-size 的值,从而让 1rem 所对应的 px 值一直都是动态适应变化的。

跨域代理配置

resolve.alias 别名设置

二次封装 axios

  • 配置环境变量,判断当前代码运行在开发环境还是生产环境
  • 配置基础路径
  • 配置请求头,配置Authorizationtoken来让我们在服务端鉴权的时候使用
  • 配置get/post请求体
  • 设置拦截器,统一判断请求内容

引入 Zarm UI 组件库并按需加载

You might also like...

React Gatsby static web tool for generative artists working on token based NFT artwork (ex: Artblocks)

React Gatsby static web tool for generative artists working on token based NFT artwork (ex: Artblocks)

token-art-tools React Gatsby static web tool for generative artists working on token/hash based NFT artwork (ex: Artblocks) https://ctrlshiftmake.gith

Dec 15, 2022

Build a Full Stack Marketplace on Ethereum with React, Solidity, Hardhat, and Ethers.js

Build a Full Stack Marketplace on Ethereum with React, Solidity, Hardhat, and Ethers.js

Building a Digital Marketplace on Ethereum The technologies used in this workshop are React, Next.js, Tailwind CSS, HardHat, Solidity, and Ethers. Get

Nov 15, 2022

A nonsensical React application made (almost) entirely by GitHub Copilot

GitHub Copilot Demo This is a demo project for the GitHub Copilot project. The previous sentence was written by it! This is a (fairly ugly) timer app

May 1, 2022

Algorithm visualizer made with React, Material UI and P5JS.

Algorithm visualizer made with React, Material UI and P5JS.

Made with React, P5JS and Material UI. Link https://andresrodriguez55.github.io/algorithmsVisualizer/#/ Description The purpose of doing this was to l

Nov 22, 2022

Solana blockchain candy machine app boilerplate on top of Metaplex Candy Machine. NextJS, Tailwind, Anchor, SolanaLabs.React, dev/mainnet automation scripts.

NFT Candy Factory NOTE: This repo will prob only work on unix-based environments. The NFT Candy Factory project is designed to let users fork, customi

Dec 30, 2022

基于React开发的新一代web调试工具,支持React组件调试,类似于Chrome Devtools。A Lightweight, Easy To Extend Web Debugging Tool Build With React

基于React开发的新一代web调试工具,支持React组件调试,类似于Chrome Devtools。A Lightweight, Easy To Extend Web Debugging Tool Build With React

English | 简体中文 基于React开发的移动web调试工具 更新日志 简单易用 功能全面 易扩展 高性能 使用cdn方式,一键接入 类Chrome devtools, 内嵌React开发者工具,支持日志,网络,元素,代理,存储,性能等, 具有更好的网络捕获能力和丰富的日志展现形式 暴露内部

Dec 25, 2022

This is a cloned website of the official tesla page built with react js

TESLA-CLONE This is a cloned website of the official tesla page built with react js. The page has simillar sections which made duplicating these secti

Nov 7, 2022

Website to present projects made by me and that are part of my personal portfolio. It was made using React, HTML y Scss (CSS).

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Dec 23, 2021

🎸A guitar partice website based on react.js🎸

Guitar-Editor A simple guitar chords editor based on react.js The chords component based on canvas tech. ScreenShot Directory ├── README.md ├── Screen

Dec 19, 2021
Owner
谭志锦
web前端开发工程师
谭志锦
A quick start Create React App template with react-router-dom, material-ui, gh-pages and firebase

A quick start Create React App template with react-router-dom, material-ui, gh-pages and firebase. With google authentication, routing and deployment capabilities built in.

Hussain Pettiwala 5 Feb 22, 2022
(🔗, 🌲) Web3 Link Tree is a free & open-source alternative to Linktree built with React.js, Next.js, Tailwind and Web3-React

Getting Started Read the detailed guide here Customize Add your name, wallet address, social media links and more in config.ts Images Save images to t

Naut 35 Sep 20, 2022
A free book that talks about design patterns/techniques used while developing with React.

React in patterns ?? A free book that talks about design patterns/techniques used while developing with React. Book GitBook Web PDF Mobi ePub Translat

Krasimir Tsonev 12.2k Dec 30, 2022
A new Node.js resource built using Gatsby.js with React.js, TypeScript, and Remark.

Nodejs.dev Nodejs.dev site built using Gatsby.js with React.js, TypeScript, SCSS, and Remark. You can find the latest Figma design protype here. ?? Ge

Node.js 2.2k Jan 5, 2023
Atividade do Módulo 03 - Especialização em Front-end - Turma 01; Criação de uma API de Rick and Morty com React.js.

Screenshots Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you

Daniela 0 Dec 1, 2021
vite-react-typescript with eslint and prettier predefined settings

Vite + React + Typescript + Eslint + Prettier A starter for React with Typescript with the fast Vite and all static code testing with Eslint and forma

The Sword Breaker 315 Dec 30, 2022
Shopping cart built with React

Shopping Cart In this project, I performed operations such as listing products, adding products to the cart and removing products from the cart, which

Efecan Pınar 6 Jun 17, 2021
A demo of LaunchDarkly, React, and Vite, using the Pokémon API!

Pokémon Feature Flags demo Here's a demo for integrating feature flags into a React project! Built with React, Vite, the PokeAPI, and LaunchDarkly! Wh

Cassidy Williams 15 Jan 5, 2022
This is the FARM Stack course, where you are going to learn how to build an application from scratch using FASTAPI, React and mongoDB

FARM-Stack-Course This is the FARM Stack course, where you are going to learn how to build an application from scratch using FASTAPI, React and mongoD

Bek Brace 121 Jan 2, 2023
🕹 GBA emulator on your React project - easy and powerful to use!

GBA emulator on your React project - easy and powerful to use! Just three steps to set it up ✨ 1 - Apply GbaProvider import { GbaProvider } from 'reac

Bruno Macabeus 43 Dec 23, 2022