|
|
@@ -43,6 +43,14 @@
|
|
|
<search />
|
|
|
</a-col>
|
|
|
<a-col class="df-center" style="height: 54px;">
|
|
|
+ <a-tooltip placement="bottom">
|
|
|
+ <template #title>
|
|
|
+ <span>添加网页到桌面</span>
|
|
|
+ </template>
|
|
|
+ <a-button type="text" @click="addDeskToApp" > <DesktopOutlined style="font-size: 22px;" /></a-button>
|
|
|
+ </a-tooltip>
|
|
|
+ </a-col>
|
|
|
+ <a-col class="df-center" style="height: 54px;">
|
|
|
<a-button type="text" @click="changeTheme" > <IconTsx :name="iconName" /></a-button>
|
|
|
</a-col>
|
|
|
<a-col class="df-center" style="height: 54px;">
|
|
|
@@ -63,6 +71,8 @@ import { IconTsx } from '@/components/MicroComponents/index'
|
|
|
import { useDesignStore } from '@/store'
|
|
|
import { useDeviceType } from '@/hooks'
|
|
|
import search from './components/search/index.vue'
|
|
|
+import { DesktopOutlined } from '@ant-design/icons-vue'
|
|
|
+import { message } from 'ant-design-vue'
|
|
|
|
|
|
const logoPng = require('@/assets/logo/logo-blue.png')
|
|
|
|
|
|
@@ -97,6 +107,21 @@ const changeRouter = (route: ROUTER.RoutesProps) => {
|
|
|
appRouter.changeNavbarRoute(route)
|
|
|
}
|
|
|
|
|
|
+const addDeskToApp = () => {
|
|
|
+ if ('beforeinstallprompt' in window) {
|
|
|
+ // 在支持 PWA 安装的浏览器中,手动触发安装提示
|
|
|
+ window.beforeinstallprompt.prompt()
|
|
|
+ window.beforeinstallprompt.userChoice.then((choiceResult) => {
|
|
|
+ if (choiceResult.outcome === 'accepted') {
|
|
|
+ console.log('用户已接受安装提示')
|
|
|
+ } else {
|
|
|
+ console.log('用户已拒绝安装提示')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ message.error('浏览器暂不支持此操作')
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped >
|