Git Product home page Git Product logo

xiangshu233 / vue3-vant4-mobile Goto Github PK

View Code? Open in Web Editor NEW
364.0 10.0 85.0 469 KB

👋👋👋 基于Vue3.4、Vite5、Vant4、Pinia、Typescript、UnoCSS等主流技术开发,集成 Dark Mode(暗黑)模式和系统主题色,且持久化保存,集成 Mock 数据,包括登录/注册/找回/keep-alive/Axios/useEcharts/IconSvg等其他扩展。你可以在此之上直接开发你的业务代码!

Home Page: https://vvmobile.xiangshu233.cn

License: MIT License

JavaScript 5.76% TypeScript 58.77% HTML 1.92% Vue 28.07% Less 3.54% CSS 1.94%
android mobile-web pinia typescript vant-ui vant4 vite vue3 vuejs less

vue3-vant4-mobile's Introduction



license version repo-size languages issues

vue3-vant4-mobile

Stargazers over time

Stargazers over time

介绍

👋👋👋 Vue3 Vant4 Mobile 使用了最新的 Vue3.4Vite5Vant4PiniaTypeScriptUnoCSS 等主流技术开发,集成 Dark Mode(暗黑)模式和系统主题色,并且持久化保存,集成 Mock 数据,顺便写了登录/注册/找回密码 页面(包括逻辑),只需替换你的 API 即可,另外页面均可以 <keep-alive>,随便写了个包含 NavBarTabBar 的 Layout,集成了 AxiosuseEChartsIconSvg

项目使用了 antfu 大佬的 antfu/eslint-config 作为代码规范检查工具,摆脱繁琐无聊的 Eslint 配置,配合 cz-gitlint-stagedsimple-git-hooks可对暂存区代码提交校验,代码风格不合格可打断提交,保证多人协作开发时上游 Git 库的干净。

现在你可以在此之上直接开发你的业务代码!希望你能喜欢!

截图预览

登录页面 主控台页(首页)
消息页(图标页) 我的(我的信息页面)
展开预览暗黑模式下的界面截图
登录页面(暗黑模式) 主控台页(暗黑模式)
我的页面(暗黑模式) 主题设置页面(暗黑模式)

线上预览

预览链接:https://vvmobile.xiangshu233.cn/

账号:admin,密码:123456

账号:test,密码:123456

或者扫描以下二维码进入手机演示

基础知识

  • Vite - 熟悉 Vite 特性
  • Vue3 - 熟悉 Vue3 基础语法
  • Vant4 - 掌握 vant4 组件基本使用
  • Pinia - 熟悉 Pinia 特性
  • TypeScript - 熟悉 TypeScript 基本语法
  • Vue-Router-Next - 熟悉 Vue-Router基本使用
  • ECharts5 - 熟悉 Echarts 基本使用
  • Iconify - 本项目推荐图标库,当然你也可以使用 IconSvg
  • Postcss-Mobile-Forever - 了解手机端 pxviewport 插件的作用
  • Lodash-es - JS高性能工具库
  • UnoCSS - 原子化 CSS,熟悉 UnoCSS 基本使用
  • Mock.js - 了解 Mockjs 基本语法
  • ES6+ - 熟悉 ES6 基本语法

关于 Icon 的使用

项目使用 unocssicon 预设 作为系统 Icon

请遵循以下约定使用图标

  • <prefix><collection>-<icon>
  • <prefix><collection>:<icon>
<!-- A basic anchor icon from Phosphor icons -->
<div class="i-ph-anchor-simple-thin" />
<!-- An orange alarm from Material Design Icons -->
<div class="i:mdi:alarm" />

点击这里获取所有可用的图标,找到想要的图标后点击复制 icon name 到 class 里即可

Warning

记得加 i-xxx 前缀,从 icones 复制的 icon name 是没有 i- 前缀的

更多详细使用请看 https://unocss.dev/presets/icons#icons-preset

