自动化接入
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@
|
||||
*/package-lock.json
|
||||
/server/logs/
|
||||
/server/run/
|
||||
/wxmp/src/pages.json
|
||||
|
||||
@@ -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/)
|
||||
|
||||
41
wxmp/bin/PageBase.js
Normal file
41
wxmp/bin/PageBase.js
Normal file
@@ -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
|
||||
43
wxmp/bin/pages.js
Normal file
43
wxmp/bin/pages.js
Normal file
@@ -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();
|
||||
84
wxmp/bin/tools.js
Normal file
84
wxmp/bin/tools.js
Normal file
@@ -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}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function () {
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow: function () {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function () {
|
||||
console.log('App Hide')
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "uni-app"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
}
|
||||
}
|
||||
23
wxmp/src/pages/home.vue
Normal file
23
wxmp/src/pages/home.vue
Normal file
@@ -0,0 +1,23 @@
|
||||
<template>
|
||||
<section class="home">
|
||||
<open-data type="userAvatarUrl"/>
|
||||
<open-data type="userNickName"/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "home",
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {},
|
||||
created() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.home {
|
||||
}
|
||||
</style>
|
||||
@@ -1,48 +0,0 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<image class="logo" src="/static/logo.png"></image>
|
||||
<view class="text-area">
|
||||
<text class="title">{{ title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: 'Hello',
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
margin-top: 200px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.text-area {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 36px;
|
||||
color: #8f8f94;
|
||||
}
|
||||
</style>
|
||||
22
wxmp/src/pages/mine.vue
Normal file
22
wxmp/src/pages/mine.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<section class="mine">
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "mine",
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {},
|
||||
created() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.mine {
|
||||
}
|
||||
</style>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 KiB |
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user