我正在使用phantomjs生成pdf文件,但我想用HTML重复一个已定义的标题,它在没有图像的情况下工作,但是一旦我添加它就不起作用
page.viewportSize = { width: 600, height: 600 };
page.paperSize = {
format: 'A4', orientation: 'portrait', margin: '0px',
header: {
height: "1.2cm",
contents: phantom.callback(function(pageNum, numPages) {
return '<img src="https://www.google.com.bo/images/srpr/logo4w.png" height="0.95cm"/>';
})
},
footer: {
height: "0.7cm",
contents: phantom.callback(function(pageNum, numPages) {
return '<h3 class="header">Footer</h>';
})
}
}
Run Code Online (Sandbox Code Playgroud) 我看到我的服务器正在正确地将消息发送到firebase API,因为它返回成功:1响应但我的客户端没有收到消息,发生了什么,我的代码是:
const messaging = firebase.messaging()
const that = this
messaging.requestPermission()
.then(function() {
return messaging.getToken()
})
.then(function(token) {
that.updateServerFirebaseToken(token)
})
.catch(function(err) {
console.log(err)
})
// Call to user
messaging.onMessage(function(payload) {
console.log('firebase', payload)
if(payload.data.status == 'calling') {
this.audio.play()
this.$store.commit(types.CALLING, JSON.decode(payload.data.order))
}
})
Run Code Online (Sandbox Code Playgroud)
和我的服务人员 firebase-messaging-sw.js
const messaging = firebase.messaging()
messaging.setBackgroundMessageHandler(function(payload) {
console.log('FIREBASE call', payload);
if(payload.data.status == 'calling') {
channel.postMessage(payload.data)
return self.registration.showNotification('Nuevo pedido', {body: "Llamada para transporte de un pedido"})
}
})
Run Code Online (Sandbox Code Playgroud) 我一直在尝试在postgresql中的jsonb列中保存JSON,我已经尝试过这个教程并且也开始阅读Ecto API以及Postgrex但是无法使它工作,一个工作的例子会让我高兴:)到目前为止我添加了这到我的配置
config :bonsai, Bonsai.Repo,
adapter: Ecto.Adapters.Postgres,
username: "demo",
password: "demo123",
database: "bonsai_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox,
extensions: [{Postgrex.Extensions.JSON, [library: Poison]}]
Run Code Online (Sandbox Code Playgroud)
这是我的模特
defmodule Bonsai.Organization do
use Bonsai.Web, :model
schema "organizations" do
field :name, :string
field :currency, :string
field :tenant, :string
field :info, Bonsai.Json.Type, default: %{}
field :settings, :map, default: %{} #, :map#, Bonsai.Json.Type
timestamps
end
@required_fields ~w(name currency tenant)
@optional_fields ~w()
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fields, @optional_fields)
end
end
Run Code Online (Sandbox Code Playgroud)
类型的定义是在 web/utils/json.ex
defmodule Bonsai.Json.Type …Run Code Online (Sandbox Code Playgroud) 我一直在尝试从服务工作者向客户发送消息但是如果我使用的话
self.clients.matchAll()
.then((clients) => {
clients.forEach(function(client) {
client.postMessage({msg: 'Hello from SW'})
})
})
Run Code Online (Sandbox Code Playgroud)
即使我在浏览器中打开了一个标签,它也不会发送给任何客户端,但是如果我从客户端向服务工作者发送消息
// client
navigator.serviceWorker.controller.postMessage({title: 'Send message from client'})
Run Code Online (Sandbox Code Playgroud)
在服务工作者
self.addEventListener('message', function(event) {
self.clients.fetchAll()
.then((clients) => {
clients.forEach(function(client) {
client.postMessage({msg: 'Hello from SW'})
})
})
})
Run Code Online (Sandbox Code Playgroud)
它可以发送消息并查找客户端.我做错了什么?,我应该使用indexedDB吗?
我有一个 Rails 应用程序,我已经升级到使用 webpacker 4.x 并且一切正常,但在开发中一切正常,但在生产中 Vue 单文件组件样式没有呈现,js 工作正常,甚至组件中的一些样式(例如vue-slider-component ) 正确显示。我之前使用过 webpacker 3 并且一切正常,但是该应用程序的开发开始变得非常缓慢,并决定迁移到新的 webpacker。
一个重要的注意事项是我在我的 vue 组件中使用了sass (scss)样式。
这是我的配置:
// config/webpack/environment.js
const { environment } = require('@rails/webpacker');
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');
const vue = require('./loaders/vue');
const sass = require('./loaders/sass');
environment.config.resolve.symlinks = false;
environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin());
environment.loaders.append('vue', vue);
environment.loaders.append('sass', sass);
const nodeModulesLoader = environment.loaders.get('nodeModules');
nodeModulesLoader.exclude = [nodeModulesLoader.exclude, /mapbox-gl/];
environment.config.resolve.alias = {
vue$: 'vue/dist/vue.esm.js',
'@': path.join(__dirname, '..', '..', 'app', 'javascript'),
'@stylesheets': path.join(__dirname, …Run Code Online (Sandbox Code Playgroud) 我使用 rails 6 创建了一个新项目,但我无法使用 rspec 3.8 或 3.9.0.pre 测试许多控制器,例如这个测试:
it 'OK' do
get :index
expect(response).to be_ok
end
Run Code Online (Sandbox Code Playgroud)
加注
Failure/Error: render template: 'rig_masters/index'
ActionView::Template::Error:
wrong number of arguments (given 2, expected 1)
Run Code Online (Sandbox Code Playgroud)
如果我有一个呈现json的控制器,它会通过,例如,如果控制器是
Failure/Error: render template: 'rig_masters/index'
ActionView::Template::Error:
wrong number of arguments (given 2, expected 1)
Run Code Online (Sandbox Code Playgroud)
测试通过
但是如果我尝试渲染像
def index
@components = Component.recent
render json: @components
end
Run Code Online (Sandbox Code Playgroud)
甚至
def index
@components = Component.recent
end
Run Code Online (Sandbox Code Playgroud)
引发ActionView::Template::Error: wrong number of arguments (given 2, expected 1)错误
任何使这些测试通过的帮助将不胜感激。
我正在创建一个将分散的rails 3应用程序,我需要使用UUID作为我的表的主键,什么是最好的gem,插件为Job.我还想知道是否可以在不使用polymorphicable_type列的情况下使用ActiveRecord多态关系,假设我正在使用UUID.
我创建了一个 使用UUID作为键的http://github.com/boriscy/uuidrails3 演示,你应该检查lib /中的模块UUIDHelper以及所有的迁移.无需在数据库中添加主键,只需添加索引,因为主键验证字段的唯一性,但我们不需要使用UUID.
我即将使用Ruby on Rails创建一个应用程序,我想使用多个数据库,基本上是一个会计应用程序,每个用户将拥有多个公司.我想为每家公司创建一个数据库
我发现这篇文章http://programmerassist.com/article/302 但我想阅读更多关于这个问题的想法.我必须在MySQL和PosgreSQL之间做出决定,哪个数据库可能更适合我的问题.
activerecord ×1
client ×1
d3.js ×1
database ×1
dc.js ×1
ecto ×1
elixir ×1
excel ×1
export ×1
firebase ×1
javascript ×1
jsonb ×1
mongodb ×1
multi-tenant ×1
phantomjs ×1
polymorphism ×1
rspec-rails ×1
uuid ×1
vue.js ×1
webpack ×1