检查索引的http请求改为websocket
This commit is contained in:
parent
e4827b4fe6
commit
5a1dba7a8f
|
@ -117,7 +117,7 @@ export default defineComponent({
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventBus.getInstance().on(EventNamesDefine.CheckDebug, () => {
|
EventBus.getInstance().on(EventNamesDefine.CheckDebug2, () => {
|
||||||
const to_normal_url = () => {
|
const to_normal_url = () => {
|
||||||
const p1 = window.location.href.indexOf("?debug");
|
const p1 = window.location.href.indexOf("?debug");
|
||||||
const p2 = window.location.href.indexOf("#");
|
const p2 = window.location.href.indexOf("#");
|
||||||
|
|
|
@ -1519,6 +1519,15 @@ export default class ClientConnection {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public async CheckModeIndex(mode_index:number) {
|
||||||
|
try {
|
||||||
|
return await this.doRpc<Protocol.RpcCheckModeIndexResponseEntity>(
|
||||||
|
new Protocol.RpcCheckModeIndexRequestEntity(mode_index)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NotifyMessage {
|
export interface NotifyMessage {
|
||||||
|
|
|
@ -457,13 +457,17 @@ export default defineComponent({
|
||||||
resolve($t.t("Please type 0~65535"));
|
resolve($t.t("Please type 0~65535"));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
let url = GlobalData.getInstance().createCurrentRequestUrl();
|
// let url = GlobalData.getInstance().createCurrentRequestUrl();
|
||||||
if (!url) {
|
// if (!url) {
|
||||||
url = new URL(window.location.hostname);
|
// url = new URL(window.location.hostname);
|
||||||
}
|
// }
|
||||||
url.pathname = HttpProtocol.RequestCheckModeIndex;
|
// url.pathname = HttpProtocol.RequestCheckModeIndex;
|
||||||
url.searchParams.append("index", index.value.toString());
|
// url.searchParams.append("index", index.value.toString());
|
||||||
let response = (await api.get(url.toString())).data as boolean;
|
// let response = (await api.get(url.toString())).data as boolean;
|
||||||
|
// console.log(url)
|
||||||
|
let response= (await GlobalData.getInstance().getCurrentClient()?.CheckModeIndex(index.value))?.success as boolean;
|
||||||
|
// let response:boolean;
|
||||||
|
// console.log(res)
|
||||||
if (typeof response != "boolean") {
|
if (typeof response != "boolean") {
|
||||||
try {
|
try {
|
||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
|
|
|
@ -534,6 +534,9 @@ export namespace Protocol {
|
||||||
public static get kRpcFileManagerCreateDirectory() {
|
public static get kRpcFileManagerCreateDirectory() {
|
||||||
return Commands.PROTOCOL_PREFIX + "RpcFileManagerCreateDirectory";
|
return Commands.PROTOCOL_PREFIX + "RpcFileManagerCreateDirectory";
|
||||||
}
|
}
|
||||||
|
public static get kRpcCheckModeIndex() {
|
||||||
|
return Commands.PROTOCOL_PREFIX + "RpcCheckModeIndex";
|
||||||
|
}
|
||||||
static _all_commands = new Set([
|
static _all_commands = new Set([
|
||||||
Commands.kUnKnowCommand,
|
Commands.kUnKnowCommand,
|
||||||
Commands.kSearchDevice,
|
Commands.kSearchDevice,
|
||||||
|
@ -668,6 +671,7 @@ export namespace Protocol {
|
||||||
Commands.kRpcFileManagerRename,
|
Commands.kRpcFileManagerRename,
|
||||||
Commands.kRpcFileManagerDelete,
|
Commands.kRpcFileManagerDelete,
|
||||||
Commands.kRpcFileManagerCreateDirectory,
|
Commands.kRpcFileManagerCreateDirectory,
|
||||||
|
Commands.kRpcCheckModeIndex,
|
||||||
]);
|
]);
|
||||||
public static get AllCommands() {
|
public static get AllCommands() {
|
||||||
return this._all_commands;
|
return this._all_commands;
|
||||||
|
@ -3541,4 +3545,21 @@ export namespace Protocol {
|
||||||
error_message=""
|
error_message=""
|
||||||
error_code=0;
|
error_code=0;
|
||||||
}
|
}
|
||||||
|
export class RpcCheckModeIndexRequestEntity extends PacketEntity{
|
||||||
|
constructor(mode_index:number,rpc_id = 0) {
|
||||||
|
super();
|
||||||
|
super.command = Commands.kRpcCheckModeIndex;
|
||||||
|
super.flag = PacketEntity.FLAG_REQUEST;
|
||||||
|
this.mode_index=mode_index
|
||||||
|
}
|
||||||
|
mode_index = 0;
|
||||||
|
}
|
||||||
|
export class RpcCheckModeIndexResponseEntity extends PacketEntity{
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
super.flag = PacketEntity.FLAG_RESPONSE;
|
||||||
|
}
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue