Skip to content

Commit aaf13a4

Browse files
committed
update
1 parent c7e559f commit aaf13a4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src-tauri/src/utils/init.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ use tauri_plugin_store::StoreExt;
66
pub async fn resolve_setup(app: &mut App) -> Result<(), Error> {
77
let args: Vec<String> = std::env::args().collect();
88
println!("Application started with arguments: {:?}", args);
9+
// 将参数转成查询参数格式
10+
let query_params = args
11+
.iter()
12+
.map(|arg| arg.split('=').collect::<Vec<&str>>())
13+
.collect::<Vec<Vec<&str>>>();
14+
println!("query_params: {:?}", query_params);
915
let app_handle = app.handle();
1016
// 示例 JSON 字符串
1117
let window_json = r#"
1218
{
1319
"title": "PakePlus",
1420
"visible": false,
15-
"url": "index.html?name=Tom&age=18",
21+
"url": "index.html?-name=Tom&--age=18",
1622
"label": "main"
1723
}
1824
"#;

src/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
}
1818
// { name: "Tom", age: "18" } (例如 ?name=Tom&age=18)
1919
console.log('queryParams', queryParams)
20+
// 将 queryParams 转换为 JSON 字符串
21+
const queryParamsJson = JSON.stringify(queryParams)
22+
console.log('queryParamsJson', queryParamsJson)
23+
// 将queryParamsJson 写入到root元素中显示
24+
window.addEventListener('DOMContentLoaded', () => {
25+
const root = document.getElementById('root')
26+
root.innerHTML = queryParamsJson
27+
})
2028
</script>
2129
</head>
2230
<body>

0 commit comments

Comments
 (0)