feat: 添加 TypeScript 类型检查命令,优化模板创建流程,移除不必要的上下文菜单逻辑
This commit is contained in:
1 parent
562e4f5b9e
commit
157bc47f3c
4 files changed
+31
-105
No files matched your search
@@ -64,6 +64,9 @@ pnpm dev:debug
|
||||
|
||||
# Force reinstall dependencies and start development
|
||||
pnpm dev:debug:force
|
||||
|
||||
# run Typescript Type check
|
||||
pnpm typecheck
|
||||
```
|
||||
|
||||
### Building
|
||||
@@ -103,11 +106,6 @@ pnpm lint
|
||||
# Fix linting issues automatically
|
||||
pnpm lint:fix
|
||||
|
||||
# Format code with Prettier
|
||||
pnpm format
|
||||
|
||||
# Format and fix code automatically
|
||||
pnpm format:fix
|
||||
```
|
||||
|
||||
## Key Features
|
||||
@@ -231,4 +229,6 @@ Building creates different distribution formats based on the platform:
|
||||
|
||||
Artifacts are named with the format `${productName} ${version}_${arch}.${ext}` and stored in the `release/${version}` directory.
|
||||
|
||||
run `pnpm typecheck` before finish the task
|
||||
|
||||
Always respond in 中文
|
||||
+1
-2
@@ -24,6 +24,7 @@
|
||||
"dev": "vite",
|
||||
"dev:debug": "vite -d",
|
||||
"dev:debug:force": "vite -d --force",
|
||||
"typecheck": "vue-tsc --noEmit",
|
||||
"build": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js",
|
||||
"build:pre": "vue-tsc --noEmit && vite build",
|
||||
"build:all": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js -wml",
|
||||
@@ -33,8 +34,6 @@
|
||||
"build:win": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js --windows",
|
||||
"lint": "eslint . --ext .js,.ts,.vue .",
|
||||
"lint:fix": "eslint . --ext .js,.ts,.vue --fix .",
|
||||
"format": "prettier .",
|
||||
"format:fix": "prettier . --write",
|
||||
"test": "npm run build:pre && playwright test",
|
||||
"test:linux": "npm run build:pre && xvfb-run --auto-servernum --server-args='-screen 0, 1280x960x24' -- playwright test"
|
||||
},
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
variant="outlined"
|
||||
class="pa-2"
|
||||
:height="height"
|
||||
@contextmenu.prevent="emit('showContextMenu', $event, null)"
|
||||
>
|
||||
<v-treeview
|
||||
v-model:expanded="localExpanded"
|
||||
@@ -31,27 +30,9 @@
|
||||
|
||||
<template #title="{ item }">
|
||||
<span
|
||||
@contextmenu.prevent="emit('showContextMenu', $event, item)"
|
||||
class="cursor-pointer d-flex align-center"
|
||||
>
|
||||
{{ item.name }}
|
||||
<v-btn
|
||||
v-if="!readOnly && item.type === 'directory'"
|
||||
icon
|
||||
variant="text"
|
||||
size="small"
|
||||
class="ml-2"
|
||||
@click.stop="emit('addNewItemToCurrentDirectory', item)"
|
||||
>
|
||||
<v-icon size="small">mdi-plus</v-icon>
|
||||
<v-tooltip
|
||||
v-if="!readOnly"
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
添加到目录
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@@ -61,23 +42,24 @@
|
||||
class="d-flex align-center ga-1"
|
||||
>
|
||||
<v-btn
|
||||
v-if="!readOnly"
|
||||
v-if="!readOnly && item.type === 'directory'"
|
||||
icon
|
||||
variant="text"
|
||||
size="small"
|
||||
@click.stop="emit('editItem', item)"
|
||||
class="ml-2"
|
||||
@click.stop="emit('addNewItemToCurrentDirectory', item)"
|
||||
>
|
||||
<v-icon size="small"> mdi-pencil </v-icon>
|
||||
<v-icon size="small">mdi-folder-plus</v-icon>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
{{ item.type === 'file' ? '编辑文件' : '编辑目录' }}
|
||||
添加到目录
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
v-if="item.type === 'directory' && !readOnly"
|
||||
v-if="item.type === 'directory'"
|
||||
icon
|
||||
variant="text"
|
||||
size="small"
|
||||
@@ -92,6 +74,21 @@
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
icon
|
||||
variant="text"
|
||||
size="small"
|
||||
@click.stop="emit('editItem', item)"
|
||||
>
|
||||
<v-icon size="small"> mdi-pencil </v-icon>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
{{ item.type === 'file' ? '编辑文件' : '编辑目录' }}
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
icon
|
||||
variant="text"
|
||||
@@ -99,7 +96,6 @@
|
||||
@click.stop="emit('deleteItem', item)"
|
||||
>
|
||||
<v-icon
|
||||
v-if="!readOnly"
|
||||
size="small"
|
||||
color="error"
|
||||
>
|
||||
@@ -133,39 +129,12 @@
|
||||
v-if="!readOnly"
|
||||
class="text-caption"
|
||||
>
|
||||
右键点击空白区域添加根目录或文件
|
||||
点击上方按钮添加根目录或文件
|
||||
</p>
|
||||
</div>
|
||||
</v-card>
|
||||
|
||||
<!-- Context Menu -->
|
||||
<v-menu
|
||||
v-if="!readOnly"
|
||||
v-model="localShowContextMenuVar"
|
||||
:position-x="contextMenuX"
|
||||
:position-y="contextMenuY"
|
||||
absolute
|
||||
>
|
||||
<v-list density="compact">
|
||||
<v-list-item @click="emit('addDirectory', currentContextItem)">
|
||||
<template #prepend>
|
||||
<v-icon>mdi-folder-plus</v-icon>
|
||||
</template>
|
||||
<v-list-item-title>
|
||||
{{ currentContextItem ? '添加子目录' : '添加根目录' }}
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
|
||||
<v-list-item @click="emit('addFile', currentContextItem)">
|
||||
<template #prepend>
|
||||
<v-icon>mdi-file-plus</v-icon>
|
||||
</template>
|
||||
<v-list-item-title>
|
||||
{{ currentContextItem ? '添加子文件' : '添加根文件' }}
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -182,18 +151,12 @@ interface Props {
|
||||
height?: number
|
||||
readOnly?: boolean
|
||||
emptyText?: string
|
||||
contextMenuX?: number
|
||||
contextMenuY?: number
|
||||
currentContextItem?: TreeItem | null
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
height: 600,
|
||||
readOnly: false,
|
||||
emptyText: '暂无文件或目录',
|
||||
contextMenuX: 0,
|
||||
contextMenuY: 0,
|
||||
currentContextItem: null
|
||||
emptyText: '暂无文件或目录'
|
||||
})
|
||||
|
||||
const localExpanded = defineModel<string[]>('expanded', {
|
||||
@@ -205,13 +168,10 @@ const localShowContextMenuVar = defineModel<boolean>('showContextMenuVar', {
|
||||
})
|
||||
|
||||
const emit = defineEmits([
|
||||
'showContextMenu',
|
||||
'addNewItemToCurrentDirectory',
|
||||
'editFile',
|
||||
'editItem',
|
||||
'deleteItem',
|
||||
'addDirectory',
|
||||
'addFile',
|
||||
'addFileToDirectory'
|
||||
])
|
||||
</script>
|
||||
|
||||
@@ -142,19 +142,12 @@
|
||||
:items="treeItems"
|
||||
:height="treeHeight"
|
||||
v-model:expanded="expandedNodes"
|
||||
v-model:showContextMenuVar="showContextMenuVar"
|
||||
:context-menu-x="contextMenuX"
|
||||
:context-menu-y="contextMenuY"
|
||||
:current-context-item="currentContextItem"
|
||||
:empty-text="'暂无文件或目录'"
|
||||
:read-only="false"
|
||||
@showContextMenu="showContextMenu"
|
||||
@add-new-item-to-current-directory="addNewItemToCurrentDirectory"
|
||||
@edit-file="editFile"
|
||||
@edit-item="editItem"
|
||||
@delete-item="deleteItem"
|
||||
@add-directory="addDirectory"
|
||||
@add-file="addFile"
|
||||
@add-file-to-directory="addFileToDirectory"
|
||||
/>
|
||||
</v-col>
|
||||
@@ -384,11 +377,7 @@ const fileFormValid = ref(false)
|
||||
const directoryInputRef = ref<HTMLInputElement | null>(null)
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
|
||||
// Context menu
|
||||
const showContextMenuVar = ref(false)
|
||||
const contextMenuX = ref(0)
|
||||
const contextMenuY = ref(0)
|
||||
const currentContextItem = ref<TreeItem | null>(null)
|
||||
|
||||
|
||||
// Snackbar variables
|
||||
const snackbarVisible = ref(false)
|
||||
@@ -554,18 +543,7 @@ const updateTreeHeight = () => {
|
||||
treeHeight.value = window.innerHeight - 200
|
||||
}
|
||||
|
||||
const showContextMenu = (event: MouseEvent, item: TreeItem | null) => {
|
||||
event.preventDefault()
|
||||
contextMenuX.value = event.clientX
|
||||
contextMenuY.value = event.clientY
|
||||
currentContextItem.value = item
|
||||
showContextMenuVar.value = false // Close first to reset position
|
||||
nextTick(() => {
|
||||
contextMenuX.value = event.clientX
|
||||
contextMenuY.value = event.clientY
|
||||
showContextMenuVar.value = true
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const addRootDirectory = () => {
|
||||
newDirectoryPath.value = ''
|
||||
@@ -580,8 +558,6 @@ const addRootFile = () => {
|
||||
}
|
||||
|
||||
const addDirectory = (parentItem: TreeItem | null = null) => {
|
||||
showContextMenuVar.value = false
|
||||
currentContextItem.value = parentItem
|
||||
parentDirectoryForNewItems.value = parentItem ? parentItem.name : null // Store parent context
|
||||
newDirectoryPath.value = '' // Don't pre-fill the path
|
||||
showDirectoryDialog.value = true
|
||||
@@ -589,7 +565,6 @@ const addDirectory = (parentItem: TreeItem | null = null) => {
|
||||
}
|
||||
|
||||
const addFile = (parentItem: TreeItem | null = null) => {
|
||||
showContextMenuVar.value = false
|
||||
parentDirectoryForNewItems.value = parentItem ? parentItem.name : null // Store parent context
|
||||
newFilePath.value = '' // Don't pre-fill the path
|
||||
showFileDialog.value = true
|
||||
@@ -598,7 +573,6 @@ const addFile = (parentItem: TreeItem | null = null) => {
|
||||
|
||||
// Add a file directly to a specific directory
|
||||
const addFileToDirectory = (directoryItem: TreeItem) => {
|
||||
showContextMenuVar.value = false
|
||||
parentDirectoryForNewItems.value = directoryItem.name // Store the directory as parent
|
||||
newFilePath.value = '' // Don't pre-fill the path
|
||||
showFileDialog.value = true
|
||||
@@ -606,7 +580,6 @@ const addFileToDirectory = (directoryItem: TreeItem) => {
|
||||
}
|
||||
|
||||
const addNewItemToCurrentDirectory = (directoryItem: TreeItem) => {
|
||||
currentContextItem.value = directoryItem
|
||||
parentDirectoryForNewItems.value = directoryItem.name // Store parent context
|
||||
newDirectoryPath.value = '' // Don't pre-fill the path
|
||||
showDirectoryDialog.value = true
|
||||
@@ -654,7 +627,6 @@ const confirmAddDirectory = () => {
|
||||
showDirectoryDialog.value = false
|
||||
newDirectoryPath.value = ''
|
||||
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
||||
currentContextItem.value = null
|
||||
currentEditingItem.value = null
|
||||
|
||||
// If we added to a parent directory, make sure it's expanded
|
||||
@@ -695,7 +667,6 @@ const closeDirectoryDialog = () => {
|
||||
showDirectoryDialog.value = false
|
||||
newDirectoryPath.value = ''
|
||||
parentDirectoryForNewItems.value = null
|
||||
currentContextItem.value = null
|
||||
currentEditingItem.value = null
|
||||
}
|
||||
|
||||
@@ -703,7 +674,6 @@ const closeFileDialog = () => {
|
||||
showFileDialog.value = false
|
||||
newFilePath.value = ''
|
||||
parentDirectoryForNewItems.value = null
|
||||
currentContextItem.value = null
|
||||
currentEditingItem.value = null
|
||||
selectedSourcePath.value = ''
|
||||
isAutoFindMode.value = false
|
||||
@@ -769,7 +739,6 @@ const selectAndAddFile = async () => {
|
||||
showFileDialog.value = false
|
||||
newFilePath.value = ''
|
||||
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
||||
currentContextItem.value = null
|
||||
currentEditingItem.value = null
|
||||
return
|
||||
}
|
||||
@@ -790,7 +759,6 @@ const selectAndAddFile = async () => {
|
||||
showFileDialog.value = false
|
||||
newFilePath.value = ''
|
||||
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
||||
currentContextItem.value = null
|
||||
currentEditingItem.value = null
|
||||
return
|
||||
}
|
||||
@@ -807,7 +775,6 @@ const selectAndAddFile = async () => {
|
||||
showFileDialog.value = false
|
||||
newFilePath.value = ''
|
||||
parentDirectoryForNewItems.value = null
|
||||
currentContextItem.value = null
|
||||
currentEditingItem.value = null
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user