Skip to content

Commit d98f7c1

Browse files
committed
fix: 增加默认展开参数
1 parent e67dff2 commit d98f7c1

File tree

7 files changed

+33
-5
lines changed

7 files changed

+33
-5
lines changed

config_c.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"server": {
3-
"url": "ws://192.168.9.224:18888/websocket_path",
4-
"password": "helloworld",
5-
"compress": true
3+
"url": "ws://127.0.0.1:18888/websocket_path",
4+
"password": "helloworld"
65
},
76
"client_name": "windows10_sql",
87
"log_file": "/var/log/nt/nt.log"

config_s.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"password": "helloworld",
44
"path": "/websocket_path",
55
"log_file": "/var/log/nt/nt.log",
6+
"default_expand_all": false,
67
"admin": {
78
"enable": true,
89
"admin_password": "new_password"

context/context_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from entity.message.push_config_entity import ClientData
44
from entity.server_config_entity import AdminEntity
5+
from entity.server_config_entity import ServerConfigEntity
56

67
c = {}
78

@@ -18,6 +19,8 @@ class ContextUtils:
1819
_client_name_to_config_in_server = '_client_name_to_config_in_server'
1920
_nonce_to_timestamp = '_nonce_to_timestamp'
2021

22+
_server_config = '_server_config' # 服务端配置
23+
2124
@classmethod
2225
def get_password(cls) -> str:
2326
return c.get(cls._password_key)
@@ -97,3 +100,11 @@ def get_nonce_to_time(cls) -> Dict[bytes, int]:
97100
@classmethod
98101
def set_nonce_to_time(cls, data: Dict[bytes, int]):
99102
c[cls._nonce_to_timestamp] = data
103+
104+
@classmethod
105+
def get_server_config(cls) -> ServerConfigEntity:
106+
return c[cls._server_config]
107+
108+
@classmethod
109+
def set_server_config(cls, s: ServerConfigEntity):
110+
c[cls._server_config] = s

entity/server_config_entity.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ class ServerConfigEntity(TypedDict):
2121
log_file: str
2222
admin: AdminEntity
2323

24+
default_expand_all: bool
25+
2426
client_config: Dict[str, List[_ClientEntity]] # 在服务端配置的

run_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def main():
9696
print('github: ', SystemConstant.GITHUB)
9797
signal.signal(signal.SIGINT, signal_handler)
9898
server_config = load_config()
99+
ContextUtils.set_server_config(server_config)
99100
ContextUtils.set_cookie_to_time({})
100101
ContextUtils.set_nonce_to_time({})
101102
ContextUtils.set_password(server_config['password'])

server/admin_http_handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ async def get(self):
7979
return
8080
online_client_name_list: List[str] = list(MyWebSocketaHandler.client_name_to_handler.keys())
8181
return_list = []
82+
server_config = ContextUtils.get_server_config()
83+
expand_all = server_config.get('default_expand_all', False)
8284
client_name_to_config_list_in_server = ContextUtils.get_client_name_to_config_in_server()
8385
online_set: Set[str] = set()
8486
for client_name in online_client_name_list:
@@ -95,6 +97,7 @@ async def get(self):
9597
'config_list': config_list,
9698
'status': 'online',
9799
'version': handler.version,
100+
'expand': expand_all,
98101
'can_delete_names': [x['name'] for x in client_name_to_config_list_in_server.get(client_name, [])]
99102
# 配置在服务器上的, 可以删除
100103
})
@@ -108,6 +111,7 @@ async def get(self):
108111
'config_list': config_list,
109112
'version': '',
110113
'status': 'offline',
114+
'expand': expand_all,
111115
'can_delete_names': [x['name'] for x in client_name_to_config_list_in_server.get(client_name, [])]
112116
})
113117
return_list.sort(key=lambda x: x['client_name'])

server/template/ele_index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:data="tableData"
77
medium="medium"
88
row-key="client_name"
9+
:expand-row-keys="expands"
910
style="width: 90%; margin: 0 auto">
1011
<el-table-column type="expand">
1112
<template slot-scope="props">
@@ -123,6 +124,7 @@
123124
delimiters: ['{[', ']}'], // 这句可以指定 {[ ]} 为插值表达式的新符号
124125
data() {
125126
return {
127+
expands: [],
126128
tableData: [{client_name: 'ssh'}],
127129
dialogFormVisible: false,
128130
formLabelWidth: '120px',
@@ -139,7 +141,7 @@
139141
}
140142
},
141143
mounted() {
142-
this.getClientList()
144+
this.getClientList(true)
143145
this.intervalTask = setInterval(this.getClientList, 6000)
144146
},
145147
beforeDestroy() {
@@ -217,7 +219,7 @@
217219

218220

219221
},
220-
getClientList() {
222+
getClientList(updateExpand) {
221223
var url = window.location.href.split('?')[0] + '/api'
222224
axios.get(url, {
223225
headers: {token: localStorage.getItem('token')}
@@ -233,6 +235,14 @@
233235
}
234236
}
235237
this.tableData = res.data.data
238+
if (updateExpand) {
239+
this.tableData.forEach(item => {
240+
const {client_name, expand} = item
241+
if (expand) {
242+
this.expands.push(client_name)
243+
}
244+
});
245+
}
236246
console.log(this.tableData)
237247
}).catch(err => {
238248
console.log(err)

0 commit comments

Comments
 (0)