detail.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. .search_left {
  13. width: calc(25% - 20px);
  14. }
  15. .search_left .list li {
  16. width: 100%;
  17. line-height: 30px;
  18. }
  19. .part {
  20. border-radius: 5px;
  21. }
  22. .search input {
  23. width: 200px;
  24. height: 32px;
  25. border: 1px solid #ccc;
  26. border-radius: 3px;
  27. padding: 0 10px;
  28. margin-bottom: 15px;
  29. outline: none;
  30. text-align: center;
  31. }
  32. .search{
  33. position: relative;
  34. width: 200px;
  35. margin: 0 auto;
  36. }
  37. .search img{
  38. position: absolute;
  39. right: 5px;
  40. top: 5px;
  41. cursor: pointer;
  42. }
  43. .detail_right {
  44. width: 75%;
  45. }
  46. .tag {
  47. margin-top: 10px;
  48. /* padding-left: 20px; */
  49. }
  50. .tag span {
  51. background-color: #A9ABAD20;
  52. color: #666;
  53. display: inline-block;
  54. width: 60px;
  55. line-height: 25px;
  56. margin-right: 10px;
  57. font-size: 14px;
  58. border-radius: 10px;
  59. text-align: center;
  60. }
  61. .tag a {
  62. color: #333;
  63. float: right;
  64. cursor: pointer;
  65. }
  66. .discuss {
  67. text-align: center;
  68. /* background-color: #f5f5f5; */
  69. padding: 40px 20px;
  70. /* border: 1px solid #ccc; */
  71. }
  72. .discuss button{
  73. background-color: #2268D0 !important;
  74. border-radius: 20px !important;
  75. width: 200px !important;
  76. }
  77. .answer {
  78. padding: 20px;
  79. line-height: 26px;
  80. text-align: left;
  81. }
  82. .detail_right button {
  83. width: 150px;
  84. height: 40px;
  85. border: none;
  86. background-color: #000;
  87. color: #fff;
  88. font-weight: 600;
  89. border-radius: 3px;
  90. outline: none;
  91. }
  92. .user {
  93. margin-bottom: 10px;
  94. color: #999;
  95. font-size: 13px;
  96. }
  97. .ans {
  98. line-height: 25px;
  99. margin-bottom: 10px;
  100. color: #333;
  101. }
  102. .login_div {
  103. /* background-image: linear-gradient(90deg, #0B0B0A, #E1CAA0); */
  104. text-align: center;
  105. padding: 20px;
  106. border-radius: 10px;
  107. box-shadow: 0px 0px 4px 0 rgba(0,0,0,.1);
  108. margin-bottom: 15px;
  109. }
  110. .login_div button{
  111. width: 300px;
  112. background-color: #E8E8E8;
  113. color: #000;
  114. font-weight: 500;
  115. }
  116. .login_div button span{
  117. color: #0065D7;
  118. font-weight: 600;
  119. }
  120. #list li{
  121. line-height: 30px;
  122. padding: 10px 0;
  123. font-size: 14px;
  124. border-bottom: 1px solid #BBBBBB20;
  125. }
  126. #list li a{
  127. color: #0065D7;
  128. display: flex;
  129. }
  130. .part{
  131. padding: 25px;
  132. }
  133. .sec_title{
  134. color: #0065D7;
  135. font-size: 28px;
  136. border-bottom: 1px solid #f5f5f5;
  137. }
  138. .sec_title span{
  139. border-bottom: 3px solid #0065D7;
  140. line-height: 30px;
  141. }
  142. .avatar{
  143. width: 44px;
  144. height: 40px;
  145. border-radius: 50%;
  146. background-color: greenyellow;
  147. margin-right: 15px;
  148. line-height: 40px;
  149. text-align: center;
  150. font-weight: 600;
  151. font-size: 13px;
  152. }
  153. </style>
  154. <body>
  155. <section id="app">
  156. <header>
  157. <div class="left_nav">
  158. <img @click="show=!show" class="phone" width="30" src="img/menu.png" alt="">
  159. <img class="logo" src="img/logo.png" alt="logo">
  160. </div>
  161. <div class="nav">
  162. <a class="act" href="/index.html">主页</a>
  163. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  164. <a href="https://match.yuanrenxue.cn/" target="_blank">采集进阶课程</a>
  165. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  166. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  167. <a href="https://www.yuanrenxue.cn/" target="_blank">关于猿人学</a>
  168. </div>
  169. <div class="login">
  170. <div class="pc">
  171. <!-- <img width="30px" src="img/logo.jpg" alt="logo"> -->
  172. <div v-if="userInfo" class="menu">
  173. {{userInfo.name}}
  174. <ul>
  175. <li><a href="/record.html">我的刷题记录</a></li>
  176. <li @click="logout"><a>退出登录</a></li>
  177. </ul>
  178. </div>
  179. <a v-else href="/login.html">请先登录</a>
  180. </div>
  181. <div class="phone">
  182. <span v-if="userInfo">{{userInfo.name}}</span>
  183. <a v-else href="/login.html">请先登录</a>
  184. </div>
  185. </div>
  186. </header>
  187. <transition name="slide">
  188. <div class="slide" v-if="show">
  189. <a class="act" href="/index.html">主页</a>
  190. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  191. <a href="https://match.yuanrenxue.cn/" target="_blank">采集进阶课程</a>
  192. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  193. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  194. <a href="https://www.yuanrenxue.cn/" target="_blank">关于猿人学</a>
  195. <a v-if="userInfo" href="/record.html">我的刷题记录</a>
  196. <a v-if="userInfo" @click="logout">退出登录</a>
  197. </div>
  198. </transition>
  199. <div class="content">
  200. <p class="navtation"><a href="/index.html">回到首页</a> - <a :href="'/list.html?cat='+param.category">
  201. <span v-if="detail.category=='crawler'">爬虫</span>
  202. <span v-else-if="detail.category=='js'">JS</span>
  203. <span v-else>安卓</span>面试题</a> - {{detail.name}}</p>
  204. <div class="left search_left pc">
  205. <div class="part">
  206. <p class="search">
  207. <img @click="search" width="20" src="img/search.png" alt="">
  208. <input type="text" v-model="searchKeyword" @input="search" placeholder="题目搜索">
  209. </p>
  210. <ol class="list" id="list">
  211. <li v-for="(item,i) in list" :key="item.interviewId" v-show="i<10">
  212. <a
  213. :href="'/detail.html?cat='+param.category+'&id='+item.interviewId">
  214. <span>{{i+1}}、</span>{{item.name}}</a>
  215. </li>
  216. </ol>
  217. </div>
  218. <div class="part">
  219. <h2 class="sec_title"><span>贡献面试题</span></h2>
  220. <form class="form">
  221. <input v-model="name" type="text" placeholder="面试题目">
  222. <textarea v-model="content"></textarea>
  223. <button type="button" @click="post">提交</button>
  224. </form>
  225. </div>
  226. </div>
  227. <div class="right detail_right">
  228. <div class="part">
  229. <b style="font-size: 28px;color: #000;">{{detail.name}}</b>
  230. <p class="tag">
  231. <span>{{detail.category}}</span>
  232. <a @click="copy"><img style="position: relative;top: 5px;" width="20" src="img/share.png" alt=""> 分享给朋友</a>
  233. </p>
  234. </div>
  235. <div class="part">
  236. <h2 class="sec_title"><span>优秀回答</span></h2>
  237. <div class="discuss answer" v-if="userInfo">
  238. {{detail.content}}
  239. </div>
  240. <div class="discuss" v-else>
  241. <button @click="login">点击登录查看完整内容</button>
  242. </div>
  243. </div>
  244. <div class="part">
  245. <h2 class="sec_title"><span>讨论回答</span></h2>
  246. <div style="display: flex;">
  247. <span class="avatar" :style="{background:getColor()}">
  248. {{userInfo.name?userInfo.name[0]:'x'}}
  249. </span>
  250. <div class="login_div" v-if="!userInfo" style="width: 90%;">
  251. <button @click="login">你需要<span>注册/登录</span>才可以分享内容哦</button>
  252. </div>
  253. <div class="comment" v-else style="width: 90%;margin-bottom: 15px;">
  254. <textarea v-model="form.content" placeholder="留下你的想法..."></textarea>
  255. <button style="width: 100px;" @click="sendComment">提交评论</button>
  256. </div>
  257. </div>
  258. <template v-for="(item,index) in comment">
  259. <template v-if="index == 0">
  260. <div style="display: flex;">
  261. <span class="avatar" :style="{background:getColor()}">{{item.cname[0]}}</span>
  262. <div>
  263. <p class="user">
  264. <b style="color: #000;">{{item.cname}}</b>
  265. </p>
  266. <p class="ans">
  267. {{item.content}}
  268. </p>
  269. <p class="user">
  270. {{item.ctime}}
  271. </p>
  272. </div>
  273. </div>
  274. </template>
  275. <template v-else-if="index > 0 && userInfo">
  276. <div style="display: flex;">
  277. <span class="avatar" :style="{background:getColor()}">{{item.cname[0]}}</span>
  278. <div>
  279. <p class="user">
  280. <b style="color: #000;">{{item.cname}}</b>
  281. </p>
  282. <p class="ans">
  283. {{item.content}}
  284. </p>
  285. <p class="user">
  286. {{item.ctime}}
  287. </p>
  288. </div>
  289. </div>
  290. </template>
  291. </template>
  292. </div>
  293. </div>
  294. <div class="left search_left phone">
  295. <div class="part">
  296. <p class="search">
  297. <img @click="search" width="20" src="img/search.png" alt="">
  298. <input type="text" v-model="searchKeyword" @input="search" placeholder="题目搜索">
  299. </p>
  300. <ol class="list" id="list">
  301. <li v-for="(item,i) in list" :key="item.interviewId" v-show="i<10">
  302. <a
  303. :href="'/detail.html?cat='+param.category+'&id='+item.interviewId">
  304. <span>{{i+1}}、</span>{{item.name}}</a>
  305. </li>
  306. </ol>
  307. </div>
  308. <div class="part">
  309. <h2 class="sec_title"><span>贡献面试题</span></h2>
  310. <form class="form">
  311. <input v-model="name" type="text" placeholder="面试题目">
  312. <textarea v-model="content"></textarea>
  313. <button type="button" @click="post">提交</button>
  314. </form>
  315. </div>
  316. </div>
  317. </div>
  318. <footer>
  319. <ul>
  320. <li>
  321. <b>爬虫比赛</b> <br>
  322. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  323. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  324. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  325. </li>
  326. <li>
  327. <b>爬虫课程</b> <br>
  328. <a href="https://shop45147253.m.youzan.com/wscgoods/detail/2okabph85ypv1?banner_id=f.86209928~goods.2~1~rVebiaQ5&alg_id=0&slg=0&components_style_layout=0&reft=1744878857227&spm=f.86209928&sf=wx_sm" target="_blank">爬虫逆向进阶课</a>
  329. <a href="https://shop45147253.m.youzan.com/wscgoods/detail/2xli2kj7ku3a5zk?banner_id=f.86209928~goods.2~2~lWrtebiJ&alg_id=0&slg=0&components_style_layout=0&reft=1744878880491&spm=f.86209928&sf=wx_sm" target="_blank">反爬&风控对抗课</a>
  330. <a href="https://shop45147253.m.youzan.com/wscgoods/detail/361rmliyhfwr184?banner_id=f.86209928~goods.2~3~25r4gDL2&alg_id=0&slg=0&components_style_layout=0&reft=1744878921640&spm=f.86209928&sf=wx_sm" target="_blank">0基础+爬虫逆向课</a>
  331. </li>
  332. <li>
  333. <b>关于猿人学</b> <br>
  334. <a href="https://www.yuanrenxue.cn/tricks" target="_blank">Python技术杂谈</a>
  335. <a href="https://www.yuanrenxue.cn/earn-money" target="_blank">Python爬虫挣钱</a>
  336. </li>
  337. <li class="contact" style="display: flex;line-height: 30px;">
  338. <img style="margin-right: 10px;" width="100" height="100" src="img/wx.jpg" alt="">
  339. 扫一扫加我微信 <br>
  340. 备注面试题 <br>
  341. 拉你进面试交流群
  342. </li>
  343. </ul>
  344. <p>成都老猿智能科技有限公司Copyright @ 2025 猿人学面试 蜀ICP备2022000052号-2</p>
  345. </footer>
  346. </section>
  347. <script src="js/public.js"></script>
  348. <script>
  349. const { createApp } = Vue;
  350. createApp({
  351. data() {
  352. return {
  353. name: '',
  354. content: '',
  355. userInfo: {},
  356. id: '',
  357. detail: {},
  358. comment: [],
  359. form: {
  360. content: '',
  361. interviewName: '',
  362. interviewId: ''
  363. },
  364. searchKeyword: '', // 添加 searchKeyword 变量
  365. list: [], // 添加 list 变量用于存储题目列表
  366. show: 0, // 添加 show 变量,
  367. param: {
  368. page: 1,
  369. page_size: 10
  370. }
  371. }
  372. },
  373. created() {
  374. this.id = new URLSearchParams(window.location.search).get('id') || '';
  375. this.param.category = new URLSearchParams(window.location.search).get('cat') || 'js';
  376. // 获取本地存储的用户ID并赋值给cid
  377. const userInfo = JSON.parse(localStorage.getItem('userInfo'));
  378. this.userInfo = userInfo;
  379. this.getData();
  380. this.getComment();
  381. },
  382. methods: {
  383. login() {
  384. window.location.href = '/login.html';
  385. },
  386. getColor() {
  387. // 生成随机饱和度低的颜色
  388. const r = Math.floor(Math.random() * 128)+120; // 随机生成 0-127 的红色值
  389. const g = Math.floor(Math.random() * 128)+120; // 随机生成 0-127 的绿色值
  390. const b = Math.floor(Math.random() * 128)+120; // 随机生成 0-127 的蓝色值
  391. return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
  392. },
  393. getData() {
  394. // 列表
  395. axios.get(url + '/api/yrx/que/info?interviewId=' + this.id).then(res => {
  396. if (res.data.code === 0) {
  397. this.detail = res.data.data;
  398. this.form.interviewId = this.detail.interviewId;
  399. this.form.interviewName = this.detail.name;
  400. }
  401. });
  402. // 获取题目列表
  403. axios.get(url + '/api/yrx/que/list', { params: this.param }).then(res => {
  404. if (res.data.code === 0) {
  405. this.list = res.data.data.list;
  406. }
  407. });
  408. },
  409. getComment() {
  410. axios.get(url + '/api/yrx/que/comments/list?interviewId=' + this.id).then(res => {
  411. if (res.data.code === 0) {
  412. this.comment = res.data.data.list;
  413. }
  414. });
  415. },
  416. sendComment() {
  417. if (!this.form.content) {
  418. alert('评论内容不能为空');
  419. return;
  420. }
  421. const token = localStorage.getItem('token'); // 获取token
  422. axios.post(url + '/api/yrx/que/comments', this.form, {
  423. headers: {
  424. 'Authorization': `${token}` // 添加token到header
  425. }
  426. })
  427. .then(res => {
  428. if (res.data.code === 0) {
  429. alert('评论成功');
  430. this.form.content = '';
  431. this.getComment();
  432. }
  433. })
  434. .catch(err => {
  435. alert('评论失败,请重试');
  436. console.error(err);
  437. });
  438. },
  439. post() { // 添加post方法
  440. const token = localStorage.getItem('token'); // 获取token
  441. if (!token) {
  442. window.location.href = "/login.html";
  443. return;
  444. }
  445. if (!this.name || !this.content) {
  446. alert('面试题目和内容不能为空');
  447. return;
  448. }
  449. axios.post(url + '/api/yrx/que/user/post', { name: this.name, content: this.content }, {
  450. headers: {
  451. 'Authorization': `${token}` // 添加token到header
  452. }
  453. })
  454. .then(res => {
  455. if (res.data.code === 0) {
  456. alert('提交成功');
  457. this.name = '';
  458. this.content = '';
  459. }
  460. })
  461. .catch(err => {
  462. alert('提交失败,请重试');
  463. console.error(err);
  464. });
  465. },
  466. search() { // 添加 search 方法
  467. axios.get(url + '/api/yrx/que/list', {
  468. params: {
  469. name: this.searchKeyword,
  470. category: this.detail.category,
  471. page: 1,
  472. page_size: 1000
  473. }
  474. })
  475. .then(res => {
  476. if (res.data.code === 0) {
  477. this.list = res.data.data.list;
  478. }
  479. })
  480. },
  481. logout() { // 添加 logout 方法
  482. localStorage.removeItem('userInfo');
  483. localStorage.removeItem('token');
  484. this.userInfo = null;
  485. },
  486. copy(){
  487. const text = window.location.href;
  488. navigator.clipboard.writeText(text)
  489. .then(() => {
  490. alert('链接已复制,求分享给好友吧!');
  491. })
  492. .catch((error) => {
  493. alert('复制失败,请重试。');
  494. console.error('复制失败:', error);
  495. });
  496. }
  497. }
  498. }).mount('#app');
  499. </script>
  500. </body>
  501. </html>