“Trabalhador de serviço” Respostas de código

Como criar um serviço de trabalhador

//Step 1: Publish the Worker service

cd "Path to the Worker service project"
dotnet restore
dotnet publish -o PathToThePublishFolder

//Step 2: Deploy and start with sc utility

sc.exe create DemoWorker binpath= PathToThePublishFolder\YourWorkerClassName.exe
sc.exe start YourWorkerClassName

//Step 3: Stop and delete with sc utility

sc.exe stop YourWorkerClassName 
sc.exe delete YourWorkerClassName 
ozioma ene

Service Worker.js

if ('serviceWorker' in navigator) {  window.addEventListener('load', function() {    navigator.serviceWorker.register('/sw.js').then(function(registration) {      // Registration was successful      console.log('ServiceWorker registration successful with scope: ', registration.scope);    }, function(err) {      // registration failed :(      console.log('ServiceWorker registration failed: ', err);    });  });}
Tough Trout

Trabalhador de serviço

const filter = {
  url: [
    {
      urlMatches: 'https://www.google.com/',
    },
  ],
};

chrome.webNavigation.onCompleted.addListener(() => {
  console.info("The user has loaded my favorite website!");
}, filter);
cool dude

Respostas semelhantes a “Trabalhador de serviço”

Procure respostas de código populares por idioma

Procurar outros idiomas de código