Skip to content

Commit

Permalink
feat: extension detail support web preview
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Jul 4, 2022
1 parent 82b3a01 commit f41420d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ExtensionDetailComponent implements OnInit {
this.route.snapshot.queryParams.id,
this.route.snapshot.queryParams.name
);
if (!this.extensionDetail?.introduction && !this.extensionDetail?.installed) {
if (!this.extensionDetail?.installed) {
await this.fetchReadme();
}
this.extensionDetail.introduction ||= $localize`This plugin has no documentation yet.`;
Expand All @@ -41,10 +41,8 @@ export class ExtensionDetailComponent implements OnInit {
async fetchReadme() {
try {
this.introLoading = true;
const htmlText = await (await fetch(`https://www.npmjs.com/package/${this.extensionDetail.name}`)).text();
const domParser = new DOMParser();
const html = domParser.parseFromString(htmlText, 'text/html');
this.extensionDetail.introduction = html.querySelector('#readme').innerHTML;
const htmlText = await (await fetch(`https://unpkg.com/${this.extensionDetail.name}/README.md`)).text();
this.extensionDetail.introduction = htmlText;
} catch (error) {
} finally {
this.introLoading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { lastValueFrom } from 'rxjs';
import { ModuleInfo } from '../../utils/module-loader';
import { EoExtensionInfo } from './extension.model';

const HOST = isElectron()
? 'http://106.12.149.147'
: 'https://mockapi.eolink.com/ztBFKai20ee60c12871881565b5a6ddd718337df0e30979';
const HOST = 'http://106.12.149.147';
@Injectable()
export class ExtensionService {
ignoreList = ['default'];
Expand Down

0 comments on commit f41420d

Please sign in to comment.