mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-23 15:47:23 +08:00
feat: mac 添加权限
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
<n-message-provider>
|
||||
<router-view></router-view>
|
||||
<traffic-warning-drawer v-if="!isElectron"></traffic-warning-drawer>
|
||||
<disclaimer-modal></disclaimer-modal>
|
||||
</n-message-provider>
|
||||
</n-dialog-provider>
|
||||
</n-config-provider>
|
||||
@@ -18,6 +19,7 @@ import { computed, nextTick, onMounted, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import DisclaimerModal from '@/components/common/DisclaimerModal.vue';
|
||||
import TrafficWarningDrawer from '@/components/TrafficWarningDrawer.vue';
|
||||
import { usePlayerStore } from '@/store/modules/player';
|
||||
import { useSettingsStore } from '@/store/modules/settings';
|
||||
|
||||
@@ -237,6 +237,7 @@ import { useI18n } from 'vue-i18n';
|
||||
// 导入收款码图片
|
||||
import alipayQRCode from '@/assets/alipay.png';
|
||||
import wechatQRCode from '@/assets/wechat.png';
|
||||
import { isElectron, isLyricWindow } from '@/utils';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -250,20 +251,8 @@ const qrcodeType = ref<'wechat' | 'alipay'>('wechat');
|
||||
const isTransitioning = ref(false); // 防止用户点击过快
|
||||
|
||||
// 检查是否需要显示免责声明
|
||||
const shouldShowDisclaimer = (): boolean => {
|
||||
const agreedTime = localStorage.getItem(DISCLAIMER_AGREED_KEY);
|
||||
|
||||
// 从未同意过
|
||||
if (!agreedTime) return true;
|
||||
|
||||
const savedTime = parseInt(agreedTime, 10);
|
||||
const now = Date.now();
|
||||
|
||||
// 随机 3-10 天后再次显示
|
||||
const randomDays = Math.floor(Math.random() * 8) + 3; // 3-10 天
|
||||
const intervalMs = randomDays * 24 * 60 * 60 * 1000;
|
||||
|
||||
return now - savedTime >= intervalMs;
|
||||
const shouldShowDisclaimer = () => {
|
||||
return !localStorage.getItem(DISCLAIMER_AGREED_KEY);
|
||||
};
|
||||
|
||||
// 处理同意
|
||||
@@ -278,13 +267,18 @@ const handleAgree = () => {
|
||||
}, 300);
|
||||
};
|
||||
|
||||
// 处理不同意 - 关闭窗口
|
||||
// 处理不同意 - 退出应用
|
||||
const handleDisagree = () => {
|
||||
if (isTransitioning.value) return;
|
||||
isTransitioning.value = true;
|
||||
|
||||
// Web 环境下尝试关闭窗口
|
||||
window.close();
|
||||
if (isElectron) {
|
||||
// Electron 环境下强制退出应用
|
||||
window.api?.quitApp?.();
|
||||
} else {
|
||||
// Web 环境下尝试关闭窗口
|
||||
window.close();
|
||||
}
|
||||
isTransitioning.value = false;
|
||||
};
|
||||
|
||||
@@ -316,6 +310,9 @@ const handleEnterApp = () => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 歌词窗口不显示免责声明
|
||||
if (isLyricWindow.value) return;
|
||||
|
||||
// 检查是否需要显示免责声明
|
||||
if (shouldShowDisclaimer()) {
|
||||
showDisclaimer.value = true;
|
||||
|
||||
Reference in New Issue
Block a user