Skip to content

Commit

Permalink
Merge pull request #424 from anobaka/v1.7.1-beta6
Browse files Browse the repository at this point in the history
  • Loading branch information
anobaka authored Aug 12, 2023
2 parents 5cf710a + 13f86cf commit 1ce8a3d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

.title {
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 5px;

.next-radio-wrapper {
.next-radio-label {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Input, Radio, Tag } from '@alifd/next';
import { Balloon, Button, Input, Radio, Tag } from '@alifd/next';
import React, { useState } from 'react';
import './index.scss';
import { useUpdateEffect } from 'react-use';
Expand All @@ -8,6 +8,7 @@ import type { IMatcherValue } from '@/components/PathSegmentsConfiguration/model
import { ResourceMatcherValueType } from '@/components/PathSegmentsConfiguration/models/MatcherValue';
import { execAll } from '@/components/utils';
import { getResultFromExecAll } from '@/components/PathSegmentsConfiguration/utils';
import CustomIcon from '@/components/CustomIcon';

interface IValue {
layer?: number;
Expand Down Expand Up @@ -165,9 +166,20 @@ const SegmentMatcherConfiguration = (props: ISegmentMatcherConfiguration) => {
label={t('Set by {{thing}}', { thing: t('regex') })}
checked={mode == 'regex'}
/>
<div className="tip">
<Balloon.Tooltip
trigger={(
<CustomIcon type={'question-circle'} />
)}
triggerType={'hover'}
align={'t'}
v2
>
{t('/ is the directory separator always, not \\')}
<br />
<br />
{t('The whole matched text will be ignored if capturing groups are used')}
</div>
{t('You should not use capturing groups on Resource property due to partial path is not available to match a file system entry')}
</Balloon.Tooltip>
</div>
<div className="value">
<div className="text">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const PathSegmentsConfiguration = React.forwardRef((props: IPathSegmentsConfigur
const rootSegmentIndex = rootMatch?.index ?? -1;

const resourceSegmentIndex = PathSegmentMatcher
.match(segments, resourceMatcherValue, rootSegmentIndex, undefined)?.index ?? -1;
.match(segments, resourceMatcherValue, rootSegmentIndex, segments.length)?.index ?? -1;
if (resourceSegmentIndex > -1) {
const resourceMatcherMatchesLastLayer = resourceSegmentIndex == segments.length - 1;
if (resourceMatcherMatchesLastLayer != resourceMatcherMatchesLastLayerRef.current) {
Expand Down Expand Up @@ -711,6 +711,13 @@ const PathSegmentsConfiguration = React.forwardRef((props: IPathSegmentsConfigur
setFileResourceExtensions(list);
if (currentFileExt) {
setFileResourceExtensionCandidates([currentFileExt]);

// we should change the value of resource matcher to file-extension-based regex immediately when user click this button
const newRegex = buildLayerBasedPathRegexString(segments.length - rootSegmentIndex - 1, [currentFileExt]);
value[ResourceProperty.Resource] = [
MatcherValue.Regex(newRegex),
];
setValue({ ...value });
}
}
})
Expand Down Expand Up @@ -765,7 +772,7 @@ const PathSegmentsConfiguration = React.forwardRef((props: IPathSegmentsConfigur
const idx = candidates.indexOf(e.ext);

const apply = candidates => {
const newRegex = buildLayerBasedPathRegexString(segments.length, candidates);
const newRegex = buildLayerBasedPathRegexString(segments.length - rootSegmentIndex - 1, candidates);
value[ResourceProperty.Resource] = [
MatcherValue.Regex(newRegex),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export function buildLayerBasedPathRegexString(layer, extensions?: string[]): st
} else {
if (extensions) {
if (extensions.length > 0) {
reg += `\\.(${extensions.map(e => e.replace(/^\./, '')
reg += `\\.(?:${extensions.map(e => e.replace(/^\./, '')
.replaceAll('.', '\\.'))
.join('|')})`;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,5 +864,7 @@
"Exit behavior": "退出交互",
"Minimize": "最小化",
"Exit": "退出",
"Prompt": "提示"
"Prompt": "提示",
"/ is the directory separator always, not \\": "除非特别说明,一般使用/作为目录路径分隔符,而不是\\",
"You should not use capturing groups on Resource property due to partial path is not available to match a file system entry": "您不应该在*资源*属性中使用捕获组,因为不完整的匹配结果将无法定位到文件系统中的文件(夹)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.7.1-beta5</Version>
<Version>1.7.1-beta6</Version>
<SpaRoot>ClientApp\</SpaRoot>
<ApplicationIcon>Assets/favicon.ico</ApplicationIcon>
<InsideWorldCoreAssembly>Bakabase.InsideWorld.App.Core</InsideWorldCoreAssembly>
Expand Down
14 changes: 4 additions & 10 deletions src/Bakabase.InsideWorld.Business/Services/MediaLibraryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void SetPropertiesByMatchers(ResourceDto pr, string rootPath, List<Match
case ResourceProperty.CustomProperty:
{
var matchResult =
ResourcePropertyMatcher.Match(segments, s, rootPathSegments.Length - 1, segments.Length - 1);
ResourcePropertyMatcher.Match(segments, s, rootPathSegments.Length - 1, segments.Length);


if (matchResult != null)
Expand Down Expand Up @@ -853,8 +853,8 @@ public async Task<SingletonResponse<PathConfigurationValidateResult>> Test(Media
{
var segments = f.SplitPathIntoSegments();
var resourceMatchValue = ResourcePropertyMatcher.Match(segments, resourceMatcherValue,
rootSegments.Length - 1, segments.Length - 1);
if (resourceMatchValue is not {Type: MatchResultType.Layer} || resourceMatchValue.Index < segments.Length - 1)
rootSegments.Length - 1, segments.Length);
if (resourceMatchValue is not {Type: MatchResultType.Layer} || resourceMatchValue.Index < rootSegments.Length)
{
continue;
}
Expand All @@ -871,18 +871,12 @@ public async Task<SingletonResponse<PathConfigurationValidateResult>> Test(Media
RelativePath = relativePath
};

if (f.Contains("防嵌套"))
{

}

var otherMatchers = pc.RpmValues!.Where(a =>
a.Property != ResourceProperty.Resource && a.Property != ResourceProperty.RootPath).ToList();

foreach (var m in otherMatchers)
{
var result = ResourcePropertyMatcher.Match(segments, m, rootSegments.Length - 1,
segments.Length - 1);
var result = ResourcePropertyMatcher.Match(segments, m, rootSegments.Length - 1, segments.Length);
if (result != null)
{
switch (result.Type)
Expand Down

0 comments on commit 1ce8a3d

Please sign in to comment.