diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 84c19ad..627a085 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -192,8 +192,6 @@ fn start_agent(app: tauri::AppHandle) -> u32 { } }; //reload app - let result = app.emit_all("reload", ()); - log::info!("reload result: {:?}", result); child } #[tauri::command] @@ -339,38 +337,6 @@ fn main() -> std::io::Result<()> { std::fs::write(format!("{}/port.txt", work_dir), "8090")?; std::fs::write(format!("{}/wsport.txt", work_dir), "8092")?; - //迁移数据 - #[cfg(target_os = "windows")] - if Path::new("data").exists() { - if Path::new("data/settings.db").exists() { - std::fs::copy( - "data/settings.db", - format!("{}/{}", work_dir, "data/settings.db"), - )?; - std::fs::rename("data/settings.db", "data/settings.db.bak")?; - } - if Path::new("data/tiktok.db").exists() { - std::fs::copy( - "data/tiktok.db", - format!("{}/{}", work_dir, "data/tiktok.db"), - )?; - std::fs::rename("data/tiktok.db", "data/tiktok.db.bak")?; - } - if Path::new("data/tiktok.db-shm").exists() { - std::fs::copy( - "data/tiktok.db-shm", - format!("{}/{}", work_dir, "data/tiktok.db-shm"), - )?; - std::fs::rename("data/tiktok.db-shm", "data/tiktok.db-shm.bak")?; - } - if Path::new("data/tiktok.db-wal").exists() { - std::fs::copy( - "data/tiktok.db-wal", - format!("{}/{}", work_dir, "data/tiktok.db-wal"), - )?; - std::fs::rename("data/tiktok.db-wal", "data/tiktok.db-wal.bak")?; - } - } stop_agent(); start_agent(app.app_handle()); Ok(()) diff --git a/src/App.vue b/src/App.vue index ea97460..8a55ff2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -388,12 +388,7 @@ export default { this.$emitter.on('updateService', () => { this.check_update() }); - listen("reload", async () => { - if (this.is_updating) { - return; - } - window.location.reload(); - }); + } } diff --git a/src/main.js b/src/main.js index ef37844..c767d21 100644 --- a/src/main.js +++ b/src/main.js @@ -22,8 +22,10 @@ import mitt from 'mitt' import VueDragSelect from "@coleqiu/vue-drag-select"; import VueDraggableResizable from 'vue-draggable-resizable' import { readTextFile, BaseDirectory } from '@tauri-apps/api/fs' + const port = await readTextFile('port.txt', { dir: BaseDirectory.AppData }); const wsPort = await readTextFile('wsport.txt', { dir: BaseDirectory.AppData }); + const emitter = mitt() let devices = reactive({ list: [] }) async function getDevices() { @@ -39,13 +41,25 @@ async function getDevices() { } getDevices() //get devices on page load setInterval(getDevices, 10000) -localStorage.setItem('port', port); -localStorage.setItem('wsPort', wsPort); + let config = { - wsUrl: 'ws://127.0.0.1:' + wsPort, - apiUrl: 'http://127.0.0.1:' + port + wsUrl: '', + apiUrl: '' } +async function updatePorts() { + const port = await readTextFile('port.txt', { dir: BaseDirectory.AppData }); + const wsPort = await readTextFile('wsport.txt', { dir: BaseDirectory.AppData }); + localStorage.setItem('port', port); + localStorage.setItem('wsPort', wsPort); + console.log(port, wsPort) + config.wsUrl = 'ws://127.0.0.1:' + wsPort; + config.apiUrl = 'http://127.0.0.1:' + port; +} + +updatePorts(); // update ports on page load +setInterval(updatePorts, 3000); // update ports every 3 seconds + const app = createApp(App) app.use(VueAxios, axios) app.use(i18n)