feat: 优化浏览器环境登录事件
This commit is contained in:
parent
af3547b4b3
commit
bd62afd255
@ -4,7 +4,7 @@
|
||||
<Button v-if="!loginStatus" type="primary" shape="circle" icon="md-person"
|
||||
@click="showLoginModal = true"></Button>
|
||||
<Button v-else type="error" shape="circle" icon="md-log-out" @click="logout"></Button>
|
||||
<SelectFolder :rootPath="rootFolderPath" :nodeDataCallback="appendDataForNode"
|
||||
<SelectFolder ref="selectFolderRef" :rootPath="rootFolderPath" :nodeDataCallback="appendDataForNode"
|
||||
@update:rootPath="changeRootPath" @folder-selected="showFileTree" />
|
||||
</Space>
|
||||
<FolderTree ref="folderTreeRef" :treeData="folderTreeData" :expandLevel="1" :selectedNode="[currentFilePath]"
|
||||
@ -17,7 +17,7 @@
|
||||
import UserLogin from './UI/UserLogin.vue';
|
||||
import SelectFolder from './UI/SelectFolder.vue';
|
||||
import FolderTree from './UI/FolderTree.vue';
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { mkdir, remove, create, exists, rename } from '@tauri-apps/plugin-fs';
|
||||
import { Message } from 'view-ui-plus'
|
||||
|
||||
@ -47,6 +47,14 @@ const logout = () => {
|
||||
loginRef.value.logout();
|
||||
};
|
||||
|
||||
const selectFolderRef = ref(null)
|
||||
watch(loginStatus, (newStatus) => {
|
||||
if (newStatus === true && window.__TAURI_INTERNALS__ === undefined) {
|
||||
// (仅限浏览器环境)如果登录成功,获取当前用户的文件树
|
||||
selectFolderRef.value.exposeTreeData();
|
||||
}
|
||||
})
|
||||
|
||||
const folderTreeRef = ref(null)
|
||||
// <SelectFolder> 返回的文件树数据,增加自定义数据,便于传给 <FolderTree> 进行渲染
|
||||
function appendDataForNode(nodeData) {
|
||||
|
||||
@ -73,7 +73,7 @@ export default {
|
||||
data.articles.forEach((article) => {
|
||||
folderTreeData.nodes.push({
|
||||
"path": folderPath + '/' + article.article_id,
|
||||
"name": article.article_id + '.md',
|
||||
"name": article.article_id + '_' + article.title,
|
||||
"suffix": "md",
|
||||
"directory": false,
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user