Alex

有的故事值得一直说下去.
Home » Latest Posts

概述

Nuxt.js 是一个基于 Vue.js 的服务端渲染应用框架,可以快速搭建一个 SSR(Server-Side Rendering)项目。而 Electron 是一个可以使用 HTML、CSS 和 JavaScript 构建跨平台桌面应用的开源框架。将这两个框架结合起来,可以很方便地构建跨平台桌面应用。

在使用 Nuxt3 和 Electron 构建桌面应用时,需要安装 electron-builder。electron-builder 是一个用于打包 Electron 应用的开源工具。它可以将应用程序打包成可执行文件,并生成安装包。

以下是构建基于 Nuxt3 和 Electron 的桌面应用的步骤。

构建步骤

在 Nuxt3 中配置 Electron 的步骤如下:

  1. 在 Nuxt3 项目中安装 electron 和 electron-builder:
npm install --save-dev electron electron-builder
  1. 在项目根目录下创建一个 build 目录,并在其中创建一个 electron.js 文件。在该文件中,可以进行一些 Electron 应用的相关配置,如窗口大小、位置、图标等。示例配置如下:
const { app, BrowserWindow } = require('electron')
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadURL('<http://localhost:3000>')
}
app.whenReady().then(() => {
createWindow()
}) 
  1. 在 package.json 文件中,添加以下配置项:
{
"build": {
"appId": "com.example.app",
"productName": "My App",
"directories": {
"output": "dist_electron"
},
"files": [
"build/**/*",
"nuxt.config.js",
"package.json"
],
"extraResources": [
{
"from": "public",
"to": "public"
}
],
"mac": {
"category": "public.app-category.developer-tools"
}
}
}
  1. 在 nuxt.config.js 文件中,添加以下配置项:
export default {
// ...
target: 'static',
ssr: false,
// ...
build: {
// ...
extend(config, { isClient }) {
if (isClient) {
config.target = 'electron-renderer'
}
}
}
}

其中,target 设置为 'static'ssr 设置为 falsebuild.extend 中的代码用于将客户端构建的目标设置为 electron-renderer

  1. 在 package.json 文件中,添加以下启动脚本:
{
"scripts": {
"electron:dev": "nuxt dev && electron .",
"electron:build": "nuxt build && electron-builder"
}
}

其中,electron:dev 用于在开发模式下启动 Electron,electron:build 用于构建 Electron 应用。

  1. 运行以下命令启动 Electron 应用:
 npm run electron:dev

在开发过程中,可以使用 electron-storeelectron-updaterelectron-log 等 Electron 的开源工具和库来提高开发效率和应用体验。

此外,如果需要在 Nuxt3 中使用 Electron API,可以使用 nuxt-electron 插件。这个插件可以让你在 Nuxt3 中直接使用 Node.js 和 Electron 的 API,例如 remoteipcMainipcRenderer 等。使用该插件的步骤如下:

  1. 在 Nuxt3 项目中安装 nuxt-electron 插件:
npm install --save-dev @nuxtjs/electron
  1. 在 nuxt.config.js 文件中,添加以下配置项:
export default {
// ...
buildModules: [
'@nuxtjs/electron'
],
electron: {
// ...
}
}

其中,buildModules 中添加 @nuxtjs/electronelectron 中可以添加一些 Electron 的配置项,例如 nodeIntegrationcontextIsolation 等。

  1. 在你的 Vue 组件中,可以通过 $electron 访问到 Electron 对象。例如:
<template>
<div>
<h1>{{ message }}</h1>
<button @click="openDialog">打开对话框</button>
</div>
</template>
<script>
export default {
data() {
return {
message: 'Hello, Electron!'
}
},
methods: {
openDialog() {
const { dialog } = this.$electron.remote
dialog.showMessageBox({ message: 'Hello, Electron!' })
}
}
}
</script>

适配插件

此外,Nuxt3 还提供了一些特性来适配 Electron 应用,例如:

  • 使用 nuxt-start 来启动 Electron 应用。
  • 使用 nuxt-electron 插件来在 Nuxt3 中使用 Electron API。
  • 使用 nuxt-webdriverio 插件来进行端到端测试。

