refactor: remove HBuilderX (#87)

* refactor: Does not depend on HBuilderX

* refactor: Remove redundant files and configurations

* doc: Add development instructions

* feat: 添加 `build:h5-netlify` 命令以 build 到不同目录

* chore: Add post-release test function
This commit is contained in:
xw 2021-11-23 11:07:28 +08:00 committed by GitHub
parent b38ab94969
commit d54a2af230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 92 additions and 17391 deletions

View File

@ -1,2 +0,0 @@
*.js
*.vue

View File

@ -1,27 +0,0 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: ["plugin:vue/essential", "@vue/standard"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
camelcase: "off",
eqeqeq: "off",
},
parserOptions: {
parser: "babel-eslint",
},
overrides: [
{
files: [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)",
],
env: {
jest: true,
},
},
],
};

3
.gitignore vendored
View File

@ -40,3 +40,6 @@ yarn-error.log*
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
# mockm
httpData

View File

@ -32,6 +32,32 @@ Markdown 文档自动即时渲染为微信图文,让你不再为微信文章
欢迎各位朋友随时提交 PR让这款微信 Markdown 编辑器变得更好!如果你有新的想法,也欢迎在 [Discussions 讨论区](https://github.com/doocs/md/discussions)反馈。 欢迎各位朋友随时提交 PR让这款微信 Markdown 编辑器变得更好!如果你有新的想法,也欢迎在 [Discussions 讨论区](https://github.com/doocs/md/discussions)反馈。
## 如何开发和部署
``` sh
# 安装依赖
npm i
# 启动开发模式
npm run serve
# 输出部署版本
npm run build
```
## 测试
``` sh
# 启动接口服务
npm run mm
# 编译到 dist/md
npm run build
# 访问 http://127.0.0.1:9000/md
# 编译到 dist
npm run build:h5-netlify
# 访问 http://127.0.0.1:9000/
```
## 功能特性 ## 功能特性
- [x] 支持自定义 CSS 样式 - [x] 支持自定义 CSS 样式

View File

@ -1,60 +1,3 @@
const plugins = [];
if (process.env.UNI_OPT_TREESHAKINGNG) {
plugins.push(
require("@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js")
);
}
if (
(process.env.UNI_PLATFORM === "app-plus" && process.env.UNI_USING_V8) ||
(process.env.UNI_PLATFORM === "h5" &&
process.env.UNI_H5_BROWSER === "builtin")
) {
const path = require("path");
const isWin = /^win/.test(process.platform);
const normalizePath = (path) => (isWin ? path.replace(/\\/g, "/") : path);
const input = normalizePath(process.env.UNI_INPUT_DIR);
try {
plugins.push([
require("@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console"),
{
file(file) {
file = normalizePath(file);
if (file.indexOf(input) === 0) {
return path.relative(input, file);
}
return false;
},
},
]);
} catch (e) {}
}
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ["@dcloudio/uni-ui"];
process.UNI_LIBRARIES.forEach((libraryName) => {
plugins.push([
"import",
{
libraryName: libraryName,
customName: (name) => {
return `${libraryName}/lib/${name}/${name}`;
},
},
]);
});
module.exports = { module.exports = {
presets: [ presets: [`@vue/cli-plugin-babel/preset`],
[ }
"@vue/app",
{
modules: "commonjs",
useBuiltIns: process.env.UNI_PLATFORM === "h5" ? "usage" : "entry",
},
],
],
plugins,
};

View File

@ -1,11 +0,0 @@
const fs = require("fs");
const manifest = require("./src/manifest.json");
manifest.h5.publicPath = process.env.SERVER_ENV !== "NETLIFY" ? "/md/" : "/";
const result = JSON.stringify(manifest, null, 2);
fs.writeFile("./src/manifest.json", result, function (err) {
if (err) {
console.error(err);
}
});

17074
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,59 +3,12 @@
"version": "1.5.6", "version": "1.5.6",
"private": false, "private": false,
"scripts": { "scripts": {
"serve": "node manifest.js & npm run dev:h5", "serve": "vue-cli-service serve",
"build": "node manifest.js & npm run build:h5", "build:h5-netlify": "cross-env SERVER_ENV=NETLIFY vue-cli-service build",
"build:h5-netlify": "cross-env SERVER_ENV=NETLIFY node manifest.js & npm run build:h5", "build": "vue-cli-service build",
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build", "mm": "npx mockm static=dist"
"build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
"build:h5": "cross-env NODE_ENV=production UNI_OUTPUT_DIR=dist UNI_PLATFORM=h5 vue-cli-service uni-build",
"build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build",
"build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
"build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
"build:mp-kuaishou": "cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build",
"build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
"build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build",
"build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
"build:quickapp-native": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build",
"build:quickapp-webview": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build",
"build:quickapp-webview-huawei": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build",
"build:quickapp-webview-union": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build",
"dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
"dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
"dev:h5": "cross-env NODE_ENV=development UNI_OUTPUT_DIR=dist UNI_PLATFORM=h5 vue-cli-service uni-serve",
"dev:mp-360": "cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch",
"dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
"dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
"dev:mp-kuaishou": "cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch",
"dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
"dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch",
"dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch",
"dev:quickapp-native": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch",
"dev:quickapp-webview": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview vue-cli-service uni-build --watch",
"dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch",
"dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch",
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
"serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js",
"test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i",
"test:h5": "cross-env UNI_PLATFORM=h5 jest -i",
"test:ios": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=ios jest -i",
"test:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu jest -i",
"test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i"
}, },
"dependencies": { "dependencies": {
"@dcloudio/uni-app-plus": "^2.0.0-31820210406002",
"@dcloudio/uni-h5": "^2.0.0-31820210406002",
"@dcloudio/uni-helper-json": "*",
"@dcloudio/uni-mp-360": "^2.0.0-31820210406002",
"@dcloudio/uni-mp-alipay": "^2.0.0-31820210406002",
"@dcloudio/uni-mp-baidu": "^2.0.0-31820210406002",
"@dcloudio/uni-mp-qq": "^2.0.0-31820210406002",
"@dcloudio/uni-mp-toutiao": "^2.0.0-31820210406002",
"@dcloudio/uni-mp-vue": "^2.0.0-31820210406002",
"@dcloudio/uni-mp-weixin": "^2.0.0-31820210406002",
"@dcloudio/uni-quickapp-native": "^2.0.0-31820210406002",
"@dcloudio/uni-quickapp-webview": "^2.0.0-31820210406002",
"@dcloudio/uni-stat": "^2.0.0-31820210406002",
"@vue/shared": "^3.0.11", "@vue/shared": "^3.0.11",
"ali-oss": "^6.15.2", "ali-oss": "^6.15.2",
"axios": "^0.21.2", "axios": "^0.21.2",
@ -65,7 +18,6 @@
"cos-js-sdk-v5": "^1.2.9", "cos-js-sdk-v5": "^1.2.9",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"element-ui": "^2.15.1", "element-ui": "^2.15.1",
"flyio": "^0.6.14",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"juice": "^7.0.0", "juice": "^7.0.0",
"marked": "^2.0.3", "marked": "^2.0.3",
@ -79,17 +31,6 @@
"vuex": "^3.5.1" "vuex": "^3.5.1"
}, },
"devDependencies": { "devDependencies": {
"@dcloudio/types": "*",
"@dcloudio/uni-automator": "^2.0.0-31820210406002",
"@dcloudio/uni-cli-i18n": "^2.0.0-32920211029004",
"@dcloudio/uni-cli-shared": "^2.0.0-31820210406002",
"@dcloudio/uni-migration": "^2.0.0-31820210406002",
"@dcloudio/uni-template-compiler": "^2.0.0-31820210406002",
"@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.0-31820210406002",
"@dcloudio/vue-cli-plugin-uni": "^2.0.0-31820210406002",
"@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.0-31820210406002",
"@dcloudio/webpack-uni-mp-loader": "^2.0.0-31820210406002",
"@dcloudio/webpack-uni-pages-loader": "^2.0.0-31820210406002",
"@vue/cli-plugin-babel": "~4.5.12", "@vue/cli-plugin-babel": "~4.5.12",
"@vue/cli-service": "~4.5.12", "@vue/cli-service": "~4.5.12",
"async-validator": "^3.5.1", "async-validator": "^3.5.1",
@ -100,6 +41,7 @@
"less-loader": "^5.0.0", "less-loader": "^5.0.0",
"mini-types": "*", "mini-types": "*",
"miniprogram-api-typings": "*", "miniprogram-api-typings": "*",
"mockm": "^1.1.25",
"postcss-comment": "^2.0.0", "postcss-comment": "^2.0.0",
"sass-loader": "^11.0.1", "sass-loader": "^11.0.1",
"vue-template-compiler": "^2.6.12" "vue-template-compiler": "^2.6.12"

View File

@ -1,22 +0,0 @@
const path = require("path");
module.exports = {
parser: require("postcss-comment"),
plugins: [
require("postcss-import")({
resolve(id, basedir, importOptions) {
if (id.startsWith("~@/")) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3));
} else if (id.startsWith("@/")) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2));
} else if (id.startsWith("/") && !id.startsWith("//")) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1));
}
return id;
},
}),
require("autoprefixer")({
remove: process.env.UNI_PLATFORM !== "h5",
}),
require("@dcloudio/vue-cli-plugin-uni/packages/postcss"),
],
};

