55 <a
66 :href =" 'https://linux.do/t/topic/' + item.id"
77 @click =" handleLinkClick($event, item.id)"
8- class =" news-link"
9- >
8+ class =" news-link" >
109 {{ item.title }}
1110 </a >
11+ </div >
12+ <div class =" news-meta" >
1213 <em >{{ item.highest_post_number }}</em >
13- <button class =" preview-btn" @click =" previewPost(item.id)" title =" 设为已读" >
14+ <button
15+ class =" preview-btn"
16+ @click =" previewPost(item.id)"
17+ title =" 设为已读" >
1418 <svg
1519 xmlns =" http://www.w3.org/2000/svg"
1620 width =" 16"
2024 stroke =" currentColor"
2125 stroke-width =" 2"
2226 stroke-linecap =" round"
23- stroke-linejoin =" round"
24- >
27+ stroke-linejoin =" round" >
2528 <path d =" M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
2629 <circle cx =" 12" cy =" 12" r =" 3" />
2730 <path d =" M12 1v6m0 6v6" />
3538
3639<script >
3740export default {
38- props: [" list" ],
39- emits: [" remove-item" ],
41+ props: [' list' ],
42+ emits: [' remove-item' ],
4043 data () {
41- return {
42-
43- };
44+ return {};
4445 },
4546 methods: {
4647 async handleLinkClick (event , itemId ) {
@@ -51,7 +52,7 @@ export default {
5152 const targetUrl = ` https://linux.do/t/topic/${ itemId} ` ;
5253
5354 try {
54- const browserAPI = typeof browser !== " undefined" ? browser : chrome;
55+ const browserAPI = typeof browser !== ' undefined' ? browser : chrome;
5556
5657 // 查询当前活动的标签页
5758 const tabs = await new Promise ((resolve ) => {
@@ -80,32 +81,32 @@ export default {
8081 }
8182
8283 // 向父组件发送移除事件
83- this .$emit (" remove-item" , itemId);
84+ this .$emit (' remove-item' , itemId);
8485 },
8586
8687 previewPost (itemId ) {
8788 // 后台预览帖子,保持用户登录状态
88- console .log (" 开始后台预览帖子:" , itemId);
89+ console .log (' 开始后台预览帖子:' , itemId);
8990 this .loadPostInBackground (` https://linux.do/t/topic/${ itemId} ` );
9091 // 预览后也移除这条目
91- this .$emit (" remove-item" , itemId);
92- this .$message .success (' 设为已读!' )
92+ this .$emit (' remove-item' , itemId);
93+ this .$message .success (' 设为已读!' );
9394 },
9495
9596 loadPostInBackground (url ) {
9697 // 创建隐藏的 iframe 来加载页面,保持用户登录状态
97- const iframe = document .createElement (" iframe" );
98- iframe .style .display = " none" ;
99- iframe .style .width = " 0 " ;
100- iframe .style .height = " 0 " ;
101- iframe .style .border = " none" ;
102- iframe .style .position = " absolute" ;
103- iframe .style .left = " -9999px" ;
98+ const iframe = document .createElement (' iframe' );
99+ iframe .style .display = ' none' ;
100+ iframe .style .width = ' 0 ' ;
101+ iframe .style .height = ' 0 ' ;
102+ iframe .style .border = ' none' ;
103+ iframe .style .position = ' absolute' ;
104+ iframe .style .left = ' -9999px' ;
104105 iframe .src = url;
105106
106107 // 监听加载完成
107108 iframe .onload = () => {
108- console .log (" 后台预览完成:" , url);
109+ console .log (' 后台预览完成:' , url);
109110 // 延迟移除 iframe,确保页面完全加载
110111 setTimeout (() => {
111112 if (iframe .parentNode ) {
@@ -116,16 +117,15 @@ export default {
116117
117118 // 错误处理
118119 iframe .onerror = () => {
119- console .error (" 后台预览失败:" , url);
120+ console .error (' 后台预览失败:' , url);
120121 if (iframe .parentNode ) {
121122 document .body .removeChild (iframe);
122123 }
123124 };
124125
125126 // 添加到页面
126127 document .body .appendChild (iframe);
127- },
128-
129- },
128+ }
129+ }
130130};
131131 </script >
0 commit comments