另外,Nuxt3 还支持 TypeScript,这意味着开发者可以使用 TypeScript 来开发基于 Nuxt3 和 Electron 的桌面应用,从而提高代码的可维护性和可读性。

在开发过程中,还可以使用一些 Electron 的开源工具和库,例如:

  • electron-store:轻松地在 Electron 应用中存储和读取数据。
  • electron-updater:自动更新 Electron 应用。
  • electron-log:在 Electron 应用中记录日志。

总之,基于 Nuxt3 和 Electron 构建桌面应用是一种非常具有前景的开发方式。它不仅可以让开发者使用熟悉的技术栈来开发跨平台的桌面应用,还可以为用户提供更好的使用体验。同时,Nuxt3 和 Electron 的不断更新也将为开发者带来更多的可能性。

imgSpider 采集中...

通常准备移民、海外升学、开展跨境贸易、启动海外业务线等,开设了离岸银行户口或要调动资金时,就会有跨境汇款的需要。但进行汇款时,为什么要填 SWIFT?有时又要再填 IBAN /BSB/ ABA No./FedWire No. / Sort Code?
因为不同国家及地区所遵行的交易系统各有不同,所以汇款到世界不同地方就有需要提供指定的识别代码。例如汇款至欧洲要提供 IBAN;汇款至美国要提供 FedWire No.;汇款英镑到英国则要提供 Sort Code 等。而 SWIFT Code,因为已被世界各地广泛应用,所以基乎已成为汇款必备的资料之一。

imgSpider 采集中...

一、国际汇款必备的识别代码—SWIFT
SWIFT 是环球银行金融电信协会(Society for Worldwide Interbank Financial Telecommunication)的简称,它提供了一套被广泛使用的国际编号系统,让世界各地的多间银行及金融机构都拥有一个专属的 SWIFT Code 国际银行代码(又称为 BIC 银行识别码),可应用在国际之间的金融交易之中,并用作识别指定的银行。简单而言,SWIFT 是一种国际银行代码,常应用于国际汇款上。
SWIFT Code 由 8 或 11 个字符组成,并可分拆成 4 个部分,用于识别银行机构、国家、位置及分行。前4位是收款银行的缩写,第5和6两位是国别,第7至11位是地区识别码。例如BKCHCNBJ400,前4位BKCH代表BANK OF CHINA,CN代表CHINA,BJ400代表广东省。BKCHCNBJ400就是中国银行广东省分行的SWIFT。
二、收款地区使用的识别代码
1. IBAN|适用于欧洲汇款
IBAN 是国际银行账户号码(International Bank Account Number)的简称,同样是一种国际编号系统,是用作识别与跨境交易有关的银行账户。与 SWIFT Code 国际银行代码不同,IBAN 不只用作识别银行,而是可识别到银行内的指定账户,常应用在与欧盟或欧洲有关的国际交易。IBAN号码最多是34位字符串。IBAN的编号规定包括国别代码+银行代码+地区+账户人账号+校验码,当在欧元区未使用IBAN账号时,会被额外收取人工干预费。
2. FedWire|适用于美国汇款
FedWire, 是由美国联邦储备银行(Federal Reserve Bank,简称 FED)所开发的电子转账系统,为美国境内及来自境外汇款提供转账及清算服务。FedWire Number(又可被称为 ABA Number / Routing Number)可以用作识别美国不同的银行或金融机构,以方便进行当地转账或国际汇款等交易。由9位(8位内容+1位验证码)组成,主要用于美国及北美地区。
3. BSB |适用于汇款澳元/新西兰元至澳洲
BSB Number,是在澳大利亚等地使用的电汇清算网络编码,即Bank State Branch Number。主要在澳元、新西兰元的银行及向澳洲办理清付结算时使用。一般都是6位数字。
4. Sort Code|适用于汇款英镑至英国
Sort Code即SC。若汇款到英国通常都要提供 IBAN 号码,而汇款英镑至英国另外也要提供 Sort Code 以便清算行能将款项转账到正确的英国银行账户。
我们通常可以透过登入银行账户或查阅银行月结单就可以找到 Sort Code,以用作接收款项。
5.TRANSIT NO| 适用于汇加元至加拿大
TRANSIT NO即CC,汇加元到加拿大必须提供,它由9位数字(4位银行号+5位分行号)组成。
填写正确的收款银行SWIFT和清算号是汇出汇款业务关键所在,可以起到事半功倍的作用。但是使用传统的国际电汇汇款,所填写的资料太繁琐,稍不留意填错信息就会导致汇款不成功而损失大笔手续费和你宝贵的时间
 

