pref: router scroll behavior

This commit is contained in:
KUN1007 2023-09-07 21:37:40 +08:00
parent 3522321a00
commit 96f41e2ef2
4 changed files with 13 additions and 28 deletions

View file

@ -62,7 +62,7 @@ const handleRefreshPage = () => location.reload()
<div class="editor-advance"> <div class="editor-advance">
<div class="editor-advance-title"> <div class="editor-advance-title">
<Transition mode="out-in" name="slide-up"> <Transition mode="out-in" name="slide-up">
<span v-if="!isRefreshPage"> 编辑器模式 </span> <span v-if="!isRefreshPage"> 编辑器配置 </span>
<span <span
@click="handleRefreshPage" @click="handleRefreshPage"
class="refresh" class="refresh"

View file

@ -1,12 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { import { defineAsyncComponent, computed, ref, onBeforeMount } from 'vue'
defineAsyncComponent,
computed,
ref,
onBeforeMount,
onBeforeUnmount,
onMounted,
} from 'vue'
import { QuillEditor } from '@vueup/vue-quill' import { QuillEditor } from '@vueup/vue-quill'
// quill // quill
@ -51,7 +44,7 @@ const props = defineProps<{
}>() }>()
// //
const editorRef = ref() const editorRef = ref<typeof QuillEditor>()
// //
const editorHeightStyle = computed( const editorHeightStyle = computed(
@ -75,18 +68,6 @@ const editorOptions = {
// //
const onEditorReady = () => {} const onEditorReady = () => {}
//
const toolbarOptions = {
container: [
['bold', 'italic', 'underline', 'strike'],
['markdown'], // Add this.
],
handlers: {
// Add this.
markdown: function () {},
},
}
// //
onBeforeMount(() => { onBeforeMount(() => {
if (isSave.value) { if (isSave.value) {
@ -97,18 +78,18 @@ onBeforeMount(() => {
}) })
// //
const handleTextChange = () => { const handleTextChange = async () => {
// //
const debouncedUpdateContent = debounce(() => { const debouncedUpdateContent = debounce(() => {
// xss // xss
content.value = DOMPurify.sanitize(editorRef.value.getHTML()) content.value = DOMPurify.sanitize(editorRef.value?.getHTML())
}, 1007) }, 1007)
// //
debouncedUpdateContent() debouncedUpdateContent()
// //
const length = computed(() => editorRef.value.getText().trim().length) const length = computed(() => editorRef.value?.getText().trim().length)
textCount.value = length.value textCount.value = length.value
} }
</script> </script>

View file

@ -5,6 +5,13 @@ import { asyncRoutes } from './router'
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes: [...constantRoutes, ...asyncRoutes] as RouteRecordRaw[], routes: [...constantRoutes, ...asyncRoutes] as RouteRecordRaw[],
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { top: 0, behavior: 'smooth' }
}
},
}) })
export function resetRouter() { export function resetRouter() {

View file

@ -94,9 +94,6 @@ watch(
/* /*
以便能够正确地计算移动的动画 */ 以便能够正确地计算移动的动画 */
.list-leave-active { .list-leave-active {
/**
这里为 2 + 5 + 60 + 5 + 2 = 74px */
width: calc(100% - 74px);
position: absolute; position: absolute;
} }
</style> </style>