diff --git a/.browserslistrc b/.browserslistrc deleted file mode 100644 index 1edc279..0000000 --- a/.browserslistrc +++ /dev/null @@ -1,5 +0,0 @@ -> 1% -last 2 versions -not dead -chrome > 40 -not ie 11 diff --git a/.editorconfig b/.editorconfig index d93636a..4627c3e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,38 +1,9 @@ +root=true + [*] charset=utf-8 -end_of_line=lf -insert_final_newline=false -indent_style=space -indent_size=2 - -[{*.ng,*.sht,*.html,*.shtm,*.shtml,*.htm}] -indent_style=space -indent_size=2 - -[{*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}] -indent_style=space -indent_size=2 - -[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}] -indent_style=space -indent_size=2 - -[*.svg] -indent_style=space -indent_size=2 - -[*.js.map] -indent_style=space -indent_size=2 - -[*.less] -indent_style=space -indent_size=2 - -[{*.vue,*.ts,*.tsx}] -indent_style=space -indent_size=2 - -[{.analysis_options,*.yml,*.yaml}] indent_style=space indent_size=2 +end_of_line=lf +insert_final_newline=true +trim_trailing_whitespace=true diff --git a/.env b/.env index 6d32d0d..5ce1143 100644 --- a/.env +++ b/.env @@ -1,3 +1,5 @@ VITE_APP_PUBLIC_PATH=/ VITE_APP_PREVIEW=true -VITE_APP_API_BASE_URL=/api \ No newline at end of file +VITE_APP_API_BASE_URL=/api +VITE_APP_OUT_DIR=dist +VITE_APP_VCONSOLE=false diff --git a/.env.development b/.env.development index 19c8495..8d06b22 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ +NODE_ENV=development VITE_APP_PREVIEW=true VITE_APP_API_BASE_URL=/api -VITE_HTTP_MOCK=true \ No newline at end of file diff --git a/.env.production b/.env.production index b2daa6a..7d43c3e 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,2 @@ -NODE_ENV=production VITE_APP_PREVIEW=false -VITE_APP_API_URL=/api \ No newline at end of file +VITE_APP_API_BASE_URL=https://easyapi.devv.zone/api diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index db4c6d9..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -dist -node_modules \ No newline at end of file diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 98b5fd0..0000000 --- a/.eslintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": [ - "@antfu" - ], - - "rules": { - "brace-style": "off", - "@typescript-eslint/brace-style": "off" - } -} diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..eb0b6d4 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,77 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to make participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [18888351756@163.com]. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e7fc939 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set node + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - run: npx conventional-github-releaser -p angular + env: + CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.gitignore b/.gitignore index fe39c84..3c1f26a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ dist-ssr stats.html # Editor directories and files -.vscode/extensions.json .idea *.suo *.ntvs* @@ -24,3 +23,4 @@ stats.html # Misc .DS_Store +.history diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index cd4483a..0000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -node scripts/verifyCommit.js diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index e9884e8..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -pnpm run lint diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..bf2e764 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +shamefully-hoist=true diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..a497cdf --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,12 @@ +{ + "recommendations": [ + "Vue.volar", + "antfu.unocss", + "antfu.goto-alias", + "antfu.iconify", + "antfu.file-nesting", + "lokalise.i18n-ally", + "blueglassblock.better-json5", + "dbaeumer.vscode-eslint" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index cb0d092..87c793c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,66 @@ { + // Disable the default formatter, use eslint instead "prettier.enable": false, "editor.formatOnSave": false, + + // Auto fix "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "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", "fixable": true }, + { "rule": "format/*", "severity": "off", "fixable": true }, + { "rule": "*-indent", "severity": "off", "fixable": true }, + { "rule": "*-spacing", "severity": "off", "fixable": true }, + { "rule": "*-spaces", "severity": "off", "fixable": true }, + { "rule": "*-order", "severity": "off", "fixable": true }, + { "rule": "*-dangle", "severity": "off", "fixable": true }, + { "rule": "*-newline", "severity": "off", "fixable": true }, + { "rule": "*quotes", "severity": "off", "fixable": true }, + { "rule": "*semi", "severity": "off", "fixable": true } + ], + + // Enable eslint for all supported languages + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "html", + "markdown", + "json", + "json5", + "jsonc", + "yaml", + "toml", + "xml", + "gql", + "graphql", + "astro", + "svelte", + "css", + "less", + "scss", + "pcss", + "postcss" + ], + + // Configuration of i18n i18n-ally + "i18n-ally.enabledParsers": ["json"], + "i18n-ally.displayLanguage": "zh-CN", + "i18n-ally.localesPaths": [ + "src/locales" + ], + "i18n-ally.keystyle": "nested", + + // Markdownlint rules + "markdownlint.config": { + "default": true, + "MD033": false, + "MD041": false } } diff --git a/Guide-zh_CN.md b/Guide-zh_CN.md deleted file mode 100644 index 94f9079..0000000 --- a/Guide-zh_CN.md +++ /dev/null @@ -1,164 +0,0 @@ -

