|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div>
|
|
|
3
|
+ <h2>此处功能为实验性质,更多说明请参考 <a target="_blank" href="https://github.com/lejianwen/rustdesk-api/wiki/Rustdesk-Command">WIKI</a></h2>
|
|
|
4
|
+ <el-card class="list-query" shadow="hover">
|
|
|
5
|
+ <el-form inline label-width="80px">
|
|
|
6
|
+ <el-form-item>
|
|
|
7
|
+ <el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
|
|
8
|
+ <el-button type="danger" @click="toAdd">{{ T('Add') }}</el-button>
|
|
|
9
|
+ </el-form-item>
|
|
|
10
|
+ </el-form>
|
|
|
11
|
+ </el-card>
|
|
|
12
|
+ <el-card class="list-body" shadow="hover">
|
|
|
13
|
+
|
|
|
14
|
+ <el-table :data="listRes.list" v-loading="listRes.loading" border>
|
|
|
15
|
+ <el-table-column prop="cmd" label="cmd" align="center"></el-table-column>
|
|
|
16
|
+ <el-table-column prop="alias" label="alias" align="center"></el-table-column>
|
|
|
17
|
+ <el-table-column prop="option" label="option" align="center"></el-table-column>
|
|
|
18
|
+ <el-table-column prop="explain" label="explain" align="center"></el-table-column>
|
|
|
19
|
+ <el-table-column label="actions" align="center">
|
|
|
20
|
+ <template #default="{row}">
|
|
|
21
|
+ <el-button type="success" @click="showCmd(row)">执行</el-button>
|
|
|
22
|
+ <el-button v-if="row.id" type="primary" @click="toUpdate(row)">编辑</el-button>
|
|
|
23
|
+ <el-button v-if="row.id" type="danger" @click="del(row)">删除</el-button>
|
|
|
24
|
+ </template>
|
|
|
25
|
+ </el-table-column>
|
|
|
26
|
+ </el-table>
|
|
|
27
|
+
|
|
|
28
|
+ <el-dialog v-model="formVisible">
|
|
|
29
|
+ <el-form label-width="150">
|
|
|
30
|
+ <el-form-item label="cmd">
|
|
|
31
|
+ <el-input v-model="formData.cmd"></el-input>
|
|
|
32
|
+ </el-form-item>
|
|
|
33
|
+ <el-form-item label="alias">
|
|
|
34
|
+ <el-input v-model="formData.alias"></el-input>
|
|
|
35
|
+ </el-form-item>
|
|
|
36
|
+ <el-form-item label="option">
|
|
|
37
|
+ <el-input v-model="formData.option"></el-input>
|
|
|
38
|
+ </el-form-item>
|
|
|
39
|
+ <el-form-item label="explain">
|
|
|
40
|
+ <el-input v-model="formData.explain"></el-input>
|
|
|
41
|
+ </el-form-item>
|
|
|
42
|
+ <el-form-item>
|
|
|
43
|
+ <el-button type="primary" @click="submit">提交</el-button>
|
|
|
44
|
+ <el-button @click="cancel">取消</el-button>
|
|
|
45
|
+ </el-form-item>
|
|
|
46
|
+ </el-form>
|
|
|
47
|
+ </el-dialog>
|
|
|
48
|
+
|
|
|
49
|
+ <el-dialog title="发送指令" v-model="showCmdForm">
|
|
|
50
|
+ <el-form label-width="300">
|
|
|
51
|
+ <el-form-item label="cmd">
|
|
|
52
|
+ <el-input v-model="customCmd.cmd"></el-input>
|
|
|
53
|
+ </el-form-item>
|
|
|
54
|
+ <el-form-item label="option">
|
|
|
55
|
+ <el-input type="textarea" v-model="customCmd.option"></el-input>
|
|
|
56
|
+ </el-form-item>
|
|
|
57
|
+ <el-form-item>
|
|
|
58
|
+ <el-button type="primary" @click="submitCmd">发送</el-button>
|
|
|
59
|
+ </el-form-item>
|
|
|
60
|
+ <el-form-item label="执行结果">
|
|
|
61
|
+ <el-input type="textarea" readonly disabled v-model="customCmd.res" rows="20"></el-input>
|
|
|
62
|
+ </el-form-item>
|
|
|
63
|
+ </el-form>
|
|
|
64
|
+ </el-dialog>
|
|
|
65
|
+ </el-card>
|
|
|
66
|
+ </div>
|
|
|
67
|
+</template>
|
|
|
68
|
+
|
|
|
69
|
+
|
|
|
70
|
+<script setup>
|
|
|
71
|
+ import { list, sendCmd, remove, create, update } from '@/api/rustdesk'
|
|
|
72
|
+ import { onMounted, reactive, ref } from 'vue'
|
|
|
73
|
+ import { T } from '@/utils/i18n'
|
|
|
74
|
+ import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
75
|
+
|
|
|
76
|
+ const listRes = reactive({
|
|
|
77
|
+ list: [], total: 0, loading: false,
|
|
|
78
|
+ })
|
|
|
79
|
+ const listQuery = reactive({
|
|
|
80
|
+ page: 1,
|
|
|
81
|
+ page_size: 10,
|
|
|
82
|
+ })
|
|
|
83
|
+ const getList = async () => {
|
|
|
84
|
+ listRes.loading = true
|
|
|
85
|
+ const res = await list(listQuery).catch(_ => false)
|
|
|
86
|
+ listRes.loading = false
|
|
|
87
|
+ if (res) {
|
|
|
88
|
+ listRes.list = res.data.list
|
|
|
89
|
+ listRes.total = res.data.total
|
|
|
90
|
+ }
|
|
|
91
|
+ }
|
|
|
92
|
+ const handlerQuery = () => {
|
|
|
93
|
+ if (listQuery.page === 1) {
|
|
|
94
|
+ getList()
|
|
|
95
|
+ } else {
|
|
|
96
|
+ listQuery.page = 1
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+ onMounted(getList)
|
|
|
100
|
+ const del = async (row) => {
|
|
|
101
|
+ const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
|
|
102
|
+ confirmButtonText: T('Confirm'),
|
|
|
103
|
+ cancelButtonText: T('Cancel'),
|
|
|
104
|
+ type: 'warning',
|
|
|
105
|
+ }).catch(_ => false)
|
|
|
106
|
+ if (!cf) {
|
|
|
107
|
+ return false
|
|
|
108
|
+ }
|
|
|
109
|
+
|
|
|
110
|
+ const res = await remove({ id: row.id }).catch(_ => false)
|
|
|
111
|
+ if (res) {
|
|
|
112
|
+ ElMessage.success(T('OperationSuccess'))
|
|
|
113
|
+ getList()
|
|
|
114
|
+ }
|
|
|
115
|
+ }
|
|
|
116
|
+ const formData = reactive({
|
|
|
117
|
+ cmd: '',
|
|
|
118
|
+ alias: '',
|
|
|
119
|
+ option: '',
|
|
|
120
|
+ explain: '',
|
|
|
121
|
+ })
|
|
|
122
|
+ const formVisible = ref(false)
|
|
|
123
|
+ const toAdd = () => {
|
|
|
124
|
+ formVisible.value = true
|
|
|
125
|
+ formData.cmd = ''
|
|
|
126
|
+ formData.alias = ''
|
|
|
127
|
+ formData.option = ''
|
|
|
128
|
+ formData.explain = ''
|
|
|
129
|
+ }
|
|
|
130
|
+ const toUpdate = (row) => {
|
|
|
131
|
+ formVisible.value = true
|
|
|
132
|
+ formData.id = row.id
|
|
|
133
|
+ formData.cmd = row.cmd
|
|
|
134
|
+ formData.alias = row.alias
|
|
|
135
|
+ formData.option = row.option
|
|
|
136
|
+ formData.explain = row.explain
|
|
|
137
|
+ }
|
|
|
138
|
+ const submit = async () => {
|
|
|
139
|
+ if (!formData.cmd) {
|
|
|
140
|
+ ElMessage.error(T('ParamRequired', { param: 'cmd' }))
|
|
|
141
|
+ return
|
|
|
142
|
+ }
|
|
|
143
|
+ const api = formData.id ? update : create
|
|
|
144
|
+ const res = await api(formData).catch(_ => false)
|
|
|
145
|
+ if (res) {
|
|
|
146
|
+ ElMessage.success(T('OperationSuccess'))
|
|
|
147
|
+ formVisible.value = false
|
|
|
148
|
+ getList()
|
|
|
149
|
+ }
|
|
|
150
|
+ }
|
|
|
151
|
+ const cancel = () => {
|
|
|
152
|
+ formVisible.value = false
|
|
|
153
|
+ }
|
|
|
154
|
+
|
|
|
155
|
+ const showCmdForm = ref(false)
|
|
|
156
|
+ const customCmd = reactive({
|
|
|
157
|
+ cmd: '',
|
|
|
158
|
+ option: '',
|
|
|
159
|
+ res: '',
|
|
|
160
|
+ })
|
|
|
161
|
+ const showCmd = (row) => {
|
|
|
162
|
+ showCmdForm.value = true
|
|
|
163
|
+ customCmd.cmd = row.cmd
|
|
|
164
|
+ customCmd.option = ''
|
|
|
165
|
+ customCmd.res = ''
|
|
|
166
|
+ }
|
|
|
167
|
+ const submitCmd = async () => {
|
|
|
168
|
+ sendCmd(customCmd).then(res => {
|
|
|
169
|
+ console.log(res)
|
|
|
170
|
+ customCmd.res = res.data
|
|
|
171
|
+ })
|
|
|
172
|
+ }
|
|
|
173
|
+
|
|
|
174
|
+</script>
|
|
|
175
|
+
|
|
|
176
|
+<style scoped lang="scss">
|
|
|
177
|
+
|
|
|
178
|
+</style>
|