Compare commits

...

7 Commits

Author SHA1 Message Date
h_mo
3a4a200c3b
!27 ci: 添加版本控制配置文件- 新增 .versionrc.cjs 文件,用于配置版本控制规则- 定义了常见的提交类型,包括新功能、Bug …
Merge pull request !27 from h_mo/dev
2025-04-02 15:47:51 +00:00
h_mo
eeb6cdcd6e ci: 添加版本控制配置文件- 新增 .versionrc.cjs 文件,用于配置版本控制规则- 定义了常见的提交类型,包括新功能、Bug 修复、文档、风格、重构和性能优化
- 每种类型都包含了对应的中文描述,便于团队成员理解和使用
2025-04-02 23:45:35 +08:00
h_mo
0996b95488 chore(release): 2.1.0 2025-04-02 23:44:52 +08:00
h_mo
642ee9e637 feat: add unocss configuration for styling
- Introduced a new unocss.config.ts file to define styling configurations.
- Configured presets for Weapp and Icons, including custom transform rules.
- Set up theme colors and font sizes for consistent styling across the application.
- Added transformers for attributify and class handling.
2025-04-02 23:34:35 +08:00
h_mo
a00d3a3c2d build(deps): 更新依赖版本 2025-04-02 20:43:42 +08:00
h_mo
dce5d85f65 chore: 升级依赖并重构项目配置
- 更新多个依赖到最新版本,包括 uni-app、alova、pinia、tailwindcss 等
- 移除 postcss.config.ts 配置文件
- 调整 vite 配置和 tailwindcss 引入方式
- 更新 App.vue 和 main.ts 中的样式引入
- 优化 stores 中的 defineStore 使用方式
- 新增 src/styles/main.css 文件
2025-03-12 15:47:23 +08:00
h_mo
4aa9201989 build(deps): 更新项目依赖版本
- 更新 @alova/adapter-uniapp 从 2.0.9 到 2.0.11
- 更新 @alova/mock 从 2.0.9 到 2.0.11
- 更新 @alova/shared 从 1.1.0 到 1.1.2
- 更新 uni-app 相关依赖到 3.0.0-alpha-4040220241217001 版本
- 更新 alova 从3.2.2 到3.2.7
- 更新 pinia 从 2.2.6 到 2.3.0
- 更新 vue 从 3.5.12到 3.5.13
- 更新 @antfu/eslint-config 从 3.8.0 到 3.12.0
- 更新 @egoist/tailwindcss-icons 从1.8.1 到1.8.2
- 更新 @iconify/json 从 2.2.270 到 2.2.287
- 更新 @rollup/plugin-node-resolve 从 15.3.0 到 16.0.0
- 更新 @types/node 从 20.17.6 到 22.10.2
- 更新 @vitejs/plugin-vue 从 5.1.4 到 5.2.1
- 更新 eslint 从 9.14.0 到9.17.0
- 更新 eslint-plugin-format 从 0.1.2 到 0.1.3
- 更新 globals 从 15.12.0 到 15.14.0
- 更新 lint-staged 从 15.2.10 到 15.2.11
- 更新 postcss 从 8.4.47 到 8.4.49
- 更新 sass 从 1.80.6 到 1.83.0
- 更新 tailwindcss 从 3.4.14 到 3.4.17
- 更新 unplugin-auto-import 从 0.18.3 到 0.19.0
- 更新 vite 从 5.4.10 到 6.0.5
- 更新 vite-plugin-restart 从 0.4.1 到 0.4.2
- 更新 typescript 从5.6.3 到5.7.2
2024-12-23 10:27:10 +08:00
24 changed files with 169 additions and 101 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

5
.npmrc
View File

@ -1,6 +1,9 @@
# 提示:如果你想自动安装对等依赖,在项目根目录下的.npmrc文件中添加"auto-install-peers=true"。
# 提示:如果你不希望pnpm在对等依赖问题上失败在项目根目录下的.npmrc文件中添加"strict-peer-dependencies=false"。
# auto-install-peers=true
auto-install-peers=true
strict-peer-dependencies=false
registry=https://registry.npmmirror.com
# registry=https://registry.npmjs.org
public-hoist-pattern[]=*vue*
shamefully-hoist=true

View File

@ -1,10 +0,0 @@
{
"types": [
{"type": "feat", "section": "✨ Features | 新功能", "hidden": false},
{"type": "fix", "section": "🐛 Bug Fixes | Bug 修复", "hidden": false},
{"type": "docs", "section":"📝 Documentation | 文档", "hidden": false},
{"type": "style", "section":"💄 Styles | 风格", "hidden": false},
{"type": "refactor", "section":"💄 Refactor | 重构", "hidden": false},
{"type": "perf", "section":"⚡ Performance Improvements | 性能优化", "hidden": false},
]
}