环境准备

本地环境需要安装 PnpmNode.jsGit

  • 必须使用 pnpm>=8.6.10,否则依赖可能安装不上。
  • Node.js 版本要求18.x以上,且不能为13.x版本,这里推荐 ^20.9.0 || >=21.1.0

VS Code 配套插件

如果你使用的 IDE 是 VS Code(推荐)的话,可以安装以下工具来提高开发效率及代码格式化

VS Code Eslint 支持(自动修复)

安装 VS Code ESLint extension

将以下设置添加到您的 .vscode/settings.json 中:

{
  // Enable the ESlint flat config support
  "eslint.experimental.useFlatConfig": true,

  // Disable the default formatter, use eslint instead
  "prettier.enable": false,
  "editor.formatOnSave": false,

  // Auto fix
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never"
  },

  // Silent the stylistic rules in you IDE, but still auto fix them
  "eslint.rules.customizations": [
    { "rule": "style/*", "severity": "off" },
    { "rule": "format/*", "severity": "off" },
    { "rule": "*-indent", "severity": "off" },
    { "rule": "*-spacing", "severity": "off" },
    { "rule": "*-spaces", "severity": "off" },
    { "rule": "*-order", "severity": "off" },
    { "rule": "*-dangle", "severity": "off" },
    { "rule": "*-newline", "severity": "off" },
    { "rule": "*quotes", "severity": "off" },
    { "rule": "*semi", "severity": "off" }
  ],

  // Enable eslint for all supported languages
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "html",
    "markdown",
    "json",
    "jsonc",
    "yaml",
    "toml"
  ]
}

使用

# 获取项目代码
git clone https://github.com/xiangshu233/vue3-vant4-mobile.git

# 安装依赖
cd vue3-vant4-mobile
pnpm install

# 运行
pnpm dev

# 打包
pnpm build

Git 提交规范

提交规范

参考 vue 规范 (Angular)

  • feat 增加新功能
  • fix 修复问题/BUG
  • style 代码风格相关无影响运行结果的
  • perf 优化/性能提升
  • refactor 重构
  • revert 撤销修改
  • test 测试相关
  • docs 文档/注释
  • chore 依赖更新/脚手架配置修改等
  • workflow 工作流改进
  • ci 持续集成
  • types 类型定义文件更改
  • wip 开发中

提交校验

Tip

关于前端工程化 配置构建代码检查工作流 不了解的可以看下面这两篇文章了解下

前端工程化配置(上) 构建代码检查工作流

前端工程化配置(下) 规范仓库提交记录 commitlint + commitizen + cz-git + 配置

Important

首次 clone 代码 pnpm install 后 需要执行以下命令来更新git hooks

# Update ./git/hooks
npx simple-git-hooks

本项目提交规范校验使用 simple-git-hooks 作为 git hooks,使用 cz-git 作为 commitlint commitizen。

Important

更改的代码若想要使用 Commitlint 规范提交需要将文件(放入暂存区) git add 后,控制台执行 cz 命令开启 cz-git CLI 。若想直接执行 git commit 需要满足上面提交规范才能通过校验,否则将会被 Git Hook 打断提交

simple-git-hooks 和 husky 都是用于管理 Git 钩子(Git hooks)的工具,但它们有一些区别:

simple-git-hooks:

  • 简介: simple-git-hooks 是一个轻量级的工具,用于管理和运行Git钩子。
  • 特点:
    • 提供了简单的配置方式来定义和运行 Gi 钩子。
    • 适合于小型项目或对 Git 钩子需求不复杂的项目。
    • 相对较少的功能和配置选项。
    • 使用场景: 适用于简单的项目或对 Git 钩子管理需求不高的情况。

