我正在用Ionic2/Cordova/Typescript/Angular做一个测试应用程序.我正在使用tslint 5.6.0.
我正在使用以下模块:https: //www.npmjs.com/package/tslint
专注于一个文件......
当linting以下文件时:
import { NgModule, ErrorHandler } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { IonicApp, IonicModule, IonicErrorHandler } from "ionic-angular";
import { MyApp } from "./app.component";
import { AboutPage } from "../pages/about/about";
import { ContactPage } from "../pages/contact/contact";
import { HomePage } from "../pages/home/home";
import { TabsPage } from "../pages/tabs/tabs";
import { StatusBar } from "@ionic-native/status-bar";
import { SplashScreen } from "@ionic-native/splash-screen";
@NgModule( {
declarations: [
MyApp,
AboutPage,
ContactPage, …
Run Code Online (Sandbox Code Playgroud) 我的Node + Express + Babel + ES6
项目包含以下文件:
/package.json
{
"name": "test-backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "babel-node src/index.mjs",
"build": "babel src --out-dir build",
"start": "node build/index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
},
"devDependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.6",
"@babel/node": "^7.19.1",
"@babel/plugin-transform-runtime": "^7.19.6",
"@babel/preset-env": "^7.19.4",
"babel-plugin-module-extension": "^0.1.3"
}
}
Run Code Online (Sandbox Code Playgroud)
/.babelrc.js
module.exports = {
presets: ['@babel/preset-env'],
plugins: ['@babel/transform-runtime', ['module-extension', { mjs: 'js' }]],
sourceMaps: false,
retainLines: false,
minified: true,
};
Run Code Online (Sandbox Code Playgroud)
/src/index.mjs
import …
Run Code Online (Sandbox Code Playgroud) 我有以下两个文件:
index.html
<html>
<head>
<meta charset="utf-8" />
<title>Web Page</title>
<style type="text/css">
.text {
display: inline-block;
font-family: tahoma;
font-size: 14px;
max-width: 400px;
background-color: #ddedff;
padding: 10px;
text-align: justify;
}
</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
get_data('info.txt');
});
function get_data(file) {
var request = new Request(file);
fetch(request).then(function(response) {
return response.text().then(function(text) {
$('.text').html(text);
});
});
}
</script>
</head>
<body>
<div class="text"></div>
</body>
<html>
Run Code Online (Sandbox Code Playgroud)
info.txt
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's …
Run Code Online (Sandbox Code Playgroud) 我有一个PWA
应用程序需要通过Facebook/OAuth
. 问题是该OAuth
机制适用于所有情况,但iPhone/Standalone
.
我需要找到某种方法来使PWA
应用程序与Facebook/OAuth
on 一起工作iPhone
。是否可以?Yes
/ No
?
我创建了一个示例项目:
https://github.com/napolev/pwa-oauth-login
基于文章:
为简单起见,在这个示例项目中,我Facebook/OAuth
用一个简单的Custom/OAuth
机制替换了机制。
索引.html
<script>
...
window.open(
url_oauth + '?url_callback=' + encodeURIComponent(url_callback),
'Login Flow',
'width=350,height=250'
);
...
window.addEventListener('message', function (e) {
token.innerText = e.data.token;
})
...
</script>
...
<div>
Token: <span id="token">...</span>
</div>
Run Code Online (Sandbox Code Playgroud)
回调.html
<script type="text/javascript">
// redirected to this page from the OAuth page …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Cordova
插件:cordova-plugin-filepath
https://www.npmjs.com/package/cordova-plugin-filepath
在Corodva
/ Ionic
( Android
) 应用程序上。
我正在尝试使用与上述网址相同的代码来使用它,我的意思是:
window.FilePath.resolveNativePath('content://...', successCallback, errorCallback);
Run Code Online (Sandbox Code Playgroud)
但我得到:
[11:36:22] typescript: D:/ionic2/test-app/src/pages/home/home.ts, line: 27
Property 'FilePath' does not exist on type 'Window'.
L26: this._camera.getPicture( options ).then(( imageData ) => {
L27: this.cameraUrl = window.FilePath.resolveNativePath(imageData);
L28: this.photoSelected = true;
Run Code Online (Sandbox Code Playgroud)
我必须以window
某种方式导入吗?
我正在使用这个插件来转换文件的路径:
content://com.android.providers.media.documents/document/...
Run Code Online (Sandbox Code Playgroud)
到:
/storage/sdcard/...
Run Code Online (Sandbox Code Playgroud)
这是我的环境信息:
Your system information:
Cordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy …
Run Code Online (Sandbox Code Playgroud) 我正在配置一个NGINX Reverse Proxy
.
在浏览器上我去:
客户端网址: https : //www.hollywood.com
那么上面的网页需要做的请求是:
server url: https://server.hollywood.com/api/auth/login
这是对应的配置server.hollywood.com
:
server {
listen 443 ssl;
server_name server.hollywood.com;
# add_header 'Access-Control-Allow-Origin' "https://www.hollywood.com" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
ssl_certificate ../ssl/lets-encrypt/hollywood.com.crt;
ssl_certificate_key ../ssl/lets-encrypt/hollywood.com.key;
location /
{
proxy_pass http://localhost:9201;
include "../proxy_params.conf";
}
}
Run Code Online (Sandbox Code Playgroud)
实验一:
Access-Control-Allow-Origin
注释掉该行后,当我访问:
客户端网址: https : //www.hollywood.com
我在浏览器控制台上收到以下错误(在我的例子中是 Chrome):
POST https://server.hollywood.com/api/auth/login/local 502 (Bad Gateway)
(index):1 Failed to load https://server.hollywood.com/api/auth/login/local: No 'Access-Control-Allow-Origin' header …
Run Code Online (Sandbox Code Playgroud) reverse-proxy nginx nginx-location nginx-reverse-proxy nginx-status
我正在阅读本教程:https :
//angular.io/tutorial/toh-pt6#error-handling
我无法完全理解error-handling
函数:handleError
.
该函数用于此代码片段:
/** GET heroes from the server */
getHeroes (): Observable<Hero[]> {
return this.http.get<Hero[]>(this.heroesUrl)
.pipe(
tap(heroes => this.log(`fetched heroes`)),
catchError(this.handleError('getHeroes', []))
);
}
Run Code Online (Sandbox Code Playgroud)
这是handleError
功能:
/**
* Handle Http operation that failed.
* Let the app continue.
* @param operation - name of the operation that failed
* @param result - optional value to return as the observable result
*/
private handleError<T> (operation = 'operation', result?: T) {
return (error: …
Run Code Online (Sandbox Code Playgroud) 我有一项gulp
任务负责使用mocha
.
gulp.task('test', ['cls'], () => {
execout('mocha -r ts-node/register --timeout 999999 --colors test/*.test.ts');
});
Run Code Online (Sandbox Code Playgroud)
我的问题是,如您所见,有些灰线很难看到:
我的问题是,我怎样才能改变这种颜色?
我成功地尝试了这里推荐的内容(它有效):
https : //github.com/mochajs/mocha/issues/802#issuecomment-18254298):
$ gulp test > >(perl -pe 's/\x1b\[90m/\x1b[92m/g') 2> >(perl -pe 's/\x1b\[90m/\x1b[92m/g' 1>&2)
Run Code Online (Sandbox Code Playgroud)
但我不喜欢那样,因为我不想每次运行该命令时都在命令行上写下所有内容。
然后我尝试将所有这些移动到gulp
任务内部,如下所示:
gulp.task('test', ['cls'], () => {
execout("mocha -r ts-node/register --timeout 999999 --colors test/*.test.ts > >(perl -pe 's/\x1b\[90m/\x1b[92m/g') 2> >(perl -pe 's/\x1b\[90m/\x1b[92m/g' 1>&2)");
});
Run Code Online (Sandbox Code Playgroud)
但是后来我在终端上收到以下错误。
ERR: > was unexpected at this time.
Run Code Online (Sandbox Code Playgroud)
另一方面,这里还有另一个建议/方法,但我不知道如何使用它:
https://github.com/mochajs/mocha/issues/1200#issuecomment-62780003
关于如何修改难以阅读的灰线颜色的任何想法?
谢谢!
我刚刚下载了这个项目:
https://github.com/oktadeveloper/okta-spring-boot-2-angular-5-example
在本教程中解释:
https://developer.okta.com/blog/2017/12/04/basic-crud-angular-and-spring-boot
但是当我尝试使用推荐的命令运行服务器时:
./mvnw spring-boot:run
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
David@HP /cygdrive/d/wamp64/www/external/okta.example.com/server
$ ./mvnw spring-boot:run
/cygdrive/d/wamp64/www/external/okta.example.com/server
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.okta.developer:demo >-----------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.0.1.RELEASE:run (default-cli) > test-compile @ demo >>>
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ demo ---
[INFO] Nothing to compile - all classes …
Run Code Online (Sandbox Code Playgroud) 在以下存储库中:
https://github.com/napolev/lab-nginx-angular/tree/nasiruddin-suggestions
我有3个元素
nginx
服务器app1
app2
app2
是一个克隆app1
我正在使用Windows 10
操作系统与Cygwin
.
要试用该系统,请打开 3 个终端窗口并执行以下操作:
$ mkdir lab-nginx-angular
$ cd lab-nginx-angular
$ git clone https://github.com/napolev/lab-nginx-angular .
$ git checkout nasiruddin-suggestions
---
$ cd nginx
$ ./nginx.exe
---
$ cd app1
$ ng serve
---
$ cd app2
$ ng serve
Run Code Online (Sandbox Code Playgroud)
内部文件:.angular-cli.json
我有以下内容(例如app1
:):
{
...
"defaults": {
"styleExt": "css",
"component": {},
"serve": {
"host": "app1.example.com",
"port": 4201
}
}
...
}
Run Code Online (Sandbox Code Playgroud)
app1 …