mirror of
https://github.com/blossom-editor/blossom
synced 2024-11-17 22:48:03 +08:00
fix: 切换文章后将滚动条置顶(#67)
This commit is contained in:
parent
80330b57d5
commit
d59bf97b17
@ -148,7 +148,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// vue
|
// vue
|
||||||
import { ref, computed, provide, onMounted, onBeforeUnmount, onActivated, onDeactivated, defineAsyncComponent, watch } from 'vue'
|
import { ref, computed, provide, onMounted, onBeforeUnmount, onActivated, onDeactivated, defineAsyncComponent, watch, nextTick } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import type { UploadProps, UploadRawFile } from 'element-plus'
|
import type { UploadProps, UploadRawFile } from 'element-plus'
|
||||||
import { useUserStore } from '@renderer/stores/user'
|
import { useUserStore } from '@renderer/stores/user'
|
||||||
@ -430,6 +430,9 @@ const clickCurDoc = async (tree: DocTree) => {
|
|||||||
editorLoading.value = false
|
editorLoading.value = false
|
||||||
articleChanged = false
|
articleChanged = false
|
||||||
})
|
})
|
||||||
|
nextTick(() => {
|
||||||
|
scrollTopReset()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -603,7 +606,6 @@ const setNewState = (md: string): void => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
parse()
|
parse()
|
||||||
// scrollTopReset()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
@ -725,6 +727,12 @@ const scroll = (event: Event | string, source?: string, lineno?: number, colno?:
|
|||||||
scrollWrapper.sycnScroll(event, source, lineno, colno, error)
|
scrollWrapper.sycnScroll(event, source, lineno, colno, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const scrollTopReset = () => {
|
||||||
|
if (scrollWrapper) {
|
||||||
|
scrollWrapper.scrollTopReset()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const scrollTopLast = () => {
|
const scrollTopLast = () => {
|
||||||
if (scrollWrapper) {
|
if (scrollWrapper) {
|
||||||
scrollWrapper.scrollTopLast()
|
scrollWrapper.scrollTopLast()
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
</el-menu>
|
</el-menu>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="article">
|
<div class="article" ref="PreviewRef">
|
||||||
<div class="bl-preview" v-html="article.html"></div>
|
<div class="bl-preview" v-html="article.html"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -125,7 +125,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { ref, onUnmounted } from 'vue'
|
import { ref, onUnmounted, nextTick } from 'vue'
|
||||||
import { ArrowDownBold, ArrowRightBold } from '@element-plus/icons-vue'
|
import { ArrowDownBold, ArrowRightBold } from '@element-plus/icons-vue'
|
||||||
import { articleInfoOpenApi, articleInfoApi, docTreeOpenApi, docTreeApi } from '@/api/blossom'
|
import { articleInfoOpenApi, articleInfoApi, docTreeOpenApi, docTreeApi } from '@/api/blossom'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
@ -149,10 +149,6 @@ useLifecycle(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// onMounted(() => {})
|
|
||||||
|
|
||||||
// onActivated(() => {})
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('resize', onresize)
|
window.removeEventListener('resize', onresize)
|
||||||
})
|
})
|
||||||
@ -191,6 +187,7 @@ const article = ref<DocInfo>({
|
|||||||
})
|
})
|
||||||
const tocList = ref<any>([])
|
const tocList = ref<any>([])
|
||||||
const defaultOpeneds = ref<string[]>([])
|
const defaultOpeneds = ref<string[]>([])
|
||||||
|
const PreviewRef = ref()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文档树状列表
|
* 获取文档树状列表
|
||||||
@ -225,6 +222,9 @@ const clickCurDoc = async (tree: DocTree) => {
|
|||||||
if (tree.ty == 3) {
|
if (tree.ty == 3) {
|
||||||
await getCurEditArticle(tree.i)
|
await getCurEditArticle(tree.i)
|
||||||
window.history.replaceState('', '', '#/articles?articleId=' + tree.i)
|
window.history.replaceState('', '', '#/articles?articleId=' + tree.i)
|
||||||
|
nextTick(() => {
|
||||||
|
PreviewRef.value.scrollTo({ top: 0 })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,37 +679,6 @@ const onresize = () => {
|
|||||||
color: #989898;
|
color: #989898;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 有序列表
|
|
||||||
// :deep(ol) {
|
|
||||||
// padding-left: 20px;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 无序列表
|
|
||||||
// :deep(ul) {
|
|
||||||
// padding-left: 15px;
|
|
||||||
|
|
||||||
// ul {
|
|
||||||
// padding-left: 15px;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// checkbox
|
|
||||||
// :deep(ul:has(input)) {
|
|
||||||
// padding-left: 0px;
|
|
||||||
|
|
||||||
// input {
|
|
||||||
// margin: 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ul {
|
|
||||||
// padding-left: 15px;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// li::marker {
|
|
||||||
// content: none;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* 有序列表 */
|
/* 有序列表 */
|
||||||
:deep(ol) {
|
:deep(ol) {
|
||||||
padding-left: 2em;
|
padding-left: 2em;
|
||||||
|
Loading…
Reference in New Issue
Block a user