fix: monaco run error with production

pull/4/head
bqy_fe 4 years ago
parent 04b9910a56
commit a0482d493b
  1. 1
      .eslintrc.js
  2. 6
      .gitignore
  3. 9
      .husky/common.sh
  4. 8
      .husky/lintstagedrc.js
  5. 8
      .husky/pre-commit
  6. 3
      .stylelintignore
  7. 26
      README.md
  8. 44
      package.json
  9. 10
      src/packages/base-widgets/checkbox/index.tsx
  10. 2
      src/visual-editor/components/right-attribute-panel/components/table-prop-editor/table-prop-edit.service.tsx
  11. 2
      src/visual-editor/components/right-attribute-panel/index.tsx
  12. 6
      src/visual-editor/utils/dialog-service.tsx
  13. 8
      src/visual-editor/visual-editor.props.tsx
  14. 208
      stylelint.config.js
  15. 13
      vite.config.ts
  16. 995
      yarn.lock

@ -23,7 +23,6 @@ module.exports = {
], ],
rules: { rules: {
'vue/require-default-prop': 'off', 'vue/require-default-prop': 'off',
'@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-types': 'off', '@typescript-eslint/ban-types': 'off',

6
.gitignore vendored

@ -12,6 +12,12 @@
# yarn.lock # yarn.lock
# package-lock.json # package-lock.json
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# IDEs and editors # IDEs and editors
/.idea /.idea
.project .project

@ -0,0 +1,9 @@
#!/bin/sh
command_exists () {
command -v "$1" >/dev/null 2>&1
}
# Workaround for Windows 10, Git Bash and Yarn
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi

@ -0,0 +1,8 @@
module.exports = {
'*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --write'],
'{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': ['prettier --write--parser json'],
'package.json': ['prettier --write'],
'*.vue': ['eslint --fix', 'prettier --write', 'stylelint --fix'],
'*.{scss,less,styl,html}': ['stylelint --fix', 'prettier --write'],
'*.md': ['prettier --write']
}

@ -1,4 +1,10 @@
#!/bin/sh #!/bin/sh
. "$(dirname "$0")/_/husky.sh" . "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"
npx lint-staged [ -n "$CI" ] && exit 0
# Format and submit code according to lintstagedrc.js configuration
npm run lint:lint-staged
npm run lint:pretty

@ -0,0 +1,3 @@
/dist/*
/public/*
public/*

@ -1,4 +1,4 @@
# Vite2.x + Vue3.x + TypeScript H5低代码平台 # Vite2.x + Vue3.x + TypeScript H5 低代码平台
## 技术栈 ## 技术栈
@ -7,8 +7,8 @@
- 前端框架:[Vue 3.x](https://v3.cn.vuejs.org/) - 前端框架:[Vue 3.x](https://v3.cn.vuejs.org/)
- 路由工具:[Vue Router 4.x](https://next.router.vuejs.org/zh/index.html) - 路由工具:[Vue Router 4.x](https://next.router.vuejs.org/zh/index.html)
- 状态管理:[Vuex 4.x](https://next.vuex.vuejs.org/) - 状态管理:[Vuex 4.x](https://next.vuex.vuejs.org/)
- PC端UI 框架:[Element Plus](https://element-plus.org/#/zh-CN) - PC UI 框架:[Element Plus](https://element-plus.org/#/zh-CN)
- H5端UI 框架:[vant](https://vant-contrib.gitee.io/vant/v3/#/zh-CN/) - H5 UI 框架:[vant](https://vant-contrib.gitee.io/vant/v3/#/zh-CN/)
- CSS 预编译:[Stylus](https://stylus-lang.com/) / [Sass](https://sass.bootcss.com/documentation) / [Less](http://lesscss.cn/) - CSS 预编译:[Stylus](https://stylus-lang.com/) / [Sass](https://sass.bootcss.com/documentation) / [Less](http://lesscss.cn/)
- HTTP 工具:[Axios](https://axios-http.com/) - HTTP 工具:[Axios](https://axios-http.com/)
- Git Hook 工具:[husky](https://typicode.github.io/husky/#/) + [lint-staged](https://github.com/okonet/lint-staged) - Git Hook 工具:[husky](https://typicode.github.io/husky/#/) + [lint-staged](https://github.com/okonet/lint-staged)
@ -18,6 +18,7 @@
- 自动部署:[GitHub Actions](https://docs.github.com/cn/actions/learn-github-actions) - 自动部署:[GitHub Actions](https://docs.github.com/cn/actions/learn-github-actions)
### 功能清单 ### 功能清单
- [x] 动态添加页面 - [x] 动态添加页面
- [x] 拖拽式生成组件 - [x] 拖拽式生成组件
- [ ] service worker + indexeddb 实现无服务端的前端交互 - [ ] service worker + indexeddb 实现无服务端的前端交互
@ -27,9 +28,27 @@
- [ ] 其他... - [ ] 其他...
### 简易说明 ### 简易说明
目前在使用表单时,需要把相关的`表单控件`放到`表单容器`内部,并且需要将`按钮`放到`表单容器`内, 目前在使用表单时,需要把相关的`表单控件`放到`表单容器`内部,并且需要将`按钮`放到`表单容器`内,
然后再讲`按钮的type`设置为`表单提交按钮`这时候点击提交按钮才会自动收集表单容器内部的所有字段和值 然后再讲`按钮的type`设置为`表单提交按钮`这时候点击提交按钮才会自动收集表单容器内部的所有字段和值
### 提交规范
- `feat` 增加新功能
- `fix` 修复问题/BUG
- `style` 代码风格相关无影响运行结果的
- `perf` 优化/性能提升
- `refactor` 重构
- `revert` 撤销修改
- `test` 测试相关
- `docs` 文档/注释
- `build` 对构建系统或者外部依赖项进行了修改
- `chore` 依赖更新/脚手架配置修改等
- `workflow` 工作流改进
- `ci` 持续集成
- `types` 类型定义文件更改
- `wip` 开发中
## 快速开始 ## 快速开始
### 安装依赖 ### 安装依赖
@ -51,4 +70,3 @@ npm run dev
```sh ```sh
npm run build npm run build
``` ```

@ -12,12 +12,17 @@
"format": "prettier --write ./src", "format": "prettier --write ./src",
"lint": "eslint ./src --ext .vue,.js,.ts,.tsx", "lint": "eslint ./src --ext .vue,.js,.ts,.tsx",
"lint-fix": "eslint --fix ./src --ext .vue,.js,.ts,.tsx", "lint-fix": "eslint --fix ./src --ext .vue,.js,.ts,.tsx",
"lint:eslint": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
"lint:pretty": "pretty-quick --staged",
"prepare": "husky install" "prepare": "husky install"
}, },
"dependencies": { "dependencies": {
"@vant/touch-emulator": "^1.2.0", "@vant/touch-emulator": "^1.2.0",
"@vueuse/core": "^4.11.0", "@vueuse/core": "^4.11.1",
"@vueuse/integrations": "^4.11.0", "@vueuse/integrations": "^4.11.1",
"axios": "^0.21.1", "axios": "^0.21.1",
"dayjs": "^1.10.4", "dayjs": "^1.10.4",
"dexie": "^3.0.3", "dexie": "^3.0.3",
@ -27,42 +32,47 @@
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"nprogress": "^1.0.0-1", "nprogress": "^1.0.0-1",
"qrcode": "^1.4.4", "qrcode": "^1.4.4",
"vant": "^3.0.16", "vant": "^3.0.17",
"vue": "^3.1.0-beta.3", "vue": "^3.1.0-beta.4",
"vue-router": "^4.0.8", "vue-router": "^4.0.8",
"vuedraggable": "^4.0.1", "vuedraggable": "^4.0.1",
"vuex": "^4.0.0" "vuex": "^4.0.1"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^12.1.4", "@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4", "@commitlint/config-conventional": "^12.1.4",
"@types/node": "^14.17.0", "@types/node": "^14.17.1",
"@typescript-eslint/eslint-plugin": "^4.24.0", "@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.24.0", "@typescript-eslint/parser": "^4.25.0",
"@vitejs/plugin-legacy": "^1.4.0", "@vitejs/plugin-legacy": "^1.4.0",
"@vitejs/plugin-vue": "^1.2.2", "@vitejs/plugin-vue": "^1.2.2",
"@vitejs/plugin-vue-jsx": "^1.1.4", "@vitejs/plugin-vue-jsx": "^1.1.4",
"@vue/compiler-sfc": "^3.1.0-beta.3", "@vue/compiler-sfc": "^3.1.0-beta.4",
"commitizen": "^4.2.4", "commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0", "cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^6.3.0", "cz-customizable": "^6.3.0",
"eslint": "^7.26.0", "eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.2", "eslint-plugin-import": "^2.23.3",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.9.0", "eslint-plugin-vue": "^7.9.0",
"gh-pages": "^3.1.0", "gh-pages": "^3.1.0",
"husky": "^6.0.0", "husky": "^6.0.0",
"lint-staged": "^10.5.4", "lint-staged": "^10.5.4",
"prettier": "^2.3.0", "prettier": "^2.3.0",
"sass": "^1.32.13", "pretty-quick": "^3.1.0",
"sass": "1.32.13",
"stylelint": "^13.13.1",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^22.0.0",
"stylelint-order": "^4.1.0",
"typescript": "^4.2.4", "typescript": "^4.2.4",
"vite": "2.3.3", "vite": "2.3.4",
"vite-plugin-components": "^0.9.1", "vite-plugin-components": "^0.10.2",
"vite-plugin-style-import": "^0.10.0", "vite-plugin-style-import": "^0.10.1",
"vite-plugin-windicss": "^0.16.0-beta.17", "vite-plugin-windicss": "^0.16.0",
"vue-eslint-parser": "^7.6.0", "vue-eslint-parser": "^7.6.0",
"vue-tsc": "^0.1.4", "vue-tsc": "^0.1.6",
"windicss": "^2.5.14" "windicss": "^2.5.14"
}, },
"repository": { "repository": {

@ -51,7 +51,15 @@ export default {
) )
}, },
props: { props: {
modelValue: createEditorInputProp({ label: '默认值', defaultValue: [] }), modelValue: createEditorSelectProp({
label: '默认值',
options: [
{ label: '萝卜', val: 'radish' },
{ label: '青菜', val: 'greens' }
],
multiple: true,
defaultValue: []
}),
name: createEditorInputProp({ label: '名称,提交表单的标识符', defaultValue: 'checkbox' }), name: createEditorInputProp({ label: '名称,提交表单的标识符', defaultValue: 'checkbox' }),
label: createEditorInputProp({ label: '输入框左侧文本', defaultValue: '复选框' }), label: createEditorInputProp({ label: '输入框左侧文本', defaultValue: '复选框' }),
options: createEditorTableProp({ options: createEditorTableProp({

@ -66,7 +66,7 @@ const ServiceComponent = defineComponent({
return () => ( return () => (
<> <>
<ElDialog modelValue={state.showFlag}> <ElDialog v-model={state.showFlag}>
{{ {{
default: () => ( default: () => (
<div> <div>

@ -54,7 +54,7 @@ export default defineComponent({
[VisualEditorPropsType.switch]: () => <ElSwitch v-model={propObj[prop]} />, [VisualEditorPropsType.switch]: () => <ElSwitch v-model={propObj[prop]} />,
[VisualEditorPropsType.color]: () => <ElColorPicker v-model={propObj[prop]} />, [VisualEditorPropsType.color]: () => <ElColorPicker v-model={propObj[prop]} />,
[VisualEditorPropsType.select]: () => ( [VisualEditorPropsType.select]: () => (
<ElSelect v-model={propObj[prop]} valueKey={'value'}> <ElSelect v-model={propObj[prop]} valueKey={'value'} multiple={propConfig.multiple}>
{(() => { {(() => {
return propConfig.options!.map((opt) => ( return propConfig.options!.map((opt) => (
<ElOption label={opt.label} value={opt.val} /> <ElOption label={opt.label} value={opt.val} />

@ -44,7 +44,9 @@ const ServiceComponent = defineComponent({
show: () => { show: () => {
state.showFlag = true state.showFlag = true
}, },
hide: () => (state.showFlag = false) hide: () => {
state.showFlag = false
}
} }
const handler = { const handler = {
@ -61,7 +63,7 @@ const ServiceComponent = defineComponent({
return () => ( return () => (
<> <>
<ElDialog modelValue={state.showFlag} title={state.option.title} key={state.key}> <ElDialog v-model={state.showFlag} title={state.option.title} key={state.key}>
{{ {{
default: () => ( default: () => (
<div> <div>

@ -11,6 +11,7 @@ export type VisualEditorProps = {
type: VisualEditorPropsType type: VisualEditorPropsType
label: string label: string
tips?: string tips?: string
multiple?: boolean
defaultValue?: any defaultValue?: any
} & { } & {
options?: VisualEditorSelectOptions options?: VisualEditorSelectOptions
@ -115,6 +116,7 @@ interface EditorSelectProp {
label: string label: string
options: VisualEditorSelectOptions options: VisualEditorSelectOptions
defaultValue?: any defaultValue?: any
multiple?: boolean
tips?: string tips?: string
} }
@ -122,14 +124,16 @@ export function createEditorSelectProp({
label, label,
options, options,
defaultValue, defaultValue,
tips tips,
multiple
}: EditorSelectProp): VisualEditorProps { }: EditorSelectProp): VisualEditorProps {
return { return {
type: VisualEditorPropsType.select, type: VisualEditorPropsType.select,
label, label,
defaultValue, defaultValue,
tips, tips,
options options,
multiple
} }
} }

@ -0,0 +1,208 @@
module.exports = {
root: true,
plugins: ['stylelint-order'],
extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
rules: {
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: ['global']
}
],
'selector-pseudo-element-no-unknown': [
true,
{
ignorePseudoElements: ['v-deep']
}
],
'at-rule-no-unknown': [
true,
{
ignoreAtRules: ['function', 'if', 'each', 'include', 'mixin']
}
],
'no-empty-source': null,
'named-grid-areas-no-invalid': null,
'unicode-bom': 'never',
'no-descending-specificity': null,
'font-family-no-missing-generic-family-keyword': null,
'declaration-colon-space-after': 'always-single-line',
'declaration-colon-space-before': 'never',
'declaration-block-trailing-semicolon': 'always',
'rule-empty-line-before': [
'always',
{
ignore: ['after-comment', 'first-nested']
}
],
'unit-no-unknown': [true, { ignoreUnits: ['rpx'] }],
'order/order': [
[
'dollar-variables',
'custom-properties',
'at-rules',
'declarations',
{
type: 'at-rule',
name: 'supports'
},
{
type: 'at-rule',
name: 'media'
},
'rules'
],
{ severity: 'warning' }
],
// Specify the alphabetical order of the attributes in the declaration block
'order/properties-order': [
'position',
'top',
'right',
'bottom',
'left',
'z-index',
'display',
'float',
'width',
'height',
'max-width',
'max-height',
'min-width',
'min-height',
'padding',
'padding-top',
'padding-right',
'padding-bottom',
'padding-left',
'margin',
'margin-top',
'margin-right',
'margin-bottom',
'margin-left',
'margin-collapse',
'margin-top-collapse',
'margin-right-collapse',
'margin-bottom-collapse',
'margin-left-collapse',
'overflow',
'overflow-x',
'overflow-y',
'clip',
'clear',
'font',
'font-family',
'font-size',
'font-smoothing',
'osx-font-smoothing',
'font-style',
'font-weight',
'hyphens',
'src',
'line-height',
'letter-spacing',
'word-spacing',
'color',
'text-align',
'text-decoration',
'text-indent',
'text-overflow',
'text-rendering',
'text-size-adjust',
'text-shadow',
'text-transform',
'word-break',
'word-wrap',
'white-space',
'vertical-align',
'list-style',
'list-style-type',
'list-style-position',
'list-style-image',
'pointer-events',
'cursor',
'background',
'background-attachment',
'background-color',
'background-image',
'background-position',
'background-repeat',
'background-size',
'border',
'border-collapse',
'border-top',
'border-right',
'border-bottom',
'border-left',
'border-color',
'border-image',
'border-top-color',
'border-right-color',
'border-bottom-color',
'border-left-color',
'border-spacing',
'border-style',
'border-top-style',
'border-right-style',
'border-bottom-style',
'border-left-style',
'border-width',
'border-top-width',
'border-right-width',
'border-bottom-width',
'border-left-width',
'border-radius',
'border-top-right-radius',
'border-bottom-right-radius',
'border-bottom-left-radius',
'border-top-left-radius',
'border-radius-topright',
'border-radius-bottomright',
'border-radius-bottomleft',
'border-radius-topleft',
'content',
'quotes',
'outline',
'outline-offset',
'opacity',
'filter',
'visibility',
'size',
'zoom',
'transform',
'box-align',
'box-flex',
'box-orient',
'box-pack',
'box-shadow',
'box-sizing',
'table-layout',
'animation',
'animation-delay',
'animation-duration',
'animation-iteration-count',
'animation-name',
'animation-play-state',
'animation-timing-function',
'animation-fill-mode',
'transition',
'transition-delay',
'transition-duration',
'transition-property',
'transition-timing-function',
'background-clip',
'backface-visibility',
'resize',
'appearance',
'user-select',
'interpolation-mode',
'direction',
'marks',
'page',
'set-link-source',
'unicode-bidi',
'speak'
]
},
ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts']
}

@ -9,6 +9,8 @@ import WindiCSS from 'vite-plugin-windicss'
const CWD = process.cwd() const CWD = process.cwd()
const prefix = `monaco-editor/esm/vs`
// https://cn.vitejs.dev/config/ // https://cn.vitejs.dev/config/
export default ({ mode }: ConfigEnv): UserConfig => { export default ({ mode }: ConfigEnv): UserConfig => {
// 环境变量 // 环境变量
@ -61,6 +63,15 @@ export default ({ mode }: ConfigEnv): UserConfig => {
input: { input: {
main: resolve(__dirname, 'index.html'), main: resolve(__dirname, 'index.html'),
preview: resolve(__dirname, 'preview/index.html') preview: resolve(__dirname, 'preview/index.html')
},
output: {
manualChunks: {
jsonWorker: [`${prefix}/language/json/json.worker`],
cssWorker: [`${prefix}/language/css/css.worker`],
htmlWorker: [`${prefix}/language/html/html.worker`],
tsWorker: [`${prefix}/language/typescript/ts.worker`],
editorWorker: [`${prefix}/editor/editor.worker`]
}
} }
} }
}, },
@ -77,7 +88,7 @@ export default ({ mode }: ConfigEnv): UserConfig => {
exclude: ['vue-demi'] exclude: ['vue-demi']
}, },
server: { server: {
port: 8080, // 设置服务启动端口号 port: 10086, // 设置服务启动端口号
open: false, // 设置服务启动时是否自动打开浏览器 open: false, // 设置服务启动时是否自动打开浏览器
cors: true // 允许跨域 cors: true // 允许跨域

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save