使用指南

- -

指南非常地详细,并非说明上手多么地复杂,只是更好的使用它做的说明而已

- -简体中文 / [English](./Guide.md) - -### 开始使用 - -本模板采用2023年最新技术栈开发,汇聚了 Vue 生态最新工具流,包括不限于 Vue3、Vite4、Pinia2、Vitest、TypeScript,前端组件库选用接受度最高的 Vant4 (按需使用)进行搭建,开发者可以在此基础模板之上,快速构建移动端应用。 - -### 包管理器 - -推荐使用 [pnpm](https://pnpm.io/) 来进行包管理,可以极大地减少install时间, 而且非常节省磁盘空间。 - -### 目录结构 - -下面是模板的主要目录结构和一些简要地说明。 - -``` -├── .husky -│ └── commit-msg # commit 信息校验 -| └── pre-commit # eslint 代码检验 -├── src -│ ├── api # Api ajax 等 -│ ├── assets # 本地静态资源 -│ ├── layouts # 封装布局组件 -│ ├── components # 业务通用组件和基础布局组件 -│ ├── router # Vue-Router -│ ├── store # Pinia -│ ├── utils # 工具库 -│ ├── views # 业务页面入口和常用模板 -│ ├── App.vue # Vue 模板入口 -│ └── main.ts # Vue 入口 JS -│ └── app.less # 全局样式 -│ └── env.d.ts # 全局公用 TypeScript 类型 -├── build/mock # mock 服务 -├── mock # mock 数据 -├── plop-templates # 代码块生成 -├── public # 静态文件 -├── scripts # 公共执行脚本 -├── tests # 单元测试 -├── plopfile.js # plop 入口 -├── auto-imports.d.ts # Vue3 组合式API 类型声明文件 -├── components.d.ts # 组件自注册类型声明文件 -├── vite.config.ts # Vite 配置文件 -├── tsconfig.json # TS 配置文件 -├── index.html # 浏览器渲染入口 -├── Guide.md # 使用指南 -├── README.md # 简单介绍 -└── package.json # 项目的依赖 -``` - -### 本地开发 - -克隆原仓库的代码到本地。 - -```bash -git clone https://github.com/CharleeWa/vue3-vant-mobile.git -``` - -进入代码目录,安装项目的依赖。 - -```bash -cd vue3-vant-mobile - -# with pnpm -pnpm install - -``` - -> 如果网络状况不佳,可以设置 pnpm 的 npm 加载源,如 pnpm config set registry https://registry.npmmirror.com - -完成前面的步骤以后,就可以启动项目,开始进行业务开发了。 - -```bash -pnpm dev -``` - -### 新增页面 - -这里的『页面』指配置了路由,能够通过链接直接访问的模块,要新建一个页面,通常只需要在脚手架的基础上进行简单的配置。 - -脚手架除了手动创建以外,还集成了 `plop`,一种代码片段快速生成插件,避免重复拷贝粘贴工作。 - -- 命令式创建 - -这里已经为大家预置了两种:`view` 和 `component`,选择一个之后按回车键就可以在项目目录的左侧看到了。 - -```bash -pnpm plop -``` - -- 手动创建 - -在 src/views 下新建页面的vue文件,如果相关页面有多个,可以新建一个文件夹来放置相关文件。 - -值得提醒的是,样式文件默认使用 `Less`,如果想要集成其它预处理器,如 `Sass` 和 `Stylus`,请自行安装。 - -最后,记得将新建的文件加入路由 - router/index.ts - - -### 新增业务组件 - -对于一些可能被多处引用的功能模块,建议提炼成业务组件统一管理。这些组件一般有以下特征: - -- 只负责一块相对独立,稳定的功能; -- 没有单独的路由配置; -- 可能是纯静态的,也可能包含自己的 state,但不涉及 pinia 的数据流,仅受父组件(通常是一个页面)传递的参数控制。 - -这里以一个简单的静态组件为例进行介绍。假设你的应用中经常需要展现图片,这些图片有固定的高度和宽度,有背景颜色,还有一段文字介绍。你可以用一个组件来实现这个功能,它有默认的样式,同时可以接收父组件传递过来的参数进行展示。 - -- 1、新建文件 - -在 src/components 下新建一个以组件名命名的文件夹,注意首字母大写,命名尽量体现组件的功能,这里就叫 image-wrapper。在此文件夹下新增 js/ts/vue 文件及样式文件(如果需要),命名为 index.ts和 index.less。 - -> 如果你的组件比较复杂,可以分为多个文件,最后在 index.ts 中统一 export。 - -你的代码大概是这个样子: - -``` - - - -``` - -- 2、使用 - -在要使用这个组件的地方,按照组件定义的 API 传入参数,直接使用就好: - -``` - - - -``` - -值得说明的是,我们不必先引入组件再使用组件,也不必先引入Vue3 API再使用API,因为这一切都由 `unplugin-vue-components` 和 `unplugin-auto-import` 帮我们做好了。 diff --git a/Guide.md b/Guide.md deleted file mode 100644 index 4167cd9..0000000 --- a/Guide.md +++ /dev/null @@ -1 +0,0 @@ -待完成 \ No newline at end of file diff --git a/LICENSE b/LICENSE index 809a518..b633e56 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Charlie Wang +Copyright (c) 2025 Charlie Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README-zh_CN.md b/README-zh_CN.md deleted file mode 100644 index 32383d3..0000000 --- a/README-zh_CN.md +++ /dev/null @@ -1,136 +0,0 @@ -

