import * as vscode from "vscode" ; import { webViewPanel } from "../webview/ShareCodeWebview" ; const processContent = ( input , START = 0 , END = 1000 ) => { const NEW_LINE = "\n" ; return new Promise < string > ( ( resolve , reject ) => { if ( START > END ) { return reject ( ) ; } let r = input . split ( NEW_LINE ) . filter ( ( line , index ) => { const CURRENT_LINE = index + 1 ; return CURRENT_LINE >= START && CURRENT_LINE <= END ; } ) . join ( NEW_LINE ) ; let start = r . indexOf ( "*[interview]: start" ) ; let end = r . indexOf ( "*[interview]: end" ) ; let title = r . slice ( 0 , r . indexOf ( "\n" , r . indexOf ( "\n" ) + 1 ) ) ; r = title . concat ( r . slice ( start + 19 , end ) ) ; resolve ( r ) ; } ) ; } ; export async function share ( content , context ) { try { const processedContent = await processContent ( content ) ; webViewPanel ( context , processedContent ) ; vscode . window . showInformationMessage ( "生成成功！" ) ; } catch ( error ) { console . log ( "err" , error ) ; vscode . window . showInformationMessage ( "生成失败！" ) ; } }