From ff550db7b63dcb143b4de48d1b75bb58770f2153 Mon Sep 17 00:00:00 2001 From: yuantao Date: Mon, 29 Sep 2025 14:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=BC=A0=E7=BB=9F=E7=9A=84?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=B7=B7=E5=85=A5=E6=94=B9=E4=B8=BA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8Vue3=E7=9A=84=E5=85=A8=E5=B1=80=E6=9A=B4=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IFLOW.md | 4 +--- README.md | 25 ++++++++++++++++++------- main.ts | 8 ++++---- mixins/global.ts | 18 ------------------ pages/index/index.vue | 5 ++++- vite.config.js | 12 +++++++++--- 6 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 mixins/global.ts diff --git a/IFLOW.md b/IFLOW.md index c7c76b8..7a094ab 100644 --- a/IFLOW.md +++ b/IFLOW.md @@ -27,8 +27,6 @@ ├── components/ # 公共组件 ├── lib/ # 第三方库 │ └── luch-request/ # luch-request 网络请求库 -├── mixins/ # Vue 混入 -│ └── global.ts # 全局混入 ├── pages/ # 主包页面 │ └── index/ # 首页 │ └── index.vue # 首页页面 @@ -98,7 +96,7 @@ npm install ## 静态资源 -* 静态资源变量 `ASSETSURL` 已进行全局混入,可以在 `` 中直接使用。 +* 静态资源变量 `ASSETSURL` 已进行全局暴露,可以在 `` 中直接使用。 * 所有静态资源URL应该使用 `ASSETSURL` 进行拼接,如:`${ASSETSURL}simple.png`。 ## 工具函数 (tool.ts) diff --git a/README.md b/README.md index 013fc24..e42a7bf 100644 --- a/README.md +++ b/README.md @@ -5,25 +5,36 @@ ## 目录结构 ``` -├── api/ # 接口相关 -│ ├── modules/ # 模块化 API 请求 -│ └── request.ts # 请求封装配置 +├── api/ # 接口相关 +│ ├── modules/ # 业务接口 +│ └── request.ts # 请求封装 ├── common/ # 公共资源 │ ├── styles/ # 全局样式 +│ │ ├── common.css # codefun原子类样式 +│ │ └── base.scss # 全局样式变量 │ └── utils/ # 工具函数 +│ └── tool.ts # 常用工具函数 ├── components/ # 公共组件 ├── lib/ # 第三方库 -├── mixins/ # Vue 混入 +│ └── luch-request/ # luch-request 网络请求库 ├── pages/ # 主包页面 +│ └── index/ # 首页 +│ └── index.vue # 首页页面 +├── subPages/ # 分包页面 ├── store/ # 状态管理 -├── uni_modules/ # uni-app 组件库 +│ └── index.ts # Vuex store +├── uni_modules/ # uni-app 组件 +│ └── z-paging/ # 分页组件库 ├── uview-plus/ # uView-Plus 组件库 ├── App.vue # 应用入口 ├── main.ts # 主入口文件 -├── pages.json # 页面路由和配置 +├── pages.json # 页面配置 ├── manifest.json # 应用配置 ├── uni.scss # 全局样式变量 -└── .env # 环境变量配置 +├── vite.config.js # Vite 编译配置 +├── .env # 环境变量 +├── .nvmdrc # Node.js 版本要求 +└── tsconfig.json # TypeScript 配置 ``` ## 使用方法 diff --git a/main.ts b/main.ts index 87dcc70..5cc0232 100644 --- a/main.ts +++ b/main.ts @@ -5,10 +5,10 @@ import App from './App.vue' // 创建应用实例 const app = createApp(App) -// 全局混入 +// 提供全局变量 // @ts-ignore -import mixin from './mixins/global' -app.use(mixin) +const ASSETSURL: string = import.meta.env.VITE_ASSETSURL +app.provide('ASSETSURL', ASSETSURL) // 全局组件 // @ts-ignore @@ -18,4 +18,4 @@ app.use(uView) // 挂载应用 app.mount('#app') -export default app \ No newline at end of file +export default app diff --git a/mixins/global.ts b/mixins/global.ts deleted file mode 100644 index b5f2318..0000000 --- a/mixins/global.ts +++ /dev/null @@ -1,18 +0,0 @@ -// @ts-ignore -const ASSETSURL = import.meta.env.VITE_ASSETSURL - -export default { - install(app: any) { - app.mixin({ - data() { - return { - // 资源地址 - ASSETSURL, - } - }, - onLoad() {}, - onShow() {}, - methods: {}, - }) - }, -} \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 418bfaf..b7f84e2 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,14 +3,17 @@ - {{ title }} + {{ title }}{{ ASSETSURL }} 点击按钮