add sitedata refresh setting

This commit is contained in:
jxxghp
2024-09-21 19:23:01 +08:00
parent 7e4f21ff33
commit 40a9caceb8
+54 -21
View File
@@ -2,9 +2,6 @@
import { useToast } from 'vue-toast-notification' import { useToast } from 'vue-toast-notification'
import api from '@/api' import api from '@/api'
// 从 provide 中获取全局设置
const globalSettings: any = inject('globalSettings')
// 提示框 // 提示框
const $toast = useToast() const $toast = useToast()
@@ -18,7 +15,7 @@ const resetSitesText = ref('重置站点数据')
const resetSitesDisabled = ref(false) const resetSitesDisabled = ref(false)
// CookieCloud设置项 // CookieCloud设置项
const cookieCloudSetting = ref({ const siteSetting = ref({
COOKIECLOUD_HOST: '', COOKIECLOUD_HOST: '',
COOKIECLOUD_KEY: '', COOKIECLOUD_KEY: '',
COOKIECLOUD_PASSWORD: '', COOKIECLOUD_PASSWORD: '',
@@ -26,6 +23,7 @@ const cookieCloudSetting = ref({
USER_AGENT: '', USER_AGENT: '',
COOKIECLOUD_ENABLE_LOCAL: '', COOKIECLOUD_ENABLE_LOCAL: '',
COOKIECLOUD_BLACKLIST: '', COOKIECLOUD_BLACKLIST: '',
SITEDATA_REFRESH_INTERVAL: 0,
}) })
// 同步间隔下拉框 // 同步间隔下拉框
@@ -39,6 +37,16 @@ const CookieCloudIntervalItems = [
{ title: '永不', value: 0 }, { title: '永不', value: 0 },
] ]
// 站点数据刷新间隔
const SiteDataRefreshIntervalItems = [
{ title: '每小时', value: 1 },
{ title: '每6小时', value: 6 },
{ title: '每12小时', value: 12 },
{ title: '每天', value: 24 },
{ title: '每周', value: 168 },
{ title: '永不', value: 0 },
]
// 重置站点 // 重置站点
async function resetSites() { async function resetSites() {
try { try {
@@ -56,8 +64,8 @@ async function resetSites() {
} }
} }
// 加载CookieCloud设置 // 加载站点设置
async function loadCookieCloudSettings() { async function loadSiteSettings() {
try { try {
const result: { [key: string]: any } = await api.get('system/env') const result: { [key: string]: any } = await api.get('system/env')
if (result.success) { if (result.success) {
@@ -69,8 +77,9 @@ async function loadCookieCloudSettings() {
USER_AGENT, USER_AGENT,
COOKIECLOUD_ENABLE_LOCAL, COOKIECLOUD_ENABLE_LOCAL,
COOKIECLOUD_BLACKLIST, COOKIECLOUD_BLACKLIST,
SITEDATA_REFRESH_INTERVAL,
} = result.data } = result.data
cookieCloudSetting.value = { siteSetting.value = {
COOKIECLOUD_HOST, COOKIECLOUD_HOST,
COOKIECLOUD_KEY, COOKIECLOUD_KEY,
COOKIECLOUD_PASSWORD, COOKIECLOUD_PASSWORD,
@@ -78,6 +87,7 @@ async function loadCookieCloudSettings() {
USER_AGENT, USER_AGENT,
COOKIECLOUD_ENABLE_LOCAL, COOKIECLOUD_ENABLE_LOCAL,
COOKIECLOUD_BLACKLIST, COOKIECLOUD_BLACKLIST,
SITEDATA_REFRESH_INTERVAL,
} }
} }
} catch (error) { } catch (error) {
@@ -86,12 +96,12 @@ async function loadCookieCloudSettings() {
} }
// 调用API保存CookieCloud设置 // 调用API保存CookieCloud设置
async function saveCookieCloudetting() { async function saveSiteSetting() {
try { try {
const result: { [key: string]: any } = await api.post('system/env', cookieCloudSetting.value) const result: { [key: string]: any } = await api.post('system/env', siteSetting.value)
if (result.success) $toast.success('保存站点同步设置成功') if (result.success) $toast.success('保存站点设置成功')
else $toast.error('保存站点同步设置失败!') else $toast.error('保存站点设置失败!')
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
@@ -99,7 +109,7 @@ async function saveCookieCloudetting() {
// 加载数据 // 加载数据
onMounted(() => { onMounted(() => {
loadCookieCloudSettings() loadSiteSettings()
}) })
</script> </script>
@@ -116,7 +126,7 @@ onMounted(() => {
<VRow> <VRow>
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VCheckbox <VCheckbox
v-model="cookieCloudSetting.COOKIECLOUD_ENABLE_LOCAL" v-model="siteSetting.COOKIECLOUD_ENABLE_LOCAL"
label="启用本地CookieCloud服务器" label="启用本地CookieCloud服务器"
hint="使用内建CookieCloud服务同步站点数据,服务地址为:http://localhost:3000/cookiecloud" hint="使用内建CookieCloud服务同步站点数据,服务地址为:http://localhost:3000/cookiecloud"
persistent-hint persistent-hint
@@ -126,17 +136,17 @@ onMounted(() => {
<VRow> <VRow>
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="cookieCloudSetting.COOKIECLOUD_HOST" v-model="siteSetting.COOKIECLOUD_HOST"
label="服务地址" label="服务地址"
placeholder="https://movie-pilot.org/cookiecloud" placeholder="https://movie-pilot.org/cookiecloud"
:disabled="!!cookieCloudSetting.COOKIECLOUD_ENABLE_LOCAL" :disabled="!!siteSetting.COOKIECLOUD_ENABLE_LOCAL"
hint="远端CookieCloud服务地址,格式:https://movie-pilot.org/cookiecloud" hint="远端CookieCloud服务地址,格式:https://movie-pilot.org/cookiecloud"
persistent-hint persistent-hint
/> />
</VCol> </VCol>
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="cookieCloudSetting.COOKIECLOUD_KEY" v-model="siteSetting.COOKIECLOUD_KEY"
label="用户KEY" label="用户KEY"
hint="CookieCloud浏览器插件生成的用户KEY" hint="CookieCloud浏览器插件生成的用户KEY"
persistent-hint persistent-hint
@@ -144,7 +154,7 @@ onMounted(() => {
</VCol> </VCol>
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="cookieCloudSetting.COOKIECLOUD_PASSWORD" v-model="siteSetting.COOKIECLOUD_PASSWORD"
type="password" type="password"
label="端对端加密密码" label="端对端加密密码"
hint="CookieCloud浏览器插件生成的端对端加密密码" hint="CookieCloud浏览器插件生成的端对端加密密码"
@@ -153,7 +163,7 @@ onMounted(() => {
</VCol> </VCol>
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VSelect <VSelect
v-model="cookieCloudSetting.COOKIECLOUD_INTERVAL" v-model="siteSetting.COOKIECLOUD_INTERVAL"
label="自动同步间隔" label="自动同步间隔"
:items="CookieCloudIntervalItems" :items="CookieCloudIntervalItems"
hint="从CookieCloud服务器自动同步站点Cookie到MoviePilot的时间间隔" hint="从CookieCloud服务器自动同步站点Cookie到MoviePilot的时间间隔"
@@ -162,7 +172,7 @@ onMounted(() => {
</VCol> </VCol>
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="cookieCloudSetting.COOKIECLOUD_BLACKLIST" v-model="siteSetting.COOKIECLOUD_BLACKLIST"
label="同步域名黑名单" label="同步域名黑名单"
placeholder="多个域名,分割" placeholder="多个域名,分割"
hint="CookieCloud同步域名黑名单,多个域名,分割" hint="CookieCloud同步域名黑名单,多个域名,分割"
@@ -171,7 +181,7 @@ onMounted(() => {
</VCol> </VCol>
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="cookieCloudSetting.USER_AGENT" v-model="siteSetting.USER_AGENT"
label="浏览器User-Agent" label="浏览器User-Agent"
hint="CookieCloud插件所在的浏览器的User-Agent" hint="CookieCloud插件所在的浏览器的User-Agent"
persistent-hint persistent-hint
@@ -181,7 +191,30 @@ onMounted(() => {
</VForm> </VForm>
</VCardText> </VCardText>
<VCardText> <VCardText>
<VBtn type="submit" @click="saveCookieCloudetting"> 保存 </VBtn> <VBtn type="submit" @click="saveSiteSetting"> 保存 </VBtn>
</VCardText>
</VCard>
</VCol>
<VCol cols="12">
<VCard title="站点数据刷新">
<VCardText>
<VForm>
<VRow>
<VCol cols="12" md="6">
<VSelect
v-model="siteSetting.SITEDATA_REFRESH_INTERVAL"
label="站点数据刷新间隔"
:items="SiteDataRefreshIntervalItems"
hint="刷新站点用户上传下载等数据的时间间隔"
persistent-hint
/>
</VCol>
</VRow>
</VForm>
</VCardText>
<VCardText>
<VBtn type="submit" @click="saveSiteSetting"> 保存 </VBtn>
</VCardText> </VCardText>
</VCard> </VCard>
</VCol> </VCol>