diff --git a/front-end/mall4uni/.eslintrc.cjs b/front-end/mall4uni/.eslintrc.cjs index a87c46f..2e051ac 100644 --- a/front-end/mall4uni/.eslintrc.cjs +++ b/front-end/mall4uni/.eslintrc.cjs @@ -1,32 +1,34 @@ module.exports = { env: { - browser: true, - es2021: true, - node: true + browser: true, // 启用浏览器环境,提供全局变量如 `window` 和 `document` + es2021: true, // 启用 ES2021 语法支持 + node: true // 启用 Node.js 环境,提供全局变量如 `require` 和 `module` }, globals: { - uni: 'readonly', - getApp: 'readonly', - wx: 'readonly', - getCurrentPages: 'readonly', - plus: 'readonly' + uni: 'readonly', // 将 `uni` 定义为只读全局变量,适用于 Uni-App 框架 + getApp: 'readonly', // 将 `getApp` 定义为只读全局函数,用于获取应用实例 + wx: 'readonly', // 将 `wx` 定义为只读全局对象,适用于微信小程序 + getCurrentPages: 'readonly', // 将 `getCurrentPages` 定义为只读全局函数,用于获取当前页面栈 + plus: 'readonly' // 将 `plus` 定义为只读全局对象,适用于 5+App(HTML5+) }, extends: [ - 'standard', - './.eslintrc-auto-import.json', - 'plugin:vue/vue3-recommended', - 'plugin:vue-scoped-css/vue3-recommended' + 'standard', // 继承 Standard 代码风格规则集 + './.eslintrc-auto-import.json', // 继承自定义的自动导入配置文件 + 'plugin:vue/vue3-recommended', // 继承 Vue 3 的推荐规则集 + 'plugin:vue-scoped-css/vue3-recommended' // 继承 Vue 3 scoped CSS 的推荐规则集 ], overrides: [ + // 用于针对特定文件或文件模式进行规则覆盖,当前为空 ], parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module' + ecmaVersion: 'latest', // 使用最新的 ECMAScript 版本解析代码 + sourceType: 'module' // 将代码视为 ES 模块 }, plugins: [ - 'vue' - ], + 'vue' // 使用 `eslint-plugin-vue` 插件来支持 Vue 文件的 linting + ] +}; rules: { // Possible Errors // 要求使用 let 或 const 而不是 var diff --git a/front-end/mall4uni/.npmrc b/front-end/mall4uni/.npmrc index febf696..ea2be49 100644 --- a/front-end/mall4uni/.npmrc +++ b/front-end/mall4uni/.npmrc @@ -1,4 +1,23 @@ +# 启用严格的引擎检查 +# 当设置为 true 时,npm 会严格检查项目的 package.json 文件中的 engines 字段, +# 确保当前环境的 Node.js 和 npm 版本符合指定的要求。如果不符合,npm 将抛出错误并阻止安装依赖。 engine-strict = true + +# 启用“羞耻地提升”(shameful hoisting) +# 在 yarn 中,默认情况下,依赖项会被提升到顶层 node_modules 目录中,以减少嵌套层级。 +# 但是,某些情况下,yarn 会避免提升一些依赖项,以防止潜在的冲突。 +# 设置为 true 时,yarn 会忽略这些规则,尽可能地将所有依赖项提升到顶层,即使这样做可能会导致冲突。 +# 这种做法被称为“羞耻地提升”,因为它可能会引入不稳定的依赖关系。 shamefully-hoist = true + +# 禁用严格的 peer 依赖检查 +# 当设置为 false 时,npm 或 yarn 不会因为 peer 依赖版本不匹配而抛出错误或警告。 +# peer 依赖通常用于插件系统,确保插件和主库的版本兼容性。 +# 设置为 false 可以避免因 peer 依赖版本不匹配而导致的安装失败,但可能会引入潜在的兼容性问题。 strict-peer-dependencies = false + +# 指定 npm 或 yarn 使用的注册表(registry) +# 默认情况下,npm 和 yarn 使用官方的 npm 注册表 (https://registry.npmjs.org)。 +# 通过设置此选项,可以切换到其他镜像源,例如国内的 npmmirror,以加快包的下载速度。 +# 这里指定了使用 https://registry.npmmirror.com 作为注册表,适用于中国大陆用户。 registry = https://registry.npmmirror.com diff --git a/front-end/mall4uni/index.html b/front-end/mall4uni/index.html index f4d9584..a499942 100644 --- a/front-end/mall4uni/index.html +++ b/front-end/mall4uni/index.html @@ -2,20 +2,33 @@ + + mall4uni-pro + + - + + -
- +
+ + + + diff --git a/front-end/mall4uni/jsconfig.json b/front-end/mall4uni/jsconfig.json index c177f0b..256e776 100644 --- a/front-end/mall4uni/jsconfig.json +++ b/front-end/mall4uni/jsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { "types": [ - "@dcloudio/types", - "miniprogram-api-typings", - "mini-types" + "@dcloudio/types", // 引入 DCloud 提供的类型定义,适用于 Uni-App 框架 + "miniprogram-api-typings", // 引入微信小程序 API 的类型定义,确保 TypeScript 能够识别小程序的 API + "mini-types" // 引入其他小程序相关的类型定义,扩展 TypeScript 对小程序的支持 ] }, "allowJs": true // 允许编译js文件 diff --git a/front-end/mall4uni/vite.config.js b/front-end/mall4uni/vite.config.js index d4a3b1f..30ff9c0 100644 --- a/front-end/mall4uni/vite.config.js +++ b/front-end/mall4uni/vite.config.js @@ -1,38 +1,42 @@ -import { defineConfig } from 'vite' -import uni from '@dcloudio/vite-plugin-uni' -import path from 'path' -import AutoImport from 'unplugin-auto-import/vite' -import h5ProdEffectPlugin from 'uni-vite-plugin-h5-prod-effect' +import { defineConfig } from 'vite'; // 从 Vite 导入 defineConfig 函数,用于定义 Vite 配置 +import uni from '@dcloudio/vite-plugin-uni'; // 导入 Uni-App 的 Vite 插件,用于支持 Uni-App 项目 +import path from 'path'; // 导入 Node.js 的 path 模块,用于处理文件路径 +import AutoImport from 'unplugin-auto-import/vite'; // 导入 unplugin-auto-import 插件,用于自动导入常用模块 +import h5ProdEffectPlugin from 'uni-vite-plugin-h5-prod-effect'; // 导入 H5 生产环境打包时的特殊处理插件 // https://vitejs.dev/config/ export default defineConfig({ plugins: [ - uni(), + uni(), // 启用 Uni-App 的 Vite 插件,确保 Vite 能够正确处理 Uni-App 项目 + AutoImport({ imports: [ - 'vue', - 'uni-app' + 'vue', // 自动导入 Vue 的全局 API + 'uni-app' // 自动导入 Uni-App 的全局 API ], dirs: [ - 'src/utils', - 'src/wxs/**' + 'src/utils', // 指定自动导入的目录,这里是 `src/utils` 目录下的所有文件 + 'src/wxs/**' // 指定自动导入的目录,这里是 `src/wxs` 目录及其子目录下的所有文件 ], - dts: 'src/auto-imports.d.ts', + dts: 'src/auto-imports.d.ts', // 生成的类型声明文件路径,用于 TypeScript 支持 eslintrc: { - enabled: true + enabled: true // 启用 ESLint 配置文件的自动生成,确保 ESLint 知道哪些模块是自动导入的 } }), - // 对h5 production环境打包时的特殊处理,否则uni-crazy-router在这个环境会异常 + + // 对 H5 生产环境打包时的特殊处理,确保 `uni-crazy-router` 在生产环境中正常工作 h5ProdEffectPlugin() ], + server: { - host: true, - port: 80, - open: true + host: true, // 允许外部访问开发服务器,设置为 `true` 可以在局域网内访问 + port: 80, // 设置开发服务器的端口号为 80 + open: true // 启动开发服务器时自动打开浏览器 }, + resolve: { alias: { - '@': path.resolve(__dirname, 'src') + '@': path.resolve(__dirname, 'src') // 设置别名 `@` 指向项目的 `src` 目录,方便路径引用 } } -}) +});