perf: 优化分享文件展示

This commit is contained in:
jmal 2023-06-08 16:29:10 +08:00
parent 20fd311ffb
commit 2128b2ab97
4 changed files with 45 additions and 16 deletions

View File

@ -255,16 +255,21 @@ export default {
const payload = $J.jsonParse(event.data) const payload = $J.jsonParse(event.data)
switch (payload.event) { switch (payload.event) {
case "init": case "init":
console.log('init')
this.ready = true this.ready = true
this.$emit('onReady') this.$emit('onReady')
this.updateContent() this.updateContent()
let helpMenu = doc.querySelector('.geMenubarContainer .geMenubar').childNodes[5] let menuBar = doc.querySelector('.geMenubarContainer .geMenubar')
doc.addEventListener('click', this.$refs.historyPopover.onGlobalClick) if (menuBar) {
helpMenu.style.display = 'none' let helpMenu = menuBar.childNodes[5]
let elementTheme = doc.querySelector('.geToolbarContainer').querySelector('[title="主题"][class="geButton geAdaptiveAsset"]'); doc.addEventListener('click', this.$refs.historyPopover.onGlobalClick)
if (elementTheme) { helpMenu.style.display = 'none'
elementTheme.addEventListener('click', this.onSwitchTheme) }
let toolbar = doc.querySelector('.geToolbarContainer')
if (toolbar) {
let elementTheme = toolbar.querySelector('[title="主题"][class="geButton geAdaptiveAsset"]');
if (elementTheme) {
elementTheme.addEventListener('click', this.onSwitchTheme)
}
} }
break break
case "load": case "load":

View File

@ -86,6 +86,7 @@
<div class="content-tree"> <div class="content-tree">
<fancy-tree <fancy-tree
ref="fancTree" ref="fancTree"
v-if="!this.shareId"
:editableTabs="editableTabs" :editableTabs="editableTabs"
:editableTabsValue.sync="editableTabsValue" :editableTabsValue.sync="editableTabsValue"
:contentsWidth="contentsWidth" :contentsWidth="contentsWidth"
@ -353,8 +354,10 @@
this.requestStream(request, params, 0) this.requestStream(request, params, 0)
this.editableTabsValue = pathname this.editableTabsValue = pathname
// 加载历史版本 if (!this.shareId) {
this.$refs.historyPopover.loadHistoryPathList(pathname) // 加载历史版本
this.$refs.historyPopover.loadHistoryPathList(pathname)
}
// 界面的渲染后的初始化工作 // 界面的渲染后的初始化工作
this.$nextTick(() => { this.$nextTick(() => {
this.onDialogDblClick() this.onDialogDblClick()
@ -375,7 +378,7 @@
if(value.endsWith('.md')){ if(value.endsWith('.md')){
this.previewMode = false this.previewMode = false
} }
this.hasHistoryVersion = this.editableVersionMap.get(value) this.hasHistoryVersion = this.editableVersionMap.get(value) || false
if (this.hasHistoryVersion) { if (this.hasHistoryVersion) {
let currentIndex = this.editableTabs.findIndex(editable => editable.name === value) let currentIndex = this.editableTabs.findIndex(editable => editable.name === value)
const tab = this.editableTabs[currentIndex] const tab = this.editableTabs[currentIndex]
@ -479,7 +482,14 @@
url = "/api/public/s/preview/text/stream" url = "/api/public/s/preview/text/stream"
} }
const abortController = new AbortController(); const abortController = new AbortController();
const response = await fetch(`${url}?${queryString}`, { signal: abortController.signal }) let headers = new Headers();
if (this.shareId) {
headers.append('share-token', this.$store.state.user.shareToken);
} else {
headers.append('jmal-token', this.$store.state.user.token);
headers.append('name', this.$store.state.user.name);
}
const response = await fetch(`${url}?${queryString}`, { signal: abortController.signal , headers: headers})
let result = ""; let result = "";
// 创建一个节流函数,限制更新频率为每 1500 毫秒一次 // 创建一个节流函数,限制更新频率为每 1500 毫秒一次
const throttledUpdateContent = _.throttle(text => { const throttledUpdateContent = _.throttle(text => {
@ -728,7 +738,6 @@
} }
} }
this.editableTabsValue = row.path this.editableTabsValue = row.path
// 加载历史版本 // 加载历史版本
this.$refs.historyPopover.loadHistoryPathList(row.path) this.$refs.historyPopover.loadHistoryPathList(row.path)
}).catch(() => { }).catch(() => {

View File

@ -1178,8 +1178,12 @@ export default {
} }
.share-code { .share-code {
> > > .el-input { text-align: center;
>>>.el-input {
width: 200px; width: 200px;
.el-input__inner {
text-align: center;
}
::placeholder { ::placeholder {
text-align: center; text-align: center;
} }

View File

@ -138,7 +138,7 @@
header-align="left" header-align="left"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.expireDate?scope.row.expireDate:'永久有效'}}</span> <span>{{expireInfo(scope.row)}}</span>
</template> </template>
</pl-table-column> </pl-table-column>
</template> </template>
@ -265,9 +265,20 @@
shareDialogObject: {}, shareDialogObject: {},
} }
}, },
mounted() {
},
methods: { methods: {
expireInfo(row) {
if (row.expireDate) {
let currentTime = new Date();
let targetTime = new Date(row.expireDate);
if (currentTime > targetTime) {
return '已过期'
} else {
return row.expireDate
}
} else {
return '永久有效'
}
},
// 请求之前的准备 // 请求之前的准备
beforeLoadData(onLoad){ beforeLoadData(onLoad){
if (onLoad) { if (onLoad) {