原simpleui可正常加载models中保存的script代码块,内容如下:
def check_server(self):
'''检测服务器链接状态'''
data = '''<span style='color:black;'>未检测</span>'''
if self.server_check:
data = '''
<span style='color:black;' id='%s'>检测中...</span>
<script>
axios.post(
'/sites/api/check_server',
{
"host":"%s",
"port":"%s"
}
).then((res)=>{
const data = res.data;
const ele = document.getElementById('%s');
ele.innerHTML = data.data;
});
</script>''' % (self.id, self.host, self.port, self.id)
return mark_safe(data)
check_server.short_description = '服务器状态'
检测socket端口后,ajax返回<span style='color:green'>正常</span>
或者<span style='color:red'>异常</span>
,但simple Pro中无法正常渲染script
代码块,导致无法发起ajax请求.