feat: Add Error component

This commit is contained in:
kailong321200875
2022-02-19 15:36:18 +08:00
parent 1492f9119a
commit 7411dbc9fd
14 changed files with 16154 additions and 17 deletions

17
src/views/Error/403.vue Normal file
View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
import { Error } from '@/components/Error'
import { usePermissionStore } from '@/store/modules/permission'
import { useRouter } from 'vue-router'
const { push } = useRouter()
const permissionStore = usePermissionStore()
const errorClick = () => {
push(permissionStore.addRouters[0]?.path as string)
}
</script>
<template>
<Error type="403" @errorClick="errorClick" />
</template>

17
src/views/Error/404.vue Normal file
View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
import { Error } from '@/components/Error'
import { usePermissionStore } from '@/store/modules/permission'
import { useRouter } from 'vue-router'
const { push } = useRouter()
const permissionStore = usePermissionStore()
const errorClick = () => {
push(permissionStore.addRouters[0]?.path as string)
}
</script>
<template>
<Error @errorClick="errorClick" />
</template>

17
src/views/Error/500.vue Normal file
View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
import { Error } from '@/components/Error'
import { usePermissionStore } from '@/store/modules/permission'
import { useRouter } from 'vue-router'
const { push } = useRouter()
const permissionStore = usePermissionStore()
const errorClick = () => {
push(permissionStore.addRouters[0]?.path as string)
}
</script>
<template>
<Error type="500" @errorClick="errorClick" />
</template>

View File

@@ -186,7 +186,7 @@ const save = async () => {
</ContentWrap>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<Write v-if="actionType === 'edit'" ref="writeRef" :current-row="tableObject.currentRow" />
<Write v-if="actionType !== 'detail'" ref="writeRef" :current-row="tableObject.currentRow" />
<Detail v-if="actionType === 'detail'" :current-row="tableObject.currentRow" />

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import { Form } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm'
import { PropType, reactive } from 'vue'
import { PropType, reactive, watch } from 'vue'
import { TableData } from '@/api/table/types'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
@@ -113,17 +113,25 @@ const { register, methods, elFormRef } = useForm({
schema
})
if (props.currentRow) {
const { setValues, setSchema } = methods
setValues(props.currentRow)
setSchema([
{
field: 'content',
path: 'componentProps.defaultHtml',
value: props.currentRow.content
}
])
}
watch(
() => props.currentRow,
(currentRow) => {
if (!currentRow) return
const { setValues, setSchema } = methods
setValues(currentRow)
setSchema([
{
field: 'content',
path: 'componentProps.defaultHtml',
value: currentRow.content
}
])
},
{
deep: true,
immediate: true
}
)
defineExpose({
elFormRef,