新增规则组的来源只收 URL
浏览器里填服务器上的本地路径既没法验证也容易写错,真有本地清单走 文件上传,落盘位置由 Patchbay 统一管。已有的 file 类型声明不受影响。
This commit is contained in:
@@ -3,8 +3,10 @@
|
|||||||
* 新增一个规则组(rule-providers 里的一条声明)。
|
* 新增一个规则组(rule-providers 里的一条声明)。
|
||||||
*
|
*
|
||||||
* 内容的拉取、缓存、定时更新全是内核的活,这里只写声明:URL 生成 http 类型,
|
* 内容的拉取、缓存、定时更新全是内核的活,这里只写声明:URL 生成 http 类型,
|
||||||
* 本地路径生成 file 类型,缓存路径自动补一个确定的——不写 path 时内核按 url
|
* 上传的清单生成 file 类型。来源不收本地路径——浏览器里填服务器上的路径既没法
|
||||||
* 哈希自己生成,那个路径这里算不出来。
|
* 验证也容易写错,真有本地清单走文件上传,落盘位置由 Patchbay 统一管。
|
||||||
|
* 缓存路径自动补一个确定的——不写 path 时内核按 url 哈希自己生成,那个路径
|
||||||
|
* 这里算不出来。
|
||||||
*/
|
*/
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { inferRuleFormat, ruleProviderPath } from '@shared/rules.ts'
|
import { inferRuleFormat, ruleProviderPath } from '@shared/rules.ts'
|
||||||
@@ -61,7 +63,7 @@ const mrsConflict = computed(() => format.value === 'mrs' && behavior.value ===
|
|||||||
const canSubmit = computed(
|
const canSubmit = computed(
|
||||||
() =>
|
() =>
|
||||||
name.value.trim() !== '' &&
|
name.value.trim() !== '' &&
|
||||||
(file.value !== null || source.value.trim() !== '') &&
|
(file.value !== null || isUrl.value) &&
|
||||||
!nameTaken.value &&
|
!nameTaken.value &&
|
||||||
!mrsConflict.value &&
|
!mrsConflict.value &&
|
||||||
!props.saving,
|
!props.saving,
|
||||||
@@ -95,8 +97,7 @@ function submit() {
|
|||||||
path: ruleProviderPath(trimmedName, format.value),
|
path: ruleProviderPath(trimmedName, format.value),
|
||||||
format: format.value,
|
format: format.value,
|
||||||
}
|
}
|
||||||
: isUrl.value
|
: {
|
||||||
? {
|
|
||||||
type: 'http',
|
type: 'http',
|
||||||
behavior: behavior.value,
|
behavior: behavior.value,
|
||||||
url: trimmedSource,
|
url: trimmedSource,
|
||||||
@@ -104,7 +105,6 @@ function submit() {
|
|||||||
format: format.value,
|
format: format.value,
|
||||||
interval: 86400,
|
interval: 86400,
|
||||||
}
|
}
|
||||||
: { type: 'file', behavior: behavior.value, path: trimmedSource, format: format.value }
|
|
||||||
emit('submit', {
|
emit('submit', {
|
||||||
name: trimmedName,
|
name: trimmedName,
|
||||||
declaration,
|
declaration,
|
||||||
@@ -158,12 +158,12 @@ function onBackdrop(event: MouseEvent) {
|
|||||||
v-model="source"
|
v-model="source"
|
||||||
class="mono"
|
class="mono"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="https://… 或本地文件路径"
|
placeholder="https://example.com/rules.list"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
/>
|
/>
|
||||||
<span v-if="source.trim() !== ''" class="note">
|
<span v-if="source.trim() !== '' && !isUrl" class="bad">
|
||||||
{{ isUrl ? 'http 类型,由内核定时拉取' : 'file 类型,读本机文件' }}
|
来源要是 http(s) 地址,本地清单走下面的文件导入
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user