feat: добавлена поддержка шаблонов $0 и \$0 для наград в задачах (v3.1.1)
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 44s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 44s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-life-web",
|
||||
"version": "3.0.1",
|
||||
"version": "3.1.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -268,10 +268,40 @@ function TaskForm({ onNavigate, taskId }) {
|
||||
|
||||
const findMaxPlaceholderIndex = (message) => {
|
||||
if (!message) return -1
|
||||
const matches = message.match(/\$\{(\d+)\}/g)
|
||||
if (!matches) return -1
|
||||
const indices = matches.map(m => parseInt(m.match(/\d+/)[0]))
|
||||
return Math.max(...indices)
|
||||
// Находим все варианты плейсхолдеров: ${0}, $0, но не \$0
|
||||
const indices = []
|
||||
|
||||
// Ищем ${N}
|
||||
const matchesCurly = message.match(/\$\{(\d+)\}/g) || []
|
||||
matchesCurly.forEach(match => {
|
||||
const numMatch = match.match(/\d+/)
|
||||
if (numMatch) {
|
||||
indices.push(parseInt(numMatch[0]))
|
||||
}
|
||||
})
|
||||
|
||||
// Ищем $N (но не \$N)
|
||||
// Используем глобальный поиск и проверяем, что перед $ нет обратного слэша
|
||||
let searchIndex = 0
|
||||
while (true) {
|
||||
const index = message.indexOf('$', searchIndex)
|
||||
if (index === -1) break
|
||||
|
||||
// Проверяем, что перед $ нет обратного слэша
|
||||
if (index === 0 || message[index - 1] !== '\\') {
|
||||
// Проверяем, что после $ идет цифра
|
||||
const afterDollar = message.substring(index + 1)
|
||||
const digitMatch = afterDollar.match(/^(\d+)/)
|
||||
if (digitMatch) {
|
||||
// Проверяем, что после цифры не идет еще одна цифра (чтобы не захватить $10 при поиске $1)
|
||||
const num = parseInt(digitMatch[0])
|
||||
indices.push(num)
|
||||
}
|
||||
}
|
||||
searchIndex = index + 1
|
||||
}
|
||||
|
||||
return indices.length > 0 ? Math.max(...indices) : -1
|
||||
}
|
||||
|
||||
|
||||
@@ -551,7 +581,7 @@ function TaskForm({ onNavigate, taskId }) {
|
||||
id="reward_message"
|
||||
value={rewardMessage}
|
||||
onChange={(e) => setRewardMessage(e.target.value)}
|
||||
placeholder="Используйте ${0}, ${1} для указания проектов"
|
||||
placeholder="Используйте ${0}, $0 для указания проектов (\\$0 для экранирования)"
|
||||
className="form-textarea"
|
||||
rows={3}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user