问题描述
我是使用 react.js 的 MobX 新手,我很高兴能探索更多有关 react 的信息。我在谷歌上搜索了很多,并在以下链接的帮助下尝试了示例,但没有运气。
有人可以介入并帮助我吗?我将此作为 POC 来启动我的项目。这是一个阻滞剂,对我来说意义重大
model.ts
Private Sub Bw_DoWork(sender As Object,e As DoWorkEventArgs)
Dim d = DirectCast(e.Argument,BwData).Path
Dim s = DirectCast(e.Argument,BwData).Start
Dim reader As IO.StreamReader = My.Computer.FileSystem.OpenTextFileReader(d)
Dim l As String
Dim lineIndex As Integer = 0
Dim linestart As Integer = 0
Dim part As String() = nothing
Try
Using ctx = New ContentsDBEntities
Dim rowN = s 'Math.Max(ctx.xHamster.Count - 100,1)
Do
l = reader.ReadLine
If l Is nothing Then
Exit Do
End If
part = l.Split("|")
If Bw.CancellationPending Then Exit Do
If lineIndex >= rowN AndAlso part.Length >= 14 Then
If lineIndex = rowN Then
linestart = lineIndex
startAt = Now
End If
Dim vId = part(0)
If IsNumeric(vId) Then
Dim there = (From c In ctx.xHamster Where c.VideoId = vId Select c).FirstOrDefault
If there Is nothing Then
Dim r = New xHamster With {
.VideoId = vId,.Url = part(1),.Umbed_Url = part(2),.Title = part(3),.Duration = StringToSec(part(4)),.dateAdded = Date.Parse(part(5)),.Thumb = part(6),.Channels = part(7),.Pornstars = part(8),.MaxResolution = part(9),.Orientation = part(10),.Title_RU = part(11),.Username = part(12),.Description = part(13)}
ctx.xHamster.Add(r)
If lineIndex Mod 100 = 0 Then
ctx.SaveChanges()
End If
End If
End If
End If
lineIndex += 1
DirectCast(sender,BackgroundWorker).ReportProgress(lineIndex,linestart)
Loop Until l Is nothing
reader.Close()
ctx.SaveChanges()
End Using
Catch ex As Exception
Debug.Print(ex.Message)
End Try
End Sub
agent.ts
export interface IActivity {
id: string;
title: string;
description: string;
category: string;
date: string;
city: string;
venue: string;
}
activityStore.ts
import axios,{ AxiosResponse } from 'axios';
axios.defaults.baseURL = 'https://localhost:xxx/api';
const responseBody = (response: AxiosResponse) => response.data;
const requests = { get: (url: string) => axios.get(url).then(responseBody) };
const Activities = { list: () => requests.get('/activities/getactivities') };
// eslint-disable-next-line import/no-anonymous-default-export
export default { Activities };
App.tsx
import { observable,action,makeObservable } from 'mobx';
import { createContext } from 'react';
import { IActivity } from './../models/agent';
import agent from '../api/agent';
class ActivityStore {
@observable activities: IActivity[] = [];
constructor() {
makeObservable(this);
}
@action loadActivities = () => {
agent.Activities.list().then((response) => {
this.activities.push(response);
});
};
}
export const activityStoreContext = createContext(new ActivityStore());
package.json
边缘浏览器的输出(在 chrome 和 firefox 中也相同)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)