View File

@ -16,10 +16,6 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/> />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<link
rel="stylesheet"
href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css"
/>
<link <link
rel="shortcut icon" rel="shortcut icon"
href="https://gitee.com/yanglbme/resource/raw/master/doocs-md/favicon.png" href="https://gitee.com/yanglbme/resource/raw/master/doocs-md/favicon.png"

View File

@ -1,3 +1,21 @@
<template>
<div id="app">
<router-view />
</div>
</template>
<style lang="less">
// 仿 uniapp
html,
body,
#app {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
</style>
<style lang="less"> <style lang="less">
/* 每个页面公共css */ /* 每个页面公共css */
@import url("./assets/less/style-mirror.css"); @import url("./assets/less/style-mirror.css");

View File

@ -13,6 +13,7 @@ import "codemirror/addon/edit/matchbrackets";
import "codemirror/addon/selection/active-line"; import "codemirror/addon/selection/active-line";
import "codemirror/addon/hint/show-hint.js"; import "codemirror/addon/hint/show-hint.js";
import "codemirror/addon/hint/css-hint.js"; import "codemirror/addon/hint/css-hint.js";
import router from './router';
Vue.use(ElementUI); Vue.use(ElementUI);
@ -21,7 +22,8 @@ Vue.config.productionTip = false;
App.mpType = "app"; App.mpType = "app";
const app = new Vue({ const app = new Vue({
router,
store, store,
...App, ...App,
}); });
app.$mount(); app.$mount("#app");

