$app.toggleCustomEndpoint(); 1

This commit is contained in:
Natsumi
2022-03-29 03:28:16 +13:00
parent 8885771789
commit fbfa3ad199
2 changed files with 18 additions and 4 deletions

View File

@@ -363,7 +363,9 @@ speechSynthesis.getVoices();
API.pendingGetRequests = new Map(); API.pendingGetRequests = new Map();
API.failedGetRequests = new Map(); API.failedGetRequests = new Map();
API.endpointDomainVrchat = 'https://api.vrchat.cloud/api/1'; API.endpointDomainVrchat = 'https://api.vrchat.cloud/api/1';
API.websocketDomainVrchat = 'wss://pipeline.vrchat.cloud';
API.endpointDomain = 'https://api.vrchat.cloud/api/1'; API.endpointDomain = 'https://api.vrchat.cloud/api/1';
API.websocketDomain = 'wss://pipeline.vrchat.cloud';
API.call = function (endpoint, options) { API.call = function (endpoint, options) {
var init = { var init = {
@@ -3821,9 +3823,7 @@ speechSynthesis.getVoices();
API.connectWebSocket = function (token) { API.connectWebSocket = function (token) {
if (this.webSocket === null) { if (this.webSocket === null) {
var socket = new WebSocket( var socket = new WebSocket(`${API.websocketDomain}/?auth=${token}`);
`wss://pipeline.vrchat.cloud/?auth=${token}`
);
socket.onclose = () => { socket.onclose = () => {
if (this.webSocket === socket) { if (this.webSocket === socket) {
this.webSocket = null; this.webSocket = null;
@@ -5993,8 +5993,10 @@ speechSynthesis.getVoices();
} }
if (loginParmas.endpoint) { if (loginParmas.endpoint) {
API.endpointDomain = loginParmas.endpoint; API.endpointDomain = loginParmas.endpoint;
API.websocketDomain = loginParmas.websocket;
} else { } else {
API.endpointDomain = API.endpointDomainVrchat; API.endpointDomain = API.endpointDomainVrchat;
API.websocketDomain = API.websocketDomainVrchat;
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.enablePrimaryPassword) { if (this.enablePrimaryPassword) {
@@ -6040,7 +6042,8 @@ speechSynthesis.getVoices();
API.login({ API.login({
username: loginParmas.username, username: loginParmas.username,
password: loginParmas.password, password: loginParmas.password,
endpoint: loginParmas.endpoint endpoint: loginParmas.endpoint,
websocket: loginParmas.websocket
}) })
.catch(() => { .catch(() => {
this.loginForm.loading = false; this.loginForm.loading = false;
@@ -6096,6 +6099,7 @@ speechSynthesis.getVoices();
username: '', username: '',
password: '', password: '',
endpoint: '', endpoint: '',
websocket: '',
saveCredentials: false, saveCredentials: false,
savedCredentials: savedCredentials:
configRepository.getString('lastUserLoggedIn') !== null configRepository.getString('lastUserLoggedIn') !== null
@@ -6124,8 +6128,10 @@ speechSynthesis.getVoices();
this.loginForm.loading = true; this.loginForm.loading = true;
if (this.loginForm.endpoint) { if (this.loginForm.endpoint) {
API.endpointDomain = this.loginForm.endpoint; API.endpointDomain = this.loginForm.endpoint;
API.websocketDomain = this.loginForm.websocket;
} else { } else {
API.endpointDomain = API.endpointDomainVrchat; API.endpointDomain = API.endpointDomainVrchat;
API.websocketDomain = API.websocketDomainVrchat;
} }
API.getConfig() API.getConfig()
.catch((err) => { .catch((err) => {
@@ -6174,6 +6180,9 @@ speechSynthesis.getVoices();
endpoint: endpoint:
this.loginForm this.loginForm
.endpoint, .endpoint,
websocket:
this.loginForm
.websocket,
saveCredentials: saveCredentials:
this.loginForm this.loginForm
.saveCredentials, .saveCredentials,
@@ -6185,6 +6194,8 @@ speechSynthesis.getVoices();
''; '';
this.loginForm.endpoint = this.loginForm.endpoint =
''; '';
this.loginForm.websocket =
'';
}); });
}); });
}); });
@@ -6198,6 +6209,7 @@ speechSynthesis.getVoices();
username: this.loginForm.username, username: this.loginForm.username,
password: this.loginForm.password, password: this.loginForm.password,
endpoint: this.loginForm.endpoint, endpoint: this.loginForm.endpoint,
websocket: this.loginForm.websocket,
saveCredentials: this.loginForm.saveCredentials saveCredentials: this.loginForm.saveCredentials
}).finally(() => { }).finally(() => {
this.loginForm.username = ''; this.loginForm.username = '';

View File

@@ -37,6 +37,8 @@ html
el-input(type="password" v-model="loginForm.password" name="password" placeholder="Password" clearable show-password) el-input(type="password" v-model="loginForm.password" name="password" placeholder="Password" clearable show-password)
el-form-item(v-if="enableCustomEndpoint" label="Endpont" prop="endpoint" style="margin-top:10px") el-form-item(v-if="enableCustomEndpoint" label="Endpont" prop="endpoint" style="margin-top:10px")
el-input(v-model="loginForm.endpoint" name="endpoint" placeholder="Endpoint URL" clearable) el-input(v-model="loginForm.endpoint" name="endpoint" placeholder="Endpoint URL" clearable)
el-form-item(v-if="enableCustomEndpoint" label="WebSocket" prop="endpoint" style="margin-top:10px")
el-input(v-model="loginForm.websocket" name="websocket" placeholder="WebSocket URL" clearable)
el-checkbox(v-model="loginForm.saveCredentials" style="margin-top:15px") Save Credentials el-checkbox(v-model="loginForm.saveCredentials" style="margin-top:15px") Save Credentials
el-form-item(style="margin-top:15px") el-form-item(style="margin-top:15px")
el-button(native-type="submit" type="primary" :loading="loginForm.loading" style="width:100%") Login el-button(native-type="submit" type="primary" :loading="loginForm.loading" style="width:100%") Login