You've already forked template-MP
Compare commits
3 Commits
future
...
1f3600103e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f3600103e | ||
|
|
d8e560536a | ||
|
|
2b99835356 |
1
.env
1
.env
@@ -2,3 +2,4 @@ VITE_BASE_URL= #接口地址
|
|||||||
VITE_ASSETSURL=https://cdn.vrupup.com/s/1598/assets/ #资源地址
|
VITE_ASSETSURL=https://cdn.vrupup.com/s/1598/assets/ #资源地址
|
||||||
VITE_APPID=wx9cb717d8151d8486 #小程序APPID
|
VITE_APPID=wx9cb717d8151d8486 #小程序APPID
|
||||||
VITE_UNI_APPID=_UNI_8842336 #UNI-APPID
|
VITE_UNI_APPID=_UNI_8842336 #UNI-APPID
|
||||||
|
VITE_LIBVERSION=3.0.0 #微信小程序基础库
|
||||||
18
IFLOW.md
18
IFLOW.md
@@ -8,7 +8,7 @@
|
|||||||
* **Vue3**: 渐进式 JavaScript 框架,用于构建用户界面。
|
* **Vue3**: 渐进式 JavaScript 框架,用于构建用户界面。
|
||||||
* **uView-Plus**: 基于 UniApp 的 UI 组件库。
|
* **uView-Plus**: 基于 UniApp 的 UI 组件库。
|
||||||
* **z-paging**: 一个用于处理分页加载的组件库。
|
* **z-paging**: 一个用于处理分页加载的组件库。
|
||||||
* **Vuex**: 状态管理库(在当前项目中未使用,使用了简单的全局状态管理)。
|
* **Vuex**: 状态管理库,用于统一管理应用状态(登录状态、用户信息等)。
|
||||||
|
|
||||||
## 目录结构
|
## 目录结构
|
||||||
|
|
||||||
@@ -119,6 +119,12 @@ npm install
|
|||||||
* 包含请求和响应拦截器,用于处理通用逻辑(如错误提示、鉴权等)。
|
* 包含请求和响应拦截器,用于处理通用逻辑(如错误提示、鉴权等)。
|
||||||
* 各业务板块的接口都应存放在 `api/modules` 下,并将单个接口进行导出以便页面按需导入。
|
* 各业务板块的接口都应存放在 `api/modules` 下,并将单个接口进行导出以便页面按需导入。
|
||||||
|
|
||||||
|
## 状态管理 (Vuex)
|
||||||
|
|
||||||
|
* 项目集成了Vuex进行全局状态管理。
|
||||||
|
* 状态管理文件位于 `store/index.js`。
|
||||||
|
* 使用 `useStore` 钩子在组件中访问状态。
|
||||||
|
|
||||||
## 组件
|
## 组件
|
||||||
|
|
||||||
* 项目集成了 `uView-Plus` 和 `z-paging` 两个组件库。
|
* 项目集成了 `uView-Plus` 和 `z-paging` 两个组件库。
|
||||||
@@ -129,6 +135,14 @@ npm install
|
|||||||
* 微信的原生组件放在页面根目录下的 `wxcomponents/`,并在使用了组件的对应页面路由配置中添加组件的引用属性 `"usingComponents": { "components": "/wxcomponents/components/components" }`。
|
* 微信的原生组件放在页面根目录下的 `wxcomponents/`,并在使用了组件的对应页面路由配置中添加组件的引用属性 `"usingComponents": { "components": "/wxcomponents/components/components" }`。
|
||||||
* 组件编写应遵循项目中已有的风格。
|
* 组件编写应遵循项目中已有的风格。
|
||||||
|
|
||||||
|
## 分页功能
|
||||||
|
|
||||||
|
* 项目使用 `z-paging` 组件实现分页功能。
|
||||||
|
* 分页组件通过 `v-model` 绑定数据,并使用 `@query` 事件处理数据查询。
|
||||||
|
* 在页面中直接使用 `v-for` 循环渲染数据项,如:`<view class="item" v-for="item in dataList" :key="item.id">`。
|
||||||
|
* 通过 `paging.value?.reload()` 触发分页组件重新加载数据。
|
||||||
|
* 通过 `paging.value?.complete()` 通知分页组件数据加载完成。
|
||||||
|
|
||||||
## 页面
|
## 页面
|
||||||
|
|
||||||
* 页面配置在 `pages.json` 中管理。
|
* 页面配置在 `pages.json` 中管理。
|
||||||
@@ -148,3 +162,5 @@ npm install
|
|||||||
## 其他
|
## 其他
|
||||||
|
|
||||||
* 页面中的分享功能应该使用原生的微信分享功能,通过 `button` 或 `<u-button>` 组件的 `open-type="share"` 属性实现。
|
* 页面中的分享功能应该使用原生的微信分享功能,通过 `button` 或 `<u-button>` 组件的 `open-type="share"` 属性实现。
|
||||||
|
* 项目使用环境变量管理不同环境的配置,通过 `.env` 文件配置。
|
||||||
|
* Vite配置文件 `vite.config.js` 包含了自定义插件用于在编译时替换 `manifest.json` 中的 appid。
|
||||||
2
main.js
2
main.js
@@ -1,6 +1,7 @@
|
|||||||
import App from './App'
|
import App from './App'
|
||||||
import uviewPlus from '/uview-plus'
|
import uviewPlus from '/uview-plus'
|
||||||
import globalMixin from './mixins/global'
|
import globalMixin from './mixins/global'
|
||||||
|
import store from './store'
|
||||||
import { createSSRApp } from 'vue'
|
import { createSSRApp } from 'vue'
|
||||||
import './uni.promisify.adaptor'
|
import './uni.promisify.adaptor'
|
||||||
|
|
||||||
@@ -15,5 +16,6 @@ export function createApp() {
|
|||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
app.use(uviewPlus)
|
app.use(uviewPlus)
|
||||||
app.use(globalMixin)
|
app.use(globalMixin)
|
||||||
|
app.use(store)
|
||||||
return { app }
|
return { app }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ function replaceManifestAppid() {
|
|||||||
dotenv.config({ path: resolve(__dirname, '.env') })
|
dotenv.config({ path: resolve(__dirname, '.env') })
|
||||||
const appid = process.env.VITE_APPID
|
const appid = process.env.VITE_APPID
|
||||||
const uni_appId = process.env.VITE_UNI_APPID
|
const uni_appId = process.env.VITE_UNI_APPID
|
||||||
|
const libVersion = process.env.VITE_LIBVERSION || '3.0.0'
|
||||||
|
|
||||||
if (appid && uni_appId) {
|
if (appid && uni_appId) {
|
||||||
// 读取 manifest.json 文件
|
// 读取 manifest.json 文件
|
||||||
@@ -37,6 +38,7 @@ function replaceManifestAppid() {
|
|||||||
|
|
||||||
if (manifest['mp-weixin']) {
|
if (manifest['mp-weixin']) {
|
||||||
manifest['mp-weixin'].appid = appid
|
manifest['mp-weixin'].appid = appid
|
||||||
|
manifest['mp-weixin'].libVersion = libVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写回文件
|
// 写回文件
|
||||||
|
|||||||
Reference in New Issue
Block a user