Skip to content

Commit 637414c

Browse files
authored
feat: open browser when toast clicked (vuejs#6001)
1 parent 48d6afd commit 637414c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/@vue/cli-ui/apollo-server/util/notification.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ const builtinIcons = {
66
error: path.resolve(__dirname, '../../src/assets/error.png')
77
}
88

9+
let notifCallback = null
10+
exports.setNotificationCallback = cb => {
11+
notifCallback = cb
12+
? (_err, action) => (action === 'activate') && cb()
13+
: null
14+
}
15+
916
// https://github.com/mikaelbr/node-notifier/issues/154
1017
// Specify appID to prevent SnoreToast shortcut installation.
1118
// SnoreToast actually uses it as the string in the notification's
@@ -19,5 +26,5 @@ exports.notify = ({ title, message, icon }) => {
1926
title,
2027
message,
2128
icon: builtinIcons[icon] || icon
22-
})
29+
}, notifCallback)
2330
}

packages/@vue/cli/lib/ui.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { log, error, openBrowser } = require('@vue/cli-shared-utils')
22
const { portfinder, server } = require('@vue/cli-ui/server')
33
const shortid = require('shortid')
4+
const { setNotificationCallback } = require('@vue/cli-ui/apollo-server/util/notification')
45

56
function simpleCorsValidation (allowedHost) {
67
return function (req, socket) {
@@ -77,6 +78,7 @@ async function ui (options = {}, context = process.cwd()) {
7778
if (options.headless) {
7879
console.log(port)
7980
} else {
81+
setNotificationCallback(() => openBrowser(url))
8082
openBrowser(url)
8183
}
8284
})

0 commit comments

Comments
 (0)