介绍
\n我正在运行 flutter v1.17.5 DeviceApps v1.0.10 和 SystemAlertWindow v0.2.2+3 (有意不是最新版本)。我想从在前台运行的系统警报窗口打开我的应用程序,即使应用程序已关闭。
\n我正在使用SystemOverlayWindow插件,该插件是一个 Activity SystemAlertWindowPlugin.java
\n在我的Application.kt中,我注册插件并传递注册表
\npublic class Application: FlutterApplication(), PluginRegistrantCallback {\n\n override fun onCreate() {\n super.onCreate();\n FlutterFirebaseMessagingService.setPluginRegistrant(this);\n SystemAlertWindowPlugin.setPluginRegistrant(this);\n createNotificationChannels();\n FlutterMain.startInitialization(this);\n }\n\n override fun registerWith(registry: PluginRegistry?) {\n if (!registry!!.hasPlugin("io.flutter.plugins.firebasemessaging")) {\n FirebaseMessagingPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));\n }\n if (!registry!!.hasPlugin("in.jvapps.system_alert_window")) {\n SystemAlertWindowPlugin.registerWith(registry!!.registrarFor("in.jvapps.system_alert_window"));\n }\n if (!registry!!.hasPlugin("fr.g123k.deviceapps")) {\n DeviceAppsPlugin.registerWith(registry!!.registrarFor("fr.g123k.deviceapps"));\n }\n }\nRun Code Online (Sandbox Code Playgroud)\n我还注册了另一个名为DeviceApps的插件。这是DeviceAppsPlugin DeviceAppsPlugin.java
\n问题
\n简而言之
\n因此,系统覆盖层(在前台运行)调用 > dart 回调 > 调用 DeviceApps 插件的方法 > 发生错误
\n …我查看了 Bootstrap 5 的文档,但我似乎找不到使用像素的最小宽度类?有没有?
你怎么能在一个非Monobehaviour阶级的实例中传递Monobehaviour?我找到了这个链接,TonyLi提到你可以通过一个Monobehaviour来启动和停止一个类的实例中的协同程序,但他没有说明你怎么能这样做.他做了这个theEvent.StartEvent(myMonoBehaviour); 但是他并没有表明他从哪里获得了我的神经行为.我在互联网上环顾四周,但我似乎无法找到.
这是我想要做的.我想在一个类的实例中运行一个协同程序.我还希望能够在类的实例中停止协程.我想这样做,以便我的场景中没有任何具有大型管理器的对象,并且我可以将代码重用于我想以这种方式打乒乓的任何对象.代码在一个方向上移动一个Gameobject然后休息一下并将其向另一个方向移动并再次休息等等.但我不能从课外开始协同程序.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[RequireComponent (typeof(Image))]
public class SpecialBar : MonoBehaviour {
public float rangeX;
public float breakTime;
public float step;
float startProgress = 0.5f;
PingPongGameObject pingPonger;
Color[] teamColors = new Color[]{new Color(255,136,0),new Color(0,170,255)};
void Start()
{
for(int i = 0; i < teamColors.Length; ++i)
{
teamColors[i] = StaticFunctions.NormalizeColor (teamColors[i]);
}
pingPonger = new PingPongGameObject (gameObject.transform.position,
new Vector3(rangeX,0.0f,0.0f),
gameObject,
startProgress,
breakTime,
step
);
}
}
Run Code Online (Sandbox Code Playgroud)
第二堂课是我的协程所在的地方.
public class PingPongGameObject
{
float step; …Run Code Online (Sandbox Code Playgroud) 我可以使用 GetX 查看导航器堆栈吗?我查看了文档,但找不到有关此主题的任何内容。我通常会关闭这样的对话框
Get.until((route) => !Get.isDialogOpen);
Run Code Online (Sandbox Code Playgroud)
但我想知道如果特定页面的实例位于路由历史记录中,我是否可以关闭路由,如下所示
Get.until((route) => !Get.routingHistory.contains('/someRoute'));
Run Code Online (Sandbox Code Playgroud)
请注意,这不是有效的语法。
我有以下型号
type PrivateGormModel struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
}
type Employee struct {
PrivateGormModel
Person `gorm:"embedded" json:"person,omitempty"`
Contact `gorm:"embedded" json:"contact,omitempty"`
Address `gorm:"embedded" json:"address,omitempty"`
AltContact `gorm:"embedded" json:"privateContact,omitempty"`
BankAccount `gorm:"embedded" json:"bankAccount,omitempty"`
EmployeeGroupID uint `json:"groupID"`
EmployeeGroup `json:"group"`
EmployeeRoleID uint `json:"roleID"`
EmployeeRole `json:"role"`
}
func (e Employee) Validate() error {
return validation.ValidateStruct(&e,
validation.Field(&e.Person, validation.Required),
validation.Field(&e.Contact),
validation.Field(&e.Address),
validation.Field(&e.AltContact),
validation.Field(&e.BankAccount),
validation.Field(&e.EmployeeGroup),
validation.Field(&e.EmployeeRole),
)
}
type EmployeeGroup struct {
PrivateGormModel
Title string `json:"title" gorm:"primaryKey;unique"`
}
func (e …Run Code Online (Sandbox Code Playgroud) 我有一个带有 pixi.js 的 javascript 画布游戏,需要玩家按下特定的按钮组合才能完成关卡。他们基本上必须按下与某种颜色相匹配的按钮。
事实证明,玩家正在用 Python 编写机器人来完成这项任务,并且他们每次都获得最高分。该游戏已经上线,用户喜欢玩它,所以我无法真正改变任何游戏玩法。
所以我考虑了一些可能的解决方案,但我有一些担忧
验证码会损害用户体验,并且有大量视频介绍如何绕过它。在机器人的创建者了解发生了什么之后,2 和 3 将失败。所以我真的被困在我能做的事情上。
每当我尝试使用 打开 URL 时window.open(),都不会打开任何窗口。所以我尝试了这个
<input
id="googleLink"
onclick="window.open('https://www.google.com', '_blank');"
style="display: none"
>
Run Code Online (Sandbox Code Playgroud)
我尝试用 Typescript 点击它
this.googleLink = document.getElementById("googleLink") as HTMLElement;
this.googleLink.click();
Run Code Online (Sandbox Code Playgroud)
并阅读此内容
window.open(url, '_blank'); 无法在 iMac/Safari 上运行
但这些都没有帮助。我没有在异步函数中运行我的代码。我能做些什么?我有 iPhone 11 和 7,两者均无法使用。它在安卓和电脑上运行得很好。我需要在新窗口中打开该 URL。
我需要用 来执行此操作,onClick因为我使用的是 pixi js 并且它是一个被单击的 pixi 容器。
设置 href 也无济于事,因为我希望页面在新选项卡中打开。
我有以下文本字段
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Playground',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Scaffold(
backgroundColor: Colors.green,
body: Align(
alignment: Alignment.bottomCenter,
child: ResponsiveInput(),
),
);
}
}
class ResponsiveInput extends StatelessWidget {
const ResponsiveInput({Key? key}) : …Run Code Online (Sandbox Code Playgroud) 我目前正在使用以下包,其中自述文件说明了以下内容
final bool loaded = await JsIsolatedWorker().importScripts(['test.js']);
Run Code Online (Sandbox Code Playgroud)
我正在使用隔离工作程序包,因此我的代码可以在网络上和网络外工作。我想从我的 dart 代码生成 javascript 代码。我有一个具有顶级功能的文件,我使用
dart compile js -O0 -o test.js test.dart
Run Code Online (Sandbox Code Playgroud)
我在这里找到的
https://dart.dev/tools/dart2js
这是我的 dart 文件
void main(List<String> args) {
doComputation('');
}
String doComputation(String input) {
return 'output';
}
Run Code Online (Sandbox Code Playgroud)
仅当我有一个 main 函数时,我才能生成 javascript,但这会生成一个 javascript 文件,其中 doComutation 不是顶级函数,所以我不确定包是否可以调用该函数。看起来它生成了整个程序,而不仅仅是生成一个函数。
生成的文件太长,无法发布
所以我的问题归根结底是这样的。有没有办法从 dart 为 1 个函数生成 javascript 并包含其依赖项,而不必生成整个程序?这样我就可以从 dart 调用这个函数。
我的应用程序具有以下文件夹结构
app
core
features
feature1
domain
entities
entity1
entity2
entity3
entity4
entity5
entity6
data
models
model1
model2
model3
model4
model5
model6
presentation
feature2
domain
entities
entity1
entity2
entity3
entity4
entity5
entity6
data
models
model1
model2
model3
model4
model5
model6
presentation
Run Code Online (Sandbox Code Playgroud)
这两个功能的模型 1 到 6 完全相同,并且随着应用程序的扩展,还会有更多功能出现。这变得越来越难以维护。干净的架构是否允许跨多个功能共享模型和实体?这是通过核心文件夹完成的吗?
flutter ×4
dart ×3
javascript ×2
typescript ×2
android ×1
bootstrap-5 ×1
bots ×1
c# ×1
dart2js ×1
flutter-get ×1
go ×1
go-gorm ×1
html ×1
java ×1
json ×1
pixi.js ×1
window.open ×1