Skip to content

Commit

Permalink
feat(webdav): support option configuration of webdav
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Oct 14, 2021
1 parent bef9047 commit d667a83
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
16 changes: 10 additions & 6 deletions packages/sharelist-web/src/views/manage/partial/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@ const valueDisplay = (value: any, type: string) => {
export default defineComponent({
setup() {
const fields = [
{ code: 'token', label: '后台密码', type: 'string', hiddenDesc: true },
{ code: 'token', label: '后台密码', type: 'string', secret: true },
{ code: 'title', label: '网站标题', type: 'string' },
{ code: 'index_enable', label: '目录索引', type: 'boolean' },
{ code: 'expand_single_disk', label: '展开单一挂载盘', type: 'boolean' },
{ code: 'anonymous_download_enable', label: '允许下载', type: 'boolean' },
{ code: 'fast_mode', label: '快速模式', type: 'boolean' },
{ code: 'ignores', label: '忽略路径', type: 'array' },
{ code: 'webdav_path', label: 'WebDAV路径', type: 'string' },
{ code: 'acl_file', label: '加密文件名', type: 'string' },
{ code: 'webdav_path', label: 'WebDAV 路径', type: 'string' },
{ code: 'webdav_proxy', label: 'WebDAV 代理', type: 'boolean' },
{ code: 'webdav_user', label: 'WebDAV 用户名', type: 'string' },
{ code: 'webdav_pass', label: 'WebDAV 密码', type: 'string', secret: true },
]
const { config, setConfig } = useSetting()

const createInputModifier = (label: string, code: string) => {
const modifier = ref(config[code])
const createInputModifier = (label: string, code: string, isSecret: boolean | undefined) => {
const modifier = ref(isSecret ? '' : config[code])
const handleChange = (e: any) => modifier.value = e.target.value

//modal 下的input v-model 有bug
Expand Down Expand Up @@ -78,14 +82,14 @@ export default defineComponent({
<div class="item__header">
<div class="item__meta">
<h4 class="item__meta-title">{i.label}</h4>
<div class="item__meta-desc">{i.hiddenDesc ? '' : valueDisplay(config[i.code], i.type)}</div>
<div class="item__meta-desc">{i.secret ? '' : valueDisplay(config[i.code], i.type)}</div>
</div>
</div>
<div class="item-action">
{i.type == 'boolean' ? (
<Switch checked={config[i.code]} onChange={(e) => setConfig({ [i.code]: e })} />
) : i.type == 'string' ? (
<a onClick={() => createInputModifier(i.label, i.code, i.isPassword)}>修改</a>
<a onClick={() => createInputModifier(i.label, i.code, i.secret)}>修改</a>
) : i.type == 'array' ? (
<a onClick={() => createListModifier(i.label, i.code)}>修改</a>
) : null}
Expand Down
6 changes: 6 additions & 0 deletions packages/sharelist/package/sharelist/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const defaultConfig = {

proxy_server: '',

webdav_proxy: true,

webdav_user: 'admin',

webdav_pass: 'sharelist',

ocr_server: '',

drives: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/sharelist/package/sharelist/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exports.getDownloadUrl = async (runtime) => {
}

try {
let url = await sharelist.get_download_url(runtime)
let { url } = await sharelist.get_download_url(runtime)
return { url }

} catch (error) {
Expand Down
18 changes: 7 additions & 11 deletions packages/sharelist/package/webdav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const createDriver = (driver, { proxy, baseUrl } = {}) => {
},
async stat(path) {
//console.log('stat', parsePath(path),)

try {
return await driver.stat({ paths: parsePath(path) })
} catch (error) {
Expand All @@ -36,18 +35,17 @@ const createDriver = (driver, { proxy, baseUrl } = {}) => {
}
},