一天的好时光!
在我的项目进行了几周的开发之后,我决定从纯Vue迁移到Nuxt。
主要是因为我需要SSR,尽管我知道Google可以执行页面上显示的JS,因此可以为其搜索机器人生成适当的内容。
另一个原因是项目开发的一般工作流程。我喜欢自动实例化路线,商店等的想法。
但是,当我在mode: universal而不是中运行该应用程序时,我遇到了一个非常奇怪的行为mode: spa。mode: spa从那时起,我就不想再切换到SSR了。
我在商店中有一个帐户模块- account.js负责处理与帐户管理相关的任何操作,例如登录/注销,获取经过身份验证的用户的个人资料,存储从登录请求中获得的令牌以及处理逻辑2FA TOTP程序。
在我的旧版应用程序中,我只需使用以下代码就可以从Cookie中获取令牌
import Cookies from 'js-cookie';
export const state = {
user: null,
token: Cookies.get('token')
}
Run Code Online (Sandbox Code Playgroud)
通过执行以下更改,在成功认证后保存令牌:
[types.ACCOUNT_SAVE_TOKEN] (state, { token, remember }) {
state.token = token;
Cookies.set('token', token, {
expires: 365,
httpOnly: true
});
}
Run Code Online (Sandbox Code Playgroud)
但是在迁移到Nuxt.js之后,每次登录时,都会填充该状态中的令牌值,但未设置cookie,并且导航到项目内的另一页(它是pwa,因此无需重新加载等) )令牌重置为空。
但是,如果将应用程序mode: spa从切换到,mode: universal并且一切运行正常,则此问题将消失。
我已经阅读了github上的许多问题,并且在试图解决同一问题的网站上进行了大量的爬网,尽管没有任何建议对我有用。
我什至从NPM 安装了cookie-universal-nuxt程序包,声称它可以与SSR一起使用,但是每次我尝试this.$cookies.get('token')在该州或其他任何地方(例如突变)访问时,我只是在上使用方法(获取/设置/删除)时出错null。
至少在没有回过头的情况下,有没有人知道或对如何解决这个问题有想法mode: spa …
一天中的好时光!
我正在使用带有npm run generate命令的静态生成的网站,虽然放置在 pages 目录中的所有页面都可以正常工作(动态页面、所有已实现的功能等),但不存在的页面只是返回默认的 Web 服务器错误页面。
在本地机器上,npm run dev我可以被强制执行Nuxt 生成的“找不到页面”错误,而在运行 Apache 的生产服务器上,我不能使用包提供的中间件(例如@nuxt/sitemap)作为以及任何可能触发错误 (40*,5**,3**) 的页面都由 Web 服务器直接处理。
由于npm run dev刚刚启动了express网络服务器,我猜任何由 express 设置的路由规则都可以在 Apache .htaccess配置中复制,我只是不知道在哪里寻找它们。
这是我在没有Nuxt的 Vue 项目中的配置,其中一切都按预期工作(重定向等)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个微服务应用程序,这取决于我的net包含一般错误的模块(因此我不必在所有模块中“复制”它们)。
问题是,由于某种原因,它能够找到该模块,但随后告诉我该模块没有包(该模块没有net该main.go文件,因为它只是一组在其他项目中使用的文件)
go: finding github.com/USERNAME/net latest
build github.com/USERNAME/micro-helix: cannot load github.com/USERNAME/net: module github.com/USERNAME/net@latest found (v0.0.0-20191209010811-97a65ac0928c), but does not contain package github.com/USERNAME/net
Run Code Online (Sandbox Code Playgroud)
这是go.mod包含所有必要要求的文件(就我而言):
module github.com/USERNAME/micro-helix
go 1.13
require (
github.com/USERNAME/net v0.0.0-20191209010811-97a65ac0928c
github.com/USERNAME/service v0.0.0-20191209005400-57ee0eb02082
github.com/golang/protobuf v1.3.2
github.com/hashicorp/consul/api v1.3.0 // indirect
github.com/micro/go-micro v1.17.1
github.com/micro/go-plugins v1.5.1 // indirect
github.com/nats-io/nats-streaming-server v0.16.2 // indirect
github.com/nats-io/stan.go v0.5.2 // indirect
github.com/nicklaw5/helix v0.5.4
github.com/spf13/viper v1.5.0 // indirect
)
Run Code Online (Sandbox Code Playgroud)
go.mod该模块的文件非常net简单:
module github.com/USERNAME/net
go 1.13
Run Code Online (Sandbox Code Playgroud)
如果您需要任何进一步的说明,我会在这里提供。我知道这可能是一些菜鸟错误(配置错误),但这是我第一周真正尝试用 Go 编写一些东西。
更新#1
github.com/USERNAME/net …
nginx-rtmp-module我正在尝试创建一个简单的 RTMP/HLS 服务器,以便能够流式传输并从中查看流,但是,我无法更改(模块)保存数据的目录的名称。
一切正常,我可以流式传输到服务器,然后在浏览器中查看 HLS 流,但是,唯一的方法是输入流密钥作为服务器上的目标文件夹以获取 m3u8 文件。
目前我有以下设置:
on_publishhttp ://app.local/stream/start,首先,它检查数据库中是否存在该密钥,如果存在,则为流创建新的数据库条目(以UUID为主键),接收创建条目得到的key,返回给脚本有谁知道如何:
PS:这只是我现在拥有的和我想要实现的目标的一个小例子
流密钥: test_stream_key_user_1
哈希密钥: 73E179A6DB3796A3120319BFE80763427A2122253A5C1D347461268304B28CEB98CE3813DDF5FA8B7173937ED9386169FD3BF8E8C3765BC53BB151 C7F5B1431E
当前目录命名: /tmp/hls/test_stream_key_user_1/index.m3u8
所需目录命名: /tmp/hls/ 73E179A6DB3796A3120319BFE80763427A2122253A5C1D347461268304B28CEB98CE3813DDF5FA8B7173937ED93 86169FD3BF8E8C3765BC53BB151C7F5B1431E/index.m3u8
PPS:我认为我的 nginx 配置文件可能会有所帮助。
RTMP配置
server {
listen 1935;
ping 30s;
notify_method get;
notify_update_timeout 10s;
application live {
live on;
hls on;
hls_nested on;
hls_path /tmp/hls;
hls_fragment 3; …Run Code Online (Sandbox Code Playgroud) 一天的好时光!
我正在尝试在Laravel Nova内部创建类似博客系统的内容。
我有一个表articles以及抽象模型AbstractArctile。
我也有3个类别:
App\Models\News\Article扩展App\Models\Abstract\AbstractArticleApp\Models\Digests\Article扩展App\Models\Abstract\AbstractArticleApp\Models\Offtopic\Article扩展App\Models\Abstract\AbstractArticle该表articles具有一个名为category的字段,并且有3种类型的类别:新闻,摘要,offtopic。
除了扩展抽象模型之外,每个资源模型还定义了一个属性,该属性按以下方式属于其类别:
/**
* To which category this article belongs to
* @var array
*/
protected $attributes = [
'category' => 'news'
];
Run Code Online (Sandbox Code Playgroud)
我在Nova中指定类别下创建文章没有问题,但是,除了显示指定类别中的文章之外,它还显示所有资源中所有类别中的文章。
有没有一种方法只能在给定资源上显示特定类别的文章?
TLDR: 一个抽象模型-> 3个扩展该模型的资源(定义了类别属性)->如何仅在nova资源中显示该类别中的项目?
我正在开发家庭安全应用程序.必须实现的功能之一是能够查看连接的设备(用于发送通知,阻止访问等).到目前为止,我已经能够创建设备的RecyclerView列表,一切都很完美(对我来说),除了这个列表中的卡片之间没有间距.
它现在看起来如何
device_data_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_margin="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp">
<ImageView
android:id="@+id/deviceIcon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:layout_marginLeft="8dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_alignBottom="@+id/deviceIcon"
android:layout_toEndOf="@+id/deviceIcon">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Username"
android:id="@+id/deviceUsername"
android:layout_gravity="center_vertical"
android:textColor="#000000"
android:layout_marginLeft="5dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Device Model"
android:gravity="center_vertical|right"
android:textColor="#000000"
android:id="@+id/deviceModel"
android:layout_marginLeft="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Device Version"
android:gravity="center_vertical|right"
android:id="@+id/deviceVersion"
android:layout_marginLeft="5dp" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
devices_list.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_vertical_margin">
<view
android:id="@+id/connectedDevicesList" …Run Code Online (Sandbox Code Playgroud)