Initial commit

This commit is contained in:
libertyspy
2026-02-08 18:05:48 +08:00
parent 82fcedfa97
commit 3bb9178399
3 changed files with 15 additions and 64 deletions

View File

@@ -7,7 +7,16 @@
* that was distributed with this source code.
*/
import type { NullableString } from '@/types';
export const generateKey = (type: string | null = ''): string => {
return `${type ? (type + '_') : ''}${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`
.replace('-', '_').toLowerCase();
};
export const substring = (s: NullableString, n: number = 10, p: string = '...') => {
if (s) {
return s.length > n ? (s.substring(0, n) + p) : s;
}
return s;
};

View File

@@ -1,61 +0,0 @@
<template>
<div class="ks-model-builder-actions">
<a-space>
<a-tooltip placement="top">
<template #title>
返回
</template>
<a-button class="ks-model-builder-goback" size="small" @click="goback">
<RollbackOutlined />
<span>返回</span>
</a-button>
</a-tooltip>
<a-tooltip v-if="graph && node" placement="top">
<template #title>
保存
</template>
<a-popconfirm
title="确定保存?"
@confirm="handleSave"
>
<a-button class="ks-model-builder-save" size="small">
<CheckOutlined />
<span>保存</span>
</a-button>
</a-popconfirm>
</a-tooltip>
</a-space>
</div>
</template>
<script lang="ts">
import {defineComponent} from 'vue';
import { CheckOutlined, RollbackOutlined } from '@ant-design/icons-vue';
import {elementProps} from './builder/props'
export default defineComponent({
components: {
CheckOutlined,
RollbackOutlined,
},
props: elementProps,
emits: ['save'],
setup(props, ctx) {
const handleSave = ()=> {
ctx.emit('save')
}
const goback = ()=> {
}
return {
graph: props.graph,
node: props.node,
handleSave,
goback,
}
},
})
</script>

View File

@@ -8,10 +8,11 @@
<template #renderItem="{ item }">
<a-tooltip placement="right">
<template #title>
{{ item.description }}
<p>名称: {{ item.name }}</p>
<p>说明: {{item.description}}</p>
</template>
<a-list-item @click="()=> handleSelect(item)">
{{ item.name }}
{{ substring(item.name, 25) }}
</a-list-item>
</a-tooltip>
</template>
@@ -25,6 +26,7 @@ import { defineComponent, onMounted, ref } from 'vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import type { BehaviorTree } from './types';
import { findTreesByQuery } from './api';
import {substring} from '@/utils/strings'
export default defineComponent({
emits: ['select-tree'],
@@ -65,6 +67,7 @@ export default defineComponent({
});
return {
substring,
activeKey,
behaviorTrees,
behaviorTreeQuery,