mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
@@ -2372,6 +2372,13 @@ app.whenReady().then(async () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.on('before-quit', async () => {
|
||||||
|
// 停止 HTTP 服务器,释放 TCP 端口占用,避免进程无法退出
|
||||||
|
try { await httpService.stop() } catch {}
|
||||||
|
// 终止 wcdb Worker 线程,避免线程阻止进程退出
|
||||||
|
try { wcdbService.shutdown() } catch {}
|
||||||
|
})
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class CloudControlService {
|
|||||||
private async reportOnline() {
|
private async reportOnline() {
|
||||||
const data: UsageStats = {
|
const data: UsageStats = {
|
||||||
appVersion: app.getVersion(),
|
appVersion: app.getVersion(),
|
||||||
platform: process.platform,
|
platform: this.getPlatformVersion(),
|
||||||
deviceId: this.deviceId,
|
deviceId: this.deviceId,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
online: true,
|
online: true,
|
||||||
@@ -46,6 +46,29 @@ class CloudControlService {
|
|||||||
this.pages.clear()
|
this.pages.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getPlatformVersion(): string {
|
||||||
|
const os = require('os')
|
||||||
|
const platform = process.platform
|
||||||
|
|
||||||
|
if (platform === 'win32') {
|
||||||
|
const release = os.release()
|
||||||
|
const parts = release.split('.')
|
||||||
|
const major = parseInt(parts[0])
|
||||||
|
const minor = parseInt(parts[1] || '0')
|
||||||
|
const build = parseInt(parts[2] || '0')
|
||||||
|
|
||||||
|
// Windows 11 是 10.0.22000+,且主版本必须是 10.0
|
||||||
|
if (major === 10 && minor === 0 && build >= 22000) {
|
||||||
|
return 'Windows 11'
|
||||||
|
} else if (major === 10) {
|
||||||
|
return 'Windows 10'
|
||||||
|
}
|
||||||
|
return `Windows ${release}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return platform
|
||||||
|
}
|
||||||
|
|
||||||
recordPage(pageName: string) {
|
recordPage(pageName: string) {
|
||||||
this.pages.add(pageName)
|
this.pages.add(pageName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,9 @@ function App() {
|
|||||||
} else {
|
} else {
|
||||||
// 协议已同意,检查数据收集同意状态
|
// 协议已同意,检查数据收集同意状态
|
||||||
const consent = await configService.getAnalyticsConsent()
|
const consent = await configService.getAnalyticsConsent()
|
||||||
if (consent === null) {
|
const denyCount = await configService.getAnalyticsDenyCount()
|
||||||
|
// 如果未设置同意状态且拒绝次数小于2次,显示弹窗
|
||||||
|
if (consent === null && denyCount < 2) {
|
||||||
setShowAnalyticsConsent(true)
|
setShowAnalyticsConsent(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -226,8 +228,9 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleAnalyticsDeny = async () => {
|
const handleAnalyticsDeny = async () => {
|
||||||
await configService.setAnalyticsConsent(false)
|
const denyCount = await configService.getAnalyticsDenyCount()
|
||||||
window.electronAPI.window.close()
|
await configService.setAnalyticsDenyCount(denyCount + 1)
|
||||||
|
setShowAnalyticsConsent(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听启动时的更新通知
|
// 监听启动时的更新通知
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ function SettingsPage() {
|
|||||||
const [wordCloudExcludeWords, setWordCloudExcludeWords] = useState<string[]>([])
|
const [wordCloudExcludeWords, setWordCloudExcludeWords] = useState<string[]>([])
|
||||||
const [excludeWordsInput, setExcludeWordsInput] = useState('')
|
const [excludeWordsInput, setExcludeWordsInput] = useState('')
|
||||||
|
|
||||||
|
// 数据收集同意状态
|
||||||
|
const [analyticsConsent, setAnalyticsConsent] = useState<boolean>(false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -343,6 +346,9 @@ function SettingsPage() {
|
|||||||
setWordCloudExcludeWords(savedExcludeWords)
|
setWordCloudExcludeWords(savedExcludeWords)
|
||||||
setExcludeWordsInput(savedExcludeWords.join('\n'))
|
setExcludeWordsInput(savedExcludeWords.join('\n'))
|
||||||
|
|
||||||
|
const savedAnalyticsConsent = await configService.getAnalyticsConsent()
|
||||||
|
setAnalyticsConsent(savedAnalyticsConsent ?? false)
|
||||||
|
|
||||||
// 如果语言列表为空,保存默认值
|
// 如果语言列表为空,保存默认值
|
||||||
if (!savedTranscribeLanguages || savedTranscribeLanguages.length === 0) {
|
if (!savedTranscribeLanguages || savedTranscribeLanguages.length === 0) {
|
||||||
const defaultLanguages = ['zh']
|
const defaultLanguages = ['zh']
|
||||||
@@ -2313,6 +2319,24 @@ function SettingsPage() {
|
|||||||
<a href="#" onClick={(e) => { e.preventDefault(); window.electronAPI.window.openAgreementWindow() }}>用户协议</a>
|
<a href="#" onClick={(e) => { e.preventDefault(); window.electronAPI.window.openAgreementWindow() }}>用户协议</a>
|
||||||
</div>
|
</div>
|
||||||
<p className="copyright">© 2025 WeFlow. All rights reserved.</p>
|
<p className="copyright">© 2025 WeFlow. All rights reserved.</p>
|
||||||
|
|
||||||
|
<div className="log-toggle-line" style={{ marginTop: '16px', justifyContent: 'center' }}>
|
||||||
|
<span style={{ fontSize: '13px', opacity: 0.7 }}>匿名数据收集</span>
|
||||||
|
<label className="switch">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="switch-input"
|
||||||
|
checked={analyticsConsent}
|
||||||
|
onChange={async (e) => {
|
||||||
|
const consent = e.target.checked
|
||||||
|
setAnalyticsConsent(consent)
|
||||||
|
await configService.setAnalyticsConsent(consent)
|
||||||
|
showMessage(consent ? '已允许数据收集' : '已拒绝数据收集', true)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span className="switch-slider"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ export const CONFIG_KEYS = {
|
|||||||
WORD_CLOUD_EXCLUDE_WORDS: 'wordCloudExcludeWords',
|
WORD_CLOUD_EXCLUDE_WORDS: 'wordCloudExcludeWords',
|
||||||
|
|
||||||
// 数据收集
|
// 数据收集
|
||||||
ANALYTICS_CONSENT: 'analyticsConsent'
|
ANALYTICS_CONSENT: 'analyticsConsent',
|
||||||
|
ANALYTICS_DENY_COUNT: 'analyticsDenyCount'
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export interface WxidConfig {
|
export interface WxidConfig {
|
||||||
@@ -1098,3 +1099,14 @@ export async function getAnalyticsConsent(): Promise<boolean | null> {
|
|||||||
export async function setAnalyticsConsent(consent: boolean): Promise<void> {
|
export async function setAnalyticsConsent(consent: boolean): Promise<void> {
|
||||||
await config.set(CONFIG_KEYS.ANALYTICS_CONSENT, consent)
|
await config.set(CONFIG_KEYS.ANALYTICS_CONSENT, consent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取数据收集拒绝次数
|
||||||
|
export async function getAnalyticsDenyCount(): Promise<number> {
|
||||||
|
const value = await config.get(CONFIG_KEYS.ANALYTICS_DENY_COUNT)
|
||||||
|
return typeof value === 'number' ? value : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置数据收集拒绝次数
|
||||||
|
export async function setAnalyticsDenyCount(count: number): Promise<void> {
|
||||||
|
await config.set(CONFIG_KEYS.ANALYTICS_DENY_COUNT, count)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user