index.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <html lang="zh">
  2. <head>
  3. <title>百日题库-题目合集</title>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  6. <script src="/static/vue.js"></script>
  7. <script src="/static/jquery.min.js"></script>
  8. <style>
  9. .click {
  10. font-size: 22px;
  11. /*text-decoration: underline;*/
  12. user-select: none;
  13. cursor: pointer;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div id="app">
  19. <p v-show="msg!=''">{{msg}}</p>
  20. <p v-show="updateTime!=''">更新时间:{{updateTime}}</p>
  21. <p class="click" v-for="c in courses" @click="chooseCourse(c.id, c.name)">{{c.name}}</p>
  22. </div>
  23. <script>
  24. var URL_PREFIX = "";
  25. var app = new Vue({
  26. el: '#app',
  27. data: {
  28. msg: "loading...",
  29. updateTime: "",
  30. courses: []
  31. },
  32. methods: {
  33. chooseCourse(id, courseName) {
  34. courseName = courseName.split(' ');
  35. if (courseName.length < 2 || courseName[1] === '') {
  36. courseName = courseName[0];
  37. }
  38. else {
  39. courseName = courseName[1];
  40. }
  41. location.href = URL_PREFIX + "/course/" + id + "?course_name=" + encodeURI(courseName);
  42. },
  43. getCourse() {
  44. var self = this;
  45. $.ajax({
  46. url: URL_PREFIX + "/get/course",
  47. success: function(data) {
  48. console.log(data);
  49. if (data["success"]) {
  50. self.msg = "";
  51. self.updateTime = data["time"];
  52. self.courses = data["data"]["results"];
  53. }
  54. else {
  55. self.msg = "获取失败";
  56. }
  57. }
  58. });
  59. }
  60. },
  61. mounted() {
  62. this.getCourse();
  63. }
  64. });
  65. </script>
  66. </body>
  67. </html>