You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 3.4 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /** Copyright 2020 Tianshu AI Platform. All Rights Reserved.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. * =============================================================
  15. */
  16. <template>
  17. <div v-mouse-wheel="getLog">
  18. <prism-render :code="logTxt" />
  19. </div>
  20. </template>
  21. <script>
  22. import PrismRender from '@/components/Prism';
  23. export default {
  24. name: 'LogContainer',
  25. components: {
  26. PrismRender,
  27. },
  28. props: {
  29. // 日志请求的接口方法
  30. logGetter: {
  31. type: Function,
  32. required: true,
  33. },
  34. // 查询日志需要用到的其他参数
  35. options: {
  36. type: Object,
  37. default: () => ({}),
  38. },
  39. // 日志请求行数
  40. logLines: {
  41. type: Number,
  42. default: 50,
  43. },
  44. showMsg: {
  45. type: Boolean,
  46. default: false,
  47. },
  48. msg: {
  49. type: String,
  50. default: '',
  51. },
  52. disabled: {
  53. type: Boolean,
  54. default: false,
  55. },
  56. },
  57. data() {
  58. return {
  59. logList: [],
  60. noMoreLog: false,
  61. currentLogLine: 1,
  62. logLoading: false,
  63. logMsgInstance: null,
  64. };
  65. },
  66. computed: {
  67. getLogDisabled() {
  68. return this.logLoading || this.noMoreLog || this.disabled;
  69. },
  70. logTxt() {
  71. return `${this.showMsg ? `${this.msg}\n` : ''}${this.logList.join('\n')}`;
  72. },
  73. },
  74. methods: {
  75. getLog(noWarning = false) {
  76. if (this.getLogDisabled) {
  77. return;
  78. }
  79. this.logLoading = true;
  80. this.logGetter({
  81. ...this.options,
  82. startLine: this.currentLogLine,
  83. lines: this.logLines,
  84. })
  85. .then((res) => {
  86. this.logList = this.logList.concat(res.content);
  87. this.currentLogLine = res.endLine + 1;
  88. // 当请求到的行数小于请求行数时,冻结请求一秒
  89. if (res.lines < this.logLines) {
  90. this.pauseRequest();
  91. // 当返回行数小于三行时提示日志已到达底部
  92. // TODO: logMsgInstance 到达底部提示是否应该设为,当有新的提示出现,关闭旧的提示,而不是等三秒后自动消失?
  93. if (!noWarning && res.lines < 3 && !this.logMsgInstance) {
  94. this.logMsgInstance = this.$message.warning({
  95. message: '已经到达日志底部了。',
  96. onClose: this.onLogMsgClose,
  97. });
  98. }
  99. }
  100. })
  101. .catch((err) => {
  102. this.pauseRequest();
  103. throw err;
  104. })
  105. .finally(() => {
  106. this.logLoading = false;
  107. });
  108. },
  109. reset(getLog = false) {
  110. this.logList = [];
  111. this.noMoreLog = false;
  112. this.currentLogLine = 1;
  113. getLog && this.getLog(true);
  114. },
  115. onLogMsgClose() {
  116. this.logMsgInstance = null;
  117. },
  118. pauseRequest() {
  119. this.noMoreLog = true;
  120. setTimeout(() => {
  121. this.noMoreLog = false;
  122. }, 1000);
  123. },
  124. },
  125. };
  126. </script>

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能

Contributors (1)