View File

@ -1,71 +0,0 @@
{
"name": "微信 Markdown 编辑器",
"appid": "",
"description": "",
"versionName": "1.5.6",
"versionCode": "100",
"transformPx": false,
"h5": {
"publicPath": "/md/"
},
"app-plus": {
"usingComponents": true,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
"modules": {},
"distribute": {
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios": {},
"sdkConfigs": {}
}
},
"quickapp": {},
"mp-weixin": {
"appid": "",
"setting": {
"urlCheck": false
},
"usingComponents": true
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"mp-qq": {
"usingComponents": true
}
}

View File

@ -1,17 +0,0 @@
{
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "微信 Markdown 编辑器"
}
}
],
"globalStyle": {
"navigationStyle": "custom",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
}
}

View File

@ -398,6 +398,13 @@ export default {
}, },
}; };
</script> </script>
<style lang="less" scoped>
.editor__header {
padding: 0;
}
</style>
<style lang="less" scoped> <style lang="less" scoped>
.main-body { .main-body {
padding-top: 12px; padding-top: 12px;

View File

@ -1,40 +1,9 @@
import Vue from "vue"; import Vue from "vue";
import { import {
Container,
Header,
Upload,
Tooltip,
Form,
FormItem,
Select,
Option,
ColorPicker,
Switch,
Button,
Main,
Col,
Row,
Dialog,
Loading, Loading,
Message, Message,
} from "element-ui"; } from "element-ui";
Vue.use(Container);
Vue.use(Header);
Vue.use(Upload);
Vue.use(Tooltip);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Select);
Vue.use(Option);
Vue.use(ColorPicker);
Vue.use(Switch);
Vue.use(Button);
Vue.use(Main);
Vue.use(Col);
Vue.use(Row);
Vue.use(Dialog);
Vue.use(Loading);
Vue.component(Message.name, Message); Vue.component(Message.name, Message);
Vue.prototype.$loading = Loading.service; Vue.prototype.$loading = Loading.service;

21
src/router/index.js Normal file
View File

@ -0,0 +1,21 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '@/pages/index/index'
Vue.use(VueRouter)
const routes = [
{
path: `/`,
name: `index`,
component: index,
}
]
const router = new VueRouter({
mode: `history`,
base: process.env.BASE_URL,
routes,
})
export default router

View File

@ -1,9 +0,0 @@
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"miniprogram-api-typings",
"mini-types"
]
}
}

7
vue.config.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
publicPath: process.env.SERVER_ENV === `NETLIFY` ? `/` : `/md/`, // 基本路径, 建议以绝对路径跟随访问目录
outputDir: process.env.SERVER_ENV === `NETLIFY` ? `./dist/` : `./dist/md/`, // 输出文件目录
css: {
sourceMap: true,
},
}