diff --git a/.gitignore b/.gitignore
index 48ca5df..9e1ccaa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
*/package-lock.json
/server/logs/
/server/run/
+/wxmp/src/pages.json
diff --git a/wxmp/README.md b/wxmp/README.md
index 370018d..84ea7e3 100644
--- a/wxmp/README.md
+++ b/wxmp/README.md
@@ -2,36 +2,3 @@
#### 介绍
和老婆的创业项目
-
-#### 软件架构
-软件架构说明
-
-
-#### 安装教程
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### 使用说明
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### 参与贡献
-
-1. Fork 本仓库
-2. 新建 Feat_xxx 分支
-3. 提交代码
-4. 新建 Pull Request
-
-
-#### 特技
-
-1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
-2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
-3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
-4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
-5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
-6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
diff --git a/wxmp/bin/PageBase.js b/wxmp/bin/PageBase.js
new file mode 100644
index 0000000..ad7c600
--- /dev/null
+++ b/wxmp/bin/PageBase.js
@@ -0,0 +1,41 @@
+class PageBase {
+ constructor(path, vue) {
+ this.path = path
+ this.name = path.replace(/.*[\\\/]([^\\\/]+)$/g, '$1')
+ this.init(vue)
+ }
+
+ init(vue) {
+ if (/customNavigation/.test(vue)) {
+ this.style = {navigationStyle: "custom"}
+ } else {
+ this.style = {navigationBarTitleText: this.label}
+ //是否开启下拉刷新
+ if (/enablePullDownRefresh/.test(vue)) {
+ this.style.enablePullDownRefresh = true
+ }
+ //导航栏标题颜色及状态栏前景颜色,仅支持 black/white
+ if (/navigationBarTextStyle/.test(vue)) {
+ this.style.navigationBarTextStyle = vue.replace(/[\s\S]*(navigationBarTextStyle:.+),[\s\S]*/gm, '$1')
+ }
+ //导航栏背景颜色(同状态栏背景色)
+ if (/navigationBarBackgroundColor/.test(vue)) {
+ this.style.navigationBarBackgroundColor = vue.replace(/[\s\S]*(navigationBarBackgroundColor:.+),[\s\S]*/gm, '$1')
+ }
+ // //下拉显示出来的窗口的背景色
+ // if (/backgroundColor/.test(vue)) {
+ // this.style.backgroundColor = vue.replace(/[\s\S]*(backgroundColor:.+),[\s\S]*/gm, '$1')
+ // }
+ }
+ if (/appName/.test(vue)) {
+ let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1')
+ this.label = appName.replace(/(appName:|["'])/g, '')?.trim()
+ }
+ }
+
+ setLabel(name) {
+ this.label = name
+ }
+}
+
+module.exports = PageBase
diff --git a/wxmp/bin/pages.js b/wxmp/bin/pages.js
new file mode 100644
index 0000000..c52c702
--- /dev/null
+++ b/wxmp/bin/pages.js
@@ -0,0 +1,43 @@
+const {chalkTag, findPages, fsExtra, fs} = require("./tools");
+const PageBase = require("./PageBase");
+const start = () => {
+ chalkTag.info('开始生成pages.json...')
+ let json = {
+ easycom: {
+ "^(K|V)(.*)": "@/components/$1$2.vue"
+ },
+ pages: [
+ {path: 'pages/home', style: {navigationBarTitleText: "buy-lite"}},
+ {path: "pages/mine", style: {navigationBarTitleText: "个人中心"}}
+ ],
+ subPackages: [
+ {root: "mods/", pages: []},
+ {root: "components/pages/", pages: []},
+ ],
+ globalStyle: {
+ pageOrientation: "auto",
+ navigationBarTextStyle: "white",
+ navigationBarBackgroundColor: "#4181FF"
+ }
+ }
+ Promise.all([
+ findPages('src/components/pages', file => {
+ if (/.+\\pages\\[^\\]+\.vue/g.test(file)) {
+ const app = new PageBase(file.replace(/^src\\components\\pages\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
+ return json.subPackages[1].pages.push(app)
+ }
+ }),
+ findPages('src/mods', file => {
+ if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
+ const app = new PageBase(file.replace(/^src\\mods\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
+ return json.subPackages[0].pages.push(app)
+ }
+ }),
+ ]).then(() => {
+ fsExtra.outputJson('src/pages.json', json, () => {
+ chalkTag.done('生成pages.json')
+ })
+ })
+}
+
+start();
diff --git a/wxmp/bin/tools.js b/wxmp/bin/tools.js
new file mode 100644
index 0000000..da43c95
--- /dev/null
+++ b/wxmp/bin/tools.js
@@ -0,0 +1,84 @@
+const fsExtra = require('fs-extra')
+const path = require('path')
+const chalk = require('chalk')
+const fs = require('fs')
+/**
+ * 将函数封装成promise
+ */
+const promisify = fn => {
+ return function () {
+ let args = arguments;
+ return new Promise(function (resolve, reject) {
+ [].push.call(args, function (err, result) {
+ if (err) {
+ console.log(err)
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ });
+ fn.apply(null, args);
+ });
+ }
+}
+
+const readdir = promisify(fs.readdir)
+const stat = promisify(fs.stat)
+
+/**
+ * 封装打印工具
+ */
+const {log} = console
+const chalkTag = {
+ info: msg => log([chalk.bgBlue.black(' INFO '), msg].join(' ')),
+ done: msg => log([chalk.bgGreen.black(' DONE '), msg].join(' ')),
+ error: msg => log([chalk.bgRed.black(' ERROR '), msg].join(' ')),
+}
+
+/**
+ * 遍历应用的方法
+ */
+const findApp = (dir, cb) => {
+ fsExtra.ensureDirSync(dir)
+ return readdir(dir).then(apps => {
+ return Promise.all(apps.map(e => {
+ let cPath = path.join(dir, e)
+ return stat(cPath).then(state => {
+ if (state.isDirectory()) {
+ return findApp(cPath, cb)
+ } else if (state.isFile()) {
+ cb && cb(dir)
+ }
+ })
+ }) || [])
+ })
+}
+const findPages = (dir, cb) => {
+ fsExtra.ensureDirSync(dir)
+ return readdir(dir).then(apps => {
+ return Promise.all(apps.map(e => {
+ let cPath = path.join(dir, e)
+ return stat(cPath).then(state => {
+ if (state.isDirectory()) {
+ return findPages(cPath, cb)
+ } else if (state.isFile()) {
+ cb && cb(cPath)
+ }
+ })
+ }) || [])
+ })
+}
+const copyFiles = (dir, source = 'src/mods') => {
+ chalkTag.info(`开始扫描${source}...`)
+ return new Promise(resolve => {
+ fsExtra.emptyDir(dir, err => {
+ if (!err) {
+ fsExtra.copy(source, dir).then(() => {
+ chalkTag.done(source + ' 扫描完毕')
+ resolve()
+ })
+ }
+ })
+ })
+}
+module.exports = {findApp, chalkTag, fsExtra, copyFiles, fs, path, findPages}
diff --git a/wxmp/package.json b/wxmp/package.json
index e2c498d..b90c59a 100644
--- a/wxmp/package.json
+++ b/wxmp/package.json
@@ -3,9 +3,10 @@
"version": "0.0.0",
"scripts": {
"dev:h5": "uni",
- "dev:mp-weixin": "uni -p mp-weixin",
+ "dev:mp-weixin": "npm run pages&&uni -p mp-weixin",
"build:h5": "uni build",
- "build:mp-weixin": "uni build -p mp-weixin"
+ "build:mp-weixin": "uni build -p mp-weixin",
+ "pages": "node bin/pages.js"
},
"dependencies": {
"@dcloudio/uni-app": "3.0.0-3061420221215001",
@@ -29,6 +30,10 @@
"@dcloudio/uni-cli-shared": "3.0.0-3061420221215001",
"@dcloudio/uni-stacktracey": "3.0.0-3061420221215001",
"@dcloudio/vite-plugin-uni": "3.0.0-3061420221215001",
+ "chalk": "^4.1.2",
+ "fs-extra": "^11.1.0",
+ "path": "^0.12.7",
+ "sass": "^1.57.1",
"vite": "^3.2.4"
}
}
diff --git a/wxmp/src/App.vue b/wxmp/src/App.vue
index 52dd89d..23c99f8 100644
--- a/wxmp/src/App.vue
+++ b/wxmp/src/App.vue
@@ -1,13 +1,10 @@
diff --git a/wxmp/src/main.js b/wxmp/src/main.js
index 0f3a925..3889ada 100644
--- a/wxmp/src/main.js
+++ b/wxmp/src/main.js
@@ -1,10 +1,9 @@
-import {
- createSSRApp
-} from "vue";
+import {createSSRApp} from "vue";
import App from "./App.vue";
+
export function createApp() {
- const app = createSSRApp(App);
- return {
- app,
- };
+ const app = createSSRApp(App);
+ return {
+ app,
+ };
}
diff --git a/wxmp/src/pages.json b/wxmp/src/pages.json
deleted file mode 100644
index 692ba11..0000000
--- a/wxmp/src/pages.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "pages": [
- {
- "path": "pages/index/index",
- "style": {
- "navigationBarTitleText": "uni-app"
- }
- }
- ],
- "globalStyle": {
- "navigationBarTextStyle": "black",
- "navigationBarTitleText": "uni-app",
- "navigationBarBackgroundColor": "#F8F8F8",
- "backgroundColor": "#F8F8F8"
- }
-}
diff --git a/wxmp/src/pages/home.vue b/wxmp/src/pages/home.vue
new file mode 100644
index 0000000..d9cc990
--- /dev/null
+++ b/wxmp/src/pages/home.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
diff --git a/wxmp/src/pages/index/index.vue b/wxmp/src/pages/index/index.vue
deleted file mode 100644
index 668ea12..0000000
--- a/wxmp/src/pages/index/index.vue
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
- {{ title }}
-
-
-
-
-
-
-
diff --git a/wxmp/src/pages/mine.vue b/wxmp/src/pages/mine.vue
new file mode 100644
index 0000000..bb76364
--- /dev/null
+++ b/wxmp/src/pages/mine.vue
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
diff --git a/wxmp/src/static/logo.png b/wxmp/src/static/logo.png
deleted file mode 100644
index b5771e2..0000000
Binary files a/wxmp/src/static/logo.png and /dev/null differ
diff --git a/wxmp/vite.config.js b/wxmp/vite.config.js
index 6f7b2c3..45c0056 100644
--- a/wxmp/vite.config.js
+++ b/wxmp/vite.config.js
@@ -1,6 +1,6 @@
-import { defineConfig } from 'vite'
+import {defineConfig} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
-// https://vitejs.dev/config/
+
export default defineConfig({
plugins: [
uni(),