我有一个文件fetchPosts(),它负责从服务器获取新帖子并将它们存储在本地 sqlite 数据库中。
按照 sqflite doc上的建议,我将单个引用存储到我的数据库中。
这是我的database.dart文件的内容:
import 'dart:async';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
class DBProvider {
DBProvider._();
static final DBProvider db = DBProvider._();
static Database _database;
static Future<Database> get database async {
if (_database != null) return _database;
// if _database is null, we instantiate it
_database = await _initDB();
return _database;
}
static Future<Database> _initDB() async {
final dbPath = await getDatabasesPath();
String path = join(dbPath, 'demo.db');
return await openDatabase(path, version: 1, onCreate: _onCreate); …Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个网站,其中导航栏项目取决于登录用户的角色.
正如Patrick Walter在他的博客上建议的那样,我正在考虑创建一个session.js文件,在那里我将存储有关当前用户的信息:他们的用户名和角色.然后我会在nav-bar.js中注入此文件,并为路由创建一个过滤器,用户无权访问.一切正常,直到我点击刷新按钮...事实上,它创建了一个新的会话对象,我松开了前一个中的所有信息存储.
我在文档中看到了单例方法,但我不确定如何使用它.如果我将它插入我的代码中,如下所示,我收到消息:aurelia.use.singleton is not a function.
import config from './auth-config';
export function configure(aurelia) {
console.log('Hello from animation-main config');
aurelia.use
.singleton(Session)
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-animator-css')
.plugin('paulvanbladel/aurelia-auth', (baseConfig) => {
baseConfig.configure(config);
});
aurelia.start().then(a => a.setRoot());
}
export class Session {
username = '';
role = '';
reset() {
console.log('Resetting session');
this.username = '';
this.role = '';
};
}
Run Code Online (Sandbox Code Playgroud)
我的最后一个想法是加密角色/用户名并使用浏览器的会话来存储信息.但我想向更有经验的开发人员询问他们对该主题的看法.
谢谢你的帮助!
编辑:这是我的session.js代码
export class Session {
username = '';
role = '';
reset() {
console.log('Resetting …Run Code Online (Sandbox Code Playgroud) 在 iOS 上,当我单击 URL 时,它会打开我的 Flutter 应用程序,但仍保留在主屏幕上。它不会转到给定页面。
\n例如,如果链接是https://my-app.com/page1,应用程序将直接转到/
这是 AASA:
\n.well-known/apple-app-site-association
{\n "applinks": {\n "apps": [],\n "details": [\n {\n "appID": "com.my-app",\n "paths": ["*"]\n }\n ]\n }\n}\nRun Code Online (Sandbox Code Playgroud)\nios/Runner/Runner.entitlements
<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n <key>aps-environment</key>\n <string>development</string>\n <key>com.apple.developer.associated-domains</key>\n <array>\n <string>applinks:my-app.com</string>\n <string>applinks:my-app-staging.com</string>\n </array>\n</dict>\n</plist>\n\nRun Code Online (Sandbox Code Playgroud)\n如果我检查https://search.developer.apple.com/appsearch-validation-tool中的网址,一切都会通过。
\n我的应用程序使用 go_router 5.0.1
\n<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n <key>aps-environment</key>\n <string>development</string>\n <key>com.apple.developer.associated-domains</key>\n <array>\n <string>applinks:my-app.com</string>\n <string>applinks:my-app-staging.com</string>\n </array>\n</dict>\n</plist>\n\nRun Code Online (Sandbox Code Playgroud)\n我尝试在重定向中放置断点,但它从未被执行。 …
我正在尝试使用doc之后的代码优先方法添加自定义指令。现在,我使用完全相同的上层指令。但是,该指令似乎没有效果,并且代码从未通过我的自定义函数。
在app.module.ts:
GraphQLModule.forRoot({
autoSchemaFile: 'src/schema.gql',
buildSchemaOptions: {
dateScalarMode: 'timestamp',
schemaDirectives: {
upper: UpperCaseDirective, // no effect
},
},
schemaDirectives: {
upper: UpperCaseDirective, // no effect
},
playground: true,
introspection: true,
debug: true,
// Allow guards and middleware to access req and headers
context: ({ req }) => ({
req,
headers: req.headers,
databaseConnection: req.databaseConnection,
updatedAt: req.updatedAt,
}),
}),
Run Code Online (Sandbox Code Playgroud)
这是我的依赖项package.json:
{
"dependencies": {
"@nestjs/common": "^7.3.2",
"@nestjs/core": "^7.3.2",
"@nestjs/graphql": "^7.5.5",
"@nestjs/jwt": "^7.1.0",
"@nestjs/passport": "^7.1.0",
"@nestjs/platform-express": "^7.3.2",
"@nestjs/typeorm": …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个小部件拖动到 InteractiveViewer 之上。
当比例为 1.0 时,代码运行良好。
但是,如果放大,当我拖动圆圈时:
为什么会发生这种情况?
这是一个演示,说明了我正在谈论的内容:
下面是这个应用程序的代码
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
enum _Action { scale, pan }
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() …Run Code Online (Sandbox Code Playgroud) 我有两张桌子objectTable和photo_table. 这是来自的示例数据objectTable
ID TEXT
1 Kaunas
2 Vilnius
3 Palanga
4 Prienai
Run Code Online (Sandbox Code Playgroud)
这里的数据来自 photo_table
OBJECT_ID PHOTO_ID NAME
1 7 tets7.jpg
1 8 tets8.jpg
1 9 tets9.jpg
1 10 tets10.jpg
1 11 tets11.jpg
2 3 tets3.jpg
2 2 tets2.jpg
3 1 tets1.jpg
3 5 tets5.jpg
4 6 tets6.jpg
4 7 tets7.jpg
4 8 tets8.jpg
Run Code Online (Sandbox Code Playgroud)
所以你可以看到一个对象可以有很多图片。我需要获得 evty 对象的第一张照片(我的输出应该是)
ID TEXT NAME
1 Kaunas tets7.jpg
2 Vilnius tets3.jpg
3 Palanga tets1.jpg
4 Prienai tets6.jpg
Run Code Online (Sandbox Code Playgroud)
这是我的查询:
select *
from …Run Code Online (Sandbox Code Playgroud) flutter ×3
aurelia ×1
draggable ×1
graphql ×1
graphql-js ×1
interactive ×1
nestjs ×1
sqflite ×1
sql ×1
sqlite ×1
unit-testing ×1