Skip to content

Commit c0c3bfd

Browse files
committed
feat: use unocss wind4 preset
1 parent 018e257 commit c0c3bfd

File tree

19 files changed

+319
-296
lines changed

19 files changed

+319
-296
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ An mobile web apps template based on the Vue 3 ecosystem.
7777
### UI Frameworks
7878

7979
- [UnoCSS](https://github.com/antfu/unocss) - The instant on-demand atomic CSS engine
80-
- [`@unocss/preset-rem-to-px`](https://github.com/unocss/unocss/tree/main/packages/preset-rem-to-px) - Converts rem to px for all utilities
81-
- [`eslint-plugin-unocss`](https://github.com/devunt/eslint-plugin-unocss) - ESLint plugin for UnoCSS
8280
- [Vant](https://github.com/youzan/vant) - Vue UI library for mobile web apps
8381
- [`vant-touch-emulator`](https://github.com/youzan/vant/tree/main/packages/vant-touch-emulator) - Simulate mobile touch events on the desktop
8482
- [`vant-use`](https://github.com/youzan/vant/tree/main/packages/vant-use) - Built-in composition APIs of Vant
@@ -88,7 +86,7 @@ An mobile web apps template based on the Vue 3 ecosystem.
8886
- [Vue Router](https://github.com/vuejs/router)
8987
- [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) - file system based routing
9088
- [Pinia](https://pinia.vuejs.org) - Intuitive, type safe, light and flexible Store for Vue using the composition api
91-
- [`pinia-plugin-persistedstate`](https://github.com/prazdevs/pinia-plugin-persistedstate) - Configurable persistence and rehydration of Pinia stores
89+
- [`pinia-plugin-persistedstate`](https://github.com/prazdevs/pinia-plugin-persistedstate) - Configurable persistence and rehydration of Pinia stores
9290
- [Vue I18n](https://github.com/intlify/vue-i18n-next) - Internationalization
9391
- [`unplugin-vue-i18n`](https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n) - unplugin for Vue I18n
9492
- [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) - components auto import
@@ -98,7 +96,7 @@ An mobile web apps template based on the Vue 3 ecosystem.
9896
- [postcss-mobile-forever](https://github.com/wswmsword/postcss-mobile-forever) - To adapt different displays by one mobile viewport
9997
- [vite-plugin-vue-devtools](https://github.com/vuejs/devtools-next) - Designed to enhance the Vue developer experience
10098
- [vueuse](https://github.com/antfu/vueuse) - collection of useful composition APIs
101-
- [@unhead/vue](https://github.com/unjs/unhead) - manipulate document head reactively
99+
- [@unhead/vue v2](https://github.com/unjs/unhead) - manipulate document head reactively
102100
- [vite-plugin-pwa](https://github.com/antfu/vite-plugin-pwa) - PWA
103101
- [vite-plugin-sitemap](https://github.com/jbaubree/vite-plugin-sitemap) - sitemap and robots generator
104102

README.zh-CN.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ An mobile web apps template based on the Vue 3 ecosystem.
7777
### UI 框架
7878

7979
- [UnoCSS](https://github.com/antfu/unocss) - 高性能且极具灵活性的即时原子化 CSS 引擎
80-
- [`@unocss/preset-rem-to-px`](https://github.com/unocss/unocss/tree/main/packages/preset-rem-to-px) - 将所有实用程序的 rem 转换为 px
81-
- [`eslint-plugin-unocss`](https://github.com/devunt/eslint-plugin-unocss) - Unocss 的 ESLint 插件
8280
- [Vant](https://github.com/youzan/vant) - 移动端 Vue 组件库
8381
- [`vant-touch-emulator`](https://github.com/youzan/vant/tree/main/packages/vant-touch-emulator) - 在桌面端上模拟移动端 touch 事件
8482
- [`vant-use`](https://github.com/youzan/vant/tree/main/packages/vant-use) - Vant 内置的组合式 API
@@ -88,7 +86,7 @@ An mobile web apps template based on the Vue 3 ecosystem.
8886
- [Vue Router](https://github.com/vuejs/router)
8987
- [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) - 以文件系统为基础的路由
9088
- [Pinia](https://pinia.vuejs.org) - 直接的, 类型安全的, 使用 Composition API 的轻便灵活的 Vue 状态管理库
91-
- [`pinia-plugin-persistedstate`](https://github.com/prazdevs/pinia-plugin-persistedstate) - 适用于 Pinia 的持久化存储插件
89+
- [`pinia-plugin-persistedstate`](https://github.com/prazdevs/pinia-plugin-persistedstate) - 适用于 Pinia 的持久化存储插件
9290
- [Vue I18n](https://github.com/intlify/vue-i18n-next) - 国际化
9391
- [`unplugin-vue-i18n`](https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n) - Vue I18n 的 Vite 插件
9492
- [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) - 自动加载组件
@@ -98,7 +96,7 @@ An mobile web apps template based on the Vue 3 ecosystem.
9896
- [postcss-mobile-forever](https://github.com/wswmsword/postcss-mobile-forever) - 一款 PostCSS 插件,将固定尺寸的移动端视图转为具有最大宽度的可伸缩的移动端视图
9997
- [vite-plugin-vue-devtools](https://github.com/vuejs/devtools-next) - 旨在增强Vue开发者体验的Vite插件
10098
- [vueuse](https://github.com/antfu/vueuse) - 实用的 Composition API 工具合集
101-
- [@unhead/vue](https://github.com/unjs/unhead) - 响应式地操作文档头信息
99+
- [@unhead/vue v2](https://github.com/unjs/unhead) - 响应式地操作文档头信息
102100
- [vite-plugin-pwa](https://github.com/antfu/vite-plugin-pwa) - PWA
103101
- [vite-plugin-sitemap](https://github.com/jbaubree/vite-plugin-sitemap) - sitemap 和 robots 生成器
104102

build/vite/vconsole.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
import path from 'node:path'
2-
import process from 'node:process'
3-
import { loadEnv } from 'vite'
4-
import { viteVConsole } from 'vite-plugin-vconsole'
5-
6-
export function createViteVConsole(mode: string) {
7-
const env = loadEnv(mode, process.cwd())
8-
return viteVConsole({
9-
entry: [path.resolve('src/main.ts')],
10-
enabled: env.VITE_APP_VCONSOLE === 'true',
11-
config: {
12-
maxLogNumber: 1000,
13-
theme: 'light',
14-
},
15-
// https://github.com/vadxq/vite-plugin-vconsole/issues/21
16-
dynamicConfig: {
17-
theme: `document.documentElement.classList.contains('dark') ? 'dark' : 'light'`,
18-
},
19-
eventListener: `
20-
const targetElement = document.querySelector('html'); // 择要监听的元素
21-
const observerOptions = {
22-
attributes: true, // 监听属性变化
23-
attributeFilter: ['class'] // 只监听class属性变化
24-
};
25-
26-
// 定义回调函数来处理观察到的变化
27-
function handleAttributeChange(mutationsList) {
28-
for(let mutation of mutationsList) {
29-
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
30-
if (window && window.vConsole) {
31-
window.vConsole.dynamicChange.value = new Date().getTime();
32-
}
33-
}
34-
}
35-
}
36-
37-
// 创建观察者实例并传入回调函数
38-
const observer = new MutationObserver(handleAttributeChange);
39-
40-
// 开始观察目标元素
41-
observer.observe(targetElement, observerOptions);
42-
43-
// 当不再需要观察时,停止观察
44-
// observer.disconnect();
45-
`,
46-
})
47-
}
1+
import path from 'node:path'
2+
import process from 'node:process'
3+
import { loadEnv } from 'vite'
4+
import { viteVConsole } from 'vite-plugin-vconsole'
5+
6+
export function createViteVConsole(mode: string) {
7+
const env = loadEnv(mode, process.cwd())
8+
return viteVConsole({
9+
entry: [path.resolve('src/main.ts')],
10+
enabled: env.VITE_APP_VCONSOLE === 'true',
11+
config: {
12+
maxLogNumber: 1000,
13+
theme: 'light',
14+
},
15+
// https://github.com/vadxq/vite-plugin-vconsole/issues/21
16+
dynamicConfig: {
17+
theme: `document.documentElement.classList.contains('dark') ? 'dark' : 'light'`,
18+
},
19+
eventListener: `
20+
const targetElement = document.querySelector('html'); // 择要监听的元素
21+
const observerOptions = {
22+
attributes: true, // 监听属性变化
23+
attributeFilter: ['class'] // 只监听class属性变化
24+
};
25+
26+
// 定义回调函数来处理观察到的变化
27+
function handleAttributeChange(mutationsList) {
28+
for(let mutation of mutationsList) {
29+
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
30+
if (window && window.vConsole) {
31+
window.vConsole.dynamicChange.value = new Date().getTime();
32+
}
33+
}
34+
}
35+
}
36+
37+
// 创建观察者实例并传入回调函数
38+
const observer = new MutationObserver(handleAttributeChange);
39+
40+
// 开始观察目标元素
41+
observer.observe(targetElement, observerOptions);
42+
43+
// 当不再需要观察时,停止观察
44+
// observer.disconnect();
45+
`,
46+
})
47+
}

eslint.config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ export default antfu(
55
vue: true,
66
typescript: true,
77

8-
// enable UnoCSS support
8+
// Enable UnoCSS support
99
// https://unocss.dev/integrations/vscode
1010
unocss: true,
11-
12-
formatters: {
13-
css: true,
14-
},
15-
11+
formatters: true,
1612
},
1713
{
1814
rules: {

index.html

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="zh-CN">
33
<head>
44
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"/>
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
66
<link rel="apple-touch-icon" href="/pwa-192x192.png" />
7-
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#f6d2d2">
8-
<meta name="msapplication-TileColor" content="#f6d2d2">
7+
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#f6d2d2" />
8+
<meta name="msapplication-TileColor" content="#f6d2d2" />
99
<script>
1010
;(function () {
1111
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
@@ -18,9 +18,6 @@
1818
<body>
1919
<div id="app"></div>
2020
<script type="module" src="/src/main.ts"></script>
21-
<noscript>
22-
This website requires JavaScript to function properly.
23-
Please enable JavaScript to continue.
24-
</noscript>
21+
<noscript> This website requires JavaScript to function properly. Please enable JavaScript to continue. </noscript>
2522
</body>
2623
</html>

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
"@types/lodash-es": "^4.17.12",
4747
"@types/node": "^22.14.1",
4848
"@types/nprogress": "^0.2.3",
49-
"@unocss/eslint-plugin": "66.1.0-beta.11",
50-
"@unocss/preset-rem-to-px": "66.1.0-beta.11",
49+
"@unocss/eslint-config": "66.1.0-beta.12",
5150
"@vant/auto-import-resolver": "^1.3.0",
5251
"@vitejs/plugin-legacy": "^6.0.2",
5352
"@vitejs/plugin-vue": "^5.2.3",
@@ -65,7 +64,7 @@
6564
"simple-git-hooks": "^2.12.1",
6665
"terser": "^5.39.0",
6766
"typescript": "^5.8.3",
68-
"unocss": "66.1.0-beta.11",
67+
"unocss": "66.1.0-beta.12",
6968
"unplugin-auto-import": "^19.1.2",
7069
"unplugin-vue-components": "^28.4.1",
7170
"unplugin-vue-router": "^0.12.0",

0 commit comments

Comments
 (0)