husky:

  • 简介: husky 是一个功能强大的工具,用于管理 Git 钩子,并且在项目中被广泛使用。
  • 特点:
    • 提供了丰富的配置选项和灵活性,可以精细地控制 Git 钩子的行为。
    • 支持在不同的 Git 钩子事件上运行自定义脚本。
    • 可以与其他工具(如linters、测试框架等)集成,实现更复杂的工作流。
    • 使用场景: 适用于需要灵活配置和管理 Git 钩子的项目,尤其是大型或复杂的项目。
// package.json
{
  "simple-git-hooks": {
    // 对暂存区执行 eslint --fix
    "pre-commit": "pnpm lint-staged",
    // 对提交信息进行校验
    "commit-msg": "npx --no-install commitlint --edit $1"
  },

  "lint-staged": {
    "*": "eslint --fix"
  }
}

浏览器支持

本地开发推荐使用Chrome 80+ 浏览器

支持现代浏览器, 不支持 IE

 Edge IE  Edge Edge Firefox Firefox Chrome Chrome Safari Safari
not support last 2 versions last 2 versions last 2 versions last 2 versions

维护者

@xiangshu233

LICENSE

MIT

vue3-vant4-mobile's People

Contributors

fairy-iu avatar wswmsword avatar xiangshu233 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue3-vant4-mobile's Issues

低版本浏览器打开空白

我尝试在一台安卓7的手机上打开项目,浏览器是谷歌56版本的,空白一片,这个怎么办呀

postcss-mobile-forever 和 windicss适配问题

postcss-mobile-forever使用的是vw,windicss使用的rem,两者存在冲突,而且在 common.less中body的 font-size: 14px;导致真实手机端显示为vw时显示太小(我使用的是iphone12),我最后还是想放弃postcss-mobile-forever,而是使用 vant中的 useWindowSize去实现适配,或者 vue-use中的useWindowSize去实现。

一个页面可能有多个get请求,ajax请求的url写死了,每次都要去修改url,不能在调用get方法的时候传入url吗

const initBaseAPIParams: BaseAPIType.IInitParams = {
uri: {
[APIMethods.GET]: {
path: 'admin/Goods/getTable', // 'data_get_detail.json'
errMsg: 'err.user.load',
// fnUrlTransfer(url, params){
// return 'data_get_detail.json'
// },
// fnParamsTransfer(url, params){
// return {
// id: 9999999,
// }
// },
},
[APIMethods.LIST]: { path: 'admin/GoodsClass/getTable', errMsg: 'err.user.load' },
[APIMethods.POST]: { path: 'admin/SystemUser/login', errMsg: '登录失败' },
},
// mapper(item: GlobalType.IRecord): IUser{
// return {
// id: get(item, 'id'),
// name: get(item, 'name111')
// }
// }
};

打包报错

node版本 :18 | 20 均已测试 运行效果相同,请问这个打包问题怎么解决呢?

node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
Error: tsx must be loaded with --import instead of --loader
The --loader flag was deprecated in Node v20.6.0
at X (file:///E:/project/2024SZLS/node_modules/.pnpm/[email protected]/node_modules/tsx/dist/esm/index.mjs:1:1920)
at Hooks.addCustomLoader (node:internal/modules/esm/hooks:202:24)
at Hooks.register (node:internal/modules/esm/hooks:168:16)
at async initializeHooks (node:internal/modules/esm/utils:167:5)
at async customizedModuleWorker (node:internal/modules/esm/worker:104:24)

Node.js v18.19.1
 ELIFECYCLE  Command failed with exit code 1.

打包后运行报错如下:
image

页面样式问题

在APP.vue中添加这个样式,在页面使用中还需要每次在根节点添加 class="h-screen flex flex-col overflow-x-hidden" 去处理内容超出滚动的问题,比较麻烦,还有其他方式吗?
<div class="absolute top-0 bottom-0 w-full overflow-hidden"> <transition :name="getTransitionName" mode="out-in" appear> <keep-alive v-if="keepAliveComponents" :include="keepAliveComponents"> <component :is="Component" /> </keep-alive> </transition> </div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.