detail.html 21 KB

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