mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-29 12:06:01 +02:00
41 lines
970 B
HTML
41 lines
970 B
HTML
<html>
|
|
<body>
|
|
<div>Plugin example</div>
|
|
<pre id="args"></pre>
|
|
<script type="module">
|
|
var argsEl = document.getElementById("args");
|
|
|
|
function cliProtocolVal({
|
|
args: {
|
|
color: { value },
|
|
},
|
|
}) {
|
|
argsEl.innerHTML = value;
|
|
document.body.style.backgroundColor = value;
|
|
}
|
|
function cliProtocolErr(err) {
|
|
argsEl.innerHTML = JSON.stringify(err);
|
|
}
|
|
|
|
window.__TAURI__.cli
|
|
.getMatches()
|
|
.then(cliProtocolVal)
|
|
.catch(cliProtocolErr);
|
|
|
|
await window.__TAURI__.event.listen(
|
|
"single-instance",
|
|
({ event, ...eventObj }) => {
|
|
console.log(event, eventObj);
|
|
let args = eventObj.payload?.args;
|
|
|
|
if (args?.length > 1) {
|
|
let color = args[1];
|
|
argsEl.innerHTML = color;
|
|
document.body.style.backgroundColor = color;
|
|
}
|
|
}
|
|
);
|
|
</script>
|
|
</body>
|
|
</html>
|