我一直在一起学习 wxWidgets 和 C++,这非常令人兴奋。我一直在使用我能找到的所有在线教程,并且已经购买并正在阅读这本书。我很清楚许多教程(和这本书)已经过时了,所以我学习的一部分是将示例带到当前的实践中。
例如,我已将 wxwidgets wiki 上的“您的第一个应用程序”教程转换为使用动态 Bind() 而不是事件表,并将对 wxEVT_COMMAND_MENU_SELECTED 的引用更新为更新和首选的 wxEVT_MENU:
MyFrame::MyFrame(const wxString &title) : wxFrame(nullptr, wxID_ANY, title) {
MainMenu = new wxMenuBar();
wxMenu *FileMenu = new wxMenu;
MainMenu->Append(FileMenu, _T("File"));
SetMenuBar(MainMenu);
CreateStatusBar(1);
FileMenu->Append(MENU_New, _T("&New"), _T("Create a new file"));
FileMenu->Append(MENU_Open, _T("&Open"), _T("Open an existing file"));
FileMenu->Append(MENU_Close, _T("&Close"), _T("Close the current document"));
FileMenu->Append(MENU_Save, _T("&Save"), _T("Save the current document"));
FileMenu->Append(MENU_SaveAs, _T("Save &As"), _T("Save current document with new name"));
FileMenu->Append(MENU_Quit, _T("&Quit"), _T("Quit the editor"));
Bind(wxEVT_MENU, &MyFrame::NewFile, this, MENU_New);
Bind(wxEVT_MENU, &MyFrame::OpenFile, this, MENU_Open); …Run Code Online (Sandbox Code Playgroud) 我一直在测试新的 Slim 4 框架,并且重定向在普通类中对我来说工作得很好,但我似乎无法让它们在中间件中工作,中间件中的响应是由请求处理程序动态生成的(显然?)。当我尝试使用 Location 标头进行重定向时,它根本无法重定向,并且我的路线继续到原始位置。
\n\n这里\xe2\x80\x99是我用于测试的身份验证中间件的基本版本:
\n\nuse Psr\\Http\\Message\\ServerRequestInterface as Request;\nuse Psr\\Http\\Message\\ResponseInterface as Response;\nuse Psr\\Http\\Server\\RequestHandlerInterface as RequestHandler;\n\nclass AuthMiddleware extends Middleware {\n\n public function __invoke(Request $request, RequestHandler $handler): Response {\n $response = $handler->handle($request);\n $loggedInTest = false;\n if ($loggedInTest) {\n echo "User authorized.";\n return $response;\n } else {\n echo "User NOT authorized.";\n return $response->withHeader(\'Location\', \'/users/login\')->withStatus(302);\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n有人让这个工作吗?如果是这样,你是如何实现的?提前致谢。
\n我正在开发一个 Flutter 应用程序,每个用户都可以创建项目并与其他用户共享项目。我创建了一个“共享”集合,其中每个用户的 ID 都是一个文档,在该文档中,与该用户共享的所有项目 ID 都像这样收集,并使用一个布尔值来表示共享是否已被共享。尚未接受:
接下来,我创建了项目本身的集合,如下所示:
现在,我想查询“项目”集合并仅返回给定用户的“共享”列表中的项目。首先,如何获取共享列表中每个文档的ID?其次,是否可以使用子句将该 ID 与列表的内容进行比较.where()?
我一直在尝试这样的事情,但没有成功:
Stream<List<Map<String, dynamic>>> getListOfProjectsForUser({@required List<String> shares}) {
var ref = _firestore.collection('projects');
return ref
.where(shares, arrayContains: ref.id)
.snapshots()
.map((QuerySnapshot snapshot) => snapshot.docs.map((DocumentSnapshot doc) => doc.data()).toList());
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个:
Stream<List<Map<String, dynamic>>> getListOfProjectsForUser({@required List<String> shares}) {
var ref = _firestore.collection('projects');
return ref
.where(shares, arrayContains: FieldPath.documentId)
.snapshots()
.map((QuerySnapshot snapshot) => snapshot.docs.map((DocumentSnapshot doc) => doc.data()).toList());
}
Run Code Online (Sandbox Code Playgroud)
我想做的事情可能吗?我已经搞砸了两天了,我的头爆炸了。任何帮助将不胜感激。提前致谢。
我刚刚学习 Flutter,并尝试使用 StreamBuilder 在用户注销时显示登录/注册页面,或者在用户登录时显示个人资料页面。我的代码如下:
认证服务:
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class AuthUser {
AuthUser({@required this.uid, @required this.email});
final String uid;
final String email;
}
abstract class AuthBase {
Future<AuthUser> currentUser();
Future<AuthUser> signIn({String email, String pw});
Future<AuthUser> registerUser({String email, String pw});
Stream<AuthUser> get onAuthStateChanged;
Future<void> signOut();
}
class Auth implements AuthBase {
final _firebaseAuth = FirebaseAuth.instance;
AuthUser _userFromFirebase(FirebaseUser user) {
if (user != null) {
return AuthUser(uid: user.uid, email: user.email);
} else {
return null;
}
}
@override
Stream<AuthUser> get onAuthStateChanged { …Run Code Online (Sandbox Code Playgroud)