Integrate KDocs auto-upload
This commit is contained in:
@@ -30,3 +30,12 @@ export async function changePassword(payload) {
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchKdocsSettings() {
|
||||
const { data } = await publicApi.get('/user/kdocs')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateKdocsSettings(payload) {
|
||||
const { data } = await publicApi.post('/user/kdocs', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import {
|
||||
changePassword,
|
||||
fetchEmailNotify,
|
||||
fetchUserEmail,
|
||||
fetchKdocsSettings,
|
||||
unbindEmail,
|
||||
updateKdocsSettings,
|
||||
updateEmailNotify,
|
||||
} from '../api/settings'
|
||||
import { useUserStore } from '../stores/user'
|
||||
@@ -111,6 +113,10 @@ const passwordForm = reactive({
|
||||
confirm_password: '',
|
||||
})
|
||||
|
||||
const kdocsLoading = ref(false)
|
||||
const kdocsSaving = ref(false)
|
||||
const kdocsUnitValue = ref('')
|
||||
|
||||
function syncIsMobile() {
|
||||
isMobile.value = Boolean(mediaQuery?.matches)
|
||||
if (!isMobile.value) drawerOpen.value = false
|
||||
@@ -231,7 +237,7 @@ async function openSettings() {
|
||||
}
|
||||
|
||||
async function loadSettings() {
|
||||
await Promise.all([loadEmailInfo(), loadEmailNotify()])
|
||||
await Promise.all([loadEmailInfo(), loadEmailNotify(), loadKdocsSettings()])
|
||||
}
|
||||
|
||||
async function loadEmailInfo() {
|
||||
@@ -262,6 +268,30 @@ async function loadEmailNotify() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadKdocsSettings() {
|
||||
kdocsLoading.value = true
|
||||
try {
|
||||
const data = await fetchKdocsSettings()
|
||||
kdocsUnitValue.value = data?.kdocs_unit || ''
|
||||
} catch {
|
||||
kdocsUnitValue.value = ''
|
||||
} finally {
|
||||
kdocsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function saveKdocsSettings() {
|
||||
kdocsSaving.value = true
|
||||
try {
|
||||
await updateKdocsSettings({ kdocs_unit: kdocsUnitValue.value.trim() })
|
||||
ElMessage.success('已更新表格县区设置')
|
||||
} catch {
|
||||
// handled by interceptor
|
||||
} finally {
|
||||
kdocsSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onBindEmail() {
|
||||
const email = bindEmailValue.value.trim().toLowerCase()
|
||||
if (!email) {
|
||||
@@ -635,6 +665,24 @@ async function dismissAnnouncementPermanently() {
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="表格上传" name="kdocs">
|
||||
<div v-loading="kdocsLoading" class="settings-section">
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="县区(可选)">
|
||||
<el-input v-model="kdocsUnitValue" placeholder="留空使用系统默认县区" />
|
||||
</el-form-item>
|
||||
<el-button type="primary" :loading="kdocsSaving" @click="saveKdocsSettings">保存</el-button>
|
||||
</el-form>
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
title="自动上传开关在“账号管理”页面设置(测试功能)。"
|
||||
show-icon
|
||||
class="settings-hint"
|
||||
/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="VIP信息" name="vip">
|
||||
<div class="settings-section">
|
||||
<el-alert
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
updateAccount,
|
||||
updateAccountRemark,
|
||||
} from '../api/accounts'
|
||||
import { fetchKdocsSettings, updateKdocsSettings } from '../api/settings'
|
||||
import { fetchRunStats } from '../api/stats'
|
||||
import { useSocket } from '../composables/useSocket'
|
||||
import { useUserStore } from '../stores/user'
|
||||
@@ -57,6 +58,9 @@ watch(batchEnableScreenshot, (value) => {
|
||||
}
|
||||
})
|
||||
|
||||
const kdocsAutoUpload = ref(false)
|
||||
const kdocsSettingsLoading = ref(false)
|
||||
|
||||
const addOpen = ref(false)
|
||||
const editOpen = ref(false)
|
||||
const upgradeOpen = ref(false)
|
||||
@@ -189,6 +193,30 @@ async function refreshAccounts() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadKdocsSettings() {
|
||||
kdocsSettingsLoading.value = true
|
||||
try {
|
||||
const data = await fetchKdocsSettings()
|
||||
kdocsAutoUpload.value = Number(data?.kdocs_auto_upload || 0) === 1
|
||||
} catch {
|
||||
kdocsAutoUpload.value = false
|
||||
} finally {
|
||||
kdocsSettingsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onToggleKdocsAutoUpload(value) {
|
||||
kdocsSettingsLoading.value = true
|
||||
try {
|
||||
await updateKdocsSettings({ kdocs_auto_upload: value ? 1 : 0 })
|
||||
ElMessage.success(value ? '已开启自动上传(测试)' : '已关闭自动上传')
|
||||
} catch (e) {
|
||||
kdocsAutoUpload.value = !value
|
||||
} finally {
|
||||
kdocsSettingsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onStart(acc) {
|
||||
try {
|
||||
await startAccount(acc.id, { browse_type: browseTypeById[acc.id] || '应读', enable_screenshot: batchEnableScreenshot.value })
|
||||
@@ -524,6 +552,7 @@ onMounted(async () => {
|
||||
unbindSocket = bindSocket()
|
||||
|
||||
await refreshAccounts()
|
||||
await loadKdocsSettings()
|
||||
await refreshStats()
|
||||
syncStatsPolling()
|
||||
})
|
||||
@@ -612,6 +641,15 @@ onBeforeUnmount(() => {
|
||||
<el-option v-for="opt in browseTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
<el-switch v-model="batchEnableScreenshot" inline-prompt active-text="截图" inactive-text="不截图" />
|
||||
<el-switch
|
||||
v-model="kdocsAutoUpload"
|
||||
:disabled="kdocsSettingsLoading"
|
||||
inline-prompt
|
||||
active-text="上传"
|
||||
inactive-text="不传"
|
||||
@change="onToggleKdocsAutoUpload"
|
||||
/>
|
||||
<span class="app-muted">表格(测试)</span>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-right">
|
||||
|
||||
Reference in New Issue
Block a user