- logo -

- -

Vue3-Vant-Mobile

- -

一个集成 Vue3、Vite4、Vant4、Pinia2、Vitest、TypeScript 构建的移动端模板

- -

- license - version - repo-size - languages - issues -

- -简体中文 / [English](./README.md) , [使用指南](./Guide-zh_CN.md) / [English Guide](./Guide.md) - -## 介绍 - -🔥🔥🔥 这是一个基于 `Vue3`, `Vite4`, `Vant4`, `Pinia2`, `Vitest`, `TypeScript` 构建的移动端模板。 🚀🚀🚀 它集成了`Plop`用于生成各种类型的代码块,同时还提供了 `Dark Mode`(暗黑模式)配置以及 `Mock` 数据等其他方便的扩展功能。💖💖💖 简而言之,它简洁、简单、易用,可供参考,能够帮助您节省一周的开发时间,希望您会喜欢。 - -## 成就 - -🎉🎉🎉 被添加到 [Awesome Vite.Js](https://github.com/vitejs/awesome-vite#vue-3) - -## 特性 - -- 🌓 支持暗黑模式 -- 💪 使用TypeScript编写 -- 🚀 Vue3 生态开箱即用 -- 🤖 自动导入组件 -- 📄 使用plop轻松创建文件 -- 📦 使用pnpm包管理器 -- 💾 支持Mock服务器 -- 🌈 支持Git hooks(lint和commit) -- 💖 移动端UI组件(Vant4) -- 🍍 Pinia,Vue的状态管理库 - -## 安装与使用 - -- 获取项目代码 - -```bash -git clone https://github.com/CharleeWa/vue3-vant-mobile.git -``` - -- 安装依赖 - -```bash -cd vue3-vant-mobile - -# with pnpm -pnpm install - -``` - -- 运行 - -```bash -pnpm dev -``` - -- 打包构建 - -```bash -pnpm build -``` - -## 浏览器支持 - -支持现代浏览器 - -| [ Edge](http://godban.github.io/browsers-support-badges/)
IE | [ Edge](http://godban.github.io/browsers-support-badges/)
Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | -| :-: | :-: | :-: | :-: | :-: | -| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions | - -## 贡献者 - - - - - - - - - - - -
- - CharleeWa -
- Charlie Wang -
-
- - weiq -
- 魏小雨 -
-
- - AlphaYoung -
- AlphaYoung -
-
- - Leezon -
- Leezon -
-
- - liuNing -
- liuNing -
-
- - wswmsword -
- wswmsword -
-
- - Kysen -
- Kysen -
-
- -## 许可证 - -♥️ [MIT](https://en.wikipedia.org/wiki/MIT_License) diff --git a/README.md b/README.md index 9be93c7..db5f86b 100644 --- a/README.md +++ b/README.md @@ -1,136 +1,238 @@ -

- logo -

+
-

Vue3-Vant-Mobile

+cover -

Mobile Template built on Vue3、Vite4、Vant4、Pinia2、Vitest、TypeScript

+

vue3-vant-mobile

-

- license - version - repo-size - languages - issues -

+English / [简体中文](./README.zh-CN.md) -English / [简体中文](./README-zh_CN.md) , [使用指南](./Guide-zh_CN.md) / [English Guide](./Guide.md) +An mobile web apps template based on the Vue 3 ecosystem. -## Introduction +一个基于 Vue 3 生态系统的移动 web 应用模板,帮助你快速完成业务开发。 -🔥🔥🔥 Vue3 Vant Mobile based on `Vue3`, `Vite4`, `Vant4`, `Pinia2`, `Vitest`, `TypeScript`; 🚀🚀🚀 Integrate `Plop` to generate any type of code block, integrate `Dark Mode` (Dark) configuration, integrate `Mock` data, and other handy extensions. 💖💖💖 In short, clean, simple, easy to use, reference, can save you a week of development time, hope you like it. +

+license +version +repo-size +languages +issues +

-## Achievement +[🌐预览](https://vue3-vant-mobile.netlify.app) / [📖文档](https://easy-temps.github.io/easy-docs/vue3-vant-mobile/) / [🗨️交流](https://github.com/easy-temps/vue3-vant-mobile/issues/56) / [📝反馈](https://github.com/easy-temps/vue3-vant-mobile/issues) -🎉🎉🎉 Added to the [Awesome Vite.Js](https://github.com/vitejs/awesome-vite#vue-3) +Ask DeepWiki [![Netlify Status](https://api.netlify.com/api/v1/badges/e6828bd2-2904-4c3e-a67c-b97d32aa1275/deploy-status)](https://app.netlify.com/sites/vue3-vant-mobile/deploys) + +
+ +
## Features -- 🌓 Support Dark Mode -- 💪 Written in TypeScript -- 🚀 Support Vue 3 out-of-the-box -- 🤖 Auto Importing components -- 📄 Easy to create files (plop) -- 📦 Using pnpm package manager -- 💾 Support Mock server -- 🌈 Support Git hooks (lint and commit) -- 💖 Mobile UI Components (Vant4) -- 🍍 Pinia, Store for Vue +- ⚡️ [Vue 3](https://github.com/vuejs/core), [Vite 6](https://github.com/vitejs/vite), [pnpm](https://pnpm.io/), [esbuild](https://github.com/evanw/esbuild) - born with fastness + +- 🗂 [File based routing](./src/router) + +- 📦 [Components auto importing](./src/components) + +- 🍍 [State Management via Pinia](https://pinia.vuejs.org) + +- 📲 [PWA](https://github.com/antfu/vite-plugin-pwa) + +- 🎨 [UnoCSS](https://github.com/antfu/unocss) - the instant on-demand atomic CSS engine + +- 🌍 [I18n ready](./src/locales) + +- 🔥 Use the [new `
+ diff --git a/mock/data.ts b/mock/data.ts new file mode 100644 index 0000000..0b0b83e --- /dev/null +++ b/mock/data.ts @@ -0,0 +1,20 @@ +import { defineMockData } from 'vite-plugin-mock-dev-server' + +// defineMockData,用于在 mock 文件中使用 data.ts 作为共享数据源。 +export default defineMockData('proses', [ + '🔖 躲在某一时间,想念一段时光的掌纹;躲在某一地点,想念一个站在来路也站在去路的,让我牵挂的人。', + '🔖 天空一碧如洗,灿烂的阳光正从密密的松针的缝隙间射下来,形成一束束粗粗细细的光柱,把飘荡着轻纱般薄雾的林荫照得通亮。', + '🔖 这一次相遇,美得彻骨,美得震颤,美得孤绝,美得惊艳。', + '🔖 沉默的状态,能让我感觉到呼吸的自由和自己原来就处于的本色位置。', + '🔖 青春,是一包象征着阳光的向日葵种子,在现在洒下,就会在未来得到收获,那一株株饱含青春的花朵。', + '🔖 燕子去了,有再来的时候;杨柳枯了,有再青的时候;桃花谢了,有再开的时候。但是,聪明的,你告诉我,我们的日子为什么一去不复返呢?', + '🔖 毕业了,青春在无形之中离去,我们即将翻开人生的另一页。', + '🔖 成长,是每个孩子的权力,也是他们必经的征程,或平坦、或崎岖,有悲欢,有离合。', + '🔖 旧时光里的人和事,琐碎而零乱。我的记忆很模糊,好像大部分都成了一种温馨的符号,静静的沉在我心底。', + '🔖 生活是一部大百科全书,包罗万象;生活是一把六弦琴,弹奏出多重美妙的旋律:生活是一座飞马牌大钟,上紧发条,便会使人获得浓缩的生命。', + '🔖 毕业了,身边的朋友一个个各奔东西,开始学会自己撑起生命的暖色。', + '🔖 已经走到尽头的东西,重生也不过是再一次的消亡。就像所有的开始,其实都只是一个写好了的结局。', + '🔖 下午茶的芬香熏陶着房内的任何一个角落,午后的阳光透过窗帘的间隙洒在木制的桌面上,一份思念随着红茶顺滑至心中。', + '🔖 这里再不是我们的校园,当我们就此离开我们的青葱岁月。', + '🔖 很久找你,一直没有找到,微风吹过的时候,我深深的呼吸,才感觉到你也在陪伴着我呼吸。', +]) diff --git a/mock/index.js b/mock/index.js deleted file mode 100644 index ebc35b6..0000000 --- a/mock/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import prose from './modules/prose' - -export default { - ...prose, -} diff --git a/mock/index.ts b/mock/index.ts new file mode 100644 index 0000000..b391e4a --- /dev/null +++ b/mock/index.ts @@ -0,0 +1,7 @@ +import prose from './modules/prose.mock' +import user from './modules/user.mock' + +export default { + ...prose, + ...user, +} diff --git a/mock/modules/prose.js b/mock/modules/prose.js deleted file mode 100644 index 8492b71..0000000 --- a/mock/modules/prose.js +++ /dev/null @@ -1,23 +0,0 @@ -const list = [ - { prose: '🔖 躲在某一时间,想念一段时光的掌纹;躲在某一地点,想念一个站在来路也站在去路的,让我牵挂的人。' }, - { prose: '🔖 天空一碧如洗,灿烂的阳光正从密密的松针的缝隙间射下来,形成一束束粗粗细细的光柱,把飘荡着轻纱般薄雾的林荫照得通亮。' }, - { prose: '🔖 这一次相遇,美得彻骨,美得震颤,美得孤绝,美得惊艳。' }, - { prose: '🔖 沉默的状态,能让我感觉到呼吸的自由和自己原来就处于的本色位置。' }, - { prose: '🔖 青春,是一包象征着阳光的向日葵种子,在现在洒下,就会在未来得到收获,那一株株饱含青春的花朵。' }, - { prose: '🔖 燕子去了,有再来的时候;杨柳枯了,有再青的时候;桃花谢了,有再开的时候。但是,聪明的,你告诉我,我们的日子为什么一去不复返呢?' }, - { prose: '🔖 毕业了,青春在无形之中离去,我们即将翻开人生的另一页。' }, - { prose: '🔖 成长,是每个孩子的权力,也是他们必经的征程,或平坦、或崎岖,有悲欢,有离合。' }, - { prose: '🔖 旧时光里的人和事,琐碎而零乱。我的记忆很模糊,好像大部分都成了一种温馨的符号,静静的沉在我心底。' }, - { prose: '🔖 生活是一部大百科全书,包罗万象;生活是一把六弦琴,弹奏出多重美妙的旋律:生活是一座飞马牌大钟,上紧发条,便会使人获得浓缩的生命。' }, - { prose: '🔖 毕业了,身边的朋友一个个各奔东西,开始学会自己撑起生命的暖色。' }, - { prose: '🔖 已经走到尽头的东西,重生也不过是再一次的消亡。就像所有的开始,其实都只是一个写好了的结局。' }, - { prose: '🔖 下午茶的芬香熏陶着房内的任何一个角落,午后的阳光透过窗帘的间隙洒在木制的桌面上,一份思念随着红茶顺滑至心中。' }, - { prose: '🔖 这里再不是我们的校园,当我们就此离开我们的青葱岁月。' }, - { prose: '🔖 很久找你,一直没有找到,微风吹过的时候,我深深的呼吸,才感觉到你也在陪伴着我呼吸。' }, -] - -export default { - 'GET /api/project/prose': (req, res) => { - res.json(list[Math.floor(Math.random() * 8)]) - }, -} diff --git a/mock/modules/prose.mock.ts b/mock/modules/prose.mock.ts new file mode 100644 index 0000000..8c6ea04 --- /dev/null +++ b/mock/modules/prose.mock.ts @@ -0,0 +1,13 @@ +import { defineMock } from 'vite-plugin-mock-dev-server' +import { builder } from '../util' +import proses from '../data' + +export default defineMock({ + url: '/api/prose', + delay: 100, + body: () => { + const rand = Math.floor(Math.random() * proses.value.length) + const prose = proses.value[rand] + return builder(prose) + }, +}) diff --git a/mock/modules/user.mock.ts b/mock/modules/user.mock.ts new file mode 100644 index 0000000..6bbfff5 --- /dev/null +++ b/mock/modules/user.mock.ts @@ -0,0 +1,67 @@ +import { defineMock } from 'vite-plugin-mock-dev-server' +import { builder } from '../util' + +export default defineMock([ + { + url: '/api/auth/login', + delay: 500, + body: () => { + return { + code: 0, + data: { + token: 'admin', + }, + msg: 'success', + } + }, + }, + { + url: '/api/user/me', + delay: 100, + body: () => { + return { + code: 0, + data: { + uid: 1, + name: 'admin', + avatar: 'https://iconfont.alicdn.com/p/user/eZQFvSX6g8f1/f0d9fd95-a5f0-474d-98b0-d51e8450f2cf.png', + }, + msg: 'success', + } + }, + }, + { + url: '/api/user/logout', + delay: 500, + body: () => { + return { + code: 0, + msg: 'success', + } + }, + }, + { + url: '/api/user/email-code', + delay: 1000, + body: () => { + const code = '123456' + return builder(code) + }, + }, + { + url: '/api/user/reset-password', + delay: 1000, + body: () => { + const res = true + return builder(res) + }, + }, + { + url: '/api/user/register', + delay: 1000, + body: () => { + const res = true + return builder(res) + }, + }, +]) diff --git a/mock/util.ts b/mock/util.ts new file mode 100644 index 0000000..c8d1d85 --- /dev/null +++ b/mock/util.ts @@ -0,0 +1,19 @@ +const responseBody = { + message: '', + timestamp: 0, + result: null as unknown, + code: 0, +} + +export function builder(data: unknown, message = 'success', code = 0) { + responseBody.result = data + + if (message !== undefined && message !== null) + responseBody.message = message + + if (code !== undefined && code !== 0) + responseBody.code = code + + responseBody.timestamp = new Date().getTime() + return responseBody +} diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..a3f17c8 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,12 @@ +[build] +base = "/" +publish = "dist" +command = "pnpm run build:pro" + +[build.environment] +NODE_VERSION = "18" + +[[redirects]] +from = "/*" +to = "/index.html" +status = 200 diff --git a/package.json b/package.json index e075f97..71d0763 100644 --- a/package.json +++ b/package.json @@ -1,91 +1,106 @@ { "name": "vue3-vant-mobile", - "version": "1.3.0", - "packageManager": "pnpm@7.14.0", - "description": "template for Vue3 Vant Mobile", + "type": "module", + "version": "3.10.2", + "packageManager": "pnpm@10.11.0", + "description": "An mobile web apps template based on the Vue 3 ecosystem", "license": "MIT", "scripts": { "dev": "cross-env MOCK_SERVER_PORT=8086 vite", - "build": "vue-tsc --noEmit && vite build", - "build:dev": "vue-tsc --noEmit && vite build --mode=development", + "build:dev": "vue-tsc --noEmit && vite build --mode development", + "build:pro": "vue-tsc --noEmit && vite build --mode production", + "preview": "vite preview", "lint": "eslint .", "lint:fix": "eslint . --fix", - "preview": "vite preview", - "test": "vitest", - "plop": "plop", - "prepare": "npx husky install" + "release": "bumpp --commit --push --tag", + "typecheck": "vue-tsc --noEmit", + "commitlint": "commitlint --edit", + "prepare": "simple-git-hooks" }, "dependencies": { + "@unhead/vue": "2.0.10", "@vant/touch-emulator": "^1.4.0", - "@vant/use": "^1.5.1", - "axios": "^1.4.0", - "echarts": "^5.4.2", + "@vant/use": "^1.6.0", + "@vueuse/core": "^13.2.0", + "axios": "^1.9.0", + "echarts": "^5.6.0", "lodash-es": "^4.17.21", "nprogress": "^0.2.0", - "pinia": "^2.0.35", - "pinia-plugin-persistedstate": "^3.1.0", + "pinia": "^3.0.2", + "pinia-plugin-persistedstate": "^4.3.0", "resize-detector": "^0.3.0", - "store": "^2.0.12", - "vant": "^4.2.0", - "vconsole": "^3.15.0", - "vue": "^3.2.47", - "vue-router": "^4.1.6" + "vant": "^4.9.19", + "vconsole": "^3.15.1", + "vue": "^3.5.14", + "vue-i18n": "^11.1.4", + "vue-router": "^4.5.1" }, "devDependencies": { - "@antfu/eslint-config": "^0.33.1", - "@babel/core": "^7.21.5", - "@babel/preset-env": "^7.21.5", - "@babel/preset-typescript": "^7.21.5", - "@babel/register": "^7.21.0", - "@types/lodash-es": "^4.17.7", - "@types/node": "^18.16.3", - "@types/nprogress": "^0.2.0", - "@types/store": "^2.0.2", - "@vitejs/plugin-legacy": "^3.0.2", - "@vitejs/plugin-vue": "^4.2.1", - "@vitejs/plugin-vue-jsx": "^3.0.1", - "autoprefixer": "^10.4.14", - "babel-plugin-module-resolver": "^4.1.0", - "commitizen": "^4.3.0", - "consola": "^2.15.3", + "@antfu/eslint-config": "4.13.2", + "@commitlint/cli": "^19.8.1", + "@commitlint/config-conventional": "^19.8.1", + "@commitlint/types": "^19.8.1", + "@iconify-json/carbon": "^1.2.8", + "@intlify/unplugin-vue-i18n": "^6.0.8", + "@types/lodash-es": "^4.17.12", + "@types/node": "^22.15.21", + "@types/nprogress": "^0.2.3", + "@unocss/eslint-config": "66.1.2", + "@vant/auto-import-resolver": "^1.3.0", + "@vitejs/plugin-legacy": "^6.1.1", + "@vitejs/plugin-vue": "^5.2.4", + "autoprefixer": "^10.4.21", + "bumpp": "^10.1.1", + "consola": "^3.4.2", "cross-env": "^7.0.3", - "cz-emoji-chinese": "^0.3.1", - "eslint": "^8.39.0", - "husky": "^8.0.3", - "less": "^4.1.3", + "eslint": "^9.27.0", + "eslint-plugin-format": "^1.0.1", + "less": "^4.3.0", + "lint-staged": "^16.0.0", "mockjs": "^1.1.0", - "path-to-regexp": "^6.2.1", - "plop": "^3.1.2", - "postcss-mobile-forever": "^3.3.1", - "rollup": "^3.21.2", - "rollup-plugin-visualizer": "^5.9.0", - "signale": "^1.4.0", - "slash2": "^2.0.0", - "terser": "^5.17.1", - "typescript": "^4.9.5", - "unplugin-auto-import": "^0.12.2", - "unplugin-vue-components": "^0.22.12", - "vite": "^4.3.3", - "vite-plugin-vconsole": "^1.3.1", - "vitest": "^0.25.8", - "vue-tsc": "^1.6.1" + "postcss-mobile-forever": "^5.0.0", + "rollup": "^4.41.1", + "simple-git-hooks": "^2.13.0", + "terser": "^5.39.2", + "typescript": "^5.8.3", + "unocss": "66.1.2", + "unplugin-auto-import": "^19.2.0", + "unplugin-vue-components": "^28.5.0", + "unplugin-vue-router": "^0.12.0", + "vite": "^6.3.5", + "vite-plugin-mock-dev-server": "^1.8.7", + "vite-plugin-pwa": "^1.0.0", + "vite-plugin-sitemap": "^0.8.2", + "vite-plugin-vconsole": "^2.1.1", + "vite-plugin-vue-devtools": "^7.7.6", + "vue-tsc": "^2.2.10" }, "pnpm": { + "allowedDeprecatedVersions": { + "glob": "7.2.3", + "inflight": "1.0.6", + "sourcemap-codec": "1.4.8" + }, "peerDependencyRules": { - "ignoreMissing": [ - "postcss" - ] - } - }, - "config": { - "commitizen": { - "path": "./node_modules/cz-emoji-chinese" + "allowedVersions": { + "typescript": "5.8.3" + } }, - "cz-emoji-chinese": { - "skipQuestions": [ - "body", - "scope" - ] - } + "onlyBuiltDependencies": [ + "core-js", + "esbuild", + "simple-git-hooks", + "unrs-resolver" + ] + }, + "resolutions": { + "vite": "^6.3.5" + }, + "simple-git-hooks": { + "pre-commit": "pnpm lint-staged", + "commit-msg": "pnpm commitlint $1" + }, + "lint-staged": { + "*": "eslint --fix" } } diff --git a/plop-templates/component/index.hbs b/plop-templates/component/index.hbs deleted file mode 100644 index 1f11640..0000000 --- a/plop-templates/component/index.hbs +++ /dev/null @@ -1,16 +0,0 @@ -{{#if template}} - -{{/if}} - -{{#if script}} - -{{/if}} - -{{#if style}} - -{{/if}} - diff --git a/plop-templates/component/prompt.js b/plop-templates/component/prompt.js deleted file mode 100644 index 70c9f6b..0000000 --- a/plop-templates/component/prompt.js +++ /dev/null @@ -1,55 +0,0 @@ -const { notEmpty } = require('../utils.js') - -module.exports = { - description: 'generate vue component', - prompts: [{ - type: 'input', - name: 'name', - message: 'component name please', - validate: notEmpty('name'), - }, - { - type: 'checkbox', - name: 'blocks', - message: 'Blocks:', - choices: [{ - name: '