Commit 70796814 by dliangx

add http plugin

parent bb13dc73
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": ">=2.0.0-rc.0", "@tauri-apps/api": ">=2.0.0-rc.0",
"@tauri-apps/plugin-http": "^2.0.0-rc.2",
"@tauri-apps/plugin-shell": ">=2.0.0-rc.0", "@tauri-apps/plugin-shell": ">=2.0.0-rc.0",
"ol": "^10.1.0", "ol": "^10.1.0",
"react": "^18.2.0", "react": "^18.2.0",
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": ">=2.0.0-rc.0", "@tauri-apps/cli": ">=2.0.0-rc.0",
"@types/ol": "^6.5.3",
"@types/react": "^18.2.15", "@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7", "@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
......
...@@ -19,4 +19,5 @@ tauri = { version = "2.0.0-rc", features = [] } ...@@ -19,4 +19,5 @@ tauri = { version = "2.0.0-rc", features = [] }
tauri-plugin-shell = "2.0.0-rc" tauri-plugin-shell = "2.0.0-rc"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1" serde_json = "1"
tauri-plugin-http = "2.0.0-rc"
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
"description": "Capability for the main window", "description": "Capability for the main window",
"windows": ["main"], "windows": ["main"],
"permissions": [ "permissions": [
"core:default", "http:default",
"core:app:default",
"shell:allow-open" "shell:allow-open"
] ]
} }
...@@ -8,6 +8,7 @@ fn greet(name: &str) -> String { ...@@ -8,6 +8,7 @@ fn greet(name: &str) -> String {
pub fn run() { pub fn run() {
tauri::Builder::default() tauri::Builder::default()
.plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_http::init())
.invoke_handler(tauri::generate_handler![greet]) .invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");
......
import { useEffect } from "react";
import Footer from "../common/Footer"; import Footer from "../common/Footer";
import Land from "../land/Land";
const Home = () => { const Home = () => {
useEffect(()=>{
},[])
return ( return (
<> <>
<Land></Land>
<Footer></Footer> <Footer></Footer>
</> </>
); );
......
.ol-attribution {
display: none;
}
\ No newline at end of file
import { useEffect, useRef } from "react";
import Footer from "../common/Footer"; import Footer from "../common/Footer";
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import 'ol/ol.css';
import './Land.css'
const Land = ()=>{ const Land = ()=>{
return(<> const mapRef = useRef(null);
useEffect(() => {
if (mapRef.current) {
const map = new Map({
target: mapRef.current,
layers: [
new TileLayer({
source: new OSM(),
}),
],
view: new View({
center: [0, 0],
zoom: 2,
}),
});
return () => {
map.setTarget();
};
}
}, []);
return(<>
<div ref={mapRef} className=" bottom-14 h-3/5 w-full absolute"></div>
<Footer></Footer> <Footer></Footer>
</>) </>)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment