index.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>猿人学面试</title>
  7. <link rel="stylesheet" href="css/index.css">
  8. <script src="js/axios.min.js"></script>
  9. <script src="js/vue.js"></script>
  10. </head>
  11. <style>
  12. .banner{
  13. margin: 16px auto;
  14. }
  15. </style>
  16. <body>
  17. <section id="app">
  18. <header>
  19. <div class="left_nav">
  20. <img @click="show=!show" class="phone" width="30" src="img/menu.png" alt="">
  21. <img class="logo" src="img/logo.png" alt="logo">
  22. </div>
  23. <div class="nav">
  24. <a class="act" href="/index.html">主页</a>
  25. <a href="">爬虫比赛</a>
  26. <a href="">关于猿人学</a>
  27. </div>
  28. <div class="login">
  29. <div class="pc">
  30. <!-- <img width="30px" src="img/logo.jpg" alt="logo"> -->
  31. <div v-if="userInfo" class="menu">
  32. {{userInfo.name}}
  33. <ul>
  34. <li><a href="/record.html">我的刷题记录</a></li>
  35. <li @click="logout"><a>退出登录</a></li>
  36. </ul>
  37. </div>
  38. <a v-else href="/login.html">请先登录</a>
  39. </div>
  40. <div class="phone">
  41. <span v-if="userInfo">{{userInfo.name}}</span>
  42. <a v-else href="/login.html">请先登录</a>
  43. </div>
  44. </div>
  45. </header>
  46. <transition name="slide">
  47. <div class="slide" v-if="show">
  48. <a class="act" href="/index.html">猿人学面试</a>
  49. <a href="">爬虫比赛</a>
  50. <a href="">关于猿人学</a>
  51. <a v-if="userInfo" href="/record.html">我的刷题记录</a>
  52. <a v-if="userInfo" @click="logout">退出登录</a>
  53. </div>
  54. </transition>
  55. <div class="content index" >
  56. <div class="left" >
  57. <div class="banner">
  58. <img width="100%" height="100%" :src="img[0]" alt="">
  59. </div>
  60. </div>
  61. <div class="right">
  62. <div class="banner">
  63. <img width="100%" height="100%" :src="img[1]" alt="">
  64. </div>
  65. </div>
  66. <div class="left" v-if="list.length>0">
  67. <div class="part">
  68. <h1 class="title"><span>JS逆向面试题</span></h1>
  69. <ul class="list">
  70. <li v-for="item in list[0].list">
  71. <div>
  72. <a :href="'/detail.html?cat=js&id='+item.interviewId">{{item.name}}</a>
  73. </div>
  74. </li>
  75. </ul>
  76. <a href="/list.html?cat=js" class="more">更多JS逆向面试题</a>
  77. </div>
  78. <div class="part">
  79. <h1 class="title"><span>安卓逆向面试题</span></h1>
  80. <ul class="list">
  81. <li v-for="item in list[1].list">
  82. <div>
  83. <a :href="'/detail.html?cat=android&id='+item.interviewId">{{item.name}}</a>
  84. </div>
  85. </li>
  86. </ul>
  87. <a href="/list.html?cat=android" class="more">更多安卓逆向面试题</a>
  88. </div>
  89. <div class="part">
  90. <h1 class="title"><span>爬虫面试题</span></h1>
  91. <ul class="list">
  92. <li v-for="item in list[2].list">
  93. <div>
  94. <a :href="'/detail.html?cat=crawler&id='+item.interviewId">{{item.name}}</a>
  95. </div>
  96. </li>
  97. </ul>
  98. <a href="/list.html?cat=crawler" class="more">更多爬虫面试题</a>
  99. </div>
  100. </div>
  101. <div class="right">
  102. <div class="part">
  103. <h2 class="sec_title"><span>面试排行榜</span> <a href="">更多</a></h2>
  104. <ul class="list list_100">
  105. <li v-for="item in top"><a :href="'/record.html?cid='+item.cid">{{item.cname}}</a><span>{{item.count}}</span></li>
  106. </ul>
  107. </div>
  108. <div class="part">
  109. <h2 class="sec_title"><span>贡献面试题</span></h2>
  110. <form class="form">
  111. <input v-model="name" type="text" placeholder="面试题目">
  112. <textarea v-model="content"></textarea>
  113. <button type="button" @click="post">提交</button>
  114. </form>
  115. </div>
  116. </div>
  117. </div>
  118. <footer></footer>
  119. </section>
  120. <script src="js/public.js"></script>
  121. <script>
  122. const { createApp } = Vue;
  123. createApp({
  124. data() {
  125. return {
  126. show:0,
  127. list:[],
  128. img:[],
  129. top:[],
  130. name:'',
  131. content:'',
  132. userInfo:{}
  133. }
  134. },
  135. created(){
  136. const userInfo = JSON.parse(localStorage.getItem('userInfo'));
  137. this.userInfo = userInfo;
  138. this.getData();
  139. },
  140. methods:{
  141. logout(){
  142. localStorage.removeItem('userInfo');
  143. localStorage.removeItem('token');
  144. this.userInfo = null;
  145. },
  146. getData(){
  147. axios.get(url+'/api/yrx/que/top').then(res=>{
  148. this.list = res.data.data;
  149. })
  150. axios.get(url+'/api/yrx/banner/list?position=index_left').then(res=>{
  151. this.img[0] = res.data.data[0].img;
  152. })
  153. axios.get(url+'/api/yrx/banner/list?position=index_right').then(res=>{
  154. this.img[1] = res.data.data[0].img;
  155. })
  156. axios.get(url+'/api/yrx/que/user/top').then(res=>{
  157. this.top = res.data.data;
  158. })
  159. },
  160. post(){
  161. const token = localStorage.getItem('token'); // 获取token
  162. if(!token){
  163. window.location.href="/login.html";
  164. return;
  165. }
  166. if (!this.name || !this.content) {
  167. alert('面试题目和内容不能为空');
  168. return;
  169. }
  170. axios.post(url+'/api/yrx/que/user/post', { name: this.name, content: this.content }, {
  171. headers: {
  172. 'Authorization': `${token}` // 添加token到header
  173. }
  174. })
  175. .then(res => {
  176. if(res.data.code === 0){
  177. alert('提交成功');
  178. this.name = '';
  179. this.content = '';
  180. }
  181. })
  182. .catch(err => {
  183. alert('提交失败,请重试');
  184. console.error(err);
  185. });
  186. }
  187. }
  188. }).mount('#app');
  189. </script>
  190. </body>
  191. </html>