|
@@ -35,6 +35,40 @@ export default defineComponent({
|
|
|
|
|
|
// }, 2000)
|
|
|
|
|
|
+
|
|
|
+ if (window.matchMedia('(display-mode: standalone)').matches) {
|
|
|
+ console.log('应用内打开')
|
|
|
+ }else{
|
|
|
+ console.log(popEvent.value,'popEvent.value')
|
|
|
+ if(popEvent.value){
|
|
|
+ showModalMask.value = true;
|
|
|
+ setTimeout(()=>{
|
|
|
+ const btn = document.querySelector('#submitBtn')
|
|
|
+ console.log(btn)
|
|
|
+ if(btn){
|
|
|
+ btn.addEventListener('click', () => {
|
|
|
+ console.log(popEvent.value )
|
|
|
+ if( !popEvent.value ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ popEvent.value.prompt();
|
|
|
+ popEvent.value.userChoice.then( (choiceResult:any) => {
|
|
|
+ if (choiceResult.outcome === 'accepted') {
|
|
|
+ console.log('用户已同意添加到桌面')
|
|
|
+ showModalMask.value = false;
|
|
|
+ } else {
|
|
|
+ console.log('用户已取消添加到桌面')
|
|
|
+ showModalMask.value = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },500)
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -46,9 +80,9 @@ export default defineComponent({
|
|
|
|
|
|
onMounted(async () => {
|
|
|
const relatedApps = await navigator.getInstalledRelatedApps();
|
|
|
- console.log(relatedApps,'navigator.getInstalledRelatedApps()')
|
|
|
+ console.log(relatedApps)
|
|
|
|
|
|
- // showModalMask.value = true;
|
|
|
+ //
|
|
|
|
|
|
})
|
|
|
|
|
@@ -119,10 +153,12 @@ export default defineComponent({
|
|
|
{/* <NButton>确定</NButton> */}
|
|
|
<NSpace style={{ padding: '20px 0 0 0' }} justify="center">
|
|
|
<NButton
|
|
|
+ {...{id
|
|
|
+ :'submitBtn'}}
|
|
|
class={styles.submitAppBtn}
|
|
|
round
|
|
|
type="primary"
|
|
|
- // onClick={() => onSubmit()}
|
|
|
+
|
|
|
>
|
|
|
确定
|
|
|
</NButton>
|