我正在寻找为我所拥有的Electron安装部署自动更新功能,但是我发现很难在网络上找到任何资源.
我之前使用Adobe Air构建了一个自包含的应用程序,编写更新代码似乎更容易,有效地检查了URL并自动下载并安装了跨Windows和MAC OSX的更新.
我目前正在使用电子样板来简化构建.
我有几个问题:
我目前正在将Backbone视为一种组织我们的javascript文件并为我们的代码创建一个干净结构的方法.
我的问题主要是"最佳实践"问题.
该库运行良好,我已成功设置AMD和requirejs的结构.我的问题涉及我正在运行的几个实用程序文件.一个从XML文档获取数据并将其转换为json数据对象(因此可以对数据进行本地化).另一个是加载并连接到Facebook的实用程序.我已将这两个创建为"模型".
可以说这些模型应该是"控制器",因为它们连接到服务但是需要调用这些模型而不需要浏览到路由器(或控制器)文件中的hashbang.
我应该扩展这两个实用程序文件的主干模型,还是我应该做些什么来实现这样的实用程序文件?
我在配置对象中有这两个布尔变量,我将它传递给angular应用程序的常量.
在页面结算时检查这些布尔值.如果两者都为真,则它将保留在页面中,如果其中一个或另一个为真,则会将用户弹回指定的页面.
请参阅下面的代码
angular
.module('ecardGeneratorPrototype')
.constant('config',
{
"enable-file-upload": true,
"enable-webcam": true
Run Code Online (Sandbox Code Playgroud)
然后我在一个解析函数中检查这些:
.when('/home', {
templateUrl: 'app/home/home.html',
controller: 'HomeController',
controllerAs: 'home',
resolve : {
choice: ['$route', '$window', 'config', function ($route, $window, config) {
if ( config["enable-file-upload"] && config["enable-webcam"] ){
//return
return;
}
else
{
if ( config["enable-file-upload"] ){
//go to the file upload page
//$log( "display the file upload page" );
$window.location.href = '#/file-upload';
}
else if ( config["enable-webcam"] ){
//$log( "display the webcam page" );
$window.location.href = '#/webcam';
}
} …Run Code Online (Sandbox Code Playgroud) 有没有人知道目前是否有办法过滤掉/ me/checkins调用返回的签到,以便它只选择当天检查的地点?
我正在尝试移植PHP preg_match表达式以从Javascript中的YouTube嵌入代码中提取视频ID.我目前在PHP中有这个:
$pattern = '%(?:https?://)?(?:www\.)?(?:youtu\.be/| youtube\.com(?:/embed/|/v/|/watch\?v=))([\w-]{10,12})[a-zA-Z0-9\<\>\"]%x';
$result = preg_match($pattern, $url, $matches);
Run Code Online (Sandbox Code Playgroud)
这有效,并返回一个视频ID.我尝试使用以下内容,以使其在Javascript中工作:
var reg = /(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=))([\w-]{10,12})/g;
var matches = uploadVideoEmbedCode.match(reg);
Run Code Online (Sandbox Code Playgroud)
我使用的测试数据是:
<iframe width="560" height="315" src="http://www.youtube.com/embed/1NMUDb3Ewhs" frameborder="0" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)
当我尝试在javascript中使用上面的正则表达式时,我收到以下错误:
未捕获的SyntaxError:意外的令牌?
非常感谢您的帮助.
javascript ×3
jquery ×2
air ×1
amd ×1
angularjs ×1
backbone.js ×1
electron ×1
facebook ×1
macos ×1
preg-match ×1
protractor ×1
regex ×1
requirejs ×1
windows ×1