10
.versionrc.cjs Normal file
View File

@ -0,0 +1,10 @@
module.exports = {
types: [
{ type: 'feat', section: '✨ Features | 新功能', hidden: false },
{ type: 'fix', section: '🐛 Bug Fixes | Bug 修复', hidden: false },
{ type: 'docs', section: '📝 Documentation | 文档', hidden: false },
{ type: 'style', section: '💄 Styles | 风格', hidden: false },
{ type: 'refactor', section: '💄 Refactor | 重构', hidden: false },
{ type: 'perf', section: '⚡ Performance Improvements | 性能优化', hidden: false },
],
};

View File

@ -2,6 +2,24 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [2.1.0](https://gitee.com/h_mo/uniapp-vue3-vite-ts-template/compare/v2.0.1...v2.1.0) (2025-04-02)
### ✨ Features | 新功能
* add unocss configuration for styling ([642ee9e](https://gitee.com/h_mo/uniapp-vue3-vite-ts-template/commit/642ee9e6374651d502fc47bb6596711a93af1e07))
### 🐛 Bug Fixes | Bug 修复
* **build:** 修复pnpm构建出错的问题 ([a0b559f](https://gitee.com/h_mo/uniapp-vue3-vite-ts-template/commit/a0b559f7d2f87e738c7b61560f0c44312e985a3f))
### 💄 Styles | 风格
* 格式化代码 ([36d036e](https://gitee.com/h_mo/uniapp-vue3-vite-ts-template/commit/36d036e08626ced71485b8566acba8a824132657))
* 格式化代码 ([bfcabd0](https://gitee.com/h_mo/uniapp-vue3-vite-ts-template/commit/bfcabd0262fefdb2d78c294cf149ec32874846b3))
## 2.0.1 (2024-08-30)

View File

@ -17,7 +17,7 @@
<img src="https://img.shields.io/badge/-pnpm-F69220?logo=pnpm&logoColor=white" />
</a>
<a href="https://unocss.dev/" target="_blank">
<img src="https://img.shields.io/badge/-tailwindcss-0f172a?logo=tailwindcss" />
<img src="https://img.shields.io/badge/-unocss-0f172a?logo=unocss" />
</a>
<a href="https://iconify.design/" target="_blank">
<img src="https://img.shields.io/badge/-Iconify-1769aa?logo=Iconify" />
@ -55,7 +55,7 @@
## 特性
- **最新技术栈**:使用 Vue3/Vite5/pinia ,TypeScript 等前端前沿技术开发;
- **[Tailwindcss](https://tailwindcss.com/)**: 原子化 CSS, [iconify](https://iconify.design/)图标
- **[Unocss](https://unocss.dev/)**: 原子化 CSS, [iconify](https://iconify.design/)图标
- **Eslint**: 规范代码格式,统一编码;
- **路由拦截**: [uni-mini-router](https://gitee.com/fant-mini/uni-mini-router),类似Vue Router的API和功能,在uni-app中进行路由跳转、传参、拦截等常用操作;
- **请求拦截**: 使用[alova 请求](https://github.com/alovajs/alova),支持请求和响应拦截等;
@ -152,7 +152,7 @@
- 安装依赖
> 若 pnpm 安装或运行失败,请使用 npm 或 yarn 安装依赖
> 若 pnpm 安装或运行失败,请使用 npm 或 **yarn** 安装依赖
```bash
pnpm install

View File

@ -3,13 +3,13 @@ import process from 'node:process';
const currentPlatform = process.env.UNI_PLATFORM;
const isH5 = currentPlatform === 'h5';
const isApp = currentPlatform === 'app';
const WeappTailwindcssDisabled = isH5 || isApp;
const isMp = !isH5 && !isApp;
const isWeixinMp = currentPlatform === 'mp-weixin';
export {
currentPlatform,
isApp,
isH5,
isMp,
WeappTailwindcssDisabled,
isWeixinMp,
};

View File

@ -1,10 +1,10 @@
import type { PluginOption } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import { visualizer } from 'rollup-plugin-visualizer';
import Unocss from 'unocss/vite';
import autoImport from 'unplugin-auto-import/vite';
import viteRestart from 'vite-plugin-restart';
import { UnifiedViteWeappTailwindcssPlugin as uvtw } from 'weapp-tailwindcss/vite';
import { isH5, WeappTailwindcssDisabled } from './platform';
import { isH5 } from './platform';
interface VitePluginConfig {
isProd: boolean
@ -14,12 +14,8 @@ export function createVitePlugins({ isProd }: VitePluginConfig): PluginOption[]
return [
// @ts-expect-error TODO uni() 会报错uni is not a function,暂时使用此方式解决
uni?.default(),
uvtw({
rem2rpx: true,
disabled: WeappTailwindcssDisabled,
// 使用新的 ast-grep 来处理 js 资源,速度是 babel 的2倍左右
// 需要先安装 `@ast-grep/napi`
// jsAstTool: 'ast-grep'
Unocss({
hmrTopLevelAwait: false,
}),
autoImport({
include: [

BIN
bun.lockb

Binary file not shown.

View File

@ -1,7 +1,7 @@
{
"name": "uniapp_vue3_vite_ts",
"type": "module",
"version": "2.0.1",
"version": "2.1.0",
"scripts": {
"dev:app": "uni -p app",
"dev:custom": "uni -p",
@ -33,7 +33,6 @@
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
"lint:fix": "eslint . --fix",
"git:hooks": "npx simple-git-hooks",
"postinstall": "weapp-tw patch",
"version:first": "commit-and-tag-version --first-release",
"version:alpha": "commit-and-tag-version --prerelease alpha",
"version:beta": "commit-and-tag-version --prerelease beta",
@ -43,65 +42,63 @@
"version:major": "commit-and-tag-version --release-as major"
},
"dependencies": {
"@alova/adapter-uniapp": "^2.0.9",
"@alova/mock": "^2.0.9",
"@alova/shared": "^1.1.0",
"@dcloudio/uni-app": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-app-plus": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-components": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-h5": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-i18n": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4030220241101001",
"@alova/adapter-uniapp": "^2.0.11",
"@alova/mock": "^2.0.13",
"@alova/shared": "^1.1.2",
"@dcloudio/uni-app": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-app-plus": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-components": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-h5": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-i18n": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4060120250328001",
"@multiavatar/multiavatar": "^1.0.7",
"alova": "^3.2.2",
"alova": "^3.2.10",
"crypto-js": "^4.2.0",
"lodash-es": "^4.17.21",
"pinia": "^2.2.6",
"vue": "^3.5.12"
"pinia": "^2.3.1",
"vue": "^3.5.13"
},
"devDependencies": {
"@antfu/eslint-config": "^3.8.0",
"@antfu/eslint-config": "^4.11.0",
"@dcloudio/types": "^3.4.14",
"@dcloudio/uni-automator": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-4030220241101001",
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4030220241101001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-4030220241101001",
"@egoist/tailwindcss-icons": "^1.8.1",
"@iconify/json": "^2.2.270",
"@rollup/plugin-node-resolve": "^15.3.0",
"@dcloudio/uni-automator": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-4060120250328001",
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4060120250328001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-4060120250328001",
"@iconify/json": "^2.2.323",
"@rollup/plugin-node-resolve": "^16.0.1",
"@types/crypto-js": "^4.2.2",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.17.6",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/runtime-core": "^3.5.12",
"autoprefixer": "^10.4.20",
"@types/node": "^22.13.17",
"@vitejs/plugin-vue": "^5.2.3",
"@vue/runtime-core": "^3.5.13",
"autoprefixer": "^10.4.21",
"commit-and-tag-version": "^12.5.0",
"eslint": "^9.14.0",
"eslint-plugin-format": "^0.1.2",
"globals": "^15.12.0",
"lint-staged": "^15.2.10",
"eslint": "^9.23.0",
"eslint-plugin-format": "^1.0.1",
"globals": "^16.0.0",
"lint-staged": "^15.5.0",
"picocolors": "^1.1.1",
"postcss": "^8.4.47",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.80.6",
"simple-git-hooks": "^2.11.1",
"tailwindcss": "^3.4.14",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"rollup-plugin-visualizer": "^5.14.0",
"sass": "^1.86.1",
"simple-git-hooks": "^2.12.1",
"tsx": "^4.19.3",
"typescript": "^5.8.2",
"uni-mini-router": "^0.1.6",
"uni-read-pages-vite": "^0.0.6",
"unplugin-auto-import": "^0.18.3",
"vite": "^5.4.10",
"vite-plugin-restart": "^0.4.1",
"weapp-tailwindcss": "^3.7.0"
"unocss": "66.1.0-beta.8",
"unocss-preset-weapp": "^66.0.0",
"unplugin-auto-import": "^19.1.2",
"vite": "^5.4.16",
"vite-plugin-restart": "^0.4.2"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged",

View File

@ -1,12 +0,0 @@
import type { AcceptedPlugin } from 'postcss';
import autoprefixer from 'autoprefixer';
import tailwindcss from 'tailwindcss';
import cssMacro from 'weapp-tailwindcss/css-macro/postcss';
const plugins: AcceptedPlugin[] = [tailwindcss(), autoprefixer()];
// 可以使用 postcss-pxtransform 来进行 px 转 rpx 的功能
plugins.push(cssMacro);
export default plugins;

BIN
src/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -15,8 +15,5 @@ onHide(() => {
});
</script>
<style lang="css">
@import 'tailwindcss/base';
@import 'tailwindcss/utilities';
@import 'tailwindcss/components';
<style>
</style>

BIN
src/components/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -2,6 +2,8 @@ import { createSSRApp } from 'vue';
import App from './App.vue';
import { setupRouter } from './router';
import { setupStore } from './stores';
import './styles/main.css';
import 'uno.css';
export function createApp() {
const app = createSSRApp(App);

BIN
src/pages/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -9,10 +9,12 @@ const appTitle = 'uniapp-vue3';
<template>
<view class="flex flex-col items-center gap-y-2 pt-36">
<image :src="logo" class="h-8 w-8" alt="" mode="widthFix" />
<view class="text-xl font-semibold">
<view class="text-xl font-semibold text-red">
{{ appTitle }}
</view>
<view>当前平台{{ platform }}</view>
<view class="text-red">
当前平台{{ platform }}
</view>
</view>
</template>

BIN
src/services/.DS_Store vendored Normal file

Binary file not shown.

BIN
src/static/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,11 +1,10 @@
import { defineStore } from 'pinia';
// import { defineStore } from 'pinia';
interface AppState {
sys?: string | number
}
export const useAppStore = defineStore({
id: 'app-store',
export const useAppStore = defineStore('app-store', {
state: (): AppState => ({}),
getters: {},
actions: {},

View File

@ -11,10 +11,10 @@ export const useUserStore = defineStore('UserStore', () => {
const userInfo = ref<UserInfoModel | null>(null);
// 初始化
function initUserInfo() {
async function initUserInfo() {
if (isLogin()) {
token.value = getToken();
getUserInfo();
await getUserInfo();
}
}
@ -35,7 +35,7 @@ export const useUserStore = defineStore('UserStore', () => {
}
// 获取用户信息
const { send: _getUserInfo } = useRequest(getUserInfoApi, { initialData: null, immediate: false });
const { send: _getUserInfo } = useRequest(getUserInfoApi, { immediate: false });
async function getUserInfo() {
try {
userInfo.value = await _getUserInfo();

BIN
src/utils/.DS_Store vendored Normal file

Binary file not shown.

69
unocss.config.ts Normal file
View File

@ -0,0 +1,69 @@
import { defineConfig, presetIcons } from 'unocss';
import presetWeapp from 'unocss-preset-weapp';
import { transformerAttributify, transformerClass } from 'unocss-preset-weapp/transformer';
import { isWeixinMp } from './build/platform';
const prefix = '';
const transformRules = {
'.': '-d2e-',
'/': '-s2f-',
':': '-c3a-',
'%': '-p25-',
'!': '-e21-',
'#': '-w23-',
'(': '-b28-',
')': '-b29-',
'[': '-f4b-',
']': '-f5d-',
'$': '-r24-',
',': '-r2c-',
};
export default defineConfig({
presets: [
// https://github.com/MellowCo/unocss-preset-weapp
presetWeapp({
prefix,
whRpx: false,
transform: isWeixinMp as boolean,
platform: 'uniapp',
transformRules,
}) as any,
presetIcons({
scale: 1.2,
warn: true,
}),
],
shortcuts: [
{
center: 'flex justify-center items-center',
},
],
theme: {
colors: {
primary: '#007AFF',
secondary: '#4CD964',
danger: '#FF3B30',
warning: '#FF9500',
info: '#5AC8FA',
light: '#F0F0F0',
dark: '#1A1A1A',
},
fontSize: {
mini: ['20rpx', '26rpx'],
},
},
transformers: [
// options https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
transformerAttributify({
classPrefix: prefix,
transformRules,
nonValuedAttribute: true,
}) as any,
// options https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
transformerClass({
transformRules,
}),
],
});

View File

@ -9,7 +9,7 @@ import process from 'node:process';
import TransformPages from 'uni-read-pages-vite';
import { defineConfig, loadEnv } from 'vite';
import { createVitePlugins, currentPlatform, resolveProxy } from './build';
import postcssPlugins from './postcss.config';
// import postcssPlugins from './postcss.config';
export default defineConfig(async ({ mode }) => {
const root = process.cwd();
@ -39,9 +39,6 @@ export default defineConfig(async ({ mode }) => {
silenceDeprecations: ['legacy-js-api'],
},
},
postcss: {
plugins: postcssPlugins,
},
},
plugins: createVitePlugins({ isProd }),
// 开发服务器配置