fix: code check (#117)

This commit is contained in:
yaoyun8 2023-12-07 20:36:26 +08:00 committed by GitHub
parent a8379f2bda
commit 009a6d0754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 135 additions and 119 deletions

View File

@ -26,7 +26,7 @@ const cacheStringFunction = (fn) => {
}
const hyphenateRE = /\B([A-Z])/g
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase())
var _export_sfc = (sfc, props) => {
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc
for (const [key, val] of props) {
target[key] = val
@ -73,7 +73,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
])
)
}
var block = /* @__PURE__ */ _export_sfc(_sfc_main, [
const block = /* @__PURE__ */ _export_sfc(_sfc_main, [
['render', _sfc_render],
['__file', 'D:/tmp/buildground/buildground_1673597935715/src/block/generated/components/PortalBlock.vue']
])

View File

@ -11,25 +11,27 @@
*/
;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory(
require('@opentiny/tiny-engine-webcomponent-core'),
require('vue'),
require('vue-i18n'),
require('@opentiny/vue-icon')
))
: typeof define === 'function' && define.amd
? define(['@opentiny/tiny-engine-webcomponent-core', 'vue', 'vue-i18n', '@opentiny/vue-icon'], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.TinyVueBlock = factory(global.TinyWebcomponentCore, global.Vue, global.VueI18n, global.TinyVueIcon)))
})(this, function (tinyWebcomponentCore, vue, vueI18n, tinyVue3Icon) {
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = factory(
require('@opentiny/tiny-engine-webcomponent-core'),
require('vue'),
require('vue-i18n'),
require('@opentiny/vue-icon')
)
} else if (typeof define === 'function' && define.amd) {
define(['@opentiny/tiny-engine-webcomponent-core', 'vue', 'vue-i18n', '@opentiny/vue-icon'], factory)
} else {
;(global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.TinyVueBlock = factory(global.TinyWebcomponentCore, global.Vue, global.VueI18n, global.TinyVueIcon))
}
})(this, (tinyWebcomponentCore, vue, vueI18n, tinyVue3Icon) => {
function _interopNamespace(e) {
if (e && e.__esModule) return e
var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } })
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } })
if (e) {
Object.keys(e).forEach(function (k) {
Object.keys(e).forEach((k) => {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k)
const d = Object.getOwnPropertyDescriptor(e, k)
Object.defineProperty(
n,
k,
@ -45,10 +47,10 @@
}
})
}
n['default'] = e
n.default = e
return Object.freeze(n)
}
var vue__namespace = /* @__PURE__ */ _interopNamespace(vue)
const vue__namespace = /* @__PURE__ */ _interopNamespace(vue)
Object.freeze({})
Object.freeze([])
const cacheStringFunction = (fn) => {
@ -60,7 +62,7 @@
}
const hyphenateRE = /\B([A-Z])/g
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase())
var _export_sfc = (sfc, props) => {
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc
for (const [key, val] of props) {
target[key] = val
@ -112,7 +114,7 @@
])
)
}
var block = /* @__PURE__ */ _export_sfc(_sfc_main, [
const block = /* @__PURE__ */ _export_sfc(_sfc_main, [
['render', _sfc_render],
['__file', 'D:/tmp/buildground/buildground_1673597935715/src/block/generated/components/PortalBlock.vue']
])

View File

@ -76,6 +76,6 @@ const Mapper = {
TinyDropdown: Dropdown,
TinyChartHistogram: ChartHistogram
}
Mapper['TinyTabs'].isGroup = true
Mapper['TinyGrid'].isGroup = true
Mapper.TinyTabs.isGroup = true
Mapper.TinyGrid.isGroup = true
export { Mapper as default }

View File

@ -1,23 +1,25 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory(require('@opentiny/vue')))
: typeof define === 'function' && define.amd
? define(['@opentiny/vue'], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.TinyLowcodeComponent = factory(global.TinyVue)))
})(this, function (tinyVue3) {
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = factory(require('@opentiny/vue'))
} else if (typeof define === 'function' && define.amd) {
define(['@opentiny/vue'], factory)
} else {
;(global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.TinyLowcodeComponent = factory(global.TinyVue))
}
})(this, (tinyVue3) => {
'use strict'
const Mapper = {
TinyCarouselItem: tinyVue3.CarouselItem,
@ -52,7 +54,7 @@
TinyDropdown: tinyVue3.Dropdown,
TinyChartHistogram: tinyVue3.ChartHistogram
}
Mapper['TinyTabs'].isGroup = true
Mapper['TinyGrid'].isGroup = true
Mapper.TinyTabs.isGroup = true
Mapper.TinyGrid.isGroup = true
return Mapper
})

View File

@ -42,9 +42,9 @@ const cacheStringFunction = (fn) => {
}
const hyphenateRE = /\B([A-Z])/g
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase())
var _style_0 =
const _style_0 =
'\n.team-list-item.active[data-v-b66e3972] {\r\n border: 1px solid #38acff;\n}\n.toolbars-item[data-v-b66e3972]:hover {\r\n cursor: pointer;\r\n background-color: #f1f2f3;\n}\n.toolbars-item.active[data-v-b66e3972] {\r\n background-color: #e5e6e8;\n}\n'
var _export_sfc = (sfc, props) => {
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc
for (const [key, val] of props) {
target[key] = val
@ -406,7 +406,7 @@ const _hoisted_22 = /* @__PURE__ */ _withScopeId(() =>
)
)
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
var _a
let _a
const _component_tiny_icon_setting = resolveComponent('tiny-icon-setting')
const _component_tiny_tooltip = resolveComponent('tiny-tooltip')
const _component_tiny_icon_check_out = resolveComponent('tiny-icon-check-out')
@ -640,7 +640,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
])
)
}
var block = /* @__PURE__ */ _export_sfc(_sfc_main, [
const block = /* @__PURE__ */ _export_sfc(_sfc_main, [
['render', _sfc_render],
['styles', [_style_0]],
['__scopeId', 'data-v-b66e3972'],

View File

@ -11,36 +11,41 @@
*/
;(function (global, factory) {
typeof exports === 'object ' && typeof module !== 'undefined '
? (module.exports = factory(
require('@opentiny/tiny-engine-webcomponent-core '),
require('vue '),
require('vue-i18n '),
require('@opentiny/vue-icon '),
require('@opentiny/vue ')
))
: typeof define === 'function ' && define.amd
? define(
['@opentiny/tiny-engine-webcomponent-core ', 'vue ', 'vue-i18n ', '@opentiny/vue-icon ', '@opentiny/vue '],
factory
)
: ((global = typeof globalThis !== 'undefined ' ? globalThis : global || self),
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = factory(
require('@opentiny/tiny-engine-webcomponent-core'),
require('vue'),
require('vue-i18n'),
require('@opentiny/vue-icon'),
require('@opentiny/vue')
)
} else if (typeof define === 'function ' && define.amd) {
define([
'@opentiny/tiny-engine-webcomponent-core',
'vue',
'vue-i18n',
'@opentiny/vue-icon',
'@opentiny/vue'
], factory)
} else {
;(global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.TinyVueBlock = factory(
global.TinyWebcomponentCore,
global.Vue,
global.VueI18n,
global.TinyVueIcon,
global.TinyVue
)))
})(this, function (tinyWebcomponentCore, vue, vueI18n, tinyVue3Icon, tinyVue3) {
))
}
})(this, (tinyWebcomponentCore, vue, vueI18n, tinyVue3Icon, tinyVue3) => {
'use strict '
function _interopNamespace(e) {
if (e && e.__esModule) return e
var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module ' } })
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module ' } })
if (e) {
Object.keys(e).forEach(function (k) {
Object.keys(e).forEach((k) => {
if (k !== 'default ') {
var d = Object.getOwnPropertyDescriptor(e, k)
const d = Object.getOwnPropertyDescriptor(e, k)
Object.defineProperty(
n,
k,
@ -59,7 +64,7 @@
n['default '] = e
return Object.freeze(n)
}
var vue__namespace = /* @__PURE__ */ _interopNamespace(vue)
const vue__namespace = /* @__PURE__ */ _interopNamespace(vue)
Object.freeze({})
Object.freeze([])
const cacheStringFunction = (fn) => {
@ -71,9 +76,9 @@
}
const hyphenateRE = /\B([A-Z])/g
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1 ').toLowerCase())
var _style_0 =
const _style_0 =
'\n.team-list-item.active[data-v-b66e3972] {\r\n border: 1px solid #38acff;\n}\n.toolbars-item[data-v-b66e3972]:hover {\r\n cursor: pointer;\r\n background-color: #f1f2f3;\n}\n.toolbars-item.active[data-v-b66e3972] {\r\n background-color: #e5e6e8;\n}\n '
var _export_sfc = (sfc, props) => {
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc
for (const [key, val] of props) {
target[key] = val
@ -446,7 +451,7 @@
)
)
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
var _a
let _a
const _component_tiny_icon_setting = vue.resolveComponent('tiny-icon-setting ')
const _component_tiny_tooltip = vue.resolveComponent('tiny-tooltip ')
const _component_tiny_icon_check_out = vue.resolveComponent('tiny-icon-check-out ')
@ -688,7 +693,7 @@
])
)
}
var block = /* @__PURE__ */ _export_sfc(_sfc_main, [
const block = /* @__PURE__ */ _export_sfc(_sfc_main, [
['render ', _sfc_render],
['styles ', [_style_0]],
['__scopeId ', 'data-v-b66e3972 '],

View File

@ -31,7 +31,7 @@ export default class AppService {
// 拼装数据源
const dataSource = {
list: source,
dataHandler: app['data_handler']
dataHandler: app.data_handler
}
// 拼装工具类
const utils = []
@ -47,7 +47,7 @@ export default class AppService {
const i18n = this.formatI18nEntrites(entriesData)
return getResponseData({
dataSource,
globalState: app['global_state'],
globalState: app.global_state,
utils,
i18n
})

View File

@ -49,7 +49,7 @@ export default class BlockCategoryService {
const categories = await this.db.findOneAsync({ _id: id })
categories.blocks.push(params._id)
await this.db.updateAsync({ _id: id }, { $set: categories })
return
return getResponseData(categories)
}
params.app = appinfo.app
await this.db.updateAsync({ _id: id }, { $set: params })

View File

@ -169,6 +169,7 @@ const parseI18n = (i18n, scope, ctx) => {
const renderDefault = (children, scope, parent) =>
children.map?.((child) =>
// eslint-disable-next-line no-use-before-define
h(renderer, {
schema: child,
scope,
@ -495,20 +496,22 @@ const stopEvent = (event) => {
return false
}
const generateSlotGroup = (children, isCustomElm) => {
const generateSlotGroup = (children, isCustomElm, schema) => {
const slotGroup = {}
children.forEach((child) => {
const { componentName, children, params = [], props } = child
const slot = child.slot || props?.slot?.name || props?.slot || 'default'
const isNotEmptyTemplate = componentName === 'Template' && children.length
isCustomElm && (child.props.slot = 'slot') // CE下需要给子节点加上slot标识
slotGroup[slot] = slotGroup[slot] || {
value: [],
params
params,
parent: isNotEmptyTemplate ? child : schema
}
slotGroup[slot].value.push(...(componentName === 'Template' && children.length ? children : [child])) // template 标签直接过滤掉
slotGroup[slot].value.push(...(isNotEmptyTemplate ? children : [child])) // template 标签直接过滤掉
})
return slotGroup
@ -516,11 +519,13 @@ const generateSlotGroup = (children, isCustomElm) => {
const renderSlot = (children, scope, schema, isCustomElm) => {
if (children.some((a) => a.componentName === 'Template')) {
const slotGroup = generateSlotGroup(children, isCustomElm)
const slotGroup = generateSlotGroup(children, isCustomElm, schema)
const slots = {}
Object.keys(slotGroup).forEach((slotName) => {
slots[slotName] = ($scope) => renderDefault(slotGroup[slotName].value, { ...scope, ...$scope }, schema)
const currentSlot = slotGroup[slotName]
slots[slotName] = ($scope) => renderDefault(currentSlot.value, { ...scope, ...$scope }, currentSlot.parent)
})
return slots

View File

@ -40,7 +40,7 @@ export default defineConfig({
return 'import "./style.css"'
}
return
return ''
}
},
external: ['vue', 'monaco-editor', /@opentiny\/tiny-engine.*/, /@opentiny\/vue.*/, /^prettier.*/]

View File

@ -522,7 +522,7 @@ const configureSlots = (blockSchema = {}) => {
export const getDeployProgress = (taskId, block) => {
fetchDeployProgress(taskId).then((data) => {
block.deployStatus = data.taskStatus
block.publishProgress = data['progress_percent']
block.publishProgress = data.progress_percent
block.taskResult = data.taskResult
if (block.publishProgress === PROGRESS.End) {

View File

@ -113,6 +113,7 @@ export default {
const secondGroupData = { groupName: '公共页面', groupId: COMMON_PAGE_GROUP_ID, data: [] }
pagesData.forEach((item) => {
const namedNode = item.name ? item : { ...item, name: item.folderName, group: 'staticPages' }
const node = item.meta
? {
...item,
@ -121,9 +122,7 @@ export default {
isPage: true,
isBody: item.meta.rootElement === ELEMENT_TAG.Body
}
: item.name
? item
: { ...item, name: item.folderName, group: 'staticPages' }
: namedNode
const { children, ...other } = node
@ -258,7 +257,16 @@ export default {
} else {
data.trueFolder = false
}
const isPageLocked = getCanvasStatus(data.occupier).state === PAGE_STATUS.Lock
const pageEditIcon = isPageLocked ? (
<SvgIcon
class="page-edit-icon"
name="locked-outline"
onMousedown={(e) => openSettingPanel(e, node, isPageLocked)}
></SvgIcon>
) : null
return (
<span class="tiny-tree-node__label" onMousedown={(e) => nodeClick(e, node)}>
<span class="page-name-label" title={node.label}>
@ -267,15 +275,7 @@ export default {
<span class="label">{node.label}</span>
</span>
<span class="icons">
{data.isPage ? (
isPageLocked ? (
<SvgIcon
class="page-edit-icon"
name="locked-outline"
onMousedown={(e) => openSettingPanel(e, node, isPageLocked)}
></SvgIcon>
) : null
) : null}
{data.isPage ? pageEditIcon : null}
{data.isHome ? (
<span class="home">
<SvgIcon class="page-edit-icon" name="text-page-home"></SvgIcon>

View File

@ -74,7 +74,7 @@ export const saveCommon = (value) => {
pageSettingState.currentPageData[pageContent] = pageSchema
return
return Promise.resolve()
}
return isBlock() ? saveBlock(pageSchema) : savePage(pageSchema)

View File

@ -54,8 +54,6 @@ function recurseChildren(children, state, description, result) {
return result
}
// const isEmptyRoot = (isRootNode, props) => isRootNode && Object.keys(props).length === 0
const isEmptySlot = (componentName, children) =>
componentName === BUILTIN_COMPONENT_NAME.TEMPLATE && !(children?.length || children?.type)
@ -168,6 +166,8 @@ function handleBinding(props, attrsArr, description, state) {
if (propType === 'i18n') {
return attrsArr.push(`:${key}="t('${item.key}')"`)
}
return attrsArr
})
}
@ -361,7 +361,6 @@ const generateVueCode = ({ schema, name, type, componentsMap }) => {
// 转换 state 中的特殊类型
traverseState(state, description)
// const { utils, bridge } = wrap(function() { return this })()
const usedResource = Object.keys(description.jsResource).filter((key) => description.jsResource[key])
const resourceStatement = usedResource.length
? `const { ${usedResource.join(',')} } = wrap(function() { return this })()`

View File

@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import { capitalize, hyphenate } from '@vue/shared'
import { tinyIcon as unifyIconName } from '../pre-processor'
@ -26,17 +26,19 @@ const getFunctionInfo = (fnStr) => {
params: result[3]
.split(',')
.map((item) => item.trim())
.filter((item) => !!item),
.filter((item) => Boolean(item)),
body: result[4]
}
}
return null
}
const safeRandom = () => crypto.getRandomValues(new Uint32Array(1))[0] / (Math.pow(2, 32) - 1)
const randomString = (length = 4, chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') => {
let result = ''
for (let i = length; i > 0; --i) {
result += chars[Math.floor(Math.random() * chars.length)]
result += chars[Math.floor(safeRandom() * chars.length)]
}
return result
}
@ -142,6 +144,7 @@ const handleIconInProps = (description, iconProp) => {
export {
getTypeOfSchema,
getFunctionInfo,
safeRandom,
randomString,
avoidDuplicateString,
lowerFirst,

View File

@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import { parse as parseSFC, compileScript, compileStyle, compileTemplate } from '@vue/compiler-sfc'
import { generateCodeFrame } from '@vue/shared'
@ -107,7 +107,7 @@ export function validateByCompile(filename, code) {
// validate via compile style
// 目前暂时没有预处理器less
const stylesResult = styles.map(({ content, module }) =>
compileStyle({ source: content, filename, id, scoped, modules: !!module })
compileStyle({ source: content, filename, id, scoped, modules: Boolean(module) })
)
const errorsInStyles = stylesResult
.filter(({ errors }) => errors.length)