mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-04-23 02:08:53 +00:00
style(schema,editor,data-source): 代码块类型定义中content去掉string类型
This commit is contained in:
parent
b3f4e42716
commit
b2888962df
@ -16,6 +16,7 @@ export default defineConfig([
|
|||||||
'*/**/public/**/*',
|
'*/**/public/**/*',
|
||||||
'*/**/types/**/*',
|
'*/**/types/**/*',
|
||||||
'*/**/*.config.ts',
|
'*/**/*.config.ts',
|
||||||
|
'./tepm/**/*',
|
||||||
'vite-env.d.ts',
|
'vite-env.d.ts',
|
||||||
]),
|
]),
|
||||||
...eslintConfig(path.join(path.dirname(fileURLToPath(import.meta.url)), 'tsconfig.json')),
|
...eslintConfig(path.join(path.dirname(fileURLToPath(import.meta.url)), 'tsconfig.json')),
|
||||||
|
|||||||
@ -79,9 +79,9 @@ export default class HttpDataSource extends DataSource<HttpDataSourceSchema> {
|
|||||||
/** 请求函数 */
|
/** 请求函数 */
|
||||||
#fetch?: RequestFunction;
|
#fetch?: RequestFunction;
|
||||||
/** 请求前需要执行的函数队列 */
|
/** 请求前需要执行的函数队列 */
|
||||||
#beforeRequest: ((...args: any[]) => any)[] = [];
|
#beforeRequest: (Function | ((...args: any[]) => any))[] = [];
|
||||||
/** 请求后需要执行的函数队列 */
|
/** 请求后需要执行的函数队列 */
|
||||||
#afterRequest: ((...args: any[]) => any)[] = [];
|
#afterRequest: (Function | ((...args: any[]) => any))[] = [];
|
||||||
|
|
||||||
#type = 'http';
|
#type = 'http';
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ const width = defineModel<number>('width', { default: 670 });
|
|||||||
const boxVisible = defineModel<boolean>('visible', { default: false });
|
const boxVisible = defineModel<boolean>('visible', { default: false });
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
content: CodeBlockContent;
|
content: Omit<CodeBlockContent, 'content'> & { content: string };
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
isDataSource?: boolean;
|
isDataSource?: boolean;
|
||||||
dataSourceType?: string;
|
dataSourceType?: string;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ const props = withDefaults(defineProps<FieldProps<DataSourceMethodsConfig>>(), {
|
|||||||
|
|
||||||
const emit = defineEmits(['change']);
|
const emit = defineEmits(['change']);
|
||||||
|
|
||||||
const codeConfig = ref<CodeBlockContent>();
|
const codeConfig = ref<Omit<CodeBlockContent, 'content'> & { content: string }>();
|
||||||
const codeBlockEditorRef = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
const codeBlockEditorRef = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
||||||
|
|
||||||
let editIndex = -1;
|
let editIndex = -1;
|
||||||
@ -72,10 +72,14 @@ const methodColumns: ColumnConfig[] = [
|
|||||||
{
|
{
|
||||||
text: '编辑',
|
text: '编辑',
|
||||||
handler: (method: CodeBlockContent, index: number) => {
|
handler: (method: CodeBlockContent, index: number) => {
|
||||||
let codeContent = method.content || '({ params, dataSource, app }) => {\n // place your code here\n}';
|
let codeContent: string = '({ params, dataSource, app }) => {\n // place your code here\n}';
|
||||||
|
|
||||||
if (typeof codeContent !== 'string') {
|
if (method.content) {
|
||||||
codeContent = codeContent.toString();
|
if (typeof method.content !== 'string') {
|
||||||
|
codeContent = method.content.toString();
|
||||||
|
} else {
|
||||||
|
codeContent = method.content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeConfig.value = {
|
codeConfig.value = {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
|
|||||||
import type { Services } from '@editor/type';
|
import type { Services } from '@editor/type';
|
||||||
|
|
||||||
export const useCodeBlockEdit = (codeBlockService: Services['codeBlockService']) => {
|
export const useCodeBlockEdit = (codeBlockService: Services['codeBlockService']) => {
|
||||||
const codeConfig = ref<CodeBlockContent>();
|
const codeConfig = ref<Omit<CodeBlockContent, 'content'> & { content: string }>();
|
||||||
const codeId = ref<string>();
|
const codeId = ref<string>();
|
||||||
const codeBlockEditorRef = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
const codeBlockEditorRef = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
||||||
|
|
||||||
@ -36,10 +36,14 @@ export const useCodeBlockEdit = (codeBlockService: Services['codeBlockService'])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let codeContent = codeBlock.content;
|
let codeContent = '';
|
||||||
|
|
||||||
if (typeof codeContent !== 'string') {
|
if (codeBlock.content) {
|
||||||
codeContent = codeContent.toString();
|
if (typeof codeBlock.content !== 'string') {
|
||||||
|
codeContent = codeBlock.content.toString();
|
||||||
|
} else {
|
||||||
|
codeContent = codeBlock.content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeConfig.value = {
|
codeConfig.value = {
|
||||||
|
|||||||
@ -186,7 +186,7 @@ export interface CodeBlockContent {
|
|||||||
/** 代码块名称 */
|
/** 代码块名称 */
|
||||||
name: string;
|
name: string;
|
||||||
/** 代码块内容 */
|
/** 代码块内容 */
|
||||||
content: ((...args: any[]) => any) | string;
|
content: ((...args: any[]) => any) | Function;
|
||||||
/** 参数定义 */
|
/** 参数定义 */
|
||||||
params: CodeParam[] | [];
|
params: CodeParam[] | [];
|
||||||
/** 注释 */
|
/** 注释 */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user