desktop/src/App.tsx

51 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-03-18 13:46:46 +08:00
import { createEffect, createSignal } from "solid-js";
import { invoke } from "@tauri-apps/api/tauri";
import "./App.css";
2023-03-18 16:41:15 +08:00
import { DisplayInfo } from './models/display-info.model';
import { DisplayInfoPanel } from './components/display-info-panel';
import { ScreenView } from './components/screen-view';
2023-03-18 13:46:46 +08:00
function App() {
const [screenshots, setScreenshots] = createSignal<string[]>([]);
const [displays, setDisplays] = createSignal<DisplayInfo[]>([]);
createEffect(() => {
2023-03-18 16:41:15 +08:00
invoke<string>('list_display_info').then((displays) => {
2023-03-18 13:46:46 +08:00
setDisplays(JSON.parse(displays));
});
});
// createEffect(() => {
// take_all_display_screenshot();
// }, [displays]);
2023-03-18 13:46:46 +08:00
async function take_all_display_screenshot() {
2023-03-18 16:41:15 +08:00
console.log('take_all_display_screenshot');
2023-03-18 13:46:46 +08:00
displays().forEach((display) => {
2023-03-18 16:41:15 +08:00
invoke<string>('take_screenshot', {
displayId: display.id,
scaleFactor: display.scale_factor,
}).then((image) => {
2023-03-18 13:46:46 +08:00
setScreenshots((screenshots) => [...screenshots, image]);
});
});
}
return (
<div class="container">
<ol>
2023-03-18 16:41:15 +08:00
{displays().map((display) => {
return (
<li>
<DisplayInfoPanel display={display} />
<ScreenView displayId={display.id} />
2023-03-18 16:41:15 +08:00
</li>
);
})}
2023-03-18 13:46:46 +08:00
</ol>
</div>
);
}
export default App;