add url protocol &
add web client on/off by api server
This commit is contained in:
@@ -6,3 +6,9 @@ export function config () {
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
export function appConfig () {
|
||||
return request({
|
||||
url: '/app-config',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { defineStore, acceptHMRUpdate } from 'pinia'
|
||||
import logo from '@/assets/logo.png'
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
import en from 'element-plus/es/locale/lang/en'
|
||||
import { appConfig } from '@/api/rustdesk'
|
||||
|
||||
export const useAppStore = defineStore({
|
||||
id: 'App',
|
||||
@@ -12,6 +13,9 @@ export const useAppStore = defineStore({
|
||||
logo,
|
||||
lang: localStorage.getItem('lang') || 'zh-CN',
|
||||
locale: localStorage.getItem('lang') === 'en' ? en : zhCn,
|
||||
appConfig: {
|
||||
web_client: 1,
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -27,6 +31,12 @@ export const useAppStore = defineStore({
|
||||
changeLang () {
|
||||
this.setLang(this.setting.lang === 'zh-CN' ? 'en' : 'zh-CN')
|
||||
},
|
||||
getAppConfig () {
|
||||
console.log('getAppConfig')
|
||||
appConfig().then(res => {
|
||||
this.setting.appConfig = res.data
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { defineStore, acceptHMRUpdate } from 'pinia'
|
||||
import { current, login } from '@/api/user'
|
||||
import { setToken, removeToken } from '@/utils/auth'
|
||||
import { useRouteStore } from '@/store/router'
|
||||
import { useAppStore } from '@/store/app'
|
||||
|
||||
export const useUserStore = defineStore({
|
||||
id: 'user',
|
||||
@@ -26,6 +27,7 @@ export const useUserStore = defineStore({
|
||||
async login (form) {
|
||||
const res = await login(form).catch(_ => false)
|
||||
if (res) {
|
||||
useAppStore().getAppConfig()
|
||||
const userData = res.data
|
||||
setToken(userData.token)
|
||||
//
|
||||
@@ -44,6 +46,7 @@ export const useUserStore = defineStore({
|
||||
async info () {
|
||||
const res = await current().catch(_ => false)
|
||||
if (res) {
|
||||
useAppStore().getAppConfig()
|
||||
const userData = res.data
|
||||
setToken(userData.token)
|
||||
this.$patch({
|
||||
|
||||
@@ -28,3 +28,12 @@ $sideBarWidth: 210px;
|
||||
--el-input-width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
.table-actions{
|
||||
.el-button{
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,5 +347,8 @@
|
||||
},
|
||||
"CopyFailed": {
|
||||
"One": "Copy Failed"
|
||||
},
|
||||
"Timeout": {
|
||||
"One": "Timeout"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,5 +334,8 @@
|
||||
},
|
||||
"CopyFailed": {
|
||||
"One": "复制失败"
|
||||
},
|
||||
"Timeout": {
|
||||
"One": "超时"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export const connectByClient = (id) => {
|
||||
//不新开窗口打开url protocol ,格式是 rustdesk://<id>
|
||||
// window.open(`rustdesk://${row.id}`)
|
||||
let a = document.createElement('a')
|
||||
a.href = `rustdesk://${id}`
|
||||
a.target = '_self'
|
||||
a.click()
|
||||
|
||||
}
|
||||
@@ -50,6 +50,7 @@
|
||||
import { shareByWebClient } from '@/api/address_book'
|
||||
import { CopyDocument } from '@element-plus/icons'
|
||||
import { handleClipboard } from '@/utils/clipboard'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
id: String,
|
||||
@@ -71,7 +72,7 @@
|
||||
formData.id = props.id
|
||||
formData.hash = props.hash
|
||||
formData.password = ''
|
||||
formData.expire = 300
|
||||
formData.expire = 1800
|
||||
formData.password_type = 'once'
|
||||
link.value = ''
|
||||
}
|
||||
@@ -106,7 +107,10 @@
|
||||
loading.value = true
|
||||
const _formData = { ...formData }
|
||||
if (formData.password !== formData.hash) {
|
||||
const res = await getPeerSlat(formData.id).catch(_ => false)
|
||||
const res = await getPeerSlat(formData.id).catch(e => {
|
||||
ElMessageBox.alert(T('Timeout'), T('Error'))
|
||||
return false
|
||||
})
|
||||
if (!res) {
|
||||
loading.value = false
|
||||
return
|
||||
|
||||
@@ -30,22 +30,23 @@
|
||||
<el-card class="list-body" shadow="hover">
|
||||
<!-- <el-tag type="danger" style="margin-bottom: 10px">不建议在此操作地址簿,可能会造成数据不同步</el-tag>-->
|
||||
<el-table :data="listRes.list" v-loading="listRes.loading" border>
|
||||
<el-table-column prop="id" label="id" align="center"/>
|
||||
<el-table-column :label="T('Owner')" align="center">
|
||||
<el-table-column prop="id" label="id" align="center" width="200"/>
|
||||
<el-table-column :label="T('Owner')" align="center" width="200">
|
||||
<template #default="{row}">
|
||||
<span v-if="row.user_id"> <el-tag>{{ allUsers?.find(u => u.id === row.user_id)?.username }}</el-tag> </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="username" :label="T('Username')" align="center"/>
|
||||
<el-table-column prop="hostname" :label="T('Hostname')" align="center"/>
|
||||
<el-table-column prop="alias" :label="T('Alias')" align="center"/>
|
||||
<el-table-column prop="platform" :label="T('Platform')" align="center"/>
|
||||
<el-table-column prop="hash" :label="T('Hash')" align="center"/>
|
||||
<el-table-column prop="tags" :label="T('Tags')" align="center"/>
|
||||
<el-table-column prop="username" :label="T('Username')" align="center" width="150"/>
|
||||
<el-table-column prop="hostname" :label="T('Hostname')" align="center" width="150"/>
|
||||
<el-table-column prop="alias" :label="T('Alias')" align="center" width="150"/>
|
||||
<el-table-column prop="platform" :label="T('Platform')" align="center" width="120"/>
|
||||
<el-table-column prop="hash" :label="T('Hash')" align="center" width="250"/>
|
||||
<el-table-column prop="tags" :label="T('Tags')" align="center" width="250"/>
|
||||
<!-- <el-table-column prop="created_at" label="创建时间" align="center"/>-->
|
||||
<!-- <el-table-column prop="updated_at" label="更新时间" align="center"/>-->
|
||||
<el-table-column label="操作" align="center" width="500">
|
||||
<el-table-column :label="T('Actions')" align="center" class-name="table-actions">
|
||||
<template #default="{row}">
|
||||
<el-button type="success" @click="connectByClient(row.id)">{{ T('Link') }}</el-button>
|
||||
<el-button type="success" @click="toWebClientLink(row)">Web Client</el-button>
|
||||
<!-- <el-button type="primary" @click="toShowShare(row)">{{ T('ShareByWebClient') }}</el-button>-->
|
||||
<el-button @click="toEdit(row)">{{ T('Edit') }}</el-button>
|
||||
@@ -158,6 +159,7 @@
|
||||
import { T } from '@/utils/i18n'
|
||||
import { useRoute } from 'vue-router'
|
||||
import shareByWebClient from '@/views/address_book/components/shareByWebClient.vue'
|
||||
import { connectByClient } from '@/utils/peer'
|
||||
|
||||
const route = useRoute()
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
|
||||
@@ -20,19 +20,20 @@
|
||||
<el-card class="list-body" shadow="hover">
|
||||
<!-- <el-tag type="danger" style="margin-bottom: 10px">不建议在此操作地址簿,可能会造成数据不同步</el-tag>-->
|
||||
<el-table :data="listRes.list" v-loading="listRes.loading" border>
|
||||
<el-table-column prop="id" label="id" align="center"/>
|
||||
<el-table-column prop="username" :label="T('Username')" align="center"/>
|
||||
<el-table-column prop="hostname" :label="T('Hostname')" align="center"/>
|
||||
<el-table-column prop="alias" :label="T('Alias')" align="center"/>
|
||||
<el-table-column prop="platform" :label="T('Platform')" align="center"/>
|
||||
<el-table-column prop="hash" :label="T('Hash')" align="center"/>
|
||||
<el-table-column prop="tags" :label="T('Tags')" align="center"/>
|
||||
<el-table-column prop="id" label="id" align="center" width="200"/>
|
||||
<el-table-column prop="username" :label="T('Username')" align="center" width="150"/>
|
||||
<el-table-column prop="hostname" :label="T('Hostname')" align="center" width="150"/>
|
||||
<el-table-column prop="alias" :label="T('Alias')" align="center" width="150"/>
|
||||
<el-table-column prop="platform" :label="T('Platform')" align="center" width="120"/>
|
||||
<el-table-column prop="hash" :label="T('Hash')" align="center" width="250"/>
|
||||
<el-table-column prop="tags" :label="T('Tags')" align="center" width="250"/>
|
||||
<!-- <el-table-column prop="created_at" label="创建时间" align="center"/>-->
|
||||
<!-- <el-table-column prop="updated_at" label="更新时间" align="center"/>-->
|
||||
<el-table-column :label="T('Actions')" align="center" width="500">
|
||||
<el-table-column :label="T('Actions')" align="center" class-name="table-actions">
|
||||
<template #default="{row}">
|
||||
<el-button type="success" @click="toWebClientLink(row)">Web Client</el-button>
|
||||
<el-button type="primary" @click="toShowShare(row)">{{ T('ShareByWebClient') }}</el-button>
|
||||
<el-button type="success" @click="connectByClient(row.id)">{{ T('Link') }}</el-button>
|
||||
<el-button v-if="appStore.setting.appConfig.web_client" type="success" @click="toWebClientLink(row)">Web Client</el-button>
|
||||
<el-button v-if="appStore.setting.appConfig.web_client" type="primary" @click="toShowShare(row)">{{ T('ShareByWebClient') }}</el-button>
|
||||
<el-button @click="toEdit(row)">{{ T('Edit') }}</el-button>
|
||||
<el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>
|
||||
</template>
|
||||
@@ -131,7 +132,10 @@
|
||||
import { toWebClientLink } from '@/utils/webclient'
|
||||
import { T } from '@/utils/i18n'
|
||||
import shareByWebClient from '@/views/address_book/components/shareByWebClient.vue'
|
||||
import { useAppStore } from '@/store/app'
|
||||
import { connectByClient } from '@/utils/peer'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const tagList = ref([])
|
||||
const fetchTagListData = async () => {
|
||||
const res = await fetchTagList({ is_my: 1 }).catch(_ => false)
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
<div>
|
||||
<el-card class="list-query" shadow="hover">
|
||||
<el-form inline label-width="150px">
|
||||
<el-form-item label="ID">
|
||||
<el-input v-model="listQuery.id" clearable/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="T('Hostname')">
|
||||
<el-input v-model="listQuery.hostname" clearable/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="T('LastOnlineTime')">
|
||||
<el-select v-model="listQuery.time_ago" clearable>
|
||||
<el-option
|
||||
@@ -42,9 +48,10 @@
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="T('Actions')" align="center" width="500">
|
||||
<el-table-column :label="T('Actions')" align="center" width="500" class-name="table-actions">
|
||||
<template #default="{row}">
|
||||
<el-button type="success" @click="toWebClientLink(row)">Web-Client</el-button>
|
||||
<el-button type="success" @click="connectByClient(row.id)">{{ T('Link') }}</el-button>
|
||||
<el-button v-if="appStore.setting.appConfig.web_client" type="success" @click="toWebClientLink(row)">Web Client</el-button>
|
||||
<el-button type="primary" @click="toAddressBook(row)">{{ T('AddToAddressBook') }}</el-button>
|
||||
<el-button @click="toEdit(row)">{{ T('Edit') }}</el-button>
|
||||
<el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>
|
||||
@@ -161,7 +168,10 @@
|
||||
import { loadAllUsers } from '@/global'
|
||||
import { list as fetchTagList } from '@/api/tag'
|
||||
import { batchCreate } from '@/api/address_book'
|
||||
import { useAppStore } from '@/store/app'
|
||||
import { connectByClient } from '@/utils/peer'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const listRes = reactive({
|
||||
list: [], total: 0, loading: false,
|
||||
})
|
||||
@@ -169,6 +179,8 @@
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
time_ago: null,
|
||||
id: '',
|
||||
hostname: '',
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
|
||||
Reference in New Issue
Block a user