周末写了一段简单的文字,表达我对于DCEP(央行数币)和SWIFT的观点,观点是两者风马牛不相及
本文讲一讲CIPS与SWIFT,最大的区别:CIPS和CHIPS处理的是资金流;SWIFT处理的信息流,即报文。
CIPS,人民币跨境支付系统,是专司人民币跨境支付清算业务的批发类支付系统。
CHIPS,纽约清算所银行同业支付系统,主要进行跨国美元交易的清算。
SWIFT,环球银行金融电信协会,国际上传递金融信息的一个主要渠道。
17f3f7af12973853fe9dbc66.png800

我的观点

2021年12月全球主要货币支付金额排名,USD占比40.5%,EUR占比36.65%,GBP占比5.89%,CNY由11月的2.14%升至2.70%,2022年1月的数据是3.2%。目前没必要争论CIPS脱离SWIFT会如何,以CNY占比3.2%这个数据而言,CIPS脱离SWIFT属于自废武功。CIPS的参与者中,有上千家是通过SWIFT提供的报文服务。CIPS与SWIFT不是竞争关系,反而是合作关系,双方早已签署了战略合作备忘录。

CIPS

哪里有人民币,哪里就有CIPS服务。作为跨境支付主渠道,CIPS系统服务于金融开放和人民币国际使用。
2015年10月8日,CIPS(一期)上线运行,采用实时全额结算方式,为全球RMB资金清算结算提供服务。2018年3月26日,CIPS(二期)投产试运行;5月2日CIPS(二期)全面投产。CIPS系统运行时间由5×12小时延长至5×24小时+4小时,实现对全球各时区金融市场的全覆盖,支持全球的支付与金融市场业务。
17f3f7af33971a63fd9cf170.png800
截至目前,CIPS共有75家直接参与者,1205家间接参与者,其中亚洲934家(含境内541家),欧洲159家,非洲43家,北美洲29家,大洋洲23家,南美洲17家。——数据摘抄自「CIPS官网」

SWIFT

1977年5月9日,SWIFT网络首先在欧洲开始运转,继而扩展到北美,1980年SWIFT通过设在香港的操作中心开始提供对远东地区的服务。在1977年网络刚开始运行的时候,只有22个国家的518家金融机构通过SWIFT进行通讯,目前已经有超过200个经济体,8000多家金融机构使用SWIFT进行通讯,业务范围从一般的清算业务扩展到信用证、资金市场、货币市场和证券等领域。
17f3f7af03f72393f8c858c1.png800
SWIFT不是一个清算机构,不会参与资金划拨,也就是不涉及清算和结算。它是一个提供网络并交换标准化报文的机构,是国际上进行金融信息传递的一个渠道。
17f3f7af07572fd3fe6287c3.png800

CHIPS

主要的美元清算系统有两个。一个是CHIPS(Clearing House Interbank Payment System ),成立于1970年,用作提供国际上美元资金转移的服务。现由纽约清算中心协会负责运作,属于私有的清算系统。它由成员行和CHIPS客户组成,成员行是在清算所登记的可以直接进行清算的银行,CHIPS客户须通过这些银行才能进行清算。CHIPS不是即时清算系统,延迟净额结算(DNS),收付相抵,轧差结算。
另一个美元清算系统是FEDWIRE系统,它是复杂的电子付款网络,由十二家联邦储备银行拥有,主要用作美国国内的资金转移。它是即时支付清算系统,实时全额结算(RTGS)。RTGS模式需要银行持有更多的流动性资产来保证支付指令实时无延误的被处理,因此该模对银行的流动性要求较高。
FEDWIRE与CHIPS最大的不同是FEDWIRE只完成美国国内银行的清算,而CHIPS的客户可以来自世界各地,所以世界各地的银行都可以经由CHIPS来清算。
 
