改为typescript支持
This commit is contained in:
11
src/App.vue
11
src/App.vue
@@ -1,8 +1,9 @@
|
||||
<script setup>
|
||||
<script setup lang="ts">
|
||||
import ProjectList from './components/ProjectList.vue'
|
||||
import type { ListItem, MenuItem, ListConfig } from '@/types'
|
||||
|
||||
// 生成模拟数据
|
||||
const listData = Array.from({ length: 789 }, (_, i) => ({
|
||||
const listData: ListItem[] = Array.from({ length: 789 }, (_, i) => ({
|
||||
id: i,
|
||||
name: `project-${i + 1}`,
|
||||
path: `/Users/lanyuanxiaoyao/Project/IdeaProjects/project-${i + 1}`,
|
||||
@@ -15,7 +16,7 @@ const listData = Array.from({ length: 789 }, (_, i) => ({
|
||||
}))
|
||||
|
||||
// 自定义配置
|
||||
const listConfig = {
|
||||
const listConfig: ListConfig = {
|
||||
itemHeight: 50,
|
||||
itemPadding: 16,
|
||||
bufferCount: 10,
|
||||
@@ -23,7 +24,7 @@ const listConfig = {
|
||||
}
|
||||
|
||||
// 自定义菜单项
|
||||
const menuItems = [
|
||||
const menuItems: MenuItem[] = [
|
||||
{
|
||||
id: 'refresh',
|
||||
label: '刷新列表',
|
||||
@@ -48,7 +49,7 @@ const menuItems = [
|
||||
]
|
||||
|
||||
// 列表项点击事件处理
|
||||
const handleItemClick = (item) => {
|
||||
const handleItemClick = (item: ListItem): void => {
|
||||
console.log('点击列表项:', item)
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user