up web client v2
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import {setToken as setWCToken} from '@/utils/webclient'
|
||||||
|
|
||||||
const TokenKey = 'access_token'
|
const TokenKey = 'access_token'
|
||||||
const OidcCode = 'oidc_code'
|
const OidcCode = 'oidc_code'
|
||||||
const OidcCodeExpiry = 'oidc_code_expiry';
|
const OidcCodeExpiry = 'oidc_code_expiry';
|
||||||
@@ -7,6 +9,7 @@ export function getToken () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setToken (token) {
|
export function setToken (token) {
|
||||||
|
setWCToken(token)
|
||||||
return localStorage.setItem(TokenKey, token)
|
return localStorage.setItem(TokenKey, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-12
@@ -6,30 +6,37 @@ import * as message from '@/utils/webclient/message'
|
|||||||
import { ElMessageBox } from 'element-plus'
|
import { ElMessageBox } from 'element-plus'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
|
|
||||||
export const toWebClientLink = (row) => {
|
const prefix = 'wc-'
|
||||||
window.open(`${rustdeskConfig.value.api_server}/webclient/#/?id=${row.id}`)
|
|
||||||
|
export function setToken (token) {
|
||||||
|
localStorage.setItem(`${prefix}option:local:access_token`, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadRustdeskConfig () {
|
export const toWebClientLink = (row) => {
|
||||||
const rustdeskConfig = ref({})
|
//v2
|
||||||
const fetchConfig = async () => {
|
window.open(`${rustdeskConfig.value.api_server}/webclient2/#/${row.id}`)
|
||||||
|
// window.open(`${rustdeskConfig.value.api_server}/webclient/#/?id=${row.id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const rustdeskConfig = ref({})
|
||||||
|
|
||||||
|
export async function loadRustdeskConfig () {
|
||||||
|
console.log('loadRustdeskConfig')
|
||||||
|
if (rustdeskConfig.value.id_server === undefined || rustdeskConfig.value.key === undefined) {
|
||||||
const res = await server().catch(_ => false)
|
const res = await server().catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
rustdeskConfig.value = res.data
|
rustdeskConfig.value = res.data
|
||||||
localStorage.setItem('custom-rendezvous-server', res.data.id_server)
|
localStorage.setItem(`${prefix}custom-rendezvous-server`, res.data.id_server)
|
||||||
localStorage.setItem('key', res.data.key)
|
localStorage.setItem(`${prefix}key`, res.data.key)
|
||||||
localStorage.setItem('api-server', res.data.api_server)
|
localStorage.setItem(`${prefix}api-server`, res.data.api_server)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rustdeskConfig.value.id_server === undefined || rustdeskConfig.value.key === undefined) {
|
|
||||||
fetchConfig()
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
rustdeskConfig,
|
rustdeskConfig,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const { rustdeskConfig } = loadRustdeskConfig()
|
|
||||||
export async function getPeerSlat (id) {
|
export async function getPeerSlat (id) {
|
||||||
const [addr, port] = rustdeskConfig.value.id_server.split(':')
|
const [addr, port] = rustdeskConfig.value.id_server.split(':')
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
@@ -107,3 +114,7 @@ export async function getPeerSlat (id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getV2ShareUrl (token) {
|
||||||
|
return `${rustdeskConfig.value.api_server}/webclient2/#/?share_token=${token}`
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<el-form-item :label="T('ID')" prop="id" required>
|
<el-form-item :label="T('ID')" prop="id" required>
|
||||||
{{ formData.id }}
|
{{ formData.id }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="T('PasswordType')">
|
<!-- <el-form-item :label="T('PasswordType')">
|
||||||
<div>
|
<div>
|
||||||
<el-radio-group v-model="formData.password_type" @change="changePwdType">
|
<el-radio-group v-model="formData.password_type" @change="changePwdType">
|
||||||
<el-radio value="once">{{ T('OncePassword') }}</el-radio>
|
<el-radio value="once">{{ T('OncePassword') }}</el-radio>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
{{ T('FixedPasswordWarning') }}
|
{{ T('FixedPasswordWarning') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>-->
|
||||||
<el-form-item :label="T('Password')" prop="password" required>
|
<el-form-item :label="T('Password')" prop="password" required>
|
||||||
<el-input v-model="formData.password" type="password" show-password></el-input>
|
<el-input v-model="formData.password" type="password" show-password></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -45,13 +45,14 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import { computed, reactive, ref, watch } from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import { getPeerSlat, rustdeskConfig } from '@/utils/webclient'
|
import { loadRustdeskConfig, getV2ShareUrl } from '@/utils/webclient'
|
||||||
import * as sha256 from 'fast-sha256'
|
import * as sha256 from 'fast-sha256'
|
||||||
import { shareByWebClient } from '@/api/address_book'
|
import { shareByWebClient } from '@/api/address_book'
|
||||||
import { CopyDocument } from '@element-plus/icons'
|
import { CopyDocument } from '@element-plus/icons'
|
||||||
import { handleClipboard } from '@/utils/clipboard'
|
import { handleClipboard } from '@/utils/clipboard'
|
||||||
import { ElMessageBox } from 'element-plus'
|
import { ElMessageBox } from 'element-plus'
|
||||||
|
|
||||||
|
loadRustdeskConfig()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
id: String,
|
id: String,
|
||||||
hash: String,
|
hash: String,
|
||||||
@@ -106,7 +107,7 @@
|
|||||||
}
|
}
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const _formData = { ...formData }
|
const _formData = { ...formData }
|
||||||
if (formData.password !== formData.hash) {
|
/*if (formData.password !== formData.hash) {
|
||||||
const res = await getPeerSlat(formData.id).catch(e => {
|
const res = await getPeerSlat(formData.id).catch(e => {
|
||||||
ElMessageBox.alert(T('Timeout'), T('Error'))
|
ElMessageBox.alert(T('Timeout'), T('Error'))
|
||||||
return false
|
return false
|
||||||
@@ -117,10 +118,10 @@
|
|||||||
}
|
}
|
||||||
const p = hash([formData.password, res.salt])
|
const p = hash([formData.password, res.salt])
|
||||||
_formData.password = btoa(p.toString().split(',').map((v) => String.fromCharCode(v)).join(''))
|
_formData.password = btoa(p.toString().split(',').map((v) => String.fromCharCode(v)).join(''))
|
||||||
}
|
}*/
|
||||||
const res = await shareByWebClient(_formData).catch(_ => false)
|
const res = await shareByWebClient(_formData).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
link.value = `${rustdeskConfig.value.api_server}/webclient/#/?share_token=${res.data.share_token}`
|
link.value = getV2ShareUrl(res.data.share_token)
|
||||||
emits('success')
|
emits('success')
|
||||||
}
|
}
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user