detail.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. border-bottom: 1px solid #f5f5f5;
  136. }
  137. .sec_title span{
  138. border-bottom: 3px solid #0065D7;
  139. line-height: 30px;
  140. }
  141. .avatar{
  142. width: 44px;
  143. height: 40px;
  144. border-radius: 50%;
  145. background-color: greenyellow;
  146. margin-right: 15px;
  147. line-height: 40px;
  148. text-align: center;
  149. font-weight: 600;
  150. font-size: 13px;
  151. }
  152. </style>
  153. <body>
  154. <section id="app">
  155. <div style="background-color: #FDC606;box-shadow: 0px 0px 4px 0 rgba(0,0,0,.5);">
  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. </div>
  188. <transition name="slide">
  189. <div class="slide" v-if="show">
  190. <a class="act" href="/index.html">主页</a>
  191. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  192. <a href="https://match.yuanrenxue.cn/" target="_blank">采集进阶课程</a>
  193. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  194. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  195. <a href="https://www.yuanrenxue.cn/" target="_blank">关于猿人学</a>
  196. <a v-if="userInfo" href="/record.html">我的刷题记录</a>
  197. <a v-if="userInfo" @click="logout">退出登录</a>
  198. </div>
  199. </transition>
  200. <div class="content">
  201. <p class="navtation"><a href="/index.html">回到首页</a> - <a :href="'/list.html?cat='+param.category">
  202. <span v-if="detail.category=='crawler'">爬虫</span>
  203. <span v-else-if="detail.category=='js'">JS</span>
  204. <span v-else>安卓</span>面试题</a> - {{detail.name}}</p>
  205. <div class="left search_left pc">
  206. <div class="part">
  207. <p class="search">
  208. <img @click="search" width="20" src="img/search.png" alt="">
  209. <input type="text" v-model="searchKeyword" @input="search" placeholder="题目搜索">
  210. </p>
  211. <ol class="list" id="list">
  212. <li v-for="(item,i) in list" :key="item.interviewId" v-show="i<10">
  213. <a
  214. :href="'/detail.html?cat='+param.category+'&id='+item.interviewId">
  215. <span>{{i+1}}、</span>{{item.name}}</a>
  216. </li>
  217. </ol>
  218. </div>
  219. <div class="part">
  220. <h2 class="sec_title"><span>贡献面试题</span></h2>
  221. <form class="form">
  222. <input v-model="name" type="text" placeholder="面试题目">
  223. <textarea v-model="content"></textarea>
  224. <button type="button" @click="post">提交</button>
  225. </form>
  226. </div>
  227. </div>
  228. <div class="right detail_right">
  229. <div class="part">
  230. <b style="font-size: 28px;color: #000;">{{detail.name}}</b>
  231. <p class="tag">
  232. <span>{{detail.category}}</span>
  233. <a @click="copy"><img style="position: relative;top: 5px;" width="20" src="img/share.png" alt=""> 分享给朋友</a>
  234. </p>
  235. </div>
  236. <div class="part">
  237. <h2 class="sec_title"><span>优秀回答</span></h2>
  238. <div class="discuss answer" v-if="userInfo">
  239. {{detail.content}}
  240. </div>
  241. <div class="discuss" v-else>
  242. <button @click="login">点击登录查看完整内容</button>
  243. </div>
  244. </div>
  245. <div class="part">
  246. <h2 class="sec_title"><span>讨论回答</span></h2>
  247. <div style="display: flex;">
  248. <span class="avatar" :style="{background:getColor()}">
  249. {{userInfo?userInfo.name[0]:'x'}}
  250. </span>
  251. <div class="login_div" v-if="!userInfo" style="width: 90%;">
  252. <button @click="login">你需要<span>注册/登录</span>才可以分享内容哦</button>
  253. </div>
  254. <div class="comment" v-else style="width: 90%;margin-bottom: 15px;">
  255. <textarea v-model="form.content" placeholder="留下你的想法..."></textarea>
  256. <button style="width: 100px;" @click="sendComment">提交评论</button>
  257. </div>
  258. </div>
  259. <template v-for="(item,index) in comment">
  260. <template v-if="index == 0">
  261. <div style="display: flex;">
  262. <span class="avatar" :style="{background:getColor()}">{{item.cname[0]}}</span>
  263. <div>
  264. <p class="user">
  265. <b style="color: #000;">{{item.cname}}</b>
  266. </p>
  267. <p class="ans">
  268. {{item.content}}
  269. </p>
  270. <p class="user">
  271. {{item.ctime}}
  272. </p>
  273. </div>
  274. </div>
  275. </template>
  276. <template v-else-if="index > 0 && userInfo">
  277. <div style="display: flex;">
  278. <span class="avatar" :style="{background:getColor()}">{{item.cname[0]}}</span>
  279. <div>
  280. <p class="user">
  281. <b style="color: #000;">{{item.cname}}</b>
  282. </p>
  283. <p class="ans">
  284. {{item.content}}
  285. </p>
  286. <p class="user">
  287. {{item.ctime}}
  288. </p>
  289. </div>
  290. </div>
  291. </template>
  292. </template>
  293. </div>
  294. </div>
  295. <div class="left search_left phone">
  296. <div class="part">
  297. <p class="search">
  298. <img @click="search" width="20" src="img/search.png" alt="">
  299. <input type="text" v-model="searchKeyword" @input="search" placeholder="题目搜索">
  300. </p>
  301. <ol class="list" id="list">
  302. <li v-for="(item,i) in list" :key="item.interviewId" v-show="i<10">
  303. <a
  304. :href="'/detail.html?cat='+param.category+'&id='+item.interviewId">
  305. <span>{{i+1}}、</span>{{item.name}}</a>
  306. </li>
  307. </ol>
  308. </div>
  309. <div class="part">
  310. <h2 class="sec_title"><span>贡献面试题</span></h2>
  311. <form class="form">
  312. <input v-model="name" type="text" placeholder="面试题目">
  313. <textarea v-model="content"></textarea>
  314. <button type="button" @click="post">提交</button>
  315. </form>
  316. </div>
  317. </div>
  318. </div>
  319. <footer>
  320. <ul>
  321. <li>
  322. <b>爬虫比赛</b> <br>
  323. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  324. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  325. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  326. </li>
  327. <li>
  328. <b>爬虫课程</b> <br>
  329. <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>
  330. <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>
  331. <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>
  332. </li>
  333. <li>
  334. <b>关于猿人学</b> <br>
  335. <a href="https://www.yuanrenxue.cn/tricks" target="_blank">Python技术杂谈</a>
  336. <a href="https://www.yuanrenxue.cn/earn-money" target="_blank">Python爬虫挣钱</a>
  337. </li>
  338. <li class="contact" style="display: flex;line-height: 30px;">
  339. <img style="margin-right: 10px;" width="100" height="100" src="img/wx.jpg" alt="">
  340. 扫一扫加我微信 <br>
  341. 备注面试题 <br>
  342. 拉你进面试交流群
  343. </li>
  344. </ul>
  345. <p>成都老猿智能科技有限公司Copyright @ 2025 猿人学面试 蜀ICP备2022000052号-2</p>
  346. </footer>
  347. </section>
  348. <script src="js/public.js"></script>
  349. <script>
  350. const { createApp } = Vue;
  351. createApp({
  352. data() {
  353. return {
  354. name: '',
  355. content: '',
  356. userInfo: {},
  357. id: '',
  358. detail: {},
  359. comment: [],
  360. form: {
  361. content: '',
  362. interviewName: '',
  363. interviewId: ''
  364. },
  365. searchKeyword: '', // 添加 searchKeyword 变量
  366. list: [], // 添加 list 变量用于存储题目列表
  367. show: 0, // 添加 show 变量,
  368. param: {
  369. page: 1,
  370. page_size: 10
  371. }
  372. }
  373. },
  374. created() {
  375. this.id = new URLSearchParams(window.location.search).get('id') || '';
  376. this.param.category = new URLSearchParams(window.location.search).get('cat') || 'js';
  377. // 获取本地存储的用户ID并赋值给cid
  378. const userInfo = JSON.parse(localStorage.getItem('userInfo'));
  379. this.userInfo = userInfo;
  380. this.getData();
  381. this.getComment();
  382. },
  383. methods: {
  384. login() {
  385. window.location.href = '/login.html';
  386. },
  387. getColor() {
  388. // 生成随机饱和度低的颜色
  389. const r = Math.floor(Math.random() * 128)+120; // 随机生成 0-127 的红色值
  390. const g = Math.floor(Math.random() * 128)+120; // 随机生成 0-127 的绿色值
  391. const b = Math.floor(Math.random() * 128)+120; // 随机生成 0-127 的蓝色值
  392. return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
  393. },
  394. getData() {
  395. // 列表
  396. axios.get(url + '/api/yrx/que/info?interviewId=' + this.id).then(res => {
  397. if (res.data.code === 0) {
  398. this.detail = res.data.data;
  399. this.form.interviewId = this.detail.interviewId;
  400. this.form.interviewName = this.detail.name;
  401. }
  402. });
  403. // 获取题目列表
  404. axios.get(url + '/api/yrx/que/list', { params: this.param }).then(res => {
  405. if (res.data.code === 0) {
  406. this.list = res.data.data.list;
  407. }
  408. });
  409. },
  410. getComment() {
  411. axios.get(url + '/api/yrx/que/comments/list?interviewId=' + this.id).then(res => {
  412. if (res.data.code === 0) {
  413. this.comment = res.data.data.list;
  414. }
  415. });
  416. },
  417. sendComment() {
  418. if (!this.form.content) {
  419. alert('评论内容不能为空');
  420. return;
  421. }
  422. const token = localStorage.getItem('token'); // 获取token
  423. axios.post(url + '/api/yrx/que/comments', this.form, {
  424. headers: {
  425. 'Authorization': `${token}` // 添加token到header
  426. }
  427. })
  428. .then(res => {
  429. if (res.data.code === 0) {
  430. alert('评论成功');
  431. this.form.content = '';
  432. this.getComment();
  433. }
  434. })
  435. .catch(err => {
  436. alert('评论失败,请重试');
  437. console.error(err);
  438. });
  439. },
  440. post() { // 添加post方法
  441. const token = localStorage.getItem('token'); // 获取token
  442. if (!token) {
  443. window.location.href = "/login.html";
  444. return;
  445. }
  446. if (!this.name || !this.content) {
  447. alert('面试题目和内容不能为空');
  448. return;
  449. }
  450. axios.post(url + '/api/yrx/que/user/post', { name: this.name, content: this.content }, {
  451. headers: {
  452. 'Authorization': `${token}` // 添加token到header
  453. }
  454. })
  455. .then(res => {
  456. if (res.data.code === 0) {
  457. alert('提交成功');
  458. this.name = '';
  459. this.content = '';
  460. }
  461. })
  462. .catch(err => {
  463. alert('提交失败,请重试');
  464. console.error(err);
  465. });
  466. },
  467. search() { // 添加 search 方法
  468. axios.get(url + '/api/yrx/que/list', {
  469. params: {
  470. name: this.searchKeyword,
  471. category: this.detail.category,
  472. page: 1,
  473. page_size: 1000
  474. }
  475. })
  476. .then(res => {
  477. if (res.data.code === 0) {
  478. this.list = res.data.data.list;
  479. }
  480. })
  481. },
  482. logout() { // 添加 logout 方法
  483. localStorage.removeItem('userInfo');
  484. localStorage.removeItem('token');
  485. this.userInfo = null;
  486. },
  487. copy(){
  488. const text = window.location.href;
  489. navigator.clipboard.writeText(text)
  490. .then(() => {
  491. alert('链接已复制,求分享给好友吧!');
  492. })
  493. .catch((error) => {
  494. alert('复制失败,请重试。');
  495. console.error('复制失败:', error);
  496. });
  497. }
  498. }
  499. }).mount('#app');
  500. </script>
  501. </body>
  502. </html>