作者:爱撸铁的程序猿
链接:https://xueqiu.com/9805652582/212658101
来源:雪球
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
风险提示:本文所提到的观点仅代表个人的意见,所涉及标的不作推荐,据此买卖,风险自负。

包地址:smuuf/celery-for-php: A modern PHP client library for Celery. (github.com)

Requirements

  • PHP 8.0+

Installation

Install celery-for-php via Composer.

composer require smuuf/celery-for-php

Redis (Predis)

If you want to use Redis as a broker and/or result backend, celery-for-php contains a Redis driver backed by Predis.

The Predis Client object then needs to be wrapped in our Smuuf\CeleryForPhp\Drivers\PredisRedisDriver driver object, which provides the necessary interface for celery-for-php's actual communication with Redis.

Example usage

<?php
use Predis\Client as PredisClient;
use Smuuf\CeleryForPhp\Celery;
use Smuuf\CeleryForPhp\TaskSignature;
use Smuuf\CeleryForPhp\Brokers\RedisBroker;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Backends\RedisBackend;
$predis = new PredisClient(['host' => '127.0.0.1']);
$redisDriver = new PredisRedisDriver($predis);
$celery = new Celery(
new RedisBroker($redisDriver),
new RedisBackend($redisDriver),
// Optionally explicit config object.
// config: new \Smuuf\CeleryForPhp\Config(...)
);
$task = new TaskSignature(
taskName: 'my_celery_app.add_numbers',
queue: 'my_queue', // Optional, 'celery' by default.
args: [1, 3, 5],
// kwargs: ['arg_a' => 123, 'arg_b' => 'something'],
// eta: 'now +10 minutes',
// ... or more optional arguments.
);
// Send the task into Celery.
$asyncResult = $celery->sendTask($task);
// Wait for the result (up to 10 seconds by default) and return it.
// Alternatively a \Smuuf\CeleryForPhp\Exc\CeleryTimeoutException exception will
// be thrown if the task won't finish in time.
$result = $asyncResult->get();
// $result === 9

AMQP/RabbitMQ (PhpAmqpLib)

You can use AMQP/RabbitMQ as the broker instead, with Redis as the backend. celery-for-php contains a AMQP driver backed by PhpAmqpLib.

The PhpAmqpLib AMQPConnection or AMQPSSLConnection object needs to be wrapped in our Smuuf\CeleryForPhp\Drivers\PhpAmqpLibAmqpDriver driver object, which provides the necessary interface for celery-for-php's actual communication via AMQP.

Example usage

<?php
use Predis\Client as PredisClient;
use Smuuf\CeleryForPhp\Celery;
use Smuuf\CeleryForPhp\TaskSignature;
use Smuuf\CeleryForPhp\Brokers\AmqpBroker;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Drivers\PhpAmqpLibAmqpDriver;
use PhpAmqpLib\Connection\AMQPSSLConnection;
use Smuuf\CeleryForPhp\Backends\RedisBackend;
//$amqpConn = new AMQPConnection(['127.0.0.1', '5672', '', '', '/']);
$amqpConn = new AMQPSSLConnection(['127.0.0.1', '5672', '', '', '/', ['verify_peer'=>false]]);
$amqpDriver = new PhpAmqpLibAmqpDriver($amqpConn);
$predis = new PredisClient(['host' => '127.0.0.1']);
$redisDriver = new PredisRedisDriver($predis);
$celery = new Celery(
new AmqpBroker($amqpDriver),
new RedisBackend($redisDriver),
// Optionally explicit config object.
// config: new \Smuuf\CeleryForPhp\Config(...)
);
$task = new TaskSignature(
taskName: 'my_celery_app.add_numbers',
queue: 'my_queue', // Optional, 'celery' by default.
args: [1, 3, 5],
// kwargs: ['arg_a' => 123, 'arg_b' => 'something'],
// eta: 'now +10 minutes',
// ... or more optional arguments.
);
// Send the task into Celery.
$asyncResult = $celery->sendTask($task);
// Wait for the result (up to 10 seconds by default) and return it.
// Alternatively a \Smuuf\CeleryForPhp\Exc\CeleryTimeoutException exception will
// be thrown if the task won't finish in time.
$result = $asyncResult->get();
// $result === 9

