Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
niostack committed Sep 25, 2024
1 parent 11ab8e6 commit 244b95c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 44 deletions.
34 changes: 0 additions & 34 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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(())
Expand Down
7 changes: 1 addition & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,7 @@ export default {
this.$emitter.on('updateService', () => {
this.check_update()
});
listen("reload", async () => {
if (this.is_updating) {
return;
}
window.location.reload();
});
}
}
</script>
22 changes: 18 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
Expand Down

0 comments on commit 244b95c

Please sign in to comment.