fix local folder resource lifecycle
This commit is contained in:
@@ -21,6 +21,7 @@ pub struct DocumentPaneViewModel {
|
||||
pub has_page_subtree: bool,
|
||||
pub primary_legacy_ids: bool,
|
||||
pub visible: bool,
|
||||
pub hide_title_header: bool,
|
||||
}
|
||||
|
||||
#[component]
|
||||
@@ -76,7 +77,11 @@ fn DocumentPane(model: DocumentPaneViewModel) -> impl IntoView {
|
||||
data-page-font={model.page_font.clone()}
|
||||
data-page-show-heading-numbers={model.page_show_heading_numbers.to_string()}
|
||||
>
|
||||
<header class="document-shell-header">
|
||||
<header
|
||||
class="document-shell-header"
|
||||
data-page-title-hidden={model.hide_title_header.to_string()}
|
||||
hidden={model.hide_title_header}
|
||||
>
|
||||
<div class="document-page-icon" aria-hidden="true">
|
||||
<span class="material-symbols-outlined material-symbols-filled mnote-material-page-icon" data-icon="home"></span>
|
||||
</div>
|
||||
@@ -177,6 +182,12 @@ pub fn DocumentPage(
|
||||
/// 右侧页面选项 JSON(可选)
|
||||
#[prop(optional)]
|
||||
secondary_page_options_json: String,
|
||||
/// 是否隐藏主文档页头标题
|
||||
#[prop(optional)]
|
||||
primary_hide_title_header: bool,
|
||||
/// 是否隐藏右侧文档页头标题
|
||||
#[prop(optional)]
|
||||
secondary_hide_title_header: bool,
|
||||
/// 是否显示管理员授权入口
|
||||
#[prop(optional)]
|
||||
show_admin_access_policy: bool,
|
||||
@@ -260,6 +271,7 @@ pub fn DocumentPage(
|
||||
has_page_subtree,
|
||||
primary_legacy_ids: true,
|
||||
visible: true,
|
||||
hide_title_header: primary_hide_title_header,
|
||||
};
|
||||
let secondary_model = DocumentPaneViewModel {
|
||||
pane_role: "secondary",
|
||||
@@ -278,6 +290,7 @@ pub fn DocumentPage(
|
||||
has_page_subtree: secondary_has_page_subtree,
|
||||
primary_legacy_ids: false,
|
||||
visible: secondary_visible,
|
||||
hide_title_header: secondary_hide_title_header,
|
||||
};
|
||||
view! {
|
||||
<PageLayout current_nav="documents" sidebar_tree_html={sidebar_tree_html.unwrap_or_default()} workspace_name={workspace_name.unwrap_or_default()} workspace_sidebar_html={workspace_sidebar_html.unwrap_or_default()} topbar_title={title.clone()} show_admin_access_policy={show_admin_access_policy} enable_tree_live={enable_tree_live}>
|
||||
|
||||
@@ -61,7 +61,54 @@ pub fn HomePage(
|
||||
</main>
|
||||
}.into_any()
|
||||
} else {
|
||||
view! {}.into_any()
|
||||
view! {
|
||||
<main
|
||||
class="document-workspace mnote-workspace-empty-editor-host"
|
||||
data-testid="mnote-document-workspace"
|
||||
data-has-secondary-pane="false"
|
||||
data-workspace-id={workspace_id.clone().unwrap_or_default()}
|
||||
>
|
||||
<section class="document-main-editor-group" data-testid="mnote-main-editor-tab-host" data-pane-role="primary">
|
||||
<div class="mnote-main-tab-strip" data-mnote-main-tab-strip="true" data-pane-role="primary" role="tablist" aria-label="主编辑区标签页">
|
||||
<button
|
||||
type="button"
|
||||
class="mnote-main-tab is-active"
|
||||
data-mnote-main-tab="page"
|
||||
data-mnote-tab-kind="page"
|
||||
data-pane-role="primary"
|
||||
data-workspace-id={workspace_id.clone().unwrap_or_default()}
|
||||
role="tab"
|
||||
aria-selected="true"
|
||||
tabindex="0"
|
||||
>
|
||||
<span class="mnote-main-tab-badge" aria-hidden="true"></span>
|
||||
<span class="mnote-main-tab-title">"文件夹"</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mnote-main-tab-panels">
|
||||
<div data-mnote-page-tab-panel="true" data-pane-role="primary">
|
||||
<section
|
||||
class="document-pane mnote-workspace-empty-pane"
|
||||
data-document-pane="true"
|
||||
data-pane-role="primary"
|
||||
data-pane-workspace-id={workspace_id.clone().unwrap_or_default()}
|
||||
data-pane-visible="true"
|
||||
aria-label="主文档"
|
||||
></section>
|
||||
</div>
|
||||
<section
|
||||
class="mnote-resource-tab-host"
|
||||
data-mnote-resource-tab-host="true"
|
||||
data-pane-role="primary"
|
||||
data-testid="mnote-resource-tab-host"
|
||||
hidden=true
|
||||
>
|
||||
<div class="mnote-resource-tab-panel-root" data-mnote-resource-tab-panel-root="true" data-pane-role="primary"></div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
}.into_any()
|
||||
}}
|
||||
</PageLayout>
|
||||
}
|
||||
|
||||
@@ -3138,8 +3138,7 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
}
|
||||
|
||||
function shouldOpenLocalResourceInNewWindow(fileName) {
|
||||
var ext = attachmentExtensionFromFileName(fileName);
|
||||
return ext === 'pdf';
|
||||
return false;
|
||||
}
|
||||
|
||||
function isLocalUploadedAsset(asset) {
|
||||
@@ -10923,9 +10922,9 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_runtime_opens_local_pdf_assets_in_browser_tab_by_default() {
|
||||
fn sidebar_runtime_opens_local_pdf_assets_in_active_resource_tab_by_default() {
|
||||
assert!(SIDEBAR_TREE_JS.contains("function shouldOpenLocalResourceInNewWindow(fileName)"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("return ext === 'pdf';"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("return false;"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("var shouldOpenInNewWindow = forceNewWindow || shouldOpenLocalResourceInNewWindow(localFileName);"));
|
||||
assert!(SIDEBAR_TREE_JS
|
||||
.contains("if (!shouldOpenInNewWindow && await openLocalResourceInActiveTab({"));
|
||||
|
||||
Reference in New Issue
Block a user