Windows in a Docker container.

Features

  • ISO downloader
  • KVM acceleration
  • Web-based viewer

Usage

Via docker-compose.yml

version: "3"
services:
windows:
image: dockurr/windows
container_name: windows
devices:
- /dev/kvm
cap_add:
- NET_ADMIN
ports:
- 8006:8006
- 3389:3389/tcp
- 3389:3389/udp
stop_grace_period: 2m
restart: on-failure

Via docker run

docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows

FAQ

  • How do I use it?


    Very simple! These are the steps:


    • Start the container and connect to port 8006 using your web browser.

    • Sit back and relax while the magic happens, the whole installation will be performed fully automatic.

    • Once you see the desktop, your Windows installation is ready for use.


    Enjoy your brand new machine, and don't forget to star this repo!

  • How do I select the Windows version?


    By default, Windows 11 will be installed. But you can add the VERSION environment variable to your compose file, in order to specify an alternative Windows version to be downloaded:


    environment:
    VERSION: "win11"

    Select from the values below:


    Value Description Source Transfer Size
    win11 Windows 11 Pro Microsoft Fast 6.4 GB
    win10 Windows 10 Pro Microsoft Fast 5.8 GB
    ltsc10 Windows 10 LTSC Microsoft Fast 4.6 GB
    win81 Windows 8.1 Pro Microsoft Fast 4.2 GB
    win7 Windows 7 SP1 Bob Pony Medium 3.0 GB
    vista Windows Vista SP2 Bob Pony Medium 3.6 GB
    winxp Windows XP SP3 Bob Pony Medium 0.6 GB
    2022 Windows Server 2022 Microsoft Fast 4.7 GB
    2019 Windows Server 2019 Microsoft Fast 5.3 GB
    2016 Windows Server 2016 Microsoft Fast 6.5 GB
    2012 Windows Server 2012 R2 Microsoft Fast 4.3 GB
    2008 Windows Server 2008 R2 Microsoft Fast 3.0 GB
    core11 Tiny 11 Core Archive.org Slow 2.1 GB
    tiny11 Tiny 11 Archive.org Slow 3.8 GB
    tiny10 Tiny 10 Archive.org Slow 3.6 GB

    To install ARM64 versions of Windows use dockur/windows-arm.

  • How do I connect using RDP?


    The web-viewer is mainly meant to be used during installation, as its picture quality is low, and it has no audio or clipboard for example.

    So for a better experience you can connect using any Microsoft Remote Desktop client to the IP of the container, using the username docker and by leaving the password empty.

    There is a good RDP client for Android available from the Play Store. One for iOS is in the Apple Store. For Linux you can use rdesktop and for Windows you don't need to install anything as it is already ships as part of the operating system.

  • How do I increase the amount of CPU or RAM?


    By default, 2 CPU cores and 4 GB of RAM are allocated to the container, as those are the minimum requirements of Windows 11.

    To increase this, add the following environment variables:


    environment:
    RAM_SIZE: "8G"
    CPU_CORES: "4"
  • How do I change the size of the disk?


    To expand the default size of 64 GB, add the DISK_SIZE setting to your compose file and set it to your preferred capacity:


    environment:
    DISK_SIZE: "256G"

    This can also be used to resize the existing disk to a larger capacity without any data loss.

  • How do I change the storage location?


    To change the storage location, include the following bind mount in your compose file:


    volumes:
    - /var/win:/storage

    Replace the example path /var/win with the desired storage folder.

  • How do I share files with the host?


    Open File Explorer and click on the Network section, you will see a computer called host.lan, double-click it and it will show a folder called Data.

    Inside this folder you can access any files that are placed in /storage/shared (see above) on the host.

  • How do I install a custom image?


    In order to download a custom ISO image, start a clean container with the URL of the ISO specified in the VERSION environment variable:


    environment:
    VERSION: "https://example.com/win.iso"

    Alternatively, you can also rename a local file to custom.iso and place it in an empty /storage folder to skip the download.

  • How do I perform a manual installation?


    It's best to use the automatic installation, as it optimizes various settings for use with this container.

    However, if you insist on performing the installation manually, start a clean container with the following environment variable:


    environment:
    MANUAL: "Y"

    Then follow these steps:


    • Start the container and connect to port 8006 of the container in your web browser. After the download is finished, you will see the Windows installation screen.

    • Start the installation by clicking Install now. On the next screen, press 'OK' when prompted to Load driver and select the VirtIO SCSI driver from the list that matches your Windows version. So for Windows 11, select D:\amd64\w11\vioscsi.inf and click 'Next'.

    • Accept the license agreement and select your preferred Windows edition, like Home or Pro.

    • Choose Custom: Install Windows only (advanced), and click Load driver on the next screen. Select 'Browse' and navigate to the D:\NetKVM\w11\amd64 folder, and click 'OK'. Select the VirtIO Ethernet Adapter from the list and click 'Next'.

    • Select Drive 0 and click 'Next'.

    • Wait until Windows finishes copying files and completes the installation.

    • Once you see the desktop, open File Explorer and navigate to the CD-ROM drive (E:). Double-click on virtio-win-gt-x64.msi and proceed to install the VirtIO drivers.


    Enjoy your brand new machine, and don't forget to star this repo!

  • How do I assign an individual IP address to the container?


    By default, the container uses bridge networking, which shares the IP address with the host.

    If you want to assign an individual IP address to the container, you can create a macvlan network as follows:


    docker network create -d macvlan \
    --subnet=192.168.0.0/24 \
    --gateway=192.168.0.1 \
    --ip-range=192.168.0.100/28 \
    -o parent=eth0 vlan

    Be sure to modify these values to match your local subnet.

    Once you have created the network, change your compose file to look as follows:


    services:
    windows:
    container_name: windows
    ..<snip>..
    networks:
    vlan:
    ipv4_address: 192.168.0.100
    networks:
    vlan:
    external: true

    An added benefit of this approach is that you won't have to perform any port mapping anymore, since all ports will be exposed by default.

    Please note that this IP address won't be accessible from the Docker host due to the design of macvlan, which doesn't permit communication between the two. If this is a concern, you need to create a second macvlan as a workaround.

  • How can Windows acquire an IP address from my router?


    After configuring the container for macvlan (see above), it is possible for Windows to become part of your home network by requesting an IP from your router, just like a real PC.

    To enable this mode, add the following lines to your compose file:


    environment:
    DHCP: "Y"
    device_cgroup_rules:
    - 'c *:* rwm'

    Please note that in this mode, the container and Windows will each have their own separate IPs. The container will keep the macvlan IP, and Windows will use the DHCP IP.

  • How do I pass-through a disk?


    It is possible to pass-through disk devices directly by adding them to your compose file in this way:


    environment:
    DEVICE: "/dev/sda"
    DEVICE2: "/dev/sdb"
    devices:
    - /dev/sda
    - /dev/sdb

    Use DEVICE if you want it to become your main drive, and use DEVICE2 and higher to add them as secondary drives.

  • How do I pass-through a USB device?


    To pass-through a USB device, first lookup its vendor and product id via the lsusb command, then add them to your compose file like this:


    environment:
    ARGUMENTS: "-device usb-host,vendorid=0x1234,productid=0x1234"
    devices:
    - /dev/bus/usb
  • How do I verify if my system supports KVM?


    To verify if your system supports KVM, run the following commands:


    sudo apt install cpu-checker
    sudo kvm-ok

    If you receive an error from kvm-ok indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.

  • Is this project legal?


    Yes, this project contains only open-source code and does not distribute any copyrighted material. Any product keys found in the code are just generic placeholders provided by Microsoft for trial purposes. So under all applicable laws, this project would be considered legal.

Stars

68747470733a2f2f7374617263686172742e63632f646f636b75722f77696e646f77732e7376673f76617269616e743d6164617074697665

Disclaimer

The product names, logos, brands, and other trademarks referred to within this project are the property of their respective trademark holders. This project is not affiliated, sponsored, or endorsed by Microsoft Corporation.

Life is fantastic
🥕 More