perf: install check

This commit is contained in:
putyy
2025-05-21 11:45:59 +08:00
committed by putyy
parent ee6698a8e8
commit 27f9fb0def
6 changed files with 70 additions and 64 deletions

View File

@@ -2,8 +2,6 @@
<NConfigProvider class="h-full" :theme="theme" :locale="uiLocale">
<NaiveProvider>
<RouterView/>
<ShowLoading :isLoading="loading"/>
<Password v-model:showModal="showPassword" @submit="handlePassword"/>
</NaiveProvider>
<NGlobalStyle/>
<NModalProvider/>
@@ -14,19 +12,14 @@
import NaiveProvider from '@/components/NaiveProvider.vue'
import {darkTheme, lightTheme, zhCN, enUS} from 'naive-ui'
import {useIndexStore} from "@/stores"
import {computed, onMounted, ref} from "vue"
import {computed, onMounted} from "vue"
import {useEventStore} from "@/stores/event"
import type {appType} from "@/types/app"
import appApi from "@/api/app"
import ShowLoading from "@/components/ShowLoading.vue"
import Password from "@/components/Password.vue"
import {useI18n} from 'vue-i18n'
const store = useIndexStore()
const eventStore = useEventStore()
const loading = ref(false)
const showPassword = ref(false)
const {t, locale} = useI18n()
const {locale} = useI18n()
const theme = computed(() => {
if (store.globalConfig.Theme === "darkTheme") {
@@ -47,11 +40,6 @@ const uiLocale = computed(() => {
onMounted(async () => {
await store.init()
loading.value = true
handleInstall().then((is: boolean)=>{
loading.value = false
})
eventStore.init()
eventStore.addHandle({
@@ -68,34 +56,4 @@ onMounted(async () => {
}
})
})
const handleInstall = async () => {
const res = await appApi.install()
if (res.code === 1) {
store.globalConfig.AutoProxy && store.openProxy()
return true
}
window.$message?.error(res.message, {duration: 5000})
if (store.envInfo.platform === 'windows' && res.message.includes('Access is denied')) {
window.$message?.error('首次启用本软件,请使用鼠标右键选择以管理员身份运行')
} else if (['darwin', 'linux'].includes(store.envInfo.platform)) {
showPassword.value = true
}
return false
}
const handlePassword = async (password: string, isCache: boolean) => {
const res = await appApi.setSystemPassword({password, isCache})
if (res.code === 0) {
window.$message?.error(res.message)
return
}
handleInstall().then((is: boolean)=>{
if (is) {
showPassword.value = false
}
})
}
</script>

View File

@@ -12,6 +12,7 @@ interface RequestOptions {
const instance = axios.create({
baseURL: "/",
timeout: 180000
})
instance.interceptors.request.use(

View File

@@ -15,7 +15,7 @@
:on-after-leave="() => { showAppName = false }"
:collapsed-width="70"
:collapsed="collapsed"
:width="140"
:width="envInfo.platform==='linux' ? 160 : 140"
:native-scrollbar="false"
:inverted="inverted"
:on-update:collapsed="collapsedChange"

View File

@@ -74,7 +74,8 @@
"video_decode_success": "Decrypt Success",
"use_data": "Please select required data",
"import_placeholder": "When adding multiple items, ensure each line contains only one (each link on a new line)",
"import_empty": "Please enter data to import"
"import_empty": "Please enter data to import",
"win_install_tip": "For the first time using this software, please right-click and select 'Run as administrator'"
},
"setting": {
"restart_tip": "Keep default if unsure, please restart software after modification",

View File

@@ -74,7 +74,8 @@
"video_decode_success": "解密成功",
"use_data": "请选择需要的数据",
"import_placeholder": "添加多个时,请确保每行只有一个(每个链接回车换行)",
"import_empty": "请输入需要导入的数据"
"import_empty": "请输入需要导入的数据",
"win_install_tip": "首次启用本软件,请使用鼠标右键选择以管理员身份运行"
},
"setting": {
"restart_tip": "如果不清楚保持默认就行,修改后请重启软件",

View File

@@ -230,7 +230,6 @@ const columns = ref<any[]>([
}
}
])
const downIndex = ref(0)
const checkedRowKeysValue = ref<DataTableRowKey[]>([])
const showPreviewRow = ref(false)
const previewRow = ref<appType.MediaInfo>()
@@ -238,8 +237,19 @@ const loading = ref(false)
const loadingText = ref("")
const showImport = ref(false)
const showPassword = ref(false)
let isOpenProxy = false
let downIndex = 0
onMounted(() => {
try {
loading.value = true
handleInstall().then((is: boolean) => {
loading.value = false
})
}catch (e) {
window.$message?.error(JSON.stringify(e), {duration: 5000})
}
buildClassify()
const temp = localStorage.getItem("resources-type")
@@ -269,12 +279,14 @@ onMounted(() => {
case "running":
loading.value = true
loadingText.value = res.Message
break;
break
case "done":
loading.value = false
if (data.value[downIndex.value]?.Id === res.Id) {
data.value[downIndex.value].SavePath = res.SavePath
data.value[downIndex.value].Status = "done"
setTimeout(()=>{
loading.value = false
}, 100)
if (data.value[downIndex]?.Id === res.Id) {
data.value[downIndex].SavePath = res.SavePath
data.value[downIndex].Status = "done"
} else {
for (const i in data.value) {
if (data.value[i].Id === res.Id) {
@@ -286,11 +298,13 @@ onMounted(() => {
}
localStorage.setItem("resources-data", JSON.stringify(data.value))
window?.$message?.success(t("index.download_success"))
break;
break
case "error":
loading.value = false
setTimeout(()=>{
loading.value = false
}, 100)
window?.$message?.error(res.Message)
break;
break
}
}
})
@@ -456,7 +470,7 @@ const download = (row: appType.MediaInfo, index: number) => {
}
loadingText.value = "ready"
loading.value = true
downIndex.value = index
downIndex = index
if (row.DecodeKey) {
appApi.download({
...row,
@@ -478,12 +492,16 @@ const download = (row: appType.MediaInfo, index: number) => {
}
const open = () => {
isOpenProxy = true
store.openProxy().then((res: appType.Res) => {
if (res.code === 1) {
return
}
if (store.envInfo.platform === "darwin" || store.envInfo.platform === "linux") {
if (["darwin", "linux"].includes(store.envInfo.platform)) {
showPassword.value = true
} else {
window.$message?.error(res.message)
}
})
}
@@ -552,14 +570,41 @@ const handleImport = (content: string) => {
showImport.value = false
}
const handlePassword = (password: string, isCache: boolean) => {
appApi.setSystemPassword({password: password, isCache: isCache}).then((res: appType.Res) => {
if (res.code === 0) {
window?.$message?.error(res.message)
return
}
const handlePassword = async (password: string, isCache: boolean) => {
const res = await appApi.setSystemPassword({password, isCache})
if (res.code === 0) {
window.$message?.error(res.message)
return
}
if (isOpenProxy) {
showPassword.value = false
store.openProxy()
return
}
handleInstall().then((is: boolean) => {
if (is) {
showPassword.value = false
}
})
}
const handleInstall = async () => {
isOpenProxy = false
const res = await appApi.install()
if (res.code === 1) {
store.globalConfig.AutoProxy && store.openProxy()
return true
}
window.$message?.error(res.message, {duration: 5000})
if (store.envInfo.platform === "windows" && res.message.includes("Access is denied")) {
window.$message?.error(t("index.win_install_tip"))
} else if (["darwin", "linux"].includes(store.envInfo.platform)) {
showPassword.value = true
}
return false
}
</script>