添加SMB网络共享支持

This commit is contained in:
jxxghp
2025-07-03 12:43:42 +08:00
parent eb70ca233b
commit bf5bbd3689
7 changed files with 201 additions and 0 deletions

View File

@@ -26,6 +26,11 @@ export const storageAttributes = [
icon: 'mdi-server-network-outline',
remote: true,
},
{
type: 'smb',
icon: 'mdi-folder-network-outline',
remote: true,
},
]
export const storageIconDict = storageAttributes.reduce((dict, item) => {

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -7,11 +7,13 @@ import u115_png from '@images/misc/u115.png'
import rclone_png from '@images/misc/rclone.png'
import alist_png from '@images/misc/openlist.svg'
import custom_png from '@images/misc/database.png'
import smb_png from '@images/misc/smb.png'
import api from '@/api'
import AliyunAuthDialog from '../dialog/AliyunAuthDialog.vue'
import U115AuthDialog from '../dialog/U115AuthDialog.vue'
import RcloneConfigDialog from '../dialog/RcloneConfigDialog.vue'
import AlistConfigDialog from '../dialog/AlistConfigDialog.vue'
import SmbConfigDialog from '../dialog/SmbConfigDialog.vue'
import { useToast } from 'vue-toastification'
import { isNullOrEmptyObject } from '@/@core/utils'
import { useI18n } from 'vue-i18n'
@@ -65,6 +67,8 @@ const u115AuthDialog = ref(false)
const rcloneConfigDialog = ref(false)
// AList配置对话框
const aListConfigDialog = ref(false)
// SMB配置对话框
const smbConfigDialog = ref(false)
// 自定义存储配置对话框
const customConfigDialog = ref(false)
@@ -83,6 +87,9 @@ function openStorageDialog() {
case 'alist':
aListConfigDialog.value = true
break
case 'smb':
smbConfigDialog.value = true
break
case 'local':
$toast.info(t('storage.noConfigNeeded'))
break
@@ -105,6 +112,8 @@ const getIcon = computed(() => {
return rclone_png
case 'alist':
return alist_png
case 'smb':
return smb_png
default:
return custom_png
}
@@ -143,6 +152,7 @@ function handleDone() {
u115AuthDialog.value = false
rcloneConfigDialog.value = false
aListConfigDialog.value = false
smbConfigDialog.value = false
customConfigDialog.value = false
// 更新存储
storage_ref.value.name = customName.value
@@ -203,6 +213,13 @@ function onClose() {
@close="aListConfigDialog = false"
@done="handleDone"
/>
<SmbConfigDialog
v-if="smbConfigDialog"
v-model="smbConfigDialog"
:conf="props.storage.config || {}"
@close="smbConfigDialog = false"
@done="handleDone"
/>
<VDialog
v-if="customConfigDialog"
v-model="customConfigDialog"

View File

@@ -0,0 +1,131 @@
<script lang="ts" setup>
import api from '@/api'
import { useI18n } from 'vue-i18n'
import { useDisplay } from 'vuetify'
// 显示器宽度
const display = useDisplay()
// 多语言支持
const { t } = useI18n()
// 定义输入
const props = defineProps({
conf: {
type: Object as PropType<{ [key: string]: any }>,
required: true,
},
})
// 定义事件
const emit = defineEmits(['done', 'close'])
// 完成
async function handleDone() {
await saveSmbConfig()
emit('done')
}
// 重置配置
async function handleReset() {
try {
const result: { [key: string]: any } = await api.get('/storage/reset/smb')
if (result.success) {
// 重置成功
handleDone()
}
} catch (e) {
console.error(e)
}
}
// 保存 SMB 设置
async function saveSmbConfig() {
try {
await api.post(`storage/save/smb`, props.conf)
} catch (e) {
console.error(e)
}
}
</script>
<template>
<VDialog width="50rem" scrollable :fullscreen="!display.mdAndUp.value">
<VCard>
<VDialogCloseBtn @click="emit('close')" />
<VCardItem>
<template #prepend>
<VIcon icon="mdi-folder-network-outline" class="me-2" />
</template>
<VCardTitle>
{{ t('dialog.smbConfig.title') }}
</VCardTitle>
</VCardItem>
<VDivider />
<VCardText>
<VRow>
<VCol cols="12" md="6">
<VTextField
v-model="props.conf.host"
:hint="t('dialog.smbConfig.hostHint')"
:label="t('dialog.smbConfig.host')"
persistent-hint
prepend-inner-icon="mdi-server"
placeholder="192.168.1.100"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="props.conf.share"
:hint="t('dialog.smbConfig.shareHint')"
:label="t('dialog.smbConfig.share')"
persistent-hint
prepend-inner-icon="mdi-folder-network"
placeholder="shared_folder"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="props.conf.username"
:hint="t('dialog.smbConfig.usernameHint')"
:label="t('dialog.smbConfig.username')"
persistent-hint
prepend-inner-icon="mdi-account"
placeholder="your_username"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
type="password"
v-model="props.conf.password"
:hint="t('dialog.smbConfig.passwordHint')"
:label="t('dialog.smbConfig.password')"
persistent-hint
prepend-inner-icon="mdi-lock"
placeholder="your_password"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="props.conf.domain"
:hint="t('dialog.smbConfig.domainHint')"
:label="t('dialog.smbConfig.domain')"
persistent-hint
prepend-inner-icon="mdi-domain"
placeholder="WORKGROUP"
/>
</VCol>
</VRow>
</VCardText>
<VCardActions>
<VBtn color="error" @click="handleReset" prepend-icon="mdi-restore" class="px-5 me-3">
{{ t('dialog.smbConfig.reset') }}
</VBtn>
<VSpacer />
<VBtn @click="handleDone" prepend-icon="mdi-check" class="px-5 me-3">
{{ t('dialog.smbConfig.complete') }}
</VBtn>
</VCardActions>
</VCard>
</VDialog>
</template>

View File

@@ -780,6 +780,7 @@ export default {
u115: '115 Cloud',
rclone: 'RClone',
alist: 'OpenList',
smb: 'SMB Network Share',
custom: 'Custom',
},
filterRules: {
@@ -1678,6 +1679,21 @@ export default {
complete: 'Complete',
reset: 'Reset',
},
smbConfig: {
title: 'SMB Network Share Configuration',
host: 'SMB Server Address',
hostHint: 'IP address or hostname of the SMB server',
share: 'Share Name',
shareHint: 'Name of the shared folder to connect to',
username: 'Username',
usernameHint: 'SMB login username',
password: 'Password',
passwordHint: 'SMB login password',
domain: 'Domain',
domainHint: 'SMB domain name, such as WORKGROUP or domain controller name',
complete: 'Complete',
reset: 'Reset',
},
workflowAddEdit: {
addTitle: 'Add Workflow',
editTitle: 'Edit Workflow',

View File

@@ -777,6 +777,7 @@ export default {
u115: '115网盘',
rclone: 'RClone',
alist: 'OpenList',
smb: 'SMB网络共享',
custom: '自定义',
},
filterRules: {
@@ -1656,6 +1657,21 @@ export default {
complete: '完成',
reset: '重置',
},
smbConfig: {
title: 'SMB网络共享配置',
host: 'SMB服务器地址',
hostHint: 'SMB服务器的IP地址或主机名',
share: '共享名称',
shareHint: '要连接的共享文件夹名称',
username: '用户名',
usernameHint: 'SMB登录用户名',
password: '密码',
passwordHint: 'SMB登录密码',
domain: '域名',
domainHint: 'SMB域名如WORKGROUP或域控制器名称',
complete: '完成',
reset: '重置',
},
workflowAddEdit: {
addTitle: '添加工作流',
editTitle: '编辑工作流',

View File

@@ -775,6 +775,7 @@ export default {
u115: '115網盤',
rclone: 'RClone',
alist: 'OpenList',
smb: 'SMB網路共享',
custom: '自定義',
},
@@ -1655,6 +1656,21 @@ export default {
complete: '完成',
reset: '重置',
},
smbConfig: {
title: 'SMB網路共享配置',
host: 'SMB伺服器地址',
hostHint: 'SMB伺服器的IP地址或主機名',
share: '共享名稱',
shareHint: '要連接的共享資料夾名稱',
username: '用戶名',
usernameHint: 'SMB登入用戶名',
password: '密碼',
passwordHint: 'SMB登入密碼',
domain: '域名',
domainHint: 'SMB域名如WORKGROUP或域控制器名稱',
complete: '完成',
reset: '重置',
},
workflowAddEdit: {
addTitle: '新增工作流',
editTitle: '編輯工作流',