Skip to content

Commit 6b581bd

Browse files
committed
feat: open browser when toast clicked
1 parent 2039117 commit 6b581bd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ 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
exports.notify = ({ title, message, icon }) => {
1017
notifier.notify({
1118
title,
1219
message,
1320
icon: builtinIcons[icon] || icon
14-
})
21+
}, notifCallback)
1522
}

Diff for: 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)