ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# horizon/_conf.html   这个文件对应的路径为:\horizon\openstack_dashboard\templates\horizon\_conf.html。可以将它复制进我们的主题目录中:horizon\openstack_dashboard\themes\maintenance\templates\horizon\_conf.html。这样随便改都不会影响其它主题了。   下面我们分析下这个文件里的代码: ~~~ {% load compress %} {% load datepicker_locale from horizon %} {% datepicker_locale as DATEPICKER_LOCALE %} ~~~ 这些不是太清楚,大概猜它是导入这些东西后,下面才能运用其对应的功能吧。 ~~~ {% comment %} Compress 3rd-party (jquery, angular, etc) and top-level Horizon JS. {% endcomment %} {% compress js %} {% for file in HORIZON_CONFIG.xstatic_lib_files %} <script src='{{ STATIC_URL }}{{ file }}'></script> {% endfor %} <script src='{{ STATIC_URL }}horizon/js/horizon.js' type='text/javascript' charset='utf-8'></script> {% endcompress %} ~~~ comment:相当于注释 compress js:自动压缩js代码。在这里面更改代码后,都需要在命令行中运行相关的命令,要不会报错。开发过程中,我们不应该压缩JS代码,这便于查找错误。所以我将这段代码改为以下: ~~~ {% comment %} Compress 3rd-party (jquery, angular, etc) and top-level Horizon JS. {% endcomment %} {% for file in HORIZON_CONFIG.xstatic_lib_files %} <script src='{{ STATIC_URL }}{{ file }}'></script> {% endfor %} <script src='{{ STATIC_URL }}horizon/js/horizon.js' type='text/javascript' charset='utf-8'></script> ~~~ 这样,我们在前端就能看到,它引入了那些JS代码: ~~~ <script src="/static/horizon/lib/jquery/jquery.js"></script> <script src="/static/horizon/lib/jquery_migrate/jquery-migrate.js"></script> <script src="/static/horizon/lib/angular/angular.js"></script> <script src="/static/horizon/lib/angular/angular-cookies.js"></script> <script src="/static/horizon/lib/angular/angular-sanitize.js"></script> <script src="/static/horizon/lib/angular/angular-route.js"></script> <script src="/static/horizon/lib/angular_bootstrap/angular-bootstrap.js"></script> <script src="/static/horizon/lib/angular_gettext/angular-gettext.js"></script> <script src="/static/horizon/lib/angular_lrdragndrop/lrdragndrop.js"></script> <script src="/static/horizon/lib/angular_smart_table/smart-table.js"></script> <script src="/static/horizon/lib/angular_fileupload/ng-file-upload-all.js"></script> <script src="/static/horizon/lib/d3/d3.js"></script> <script src="/static/horizon/lib/jquery_quicksearch/jquery.quicksearch.js"></script> <script src="/static/horizon/lib/jquery_tablesorter/jquery.tablesorter.js"></script> <script src="/static/horizon/lib/spin/spin.js"></script> <style></style> <script src="/static/horizon/lib/spin/spin.jquery.js"></script> <script src="/static/horizon/lib/jquery_ui/jquery-ui.js"></script> <script src="/static/horizon/lib/bootstrap_scss/js/bootstrap.js"></script> <script src="/static/horizon/lib/bootstrap_datepicker/bootstrap-datepicker.js"></script> <script src="/static/horizon/lib/hogan/hogan.js"></script> <script src="/static/horizon/lib/rickshaw/rickshaw.js"></script> <script src="/static/horizon/lib/jsencrypt/jsencrypt.js"></script> <script src="/static/horizon/lib/objectpath/ObjectPath.js"></script> <script src="/static/horizon/lib/tv4/tv4.js"></script> <script src="/static/horizon/lib/angular_schema_form/schema-form.js"></script> <script src="/static/horizon/js/horizon.js" type="text/javascript" charset="utf-8"></script> ~~~ 这样就一目了然,开发起来也方便多了。以后我们也可以在这个文件里引入我们所需要的JS文件了。