Просмотр исходного кода

Merge branch 'base' into tabbar

菲鸽 2 лет назад
Родитель
Сommit
137fa5846b
7 измененных файлов с 27 добавлено и 21 удалено
  1. 0 2
      .vscode/extensions.json
  2. 0 1
      package.json
  3. 5 0
      src/pages/index/index.vue
  4. 0 0
      src/types/shims-uni.d.ts
  5. 9 1
      tsconfig.json
  6. 13 15
      uno.config.ts
  7. 0 2
      vite.config.ts

+ 0 - 2
.vscode/extensions.json

@@ -7,13 +7,11 @@
     "antfu.unocss",
     "antfu.iconify",
     "evils.uniapp-vscode",
-    "mrmaoddxxaa.create-uniapp-view",
     "uni-helper.uni-helper-vscode",
     "uni-helper.uni-app-schemas-vscode",
     "uni-helper.uni-highlight-vscode",
     "uni-helper.uni-ui-snippets-vscode",
     "uni-helper.uni-app-snippets-vscode",
-    "uni-helper.uni-cloud-snippets-vscode",
     "mrmlnc.vscode-json5"
   ]
 }

+ 0 - 1
package.json

@@ -151,7 +151,6 @@
     "vite": "4.3.5",
     "vite-plugin-restart": "^0.4.0",
     "vite-plugin-svg-icons": "^2.0.1",
-    "vite-plugin-vue-setup-extend": "^0.4.0",
     "vite-svg-loader": "^5.1.0",
     "vue-tsc": "^1.8.25"
   }

+ 5 - 0
src/pages/index/index.vue

@@ -33,6 +33,11 @@
 
 <script lang="ts" setup>
 import PLATFORM from '@/utils/platform'
+
+defineOptions({
+  name: 'Home',
+})
+
 // 获取屏幕边界到安全区域距离
 const { safeAreaInsets } = uni.getSystemInfoSync()
 const author = ref('菲鸽')

shims-uni.d.ts → src/types/shims-uni.d.ts


+ 9 - 1
tsconfig.json

@@ -22,5 +22,13 @@
     "nativeTags": ["block", "template", "component", "slot"]
   },
   "exclude": ["node_modules"],
-  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/**/*.json"]
+  "include": [
+    "src/**/*.ts",
+    "src/**/*.js",
+    "src/**/*.d.ts",
+    "src/**/*.tsx",
+    "src/**/*.jsx",
+    "src/**/*.vue",
+    "src/**/*.json"
+  ]
 }

+ 13 - 15
uno.config.ts

@@ -1,7 +1,8 @@
 // uno.config.ts
 import {
-  Preset,
+  type Preset,
   defineConfig,
+  presetUno,
   presetAttributify,
   presetIcons,
   transformerDirectives,
@@ -11,28 +12,25 @@ import {
 import { presetApplet, presetRemRpx, transformerAttributify } from 'unocss-applet'
 
 // @see https://unocss.dev/presets/legacy-compat
-import presetLegacyCompat from '@unocss/preset-legacy-compat'
+import { presetLegacyCompat } from '@unocss/preset-legacy-compat'
 
-const isH5 = process.env?.UNI_PLATFORM === 'h5'
 const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false
 
 const presets: Preset[] = []
-if (!isMp) {
-  /**
-   * you can add `presetAttributify()` here to enable unocss attributify mode prompt
-   * although preset is not working for applet, but will generate useless css
-   * 为了不生产无用的css,要过滤掉 applet
-   */
-  // 支持css class属性化,eg: `<button bg="blue-400 hover:blue-500 dark:blue-500 dark:hover:blue-600" text="sm white">attributify Button</button>`
-  presets.push(presetAttributify())
-}
-if (!isH5) {
-  presets.push(presetRemRpx())
+if (isMp) {
+  // 使用小程序预设
+  presets.push(presetApplet(), presetRemRpx())
+} else {
+  presets.push(
+    // 非小程序用官方预设
+    presetUno(),
+    // 支持css class属性化
+    presetAttributify(),
+  )
 }
 export default defineConfig({
   presets: [
     ...presets,
-    presetApplet(),
     // 支持图标,需要搭配图标库,eg: @iconify-json/carbon, 使用 `<button class="i-carbon-sun dark:i-carbon-moon" />`
     presetIcons({
       scale: 1.2,

+ 0 - 2
vite.config.ts

@@ -16,7 +16,6 @@ import UnoCSS from 'unocss/vite'
 // @see https://github.com/jpkleemans/vite-svg-loader
 import svgLoader from 'vite-svg-loader'
 import AutoImport from 'unplugin-auto-import/vite'
-import vueSetupExtend from 'vite-plugin-vue-setup-extend'
 import { visualizer } from 'rollup-plugin-visualizer'
 import ViteRestart from 'vite-plugin-restart'
 
@@ -71,7 +70,6 @@ export default ({ command, mode }) => {
         vueTemplate: true, // default false
       }),
 
-      vueSetupExtend(),
       ViteRestart({
         // 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
         restart: ['vite.config.js'],