@@ -5,7 +5,7 @@ import $ from 'jquery'
55import myblog from './myblog.json'
66import dayjs from 'dayjs'
77
8-
8+ const postContainerClass = `w-full flex flex-col gap-6 break-words pb-10`
99const postClass = `weibopost bg-white flex-col pt-5 pb-8 px-8 rounded-md flex-col`
1010const postInsideClass = ` flex flex-col gap-3 w-full max-h-[50rem] overflow-y-scroll`
1111const textClass = ``
@@ -17,17 +17,30 @@ const videoContainerClass = `video flex flex-col items-center flex-wrap gap-2 mb
1717const videoClass = `cursor-pointer object-cover rounded-xl max-h-[38rem] w-fit`
1818const titleClass = `flex flex-col text-gray-500 text-sm italic`
1919
20+ const userInfoContainerClass = ` w-full h-32`
21+ const userInfoInsideClass = `py-4 fixed flex flex-row justify-start items-center gap-6 bg-gray-100 z-10 w-[46rem]`
22+ const userImageContainerClass = `flex w-24 h-24`
23+ const userImageClass = `rounded-full w-24 h-24`
24+
25+ const userProfileContainerClass = `flex flex-col text-black`
26+
27+ const weiboBaseUrl = `https://weibo.com`
28+
2029const start = async ( ) => {
2130 console . log ( `start` , start )
2231 console . log ( myblog )
23- const list = myblog . list
32+ const user = myblog . user || { }
33+ const list = myblog . list || [ ]
2434
2535 let isLoaded = false ;
2636 $ ( document ) . ready ( function ( ) {
2737 if ( isLoaded ) return ;
2838 isLoaded = true ;
2939 const $body = $ ( document . body ) ;
30- const $postsContainer = $body . find ( "#weibo-extend-posts" )
40+ const $weiboExtendPosts = $body . find ( "#weibo-extend-posts" )
41+ const $postsContainer = $ ( "<div>" ) . attr ( "id" , "#weibo-extend-post-container" ) . addClass ( postContainerClass )
42+ appendUserInfo ( { $container : $weiboExtendPosts , userInfo : user } )
43+ $weiboExtendPosts . append ( $postsContainer )
3144 _ . each ( list , item => {
3245 const { text, text_raw, picShows, region_name, source, created_at, retweetedBlog} = item || { }
3346 const $post = appendBlog ( { $container : $postsContainer , blogItem : item , postClass : postClass } )
@@ -40,6 +53,31 @@ const start=async ()=>{
4053
4154start ( )
4255
56+ const appendUserInfo = ( { $container, userInfo} : Record < string , any > ) => {
57+ if ( _ . isEmpty ( userInfo ) ) return ;
58+ const { picShow, screen_name, profile_url, idstr } = userInfo || { }
59+ const $userInfoContainer = $ ( "<div>" ) . addClass ( userInfoContainerClass ) ;
60+ const $userImageContainerDiv = $ ( "<div>" ) . addClass ( userImageContainerClass )
61+ const $userImage = $ ( "<img>" ) . addClass ( userImageClass ) . attr ( "src" , `./image/${ picShow } ` )
62+ $userImageContainerDiv . append ( $userImage )
63+
64+ const $userProfileContainer = $ ( "<div>" ) . addClass ( userProfileContainerClass ) ;
65+ const $userNameDiv = $ ( "<div>" ) . addClass ( `flex text-xl font-bold cursor-pointer` ) . append ( $ ( "<span>" ) . text ( screen_name ) )
66+ $userNameDiv . click ( function ( ) {
67+ const userUrl = profile_url ? `${ weiboBaseUrl } ${ profile_url } ` : ( idstr ? `${ weiboBaseUrl } /u/${ idstr } ` : '' )
68+ if ( userUrl ) {
69+ window . open ( userUrl , "_blank" )
70+ }
71+ } )
72+ $userProfileContainer . append ( $userNameDiv )
73+
74+ const $userInfoInside = $ ( "<div>" ) . addClass ( userInfoInsideClass ) ;
75+ $userInfoInside . append ( $userImageContainerDiv )
76+ $userInfoInside . append ( $userProfileContainer )
77+ $userInfoContainer . append ( $userInfoInside )
78+ $container . append ( $userInfoContainer )
79+ }
80+
4381const appendBlog = ( { $container, blogItem, postClass} : Record < string , any > ) => {
4482 const { text, text_raw, picShows, region_name, source, created_at, user, mediaInfoList, title } = blogItem || { }
4583
@@ -56,9 +94,9 @@ const appendBlog = ({$container, blogItem, postClass}: Record<string, any>)=>{
5694 const userInfoText = `@${ user_screen_name } `
5795 let $userInfoDiv = $ ( "<div>" ) . addClass ( `flex text-base font-bold text-gray-700 hover:text-orange-500 cursor-pointer` ) . append ( $ ( "<span>" ) . html ( userInfoText ) )
5896 $userInfoDiv . click ( function ( ) {
59- const jumpUrl = user_profile_url ? `https://weibo.com ${ user_profile_url } ` : ( user_idstr ? `https://weibo.com /u/${ user_idstr } ` : '' )
97+ const jumpUrl = user_profile_url ? `${ weiboBaseUrl } ${ user_profile_url } ` : ( user_idstr ? `${ weiboBaseUrl } /u/${ user_idstr } ` : '' )
6098 if ( jumpUrl ) {
61- window . open ( `https://weibo.com /u/${ user_idstr } ` , "_blank" ) ;
99+ window . open ( `${ weiboBaseUrl } /u/${ user_idstr } ` , "_blank" ) ;
62100 }
63101 } )
64102 $postInside . append ( $userInfoDiv )
0 commit comments