From 73fb136b91056c0f6bf03fc10098536a25f09563 Mon Sep 17 00:00:00 2001 From: IlhamTahir Date: Wed, 4 Dec 2024 21:00:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=BD=AE=E6=92=AD=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E6=80=81=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ImageUpload.vue | 14 +++--- .../article/components/ArticleDialog.vue | 6 +-- .../carousal/components/CarousalDialog.vue | 44 +++++++++++-------- src/pages/carousal/index.vue | 13 +++--- .../category/components/CategoryDialog.vue | 6 +-- 5 files changed, 45 insertions(+), 38 deletions(-) diff --git a/src/components/ImageUpload.vue b/src/components/ImageUpload.vue index 2bdbce9..5e78cda 100644 --- a/src/components/ImageUpload.vue +++ b/src/components/ImageUpload.vue @@ -39,13 +39,13 @@ const props = defineProps({ const emits = defineEmits(['on-success']) watch(() => props.imageUrl,(newVal) => { - if(newVal){ - if(newVal.url !== ''){ - file1.value = [{ ...newVal }] - }else{ - file1.value = [] - } + if (!newVal) return + if (newVal.url !== '') { + file1.value = [{...newVal}] + } else { + file1.value = [] } + },{ deep:true, immediate:true @@ -86,4 +86,4 @@ watch(() => props.imageUrl,(newVal) => { \ No newline at end of file + diff --git a/src/pages/article/components/ArticleDialog.vue b/src/pages/article/components/ArticleDialog.vue index 71e142c..c514f4c 100644 --- a/src/pages/article/components/ArticleDialog.vue +++ b/src/pages/article/components/ArticleDialog.vue @@ -60,9 +60,9 @@ const props = defineProps<{ article?: Article | {} categoryList: Category[] | [] }>() -const form = ref(null) -const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`) -const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定')) +const formRef = ref(null) +const headerText = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`) +const confirmBtnText = computed(() => (props.isEdit ? '保存' : '确定')) const articleData: FormProps['data'] = reactive({ categoryName: '' }) const popupVisible = ref(false) diff --git a/src/pages/carousal/components/CarousalDialog.vue b/src/pages/carousal/components/CarousalDialog.vue index e92d8de..d7eca72 100644 --- a/src/pages/carousal/components/CarousalDialog.vue +++ b/src/pages/carousal/components/CarousalDialog.vue @@ -1,14 +1,13 @@ diff --git a/src/pages/carousal/index.vue b/src/pages/carousal/index.vue index 4c045b4..452ae42 100644 --- a/src/pages/carousal/index.vue +++ b/src/pages/carousal/index.vue @@ -40,12 +40,12 @@ const isEdit = ref(false) const currentTableData = ref(null) -const editClick = (row: object): void => { +const handleEdit = (row: object): void => { isEdit.value = true currentTableData.value = Object.assign({}, row) carousalDialogVisible.value = true } -const showClick = async (res: CarousalResult): Promise => { +const handleShow = async (res: CarousalResult): Promise => { if (res.status === 'active') { await inactiveCarousal(res.id) } else { @@ -53,7 +53,7 @@ const showClick = async (res: CarousalResult): Promise => { } await fetchData() } -const delClick = async (row: CarousalResult): Promise => { +const handleDelete = async (row: CarousalResult): Promise => { await deleteCarousal(row.id) await fetchData() } @@ -62,7 +62,6 @@ const handleCreateCarousal = (): void => { carousalDialogVisible.value = true currentTableData.value = {} } - const handleSuccessDialog = async (): Promise => { await fetchData() carousalDialogVisible.value = false @@ -109,11 +108,11 @@ const handleSuccessDialog = async (): Promise => { () -const form = ref(null) -const header = computed(() => `${props.category ? '编辑' : '创建'}${props.headerTitle || ''}`) -const confirmBtn = computed(() => (props.category ? '保存' : '确定')) +const formRef = ref(null) +const headerText = computed(() => `${props.category ? '编辑' : '创建'}${props.headerTitle || ''}`) +const confirmBtnText = computed(() => (props.category ? '保存' : '确定')) const categoryData: FormProps['data'] = reactive({ name: '', order: 1 }) const rules: FormProps['rules'] = { name: [