forked from opentiny/tiny-engine
feat: add ESLint TypeScript rules and fix all ESLint errors (#1145)
项目ts改造基础,使用eslint9+typescript。在@vue/eslint-config-typescript默认配置上进行修改
This commit is contained in:
parent
ee01af8ecb
commit
38fe39c127
|
|
@ -1,10 +0,0 @@
|
|||
.vscode
|
||||
dist
|
||||
public
|
||||
package-lock.json
|
||||
**/node_modules/**
|
||||
tmp
|
||||
temp
|
||||
mockServer
|
||||
packages/vue-generator/**/output/**
|
||||
packages/build/vite-plugin-meta-comments/src/test/code/**
|
||||
31
.eslintrc.js
31
.eslintrc.js
|
|
@ -1,31 +0,0 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
es2015: true,
|
||||
worker: true,
|
||||
node: true,
|
||||
jest: true
|
||||
},
|
||||
extends: ['eslint:recommended', 'plugin:vue/vue3-essential'],
|
||||
parser: 'vue-eslint-parser',
|
||||
parserOptions: {
|
||||
parser: '@babel/eslint-parser',
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
requireConfigFile: false,
|
||||
babelOptions: {
|
||||
parserOpts: {
|
||||
plugins: ['jsx']
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: ['vue'],
|
||||
rules: {
|
||||
'no-console': 'error',
|
||||
'no-debugger': 'error',
|
||||
'space-before-function-paren': 'off',
|
||||
'vue/multi-word-component-names': 'off',
|
||||
'no-use-before-define': 'error',
|
||||
'no-unused-vars': ['error', { ignoreRestSiblings: true, varsIgnorePattern: '^_', argsIgnorePattern: '^_' }]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
import js from '@eslint/js'
|
||||
import { configureVueProject, defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
||||
import pluginVue from 'eslint-plugin-vue'
|
||||
import globals from 'globals'
|
||||
|
||||
configureVueProject({
|
||||
scriptLangs: ['ts', 'js', 'tsx', 'jsx']
|
||||
})
|
||||
|
||||
export default defineConfigWithVueTs(
|
||||
{
|
||||
ignores: [
|
||||
'.vscode',
|
||||
'docs',
|
||||
'**/dist',
|
||||
'**/public',
|
||||
'**/package-lock.json',
|
||||
'**/node_modules',
|
||||
'**/tmp',
|
||||
'**/temp',
|
||||
'mockServer',
|
||||
'**/bin',
|
||||
'**/expected',
|
||||
'**/output',
|
||||
'**/test'
|
||||
]
|
||||
},
|
||||
{
|
||||
files: ['**/*.{js,mjs,jsx,ts,mts,tsx,vue}']
|
||||
},
|
||||
js.configs.recommended,
|
||||
pluginVue.configs['flat/essential'],
|
||||
vueTsConfigs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.worker,
|
||||
...globals.node,
|
||||
...globals.jest
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'error',
|
||||
'no-debugger': 'error',
|
||||
'no-eq-null': 'error',
|
||||
'no-extra-semi': 'off',
|
||||
'no-eval': 'error',
|
||||
'space-before-function-paren': 'off',
|
||||
'vue/multi-word-component-names': 'off',
|
||||
'vue/prefer-import-from-vue': 'off',
|
||||
// 允许 @ts-ignore
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
// 允许非空断言
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-use-before-define': 'error',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
ignoreRestSiblings: true,
|
||||
varsIgnorePattern: '^_',
|
||||
argsIgnorePattern: '^_',
|
||||
caughtErrors: 'none'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['scripts/**/*'],
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = {
|
||||
'./packages/**/**.{js,vue,jsx}': 'eslint',
|
||||
'./packages/**/**.{vue,js,ts,html,json,less}': 'prettier --write'
|
||||
'./packages/**/**.{js,mjs,jsx,ts,mts,tsx,vue}': 'eslint',
|
||||
'./packages/**/**.{js,mjs,jsx,ts,mts,tsx,vue,html,json,less}': 'prettier --write'
|
||||
}
|
||||
|
|
|
|||
16
package.json
16
package.json
|
|
@ -10,8 +10,8 @@
|
|||
"build:alpha": "pnpm --filter designer-demo build:alpha",
|
||||
"build:prod": "pnpm --filter designer-demo build",
|
||||
"buildComponentSchemas": "node scripts/buildComponentSchemas.js",
|
||||
"lint": "eslint . --ext .js,.vue,.jsx --fix",
|
||||
"format": "prettier --write **/*{.vue,.js,.ts,.html,.json}",
|
||||
"lint": "eslint . --ext .js,.mjs,.jsx,.ts,.mts,.tsx,.vue --fix",
|
||||
"format": "prettier --write --list-different **/*{.vue,.js,.mjs,.jsx,.ts,.mts,.tsx,.html,.json}",
|
||||
"prepare": "node -e \"if(require('fs').existsSync('.git')){process.exit(1)}\" || husky install",
|
||||
"pub:premajor": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version premajor --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes",
|
||||
"pub:preminor": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version preminor --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes",
|
||||
|
|
@ -23,24 +23,26 @@
|
|||
"updateTemplate": "node ./scripts/updateTemplate.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@eslint/js": "^8.57.1",
|
||||
"@types/node": "^18.0.0",
|
||||
"@vue/eslint-config-typescript": "^11.0.3",
|
||||
"@vue/eslint-config-typescript": "^14.4.0",
|
||||
"@vue/tsconfig": "^0.7.0",
|
||||
"chokidar": "^3.5.3",
|
||||
"concurrently": "^8.2.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"dotenv": "^16.3.1",
|
||||
"eslint": "^8.38.0",
|
||||
"eslint-plugin-vue": "^8.0.0",
|
||||
"eslint": "^9.21.0",
|
||||
"eslint-plugin-vue": "^9.32.0",
|
||||
"fast-glob": "^3.3.2",
|
||||
"fs-extra": "^10.1.0",
|
||||
"globals": "^16.0.0",
|
||||
"husky": "^8.0.0",
|
||||
"lerna": "^7.2.0",
|
||||
"lint-staged": "^13.2.0",
|
||||
"mysql": "^2.18.1",
|
||||
"picocolors": "^1.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"vue-eslint-parser": "^8.0.1"
|
||||
"typescript": "~5.4.5"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
const path = require('path')
|
||||
const { rules } = require('../../.eslintrc')
|
||||
|
||||
module.exports = {
|
||||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
project: [path.join(__dirname, './tsconfig.json') ],
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
plugins: ['@typescript-eslint'],
|
||||
env: {
|
||||
browser: true,
|
||||
es2015: true,
|
||||
node: true
|
||||
},
|
||||
rules: {
|
||||
...rules,
|
||||
// 允许 @ts-ignore
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
// 允许非空断言
|
||||
"@typescript-eslint/no-non-null-asserted-optional-chain": "off"
|
||||
},
|
||||
ignorePatterns: ['test/sample/*.vue', '.eslintrc.cjs']
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import rootConfig from '../../eslint.config.mjs'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
...rootConfig,
|
||||
{
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
project: [path.join(__dirname, './tsconfig.json')]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -20,5 +20,5 @@
|
|||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts", ".eslintrc.cjs"]
|
||||
"include": ["vite.config.ts", "eslint.config.mjs"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ export function relativePathPattern(relativePath) {
|
|||
}
|
||||
|
||||
export function resolvePath(importPath, currentFilePath) {
|
||||
if (['js', 'mjs'].some(suffix =>importPath.endsWith(suffix))) { // 文件名已经带有.js,.mjs后缀
|
||||
if (['js', 'mjs'].some((suffix) => importPath.endsWith(suffix))) {
|
||||
// 文件名已经带有.js,.mjs后缀
|
||||
return importPath
|
||||
}
|
||||
const parentPath = path.resolve(currentFilePath, '../')
|
||||
|
|
@ -21,9 +22,9 @@ export function resolvePath(importPath, currentFilePath) {
|
|||
const stat = fs.statSync(filePrefix)
|
||||
if (stat.isDirectory()) {
|
||||
let mainFileName = 'index.js'
|
||||
|
||||
|
||||
const packageFile = path.resolve(filePrefix, 'package.json')
|
||||
|
||||
|
||||
if (fs.existsSync(packageFile)) {
|
||||
const packageFileContent = fs.readFileSync(packageFile, { encoding: 'utf-8' })
|
||||
const packageJson = JSON.parse(packageFileContent)
|
||||
|
|
@ -39,7 +40,7 @@ export function resolvePath(importPath, currentFilePath) {
|
|||
return importPath
|
||||
}
|
||||
const possibleSuffix = ['.js', '.mjs']
|
||||
const suffix = possibleSuffix.find(suf => fs.existsSync(filePrefix + suf))
|
||||
const suffix = possibleSuffix.find((suf) => fs.existsSync(filePrefix + suf))
|
||||
if (suffix) {
|
||||
return relativePathPattern(path.relative(path.resolve(currentFilePath, '../'), filePrefix + suffix))
|
||||
}
|
||||
|
|
@ -62,16 +63,16 @@ export function babelReplaceImportPathWithCertainFileName(content, currentFilePa
|
|||
return
|
||||
}
|
||||
const importPath = node.source.value
|
||||
if(importPath.startsWith('.')) {
|
||||
if (importPath.startsWith('.')) {
|
||||
const certainPath = resolvePath(importPath, currentFilePath)
|
||||
if(!certainPath) {
|
||||
if (!certainPath) {
|
||||
logger.warn(`File not found: ${importPath} used in ${currentFilePath}`)
|
||||
result.error.push(importPath)
|
||||
}
|
||||
if(certainPath !== importPath) {
|
||||
if (certainPath !== importPath) {
|
||||
node.source.value = certainPath
|
||||
fileChangedMark = true
|
||||
result.success.push({before: importPath, after: certainPath})
|
||||
result.success.push({ before: importPath, after: certainPath })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -86,4 +87,3 @@ export function babelReplaceImportPathWithCertainFileName(content, currentFilePa
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ const getDevAlias = (useSourceAlias) => {
|
|||
'@opentiny/tiny-engine-plugin-datasource': path.resolve(basePath, 'packages/plugins/datasource/index.js'),
|
||||
'@opentiny/tiny-engine-plugin-script': path.resolve(basePath, 'packages/plugins/script/index.js'),
|
||||
'@opentiny/tiny-engine-plugin-tree': path.resolve(basePath, 'packages/plugins/tree/index.js'),
|
||||
'@opentiny/tiny-engine-plugin-help': path.resolve(basePath, 'packages/plugins/help/index.js'),
|
||||
'@opentiny/tiny-engine-plugin-help': path.resolve(basePath, 'packages/plugins/help/index.ts'),
|
||||
'@opentiny/tiny-engine-plugin-schema': path.resolve(basePath, 'packages/plugins/schema/index.js'),
|
||||
'@opentiny/tiny-engine-plugin-page': path.resolve(basePath, 'packages/plugins/page/index.js'),
|
||||
'@opentiny/tiny-engine-plugin-i18n': path.resolve(basePath, 'packages/plugins/i18n/index.js'),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable no-new-func */
|
||||
import { reactive, ref, toRaw } from 'vue'
|
||||
import * as jsonDiffPatch from 'jsondiffpatch'
|
||||
import DiffMatchPatch from 'diff-match-patch'
|
||||
|
|
@ -90,7 +89,7 @@ const handleTinyGridColumnsSlots = (node) => {
|
|||
nodesMap.value.set(item.id, { node: item, parent: node })
|
||||
|
||||
if (Array.isArray(item.children)) {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
generateNodesMap(item.children, item)
|
||||
}
|
||||
})
|
||||
|
|
@ -589,10 +588,12 @@ const getSchema = () => {
|
|||
const getNodePath = (id, nodes = []) => {
|
||||
const { parent, node } = getNodeWithParentById(id) || {}
|
||||
|
||||
node && nodes.unshift({ name: node.componentName, node: id })
|
||||
if (node) {
|
||||
nodes.unshift({ name: node.componentName, node: id })
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
parent && getNodePath(parent.id, nodes)
|
||||
getNodePath(parent.id, nodes)
|
||||
} else {
|
||||
nodes.unshift({ name: 'BODY', node: id })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ export default {
|
|||
const insertPanel = ref(null)
|
||||
const insertPosition = ref(false)
|
||||
const loading = computed(() => useCanvas().isLoading())
|
||||
let showSettingModel = ref(false)
|
||||
let target = ref(null)
|
||||
const showSettingModel = ref(false)
|
||||
const target = ref(null)
|
||||
const srcAttrName = computed(() => (props.canvasSrc ? 'src' : 'srcdoc'))
|
||||
|
||||
const containerPanel = ref(null)
|
||||
|
|
|
|||
|
|
@ -208,7 +208,6 @@ export default {
|
|||
const toIndex = index + addend
|
||||
|
||||
if (toIndex > -1 && toIndex < list.length) {
|
||||
// eslint-disable-next-line no-extra-semi
|
||||
;[list[index], list[toIndex]] = [list[toIndex], list[index]]
|
||||
|
||||
useMessage().publish({ topic: 'schemaChange', data: {} })
|
||||
|
|
@ -229,7 +228,9 @@ export default {
|
|||
|
||||
const selectParent = () => {
|
||||
const parentId = getCurrent().parent?.id
|
||||
parentId && selectNode(parentId)
|
||||
if (parentId) {
|
||||
selectNode(parentId)
|
||||
}
|
||||
}
|
||||
|
||||
const copy = () => {
|
||||
|
|
@ -267,20 +268,20 @@ export default {
|
|||
const optionRef = ref(null)
|
||||
const fixStyle = ref('')
|
||||
|
||||
let showPopover = ref(false)
|
||||
const showPopover = ref(false)
|
||||
|
||||
const activeSetting = () => {
|
||||
showPopover.value = false
|
||||
}
|
||||
|
||||
const findParentHasClass = (target) => {
|
||||
let parent = target.parentNode
|
||||
const parent = target.parentNode
|
||||
|
||||
if (parent.className === undefined) {
|
||||
return false
|
||||
}
|
||||
|
||||
let name = JSON.stringify(parent.className)
|
||||
const name = JSON.stringify(parent.className)
|
||||
|
||||
const preventClassNameList = ['short-cut-set', 'tiny-dialog-box', 'icon-popover', 'i18n-input-popover']
|
||||
|
||||
|
|
@ -314,7 +315,7 @@ export default {
|
|||
() => props.windowGetClickEventTarget,
|
||||
(newProps) => {
|
||||
if (newProps) {
|
||||
let flag = findParentHasClass(newProps)
|
||||
const flag = findParentHasClass(newProps)
|
||||
if (!flag) {
|
||||
showPopover.value = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ export default {
|
|||
}
|
||||
|
||||
if (state.direction === 'vertical') {
|
||||
let target = schema.componentName === 'CanvasRow' ? schema : parent
|
||||
const target = schema.componentName === 'CanvasRow' ? schema : parent
|
||||
const dis = clientY - state.startPosition.y
|
||||
const minHeight = state.startPosition.height + dis
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,9 @@ export default {
|
|||
|
||||
properties.value.forEach((group) => {
|
||||
group.content.forEach((prop) => {
|
||||
shortcuts.includes(prop.property) && quickProps.push(prop)
|
||||
if (shortcuts.includes(prop.property)) {
|
||||
quickProps.push(prop)
|
||||
}
|
||||
})
|
||||
|
||||
// 如果目标元素的快速设置值没有,则取属性值放置
|
||||
|
|
|
|||
|
|
@ -154,7 +154,9 @@ const smoothScroll = {
|
|||
this.timmer = setTimeout(fn, time)
|
||||
}
|
||||
|
||||
this.timmer || fn()
|
||||
if (!this.timmer) {
|
||||
fn()
|
||||
}
|
||||
},
|
||||
stop() {
|
||||
clearTimeout(this.timmer)
|
||||
|
|
@ -764,7 +766,9 @@ export const selectNode = async (id, type) => {
|
|||
|
||||
export const hoverNode = (id, data) => {
|
||||
const element = querySelectById(id)
|
||||
element && setHoverRect(element, data)
|
||||
if (element) {
|
||||
setHoverRect(element, data)
|
||||
}
|
||||
}
|
||||
|
||||
export const insertNode = (node, position = POSITION.IN, select = true) => {
|
||||
|
|
@ -792,7 +796,9 @@ export const insertNode = (node, position = POSITION.IN, select = true) => {
|
|||
}
|
||||
}
|
||||
|
||||
select && setTimeout(() => selectNode(node.data.id))
|
||||
if (select) {
|
||||
setTimeout(() => selectNode(node.data.id))
|
||||
}
|
||||
|
||||
getController().addHistory()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,15 +30,21 @@ function handlerLeft({ parent }) {
|
|||
}
|
||||
function handlerRight({ schema }) {
|
||||
const id = schema.children?.[0]?.id
|
||||
id && selectNode(id)
|
||||
if (id) {
|
||||
selectNode(id)
|
||||
}
|
||||
}
|
||||
function handlerUp({ index, parent }) {
|
||||
const id = (parent?.children[index - 1] || parent)?.id
|
||||
id && selectNode(id)
|
||||
if (id) {
|
||||
selectNode(id)
|
||||
}
|
||||
}
|
||||
function handlerDown({ index, parent }) {
|
||||
const id = parent?.children[index + 1]?.id
|
||||
id && selectNode(id)
|
||||
if (id) {
|
||||
selectNode(id)
|
||||
}
|
||||
}
|
||||
|
||||
const { multiSelectedStates, clearMultiSelection } = useMultiSelect()
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import {
|
|||
} from './canvas-function'
|
||||
import { removeBlockCompsCache, setConfigure } from './material-function'
|
||||
import { useUtils, useBridge, useDataSourceMap, useGlobalState } from './application-function'
|
||||
import { IPageSchema, useContext, usePageContext, useSchema } from './page-block-function'
|
||||
import { type IPageSchema, useContext, usePageContext, useSchema } from './page-block-function'
|
||||
import { api, setCurrentApi } from './canvas-function/canvas-api'
|
||||
import { getPageAncestors } from './material-function/page-getter'
|
||||
import CanvasEmpty from './canvas-function/CanvasEmpty.vue'
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export interface IUtil {
|
|||
|
||||
export function useUtils(context: Record<string, any>) {
|
||||
const refreshKey = ref<number>(0)
|
||||
const utils: Record<string, Function | any> = {}
|
||||
const utils: Record<string, (...args: any) => any | any> = {}
|
||||
const getUtils = () => utils
|
||||
|
||||
const setUtils = async (data: Array<IUtil>) => {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ const removeState = (pageSchema, variableName) => {
|
|||
|
||||
traverse(ast, {
|
||||
ExpressionStatement(path) {
|
||||
path.toString().includes(variableName) && path.remove()
|
||||
if (path.toString().includes(variableName)) {
|
||||
path.remove()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import type { setController } from './controller'
|
|||
export interface IApplicationFunctionAPI
|
||||
extends Pick<ReturnType<typeof useUtils>, 'getUtils'>,
|
||||
Pick<ReturnType<typeof useDataSourceMap>, 'getDataSourceMap'> {}
|
||||
export interface IPageContextAPI extends Pick<IPageContext, 'setCondition'> {}
|
||||
export type IPageContextAPI = Pick<IPageContext, 'setCondition'>
|
||||
export interface ICanvasFunctionAPI extends Pick<ReturnType<typeof useCustomRenderer>, 'getRenderer' | 'setRenderer'> {
|
||||
getDesignMode: typeof getDesignMode
|
||||
setDesignMode: typeof setDesignMode
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { inject, watch, WritableComputedRef } from 'vue'
|
||||
import { inject, watch, type WritableComputedRef } from 'vue'
|
||||
import { I18nInjectionKey } from 'vue-i18n'
|
||||
import { useBroadcastChannel } from '@vueuse/core'
|
||||
import { constants } from '@opentiny/tiny-engine-utils'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { reactive } from 'vue'
|
||||
import { IPageContext } from '../page-block-function'
|
||||
import type { IPageContext } from '../page-block-function'
|
||||
|
||||
export interface ICurrentPage {
|
||||
pageId: string | number
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import { getCurrentInstance, nextTick, provide, inject, Ref } from 'vue'
|
||||
import { getCurrentInstance, nextTick, provide, inject, type Ref } from 'vue'
|
||||
import { I18nInjectionKey } from 'vue-i18n'
|
||||
import { api } from './RenderMain'
|
||||
import { globalNotify } from './canvas-function'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/** @ref {@vue/compiler-sfc@2.7.16/src/stylePlugins/scoped.ts } */
|
||||
/* eslint-disable no-use-before-define, prefer-const*/
|
||||
import { PluginCreator, Rule, AtRule } from 'postcss'
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define, prefer-const*/
|
||||
import { type PluginCreator, Rule, AtRule } from 'postcss'
|
||||
import selectorParser from 'postcss-selector-parser'
|
||||
|
||||
const animationNameRE = /^(-\w+-)?animation-name$/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { watchEffect, WatchStopHandle } from 'vue'
|
||||
import { watchEffect, type WatchStopHandle } from 'vue'
|
||||
import { generateFunction } from '../data-utils'
|
||||
import { globalNotify } from '../canvas-function'
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ interface IAccessor {
|
|||
|
||||
export function useAccessorMap(context) {
|
||||
const generateAccessor = (type: IAccessorType, accessor: IAccessor, property: string) => {
|
||||
const accessorFn = generateFunction(accessor[type].value, context) as Function
|
||||
const accessorFn = generateFunction(accessor[type].value, context) as (...args: any) => any
|
||||
|
||||
return { property, accessorFn, type }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ import { shallowReactive } from 'vue'
|
|||
export function useContext() {
|
||||
const context = shallowReactive({})
|
||||
const setContext = (ctx, clear) => {
|
||||
clear && Object.keys(context).forEach((key) => delete context[key])
|
||||
if (clear) {
|
||||
Object.keys(context).forEach((key) => delete context[key])
|
||||
}
|
||||
Object.assign(context, ctx)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ export function useMethods({ getContext, setContext }) {
|
|||
const getMethods = () => methods
|
||||
|
||||
const setMethods = (data: Record<string, IFuncType> = {}, clear = false) => {
|
||||
clear && reset(methods)
|
||||
if (clear) {
|
||||
reset(methods)
|
||||
}
|
||||
// 这里有些方法在画布还是有执行的必要的,比如说表格的renderer和formatText方法,包括一些自定义渲染函数
|
||||
Object.assign(
|
||||
methods,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import { useAccessorMap } from './accessor-map'
|
|||
export function useProps(generateAccessor: ReturnType<typeof useAccessorMap>['generateAccessor']) {
|
||||
const props = {}
|
||||
const setProps = (data: Record<string, any>, clear = false) => {
|
||||
clear && reset(props)
|
||||
if (clear) {
|
||||
reset(props)
|
||||
}
|
||||
Object.assign(props, data)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import { defineComponent, h, inject, provide, Ref, Suspense } from 'vue'
|
||||
import { defineComponent, h, inject, provide, type Ref, Suspense } from 'vue'
|
||||
|
||||
import {
|
||||
NODE_UID as DESIGN_UIDKEY,
|
||||
|
|
@ -26,7 +26,7 @@ import BlockLoading from './BlockLoading.vue'
|
|||
|
||||
export const renderDefault = (children, scope, parent) =>
|
||||
children.map?.((child) =>
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
h(renderer, {
|
||||
schema: child,
|
||||
scope,
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ const create = async (config) => {
|
|||
if (typeof beforeAppCreate === 'function') {
|
||||
await beforeAppCreate({ api: renderer })
|
||||
}
|
||||
App && App.unmount()
|
||||
if (App) {
|
||||
App.unmount()
|
||||
}
|
||||
App = null
|
||||
|
||||
document.body.remove()
|
||||
|
|
|
|||
|
|
@ -98,7 +98,9 @@ export default {
|
|||
const data = props?.data?.params || {}
|
||||
|
||||
curValue.replace(/\{(.+?)\}/g, (substr, key) => {
|
||||
key && params.push({ name: key, value: data[key] || '' })
|
||||
if (key) {
|
||||
params.push({ name: key, value: data[key] || '' })
|
||||
}
|
||||
})
|
||||
paramsForm.value = params
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,6 +321,7 @@ export default {
|
|||
const isEmptyInputValue = (value) => {
|
||||
// 通过 value == null 做隐式类型转换
|
||||
// 空值约定为 undefined | null | ''
|
||||
// eslint-disable-next-line no-eq-null
|
||||
return value == null || (typeOf(value) === TYPES.StringType && value.trim() === '')
|
||||
}
|
||||
const verifyRequired = (value) => {
|
||||
|
|
@ -436,7 +437,7 @@ export default {
|
|||
|
||||
const showErrorPopup = ref(false)
|
||||
|
||||
let isFocus = ref(false)
|
||||
const isFocus = ref(false)
|
||||
|
||||
watch(
|
||||
() => [verification.failed, isFocus.value],
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export default {
|
|||
const obj = {}
|
||||
|
||||
data?.forEach(({ content }) => {
|
||||
content.length &&
|
||||
if (content.length) {
|
||||
content.forEach((item) => {
|
||||
const node = item.schema?.length ? getPropsObj(item.schema) : {}
|
||||
|
||||
|
|
@ -75,6 +75,7 @@ export default {
|
|||
}
|
||||
obj[item.property] = node
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return obj
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export default {
|
|||
if (props.type === 'array' && props.arrayIndex > -1) {
|
||||
modelValue = modelValue[props.arrayIndex]
|
||||
}
|
||||
let model_value_property = modelValue[item.property]
|
||||
const model_value_property = modelValue[item.property]
|
||||
item.widget.props.modelValue =
|
||||
typeof model_value_property === 'boolean' ? model_value_property : model_value_property || null
|
||||
})
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ export default {
|
|||
if (dataType) {
|
||||
value = value === '' ? '' : { type: dataType, value }
|
||||
} else if (language === 'json') {
|
||||
// eslint-disable-next-line no-new-func
|
||||
value = new Func(`return ${content}`)()
|
||||
} else {
|
||||
value = typeof props.modelValue === 'string' ? content : JSON.parse(content)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ export default {
|
|||
const isShow = ref(false)
|
||||
const isVisible = ref(false)
|
||||
const showMask = ref(false)
|
||||
let top = ref(0)
|
||||
const top = ref(0)
|
||||
|
||||
const deleteItem = () => {
|
||||
isShow.value = true
|
||||
|
|
|
|||
|
|
@ -153,14 +153,14 @@ export default {
|
|||
|
||||
let text = ''
|
||||
|
||||
let name = computed(() => {
|
||||
const name = computed(() => {
|
||||
if (item.type) {
|
||||
text = typeDesc[item.type]
|
||||
}
|
||||
|
||||
if (item[props.textField]) {
|
||||
if (item[props.textField].i18nKey) {
|
||||
let i18nKey = item[props.textField].i18nKey
|
||||
const i18nKey = item[props.textField].i18nKey
|
||||
text = appSchemaState.langs[i18nKey][appSchemaState.currentLang]
|
||||
} else {
|
||||
text = item[props.textField]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ const durationMap = {
|
|||
const useNotify = (config) => {
|
||||
const { customClass, title, type = 'info', position = 'top-right', ...otherConfig } = config
|
||||
|
||||
|
||||
Notify({
|
||||
duration: durationMap[type],
|
||||
...otherConfig,
|
||||
|
|
@ -18,7 +17,7 @@ const useNotify = (config) => {
|
|||
title,
|
||||
type,
|
||||
customClass: `${customClass}`,
|
||||
verticalOffset: 46,
|
||||
verticalOffset: 46
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,10 +84,11 @@ export default {
|
|||
methods: {
|
||||
updateLowCodePaneComponents() {
|
||||
this.panes.forEach((item) => {
|
||||
item.update &&
|
||||
if (item.update) {
|
||||
item.update({
|
||||
[this.horizontal ? 'height' : 'width']: `${this.indexedPanes[item.id].size}%`
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
bindEvents() {
|
||||
|
|
@ -450,8 +451,8 @@ export default {
|
|||
equalize() {
|
||||
const equalSpace = 100 / this.panesCount
|
||||
let leftLowCodeToAllocate = 0
|
||||
let ungrowableLowCode = []
|
||||
let unshrinkableLowCode = []
|
||||
const ungrowableLowCode = []
|
||||
const unshrinkableLowCode = []
|
||||
|
||||
this.panes.forEach((pane) => {
|
||||
pane.size = Math.max(Math.min(equalSpace, pane.max), pane.min)
|
||||
|
|
@ -466,8 +467,8 @@ export default {
|
|||
|
||||
initialPanesSizing() {
|
||||
let leftLowCodeToAllocate = 100
|
||||
let ungrowableLowCode = []
|
||||
let unshrinkableLowCode = []
|
||||
const ungrowableLowCode = []
|
||||
const unshrinkableLowCode = []
|
||||
let definedSizes = 0
|
||||
this.panes.forEach((pane) => {
|
||||
leftLowCodeToAllocate -= pane.size
|
||||
|
|
@ -493,8 +494,8 @@ export default {
|
|||
equalizeAfterAddOrRemove({ addedPane } = {}) {
|
||||
let equalSpace = 100 / this.panesCount
|
||||
let leftLowCodeToAllocate = 0
|
||||
let ungrowableLowCode = []
|
||||
let unshrinkableLowCode = []
|
||||
const ungrowableLowCode = []
|
||||
const unshrinkableLowCode = []
|
||||
|
||||
if (addedPane && addedPane.givenSize !== null) {
|
||||
equalSpace = (100 - addedPane.givenSize) / (this.panesCount - 1)
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@ export default {
|
|||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
vueMonaco.editor && vueMonaco.editor.dispose()
|
||||
if (vueMonaco.editor) {
|
||||
vueMonaco.editor.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export default {
|
|||
|
||||
const save = () => {
|
||||
state.visible = false
|
||||
let data = {}
|
||||
const data = {}
|
||||
let index = -1
|
||||
|
||||
if (state.currentAttr.id) {
|
||||
|
|
|
|||
|
|
@ -44,14 +44,15 @@ export default {
|
|||
|
||||
watchEffect(() => {
|
||||
const slots = {}
|
||||
let children = useProperties().getSchema()?.children
|
||||
Array.isArray(children) &&
|
||||
const children = useProperties().getSchema()?.children
|
||||
if (Array.isArray(children)) {
|
||||
children.forEach((child) => {
|
||||
if (child.componentName === 'Template' && child.props?.slot) {
|
||||
const slotName = child.props.slot?.name || child.props.slot
|
||||
slots[slotName] = child.props.slot
|
||||
}
|
||||
})
|
||||
}
|
||||
slotList.value = Object.keys(props.slots).map((name) => {
|
||||
const { label, description, params } = props.slots[name] || {}
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ const defaultLifeCycles = {
|
|||
// import(`./theme/${newRegistry.config.theme}.js`)
|
||||
|
||||
const theme = localStorage.getItem(`tiny-engine-theme-${appId}`) || newRegistry.config.theme || 'light'
|
||||
// eslint-disable-next-line no-new
|
||||
|
||||
new TinyThemeTool(defaultThemeList[theme], defaultThemeList[theme]?.id)
|
||||
document.documentElement?.setAttribute?.('data-theme', theme)
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import dataSources from './dataSource.js'
|
|||
|
||||
const dataSourceMap = {}
|
||||
|
||||
Array.isArray(dataSources.list) &&
|
||||
if (Array.isArray(dataSources.list)) {
|
||||
dataSources.list.forEach((config) => {
|
||||
const dataSource = { config: config.data }
|
||||
|
||||
|
|
@ -31,5 +31,6 @@ Array.isArray(dataSources.list) &&
|
|||
|
||||
dataSource.load = () => Promise.resolve(result)
|
||||
})
|
||||
}
|
||||
|
||||
export default dataSourceMap
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ export default {
|
|||
// 通过 provide ,可以让 tiny-i18n-host 树结构下的 webcomponent 通过 inject(I18nInjectionKey),获取 i18n 对象
|
||||
provide(I18nInjectionKey, i18n)
|
||||
|
||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||
i18n.global.locale.value = props.locale
|
||||
|
||||
watch(
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ export default {
|
|||
|
||||
const previewHistory = (item) => {
|
||||
const theme = getMetaApi(META_SERVICE.ThemeSwitch)?.getThemeState()?.theme
|
||||
item &&
|
||||
if (item) {
|
||||
previewBlock({
|
||||
id: item.blockId,
|
||||
history: item.id,
|
||||
|
|
@ -254,6 +254,7 @@ export default {
|
|||
schema: item.content
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onMouseLeave = () => {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,11 @@ export default {
|
|||
}
|
||||
|
||||
const handleAddBlock = () => {
|
||||
props.fromCanvas ? createBlock(formData) : createEmptyBlock(formData)
|
||||
if (props.fromCanvas) {
|
||||
createBlock(formData)
|
||||
} else {
|
||||
createEmptyBlock(formData)
|
||||
}
|
||||
activePlugin(PLUGIN_NAME.Materials) // ?? 疑问:新建区块后,这里为啥要激活物料
|
||||
cancel()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ export default {
|
|||
}
|
||||
|
||||
const refreshList = (type) => {
|
||||
type == utilsRef.value.refresh(type)
|
||||
utilsRef.value.refresh(type)
|
||||
}
|
||||
|
||||
const addResource = (type) => {
|
||||
activedName.value == utilsRef.value.add(type)
|
||||
utilsRef.value.add(type)
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -120,10 +120,11 @@ const getAppId = () => getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id
|
|||
|
||||
export const getResources = () => {
|
||||
const id = getAppId()
|
||||
state.resources.length ||
|
||||
if (!state.resources.length) {
|
||||
fetchResourceList(id).then((data) => {
|
||||
state.resources = data || TempBridge
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const getResourceNamesByType = (type) => state.resourceNames[type]
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import { reactive, ref } from 'vue'
|
|||
import { iconArrowDown } from '@opentiny/vue-icon'
|
||||
import fieldTypes from './config'
|
||||
|
||||
let isOpen = ref(false)
|
||||
const isOpen = ref(false)
|
||||
|
||||
export const open = () => {
|
||||
isOpen.value = true
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import {
|
|||
import { useModal, useDataSource, useNotify, getMetaApi, META_SERVICE } from '@opentiny/tiny-engine-meta-register'
|
||||
import { extend } from '@opentiny/vue-renderless/common/object'
|
||||
|
||||
let isOpen = ref(false)
|
||||
const isOpen = ref(false)
|
||||
|
||||
export const open = () => {
|
||||
isOpen.value = true
|
||||
|
|
|
|||
|
|
@ -80,7 +80,9 @@ export default {
|
|||
() => isOpen.value,
|
||||
(value) => {
|
||||
nextTick(() => {
|
||||
value && window.dispatchEvent(new Event('resize'))
|
||||
if (value) {
|
||||
window.dispatchEvent(new Event('resize'))
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ const CONSTANTS = {
|
|||
MAX_LENGTH_TIP: '长度不大于'
|
||||
}
|
||||
|
||||
let isOpen = ref(false)
|
||||
let recordFormData = reactive({})
|
||||
const isOpen = ref(false)
|
||||
const recordFormData = reactive({})
|
||||
|
||||
export const open = () => {
|
||||
isOpen.value = true
|
||||
|
|
@ -158,10 +158,12 @@ export default {
|
|||
const format = item.format
|
||||
const fieldRules = []
|
||||
|
||||
!isEmptyObject(format) &&
|
||||
if (!isEmptyObject(format)) {
|
||||
Object.keys(format).forEach((key) => {
|
||||
if (key === CONSTANTS.REQUIRED) {
|
||||
format[key] && (state.recordMapping[item.name] = format[key])
|
||||
if (format[key]) {
|
||||
state.recordMapping[item.name] = format[key]
|
||||
}
|
||||
|
||||
fieldRules.push({
|
||||
[key]: format[key],
|
||||
|
|
@ -187,6 +189,7 @@ export default {
|
|||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
state.rules[item.name] = fieldRules
|
||||
})
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ import { fetchDataSourceDetail, requestUpdateDataSource } from './js/http'
|
|||
import { downloadFn, handleImportedData, overrideOrMergeData, getDataAfterPage } from './js/datasource'
|
||||
import DataSourceRecordUpload from './DataSourceRecordUpload.vue'
|
||||
|
||||
let isOpen = ref(false)
|
||||
const isOpen = ref(false)
|
||||
|
||||
export const open = () => {
|
||||
isOpen.value = true
|
||||
|
|
@ -482,8 +482,8 @@ export default {
|
|||
const syncDataToTotalData = () => {
|
||||
const { insertRecords, updateRecords } = grid.value.getRecordset()
|
||||
|
||||
let updatedData = [...insertRecords, ...updateRecords]
|
||||
let updatedIds = updatedData.filter(({ _id }) => _id)
|
||||
const updatedData = [...insertRecords, ...updateRecords]
|
||||
const updatedIds = updatedData.filter(({ _id }) => _id)
|
||||
|
||||
state.totalData = state.totalData.map((item) => {
|
||||
if (!updatedIds.includes(item._id)) {
|
||||
|
|
|
|||
|
|
@ -136,7 +136,9 @@ export default {
|
|||
state.responseData.dataHandler = dataHandler?.value || ''
|
||||
state.responseData.shouldFetch = shouldFetch?.value || ''
|
||||
state.responseData.errorHandler = errorHandler?.value || ''
|
||||
columns?.length === 0 && (state.remoteData.result = {})
|
||||
if (columns?.length === 0) {
|
||||
state.remoteData.result = {}
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import metaData from './meta.js'
|
||||
import metaData from './meta'
|
||||
import { HelpService } from './src/composable'
|
||||
import './src/styles/vars.less'
|
||||
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { reactive, onMounted, ref } from 'vue'
|
||||
import { Guide, Popover } from '@opentiny/vue'
|
||||
import { IconFilletExternalLink } from '@opentiny/vue-icon'
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ export default defineConfig({
|
|||
resolve: {},
|
||||
build: {
|
||||
lib: {
|
||||
entry: path.resolve(__dirname, './index.js'),
|
||||
entry: path.resolve(__dirname, './index.ts'),
|
||||
name: 'plugin-help',
|
||||
fileName: () => 'index.js',
|
||||
fileName: (_format, entryName) => `${entryName}.js`,
|
||||
formats: ['es']
|
||||
},
|
||||
rollupOptions: {
|
||||
|
|
@ -69,12 +69,13 @@ const ensureI18n = (obj, send) => {
|
|||
if (send) {
|
||||
const exist = langs[key]
|
||||
|
||||
globalParams.host &&
|
||||
if (globalParams.host) {
|
||||
getMetaApi(META_SERVICE.Http).post(`${i18nApi}/${exist ? 'update' : 'create'}`, {
|
||||
...globalParams,
|
||||
key,
|
||||
contents
|
||||
})
|
||||
}
|
||||
|
||||
locales.forEach((lang) => {
|
||||
if (i18nResource[lang]?.[key]) {
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ const fetchMaterial = async () => {
|
|||
const getBlockDeps = (dependencies = {}) => {
|
||||
const { scripts = [], styles = [] } = dependencies
|
||||
|
||||
scripts.length &&
|
||||
if (scripts.length) {
|
||||
scripts.forEach((npm) => {
|
||||
const { package: pkg, script, css, components } = npm
|
||||
const npmInfo = materialState.componentsDepsMap.scripts.find((item) => item.package === pkg)
|
||||
|
|
@ -456,6 +456,7 @@ const getBlockDeps = (dependencies = {}) => {
|
|||
npmInfo.components = { ...components, ...npm.components }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (Array.isArray(styles)) {
|
||||
styles.forEach((item) => materialState.componentsDepsMap.styles.add(item))
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ import { useGroupPanel } from './js/usePanel'
|
|||
const blockMap = new Map()
|
||||
const initGruopBlockMap = (groups = []) => {
|
||||
blockMap.clear()
|
||||
for (let group of groups) {
|
||||
for (const group of groups) {
|
||||
const groupBlock = group?.blocks || []
|
||||
for (let block of groupBlock) {
|
||||
for (const block of groupBlock) {
|
||||
blockMap.set(block.id, block)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,10 +132,14 @@ export default {
|
|||
const isPageChange = pageData.id !== pageSettingState.currentPageData.id
|
||||
|
||||
if (state.isFolder) {
|
||||
isPageChange && closePageSettingPanel()
|
||||
if (isPageChange) {
|
||||
closePageSettingPanel()
|
||||
}
|
||||
openFolderSettingPanel()
|
||||
} else {
|
||||
isPageChange && closeFolderSettingPanel()
|
||||
if (isPageChange) {
|
||||
closeFolderSettingPanel()
|
||||
}
|
||||
openPageSettingPanel()
|
||||
}
|
||||
const pageDetail = await fetchPageDetail(pageData?.id)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import throttle from '@opentiny/vue-renderless/common/deps/throttle'
|
|||
import meta from '../meta'
|
||||
import http from './http.js'
|
||||
|
||||
let isShow = ref(false)
|
||||
const isShow = ref(false)
|
||||
export const openFolderSettingPanel = () => {
|
||||
isShow.value = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default {
|
|||
|
||||
const currentRoute = computed(() => {
|
||||
let route = pageSettingState.currentPageData.route || ''
|
||||
let parentId = pageParentId
|
||||
let parentId = pageParentId.value
|
||||
|
||||
while (parentId !== ROOT_ID) {
|
||||
const parent = pageSettingState.treeDataMapping[parentId]
|
||||
|
|
|
|||
|
|
@ -206,7 +206,6 @@ export default {
|
|||
const getSendSeesionProcess = () => {
|
||||
const sendProcess = { ...sessionProcess }
|
||||
const firstMessage = sendProcess.messages[0]
|
||||
firstMessage.content
|
||||
sendProcess.messages = [
|
||||
{ ...firstMessage, content: `${getBlockContent()}\n${codeRules}\n${firstMessage.content}` },
|
||||
...sendProcess.messages.slice(1)
|
||||
|
|
@ -246,7 +245,7 @@ export default {
|
|||
}
|
||||
const scrollContent = async () => {
|
||||
await sleep(100)
|
||||
let scrollElement = document.getElementById('chatgpt-window')
|
||||
const scrollElement = document.getElementById('chatgpt-window')
|
||||
if (scrollElement) {
|
||||
scrollElement.scrollTop = scrollElement.scrollHeight
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export default {
|
|||
|
||||
const validateName = (rule, name, callback) => {
|
||||
let errorMessage = ''
|
||||
let isSameState = Object.keys(props.dataSource).includes(name)
|
||||
const isSameState = Object.keys(props.dataSource).includes(name)
|
||||
if (!name) {
|
||||
errorMessage = '输入内容不能为空'
|
||||
}
|
||||
|
|
@ -149,7 +149,11 @@ export default {
|
|||
errorMessage = '已存在同名 store 属性'
|
||||
}
|
||||
|
||||
errorMessage ? callback(new Error(errorMessage)) : callback()
|
||||
if (errorMessage) {
|
||||
callback(new Error(errorMessage))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
emit('nameInput', errorMessage)
|
||||
}
|
||||
const rules = {
|
||||
|
|
@ -197,7 +201,7 @@ export default {
|
|||
|
||||
const saveMethods = (editor) => {
|
||||
const storeEditor = editor === 'gettersEditor' ? gettersEditor : actionsEditor
|
||||
let gettersMap = {}
|
||||
const gettersMap = {}
|
||||
const editorContent = storeEditor?.value?.getEditor()?.getValue()
|
||||
const ast = string2Ast(editorContent)
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,11 @@ export default {
|
|||
state.errorMessage = '已存在同名 state 属性'
|
||||
}
|
||||
|
||||
state.errorMessage ? callback(new Error(state.errorMessage)) : callback()
|
||||
if (state.errorMessage) {
|
||||
callback(new Error(state.errorMessage))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const rules = {
|
||||
|
|
@ -394,9 +398,9 @@ export default {
|
|||
renderLineHighlightOnlyWhenFocus: true
|
||||
}
|
||||
const getterExample =
|
||||
'function getter() {\r\n // this.state.name = `${this.props.firstName} ${this.props.lastName}`\r\n}' // eslint-disable-line
|
||||
'function getter() {\r\n // this.state.name = `${this.props.firstName} ${this.props.lastName}`\r\n}'
|
||||
const setterExample =
|
||||
"function setter() {\r\n // const [firstName, lastName] = this.state.name.split(' ')\r\n // this.emit('update:firstName', firstName)\r\n // this.emit('update:lastName', lastName)\r\n}" // eslint-disable-line
|
||||
"function setter() {\r\n // const [firstName, lastName] = this.state.name.split(' ')\r\n // this.emit('update:firstName', firstName)\r\n // this.emit('update:lastName', lastName)\r\n}"
|
||||
|
||||
return {
|
||||
INIT,
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ export default {
|
|||
// 校验
|
||||
variableRef.value.validateForm().then(() => {
|
||||
// 获取数据
|
||||
let variable = variableRef.value.getFormData()
|
||||
const variable = variableRef.value.getFormData()
|
||||
|
||||
// 保存数据
|
||||
add(name, variable)
|
||||
|
|
@ -263,7 +263,7 @@ export default {
|
|||
delete state.dataSource[key]
|
||||
|
||||
const schema = getSchema()
|
||||
let { lifeCycles } = schema
|
||||
const { lifeCycles } = schema
|
||||
const { [key]: deletedKey, ...restState } = schema.state
|
||||
|
||||
if (key.startsWith('datasource')) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import { marked } from 'marked'
|
|||
|
||||
const rendererMD = new marked.Renderer()
|
||||
|
||||
let isOpen = ref(false)
|
||||
const isOpen = ref(false)
|
||||
|
||||
export const open = () => {
|
||||
isOpen.value = true
|
||||
|
|
|
|||
|
|
@ -133,7 +133,9 @@ const broadcast = ({ topic, data }) => {
|
|||
|
||||
export default () => {
|
||||
// 新use的message自动广播上次的异步消息
|
||||
lastMessage && publish(lastMessage)
|
||||
if (lastMessage) {
|
||||
publish(lastMessage)
|
||||
}
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ export default {
|
|||
}
|
||||
|
||||
let params = 'event'
|
||||
let extraParams = getExtraParams()
|
||||
const extraParams = getExtraParams()
|
||||
let formatParams = params
|
||||
|
||||
if (!state.isValidParams) {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ export default {
|
|||
const { modal, openModal, closeModal } = useModal()
|
||||
|
||||
const add = () => {
|
||||
let newOption = reactive({})
|
||||
const newOption = reactive({})
|
||||
newOption[itemsOptions.value.valueField] = ''
|
||||
newOption[itemsOptions.value.textField] = ''
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ export default {
|
|||
|
||||
const getPropertyByType = (type) => properties.filter((item) => item.name == type)
|
||||
const getModelvalue = (type) => getPropertyByType(type)[0].modelValue
|
||||
let optionsList = ref([])
|
||||
const optionsList = ref([])
|
||||
|
||||
const actionsOptions = {
|
||||
actions: [
|
||||
|
|
@ -112,7 +112,7 @@ export default {
|
|||
}
|
||||
|
||||
const addSelectOption = () => {
|
||||
let newOption = reactive({})
|
||||
const newOption = reactive({})
|
||||
newOption[itemsOptions.value.valueField] = ''
|
||||
newOption[itemsOptions.value.textField] = ''
|
||||
optionsList.value.push(newOption)
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ const editClassName = (curClassName, optionType = OPTION_TYPE.ADD, oldSelector =
|
|||
|
||||
const editSelectorHandler = () => {
|
||||
const oldSelType = oldSelector.startsWith('.') ? SELECTOR_TYPE.CLASS_NAME : SELECTOR_TYPE.ID
|
||||
let oldSelSymbol = oldSelector.slice(1)
|
||||
const oldSelSymbol = oldSelector.slice(1)
|
||||
let res = newClassNames
|
||||
|
||||
// 前后两种类型不一致,需要将原类型里面的删除,然后在新类型添加
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ export default {
|
|||
}
|
||||
|
||||
const reInit = (name) => {
|
||||
let option = state.gridOptions.find((item) => item.title === name)
|
||||
const option = state.gridOptions.find((item) => item.title === name)
|
||||
option.align.picked = ''
|
||||
option.justify.picked = ''
|
||||
}
|
||||
|
|
@ -402,7 +402,11 @@ export default {
|
|||
updateStyle({ [name]: null })
|
||||
})
|
||||
|
||||
state.isAlign ? reInit('Align') : reInit('Distribute')
|
||||
if (state.isAlign) {
|
||||
reInit('Align')
|
||||
} else {
|
||||
reInit('Distribute')
|
||||
}
|
||||
state.picked = ''
|
||||
state.showModal = false
|
||||
state.isAlign = false
|
||||
|
|
@ -459,9 +463,11 @@ export default {
|
|||
Object.keys(value).forEach((keys) => {
|
||||
state.gridOptions.forEach((item) => {
|
||||
if (item.key.includes(keys)) {
|
||||
keys.includes('align')
|
||||
? (item.align.picked = `${item.align.key}:${value[keys]}`)
|
||||
: (item.justify.picked = `${item.justify.key}:${value[keys]}`)
|
||||
if (keys.includes('align')) {
|
||||
item.align.picked = `${item.align.key}:${value[keys]}`
|
||||
} else {
|
||||
item.justify.picked = `${item.justify.key}:${value[keys]}`
|
||||
}
|
||||
} else {
|
||||
item.picked = ''
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ export default ({ style, updateStyle }) => {
|
|||
const updateLayout = (layout) => {
|
||||
if (typeof layout === 'string') {
|
||||
style.value.display = layout
|
||||
typeof updateStyle === 'function' && updateStyle()
|
||||
if (typeof updateStyle === 'function') {
|
||||
updateStyle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export default {
|
|||
|
||||
watch(
|
||||
() => pageState.isLock,
|
||||
// eslint-disable-next-line no-return-assign
|
||||
|
||||
(value) => (isLock.value = value)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,11 @@ export default {
|
|||
const fullscreen = () => {
|
||||
isFullscreen.value = !isFullscreen.value
|
||||
iconName.value = isFullscreen.value ? props.options.icon.cancelFullScreen : props.options.icon.fullScreen
|
||||
document.webkitFullscreenElement
|
||||
? document.webkitExitFullscreen()
|
||||
: document.documentElement.webkitRequestFullScreen()
|
||||
if (document.webkitFullscreenElement) {
|
||||
document.webkitExitFullscreen()
|
||||
} else {
|
||||
document.documentElement.webkitRequestFullScreen()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ const confirmSaveLocal = async () => {
|
|||
|
||||
const message = savePage.data.isSuccess ? '保存文件到本地成功' : errorMsg
|
||||
|
||||
savePage.data.isSuccess && setSaved(true)
|
||||
if (savePage.data.isSuccess) {
|
||||
setSaved(true)
|
||||
}
|
||||
|
||||
Modal.message({ message, status: 'error', duration: '5000', top: 60 })
|
||||
}
|
||||
|
|
@ -72,7 +74,9 @@ const savePageLocal = async () => {
|
|||
title: '查询本地文件',
|
||||
message: '本地已经存在同名文件,是否覆盖?'
|
||||
}).then((res) => {
|
||||
res === 'confirm' && confirmSaveLocal()
|
||||
if (res === 'confirm') {
|
||||
confirmSaveLocal()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default {
|
|||
})
|
||||
|
||||
const togglePanel = (item, index) => {
|
||||
let curIndex = state.arrActive.indexOf(index)
|
||||
const curIndex = state.arrActive.indexOf(index)
|
||||
|
||||
if (curIndex > -1) {
|
||||
state.arrActive.splice(curIndex, 1)
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ const state = reactive({
|
|||
})
|
||||
|
||||
const tipBoxVisibility = ref(false)
|
||||
let tipText = ref('发布成功')
|
||||
const tipText = ref('发布成功')
|
||||
const form = ref(null)
|
||||
const menus = ref(
|
||||
getMergeMeta('engine.config')?.dslMode === 'Angular' ? [] : [{ name: '应用发布', code: 'publishApp', icon: 'news' }]
|
||||
|
|
|
|||
|
|
@ -82,13 +82,21 @@ export default {
|
|||
}
|
||||
|
||||
if (isSaved()) {
|
||||
isBlock() ? refreshBlock() : refreshPage()
|
||||
if (isBlock()) {
|
||||
refreshBlock()
|
||||
} else {
|
||||
refreshPage()
|
||||
}
|
||||
} else {
|
||||
confirm({
|
||||
title: '提示',
|
||||
message: `${isBlock() ? '区块' : '页面'}尚未保存,是否要继续刷新?`,
|
||||
exec: () => {
|
||||
isBlock() ? refreshBlock() : refreshPage()
|
||||
if (isBlock()) {
|
||||
refreshBlock()
|
||||
} else {
|
||||
refreshPage()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -441,8 +441,11 @@ export const obj2StyleString = (obj) => {
|
|||
return ''
|
||||
}
|
||||
|
||||
return Object.entries(obj)
|
||||
.filter(([, value]) => value != null)
|
||||
.map(([key, value]) => `${convertCamelToKebab(key)}: ${value}`)
|
||||
.join('; ')
|
||||
return (
|
||||
Object.entries(obj)
|
||||
// eslint-disable-next-line no-eq-null
|
||||
.filter(([, value]) => value != null)
|
||||
.map(([key, value]) => `${convertCamelToKebab(key)}: ${value}`)
|
||||
.join('; ')
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
const { rules } = require('../../.eslintrc')
|
||||
|
||||
/* eslint-env node */
|
||||
require('@rushstack/eslint-patch/modern-module-resolution')
|
||||
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/eslint-config-prettier'],
|
||||
env: {
|
||||
'vue/setup-compiler-macros': true,
|
||||
browser: true,
|
||||
es2015: true,
|
||||
node: true
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
ecmaFeatures: {
|
||||
jsx: true
|
||||
}
|
||||
},
|
||||
// 忽略 expected 中的内容
|
||||
ignorePatterns: ['**/**/expected/*', '**/**.ts'],
|
||||
rules
|
||||
}
|
||||
|
|
@ -39,12 +39,9 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@opentiny/tiny-engine-vite-plugin-meta-comments": "workspace:*",
|
||||
"@rushstack/eslint-patch": "^1.1.1",
|
||||
"@vitest/coverage-v8": "^1.4.0",
|
||||
"@vue/eslint-config-prettier": "^7.0.0",
|
||||
"dir-compare": "^4.2.0",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-plugin-vue": "^8.6.0",
|
||||
"fs-extra": "^10.0.1",
|
||||
"prettier": "^2.6.1",
|
||||
"vite": "^5.4.2",
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import {
|
|||
|
||||
function recurseChildren(children, state, description, result) {
|
||||
if (Array.isArray(children)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
const subTemplate = children.map((child) => generateTemplate(child, state, description)).join('')
|
||||
result.push(subTemplate)
|
||||
} else if (children?.type === 'JSExpression') {
|
||||
|
|
@ -177,7 +178,9 @@ function handleBinding(props, attrsArr, description, state) {
|
|||
const tArguments = [`'${item.key}'`]
|
||||
const i18nParams = JSON.stringify(item.params)?.replace(/"/g, "'")
|
||||
|
||||
i18nParams && tArguments.push(i18nParams)
|
||||
if (i18nParams) {
|
||||
tArguments.push(i18nParams)
|
||||
}
|
||||
|
||||
return attrsArr.push(`:${key}="t(${tArguments.join(',')})"`)
|
||||
}
|
||||
|
|
@ -317,6 +320,7 @@ const generateImports = (description, moduleName, type, componentsMap) => {
|
|||
} else if (toPath === fromPath) {
|
||||
depPath = '.'
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const path = require('path')
|
||||
const relativePath = path?.relative(fromPath, toPath).replace(/\\/g, '/')
|
||||
depPath = relativePath.startsWith('.') ? relativePath : `./${relativePath}`
|
||||
|
|
|
|||
|
|
@ -92,7 +92,9 @@ const handleBindI18n = (key, value, isJSX) => {
|
|||
// TODO: 拿到场景用例
|
||||
const i18nParams = JSON.stringify(value.params)
|
||||
|
||||
i18nParams && tArguments.push(i18nParams)
|
||||
if (i18nParams) {
|
||||
tArguments.push(i18nParams)
|
||||
}
|
||||
|
||||
if (isJSX) {
|
||||
return `${key}={t(${tArguments.join(',')})}`
|
||||
|
|
@ -188,7 +190,7 @@ export const handleLoopAttrHook = (schemaData = {}, globalHooks, config) => {
|
|||
suffix.unshift(`)`)
|
||||
|
||||
if (prefix[0] !== '{') {
|
||||
prefix.unshift['{']
|
||||
prefix.unshift('{')
|
||||
}
|
||||
|
||||
if (suffix.at(-1) !== '}') {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/// <reference path="index.d.ts">
|
||||
import './index.d.ts'
|
||||
|
||||
export {
|
||||
generateCode,
|
||||
|
|
|
|||
|
|
@ -110,7 +110,9 @@ const generateJSXTemplate = (item, description) => {
|
|||
|
||||
result.push(`</${component}>`)
|
||||
}
|
||||
condition && result.push(' }')
|
||||
if (condition) {
|
||||
result.push(' }')
|
||||
}
|
||||
|
||||
return result.join('')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export default (config) => {
|
|||
|
||||
if (typeof MockAdapter.prototype.proxy === 'undefined') {
|
||||
MockAdapter.prototype.proxy = function ({ url, config = {}, proxy, response, handleData } = {}) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
let stream = this
|
||||
const request = (proxy, any) => {
|
||||
return (setting) => {
|
||||
|
|
@ -28,8 +29,9 @@ export default (config) => {
|
|||
axios
|
||||
.get(any ? proxy + setting.url + '.json' : proxy, config)
|
||||
.then(({ data }) => {
|
||||
/* eslint-disable no-useless-call */
|
||||
typeof handleData === 'function' && (data = handleData.call(null, data, setting))
|
||||
if (typeof handleData === 'function') {
|
||||
data = handleData.call(null, data, setting)
|
||||
}
|
||||
resolve([200, data])
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
@ -127,7 +129,9 @@ export default (config) => {
|
|||
return mock
|
||||
},
|
||||
disableMock() {
|
||||
mock && mock.restore()
|
||||
if (mock) {
|
||||
mock.restore()
|
||||
}
|
||||
mock = undefined
|
||||
},
|
||||
isMock() {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,9 @@ dataSources.list.forEach((config) => {
|
|||
}
|
||||
|
||||
const errorHandler = (error) => {
|
||||
config.errorHandler?.value && createFn(config.errorHandler.value)(error)
|
||||
if (config.errorHandler?.value) {
|
||||
createFn(config.errorHandler.value)(error)
|
||||
}
|
||||
dataSource.status = 'error'
|
||||
dataSource.error = error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
import { parse as parseSFC, compileScript, compileStyle, compileTemplate } from '@vue/compiler-sfc'
|
||||
import { generateCodeFrame } from '@vue/shared'
|
||||
import { randomString } from '.'
|
||||
|
|
@ -20,6 +21,7 @@ import { randomString } from '.'
|
|||
* @returns {Error[]} 校验出的报错信息
|
||||
*/
|
||||
export function validateByParse(code) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { parse: parseVue } = require('vue-eslint-parser')
|
||||
let errors = []
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"lint": "eslint . --ext .js,.vue --fix",
|
||||
"format": "prettier --write **/*{.vue,.js,.ts,.html,.json}",
|
||||
"publish:npm": "npm run build && npm publish --verbose"
|
||||
},
|
||||
|
|
@ -34,13 +33,6 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.1.2",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-import": "^2.24.2",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^5.1.0",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^7.17.0",
|
||||
"prettier": "^2.4.0",
|
||||
"vite": "^5.4.2"
|
||||
},
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue