Skip to content

Commit

Permalink
fix gui issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lindongchen committed Jul 19, 2024
1 parent a4bf663 commit 3c5c5bf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions gui/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VITE_APP_MODE=base
VITE_APP_API_PORT=7777
3 changes: 2 additions & 1 deletion gui/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
NODE_ENV=development
VITE_APP_MODE=base
VITE_APP_MODE=base
VITE_APP_API_PORT=7777
18 changes: 13 additions & 5 deletions gui/src/service/ShellService.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,27 @@ export default class ShellService {
const pm = platform();
if(pm != "android"){

// const args = [
// "run",
// "agent",
// `--listen`,
// `${port}`,
// `--data`,
// `${resourceDirPath}/ztm.db`,
// "--pipy-options",
// `--log-file=${resourceDirPath}/ztm.log`,
// ];
const args = [
"run",
"agent",
"--pipy",
"repo://ztm/agent",
"--args",
`--listen`,
`${port}`,
`--data`,
`${resourceDirPath}/ztm.db`,
"--pipy-options",
`--log-file=${resourceDirPath}/ztm.log`,
];

await this.pausePipy(port);
console.log(`[starting pipy:${args}]`);
const command = Command.sidecar("bin/cli", args);
Expand Down Expand Up @@ -151,8 +161,6 @@ export default class ShellService {
command.execute();
const command2 = Command.create("kill", [`${pid*1+1}`]);
command2.execute();
const command3 = Command.create("kill", [`${pid*1+12}`]);
command3.execute();
}
store.commit('account/setPid', null);
console.log('[paused pipy]');
Expand Down
4 changes: 2 additions & 2 deletions gui/src/service/common/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Cookie from './cookie'
import toast from "@/utils/toast";

const xsrfHeaderName = "Authorization";
const DEFAULT_VITE_APP_API_PORT = import.meta.env.VITE_APP_API_PORT;

const AUTH_TYPE = {
BEARER: "Bearer",
Expand Down Expand Up @@ -37,10 +38,9 @@ function getUrl(url){
return `http://127.0.0.1:${getPort()}${path}${url}`
}
}
const defaultPort = 7777;
const getPort = () => {
const VITE_APP_API_PORT = localStorage.getItem("VITE_APP_API_PORT") || (!!location?.port && location.port>=2000?location.port:null);
return VITE_APP_API_PORT || defaultPort;
return VITE_APP_API_PORT || DEFAULT_VITE_APP_API_PORT || 7777;
}
const setPort = (port) => {
localStorage.setItem("VITE_APP_API_PORT",port);
Expand Down

0 comments on commit 3c5c5bf

Please sign in to comment.