Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

充分利用路径别名 #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/target
.vscode
# .vscode
.idea
/packages
**/.DS_Store
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"slint.libraryPaths": {
"ui": "ui\\",
"sui": "ui\\modules\\surrealism-ui\\",
"views": "ui\\views\\"
}
}
9 changes: 8 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
fn main() {
slint_build::compile("ui/app.slint").unwrap();
let manifest_dir = std::path::PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap());
let library_paths = std::collections::HashMap::from([
("ui".into(), manifest_dir.join("ui")),
("views".into(), manifest_dir.join("ui/views")),
("sui".into(), manifest_dir.join("ui/modules/surrealism-ui")),
]);
let config = slint_build::CompilerConfiguration::new().with_library_paths(library_paths);
slint_build::compile_with_config("ui/app.slint", config).unwrap();
}
14 changes: 7 additions & 7 deletions ui/app.slint
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {MainView} from "./index.slint";
import {ROOT_GLOBAL} from "./global.slint";
import { MainView } from "@views/main.slint";
import { ROOT_GLOBAL } from "@ui/global.slint";

export component App inherits Window {
height: ROOT-GLOBAL.window-height;
width: ROOT-GLOBAL.window-width;
title: @tr("Slint + SurrealismUI + Rust");
MainView {}
}
height: ROOT-GLOBAL.window-height;
width: ROOT-GLOBAL.window-width;
title: @tr("Slint + SurrealismUI + Rust");
MainView { }
}
10 changes: 5 additions & 5 deletions ui/global.slint
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! global styles
export global ROOT_GLOBAL {
in-out property <length> window-height : 600px;
in-out property <length> window-width : 800px;
in-out property <length> font-size : 16px;
in-out property <length> padding : 0px;
}
in-out property <length> window-height: 600px;
in-out property <length> window-width: 800px;
in-out property <length> font-size: 16px;
in-out property <length> padding: 0px;
}
2 changes: 0 additions & 2 deletions ui/index.slint

This file was deleted.

6 changes: 0 additions & 6 deletions ui/views/index.slint

This file was deleted.

27 changes: 14 additions & 13 deletions ui/views/main.slint
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import {Hello} from "../components/index.slint";
import { SButton } from "../modules/surrealism-ui/index.slint";
import { Hello } from "@ui/components/index.slint";
import { SButton } from "@sui/index.slint";

export component MainView {
height: 100%;
width: 100%;
VerticalLayout {
Hello{}
Rectangle {
SButton {
theme:Dark;
text: "Click Me!";
}
height: 100%;
width: 100%;
VerticalLayout {
Hello { }

Rectangle {
SButton {
theme: Dark;
text: "Click Me!";
}
}
}
}
}
}