Skip to content

Commit 1940b2a

Browse files
committed
feat: rewrite index.vue
1 parent 0229e8c commit 1940b2a

File tree

5 files changed

+220
-113
lines changed

5 files changed

+220
-113
lines changed

app.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
<script setup lang="ts">
2+
import type { ConfigProviderTheme } from 'vant'
3+
const mode = ref<ConfigProviderTheme>('light')
4+
5+
</script>
6+
17
<template>
2-
<div id="app">
8+
<VanConfigProvider :theme="mode">
39
<NuxtLayout>
410
<NuxtPage />
511
</NuxtLayout>
6-
</div>
12+
</VanConfigProvider>
713
</template>
814

915
<style>
10-
html,
11-
body,
1216
#__nuxt {
1317
height: 100vh;
1418
margin: 0;
1519
padding: 0;
1620
}
1721
18-
#app {
19-
width: 100%;
20-
height: 100%;
22+
html {
23+
background: var(--van-gray-1);
24+
color-scheme: light;
2125
}
2226
</style>

nuxt.config.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
export default defineNuxtConfig({
2-
devtools: { enabled: true },
32
modules: [
43
'@vant/nuxt',
54
'@unocss/nuxt',
65
'nuxt-module-eslint-config',
76
],
87

9-
typescript: {
10-
shim: false,
11-
},
12-
138
css: [
149
'@unocss/reset/tailwind.css',
1510
],
1611

1712
postcss: {
1813
plugins: {
19-
// https://github.com/wswmsword/postcss-mobile-forever
2014
'autoprefixer': {},
15+
16+
// https://github.com/wswmsword/postcss-mobile-forever
2117
'postcss-mobile-forever': {
22-
appSelector: '#app',
18+
appSelector: '#__nuxt',
2319
viewportWidth: 375,
2420
maxDisplayWidth: 600,
25-
exclude: /node_modules/,
21+
// exclude: /node_modules/,
2622
},
2723
},
2824
},
25+
26+
devtools: { enabled: true },
27+
28+
typescript: { shim: false },
2929
})

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
},
1919
"devDependencies": {
2020
"@antfu/eslint-config": "^2.8.3",
21+
"@unocss/eslint-plugin": "^0.58.6",
2122
"@unocss/nuxt": "^0.58.6",
2223
"@unocss/preset-rem-to-px": "^0.58.6",
2324
"@vant/nuxt": "^1.0.4",
2425
"eslint": "npm:eslint-ts-patch@^8.57.0-0",
26+
"eslint-plugin-format": "^0.1.0",
2527
"eslint-ts-patch": "^8.57.0-0",
2628
"nuxt-module-eslint-config": "^0.1.1",
2729
"postcss-mobile-forever": "^4.1.2",

pages/index.vue

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1+
<script setup lang="ts">
2+
const menuItems = [
3+
{ title: '💿 Mock 指南', route: 'mock' },
4+
{ title: '📊 Echarts 演示', route: 'charts' },
5+
{ title: '🎨 Unocss 示例', route: 'unocss' },
6+
{ title: '🍍 持久化 Pinia 状态', route: 'counter' },
7+
{ title: '🙅 404页 演示', route: 'unknown'},
8+
]
9+
10+
const checked = ref<boolean>(false)
11+
12+
function toggle() {
13+
checked.value = !checked.value
14+
}
15+
16+
</script>
17+
18+
119
<template>
2-
<div class="text-16 text-gray-800">
3-
你好
4-
</div>
5-
</template>
20+
<VanCellGroup inset>
21+
<VanCell center title="🌗 暗黑模式">
22+
<template #right-icon>
23+
<VanSwitch v-model="checked" size="20px" aria-label="on/off Dark Mode" @click="toggle()" />
24+
</template>
25+
</VanCell>
626

7-
<style scoped>
8-
</style>
27+
<template v-for="item in menuItems" :key="item.route">
28+
<!-- item.route -->
29+
<VanCell :title="item.title" to="/" is-link />
30+
</template>
31+
</VanCellGroup>
32+
</template>

0 commit comments

Comments
 (0)