Skip to content

Configuration

aaajiulong edited this page Nov 7, 2020 · 6 revisions

You can customize some configuration(non-essential).

Select CDN method to import the view file.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/yoobool/flask-state@v1.0.3/packages/flask-state.min.css">
<script src="https://cdn.jsdelivr.net/gh/yoobool/flask-state@v1.0.3/packages/umd/flask-state.min.js"></script>
<script type="text/javascript">
    // Create a DOM node with ID 'test'. After init() binds the node, click to open the listening window
    flaskState.init({dom:document.getElementById('test')});
</script>

Monitor the redis status.

app.config['REDIS_CONF'] = {'REDIS_STATUS': True, 'REDIS_HOST': '192.168.1.1', 'REDIS_PORT':16380, 'REDIS_PASSWORD': 'psw'}

Modify the time interval for saving monitoring records.

# The minimum interval is 60 seconds. The default interval is 60 seconds
import flask_state
SECS = 60
flask_state.init_app(app, SECS)

Custom logger object.

import flask_state
import logging
custom_logger = logging.getLogger(__name__)
flask_state.init_app(app, interval=60, log_instance=custom_logger)

Custom binding triggers the object of the window.

/* When the initialization plug-in does not pass in an object, the plug-in will automatically create a right-hand suspension ball
   Note: all pages share a plug-in instance. Calling init() method multiple times will only trigger plug-in events for new object binding */
flaskState.init();

Select the language in which the plug-in is displayed, now support en, zh.

<!--Note: the language file imported through the tag must be after the plug-in is imported-->
<!-- CDN -->
<script src="https://cdn.jsdelivr.net/gh/yoobool/flask-state@v1.0.3/packages/umd/flask-state.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/yoobool/flask-state@v1.0.3/packages/umd/zh.js"></script>
<script type="text/javascript">
    flaskState.init({lang:flaskState.zh});
</script>
/* webpack */
import {init} from 'flask-state';
import {zh} from 'flask-state/i18n.js';
init({lang:zh});
Clone this wiki locally