-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add dialog component #7553
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
<template> | ||
<div> | ||
<el-dialog | ||
v-model="dialogVisible" | ||
:title="$t('app.checkTitle')" | ||
width="30%" | ||
:close-on-click-modal="false" | ||
:destroy-on-close="true" | ||
> | ||
<DialogPro v-model="open" :title="$t('app.checkTitle')" size="small"> | ||
<el-row> | ||
<el-col :span="22" :offset="1"> | ||
<el-alert :closable="false" :title="$t('file.vscodeHelper')" type="info"></el-alert> | ||
|
@@ -37,14 +31,14 @@ | |
</el-button> | ||
</span> | ||
</template> | ||
</el-dialog> | ||
</DialogPro> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import { reactive, ref } from 'vue'; | ||
import { FormInstance } from 'element-plus'; | ||
|
||
const dialogVisible = ref(); | ||
const open = ref(); | ||
|
||
interface DialogProps { | ||
path: string; | ||
|
@@ -60,7 +54,7 @@ const addForm = reactive({ | |
|
||
const em = defineEmits(['close']); | ||
const handleClose = () => { | ||
dialogVisible.value = false; | ||
open.value = false; | ||
if (vscodeConnectInfoForm.value) { | ||
vscodeConnectInfoForm.value.resetFields(); | ||
} | ||
|
@@ -73,7 +67,7 @@ const submit = async (formEl: FormInstance | undefined) => { | |
return; | ||
} | ||
localStorage.setItem('VscodeConnectInfo', JSON.stringify(addForm)); | ||
dialogVisible.value = false; | ||
open.value = false; | ||
const vscodeUrl = `vscode://vscode-remote/ssh-remote+${addForm.username}@${addForm.host}:${addForm.port}${addForm.path}?windowId=_blank`; | ||
window.open(vscodeUrl); | ||
}); | ||
|
@@ -91,7 +85,7 @@ const acceptParams = async (params: DialogProps): Promise<void> => { | |
} | ||
|
||
addForm.path = params.path; | ||
dialogVisible.value = true; | ||
open.value = true; | ||
}; | ||
|
||
defineExpose({ acceptParams }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code looks fine according to my knowledge cutoff of September 2021. There don't appear to be any obvious issues, problems with coding style, bugs or inconsistencies between components. Everything seems to function as intended. To suggest some minor improvements based on common practices:
For example:
type DialogProps = {
path: string;
}; This allows for automatic static types in Visual Studio Code Editor which can help reduce boilerplate code. However, since this is an older version where these features may not exist yet: These suggestions are more related to best development practices than addressing specific code errors within your snippet. The provided template file appears valid in terms of structure, but I will proceed assuming the above information applies to modern Vue.js implementations. It's always a good practice to review component files in isolation before merging them into a main package. This ensures that all changes have gone through proper testing stages. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code is not complete, but I can still give some general guidance on how to improve it.
For efficiency and usability, here's an optimized version of your component: