mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2025-01-07 11:04:50 +01:00
Update excel import
This commit is contained in:
parent
e9347e17dc
commit
8e01ec7cd0
4 changed files with 76 additions and 40 deletions
|
@ -141,7 +141,8 @@ async function addWishHistory(workbook) {
|
||||||
{ header: 'Pity', width: 4, style: { alignment: { horizontal: 'center' } } },
|
{ header: 'Pity', width: 4, style: { alignment: { horizontal: 'center' } } },
|
||||||
{ header: '#Roll', width: 7, style: { alignment: { horizontal: 'center' } } },
|
{ header: '#Roll', width: 7, style: { alignment: { horizontal: 'center' } } },
|
||||||
{ header: 'Group', width: 7, style: { alignment: { horizontal: 'center' } } },
|
{ header: 'Group', width: 7, style: { alignment: { horizontal: 'center' } } },
|
||||||
{ header: 'Banner', width: 24 },
|
{ header: 'Banner', width: 30 },
|
||||||
|
{ header: 'Part', width: 9 },
|
||||||
// { header: 'Icon', width: 5.5 },
|
// { header: 'Icon', width: 5.5 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -175,10 +176,11 @@ async function addWishHistory(workbook) {
|
||||||
pull.at,
|
pull.at,
|
||||||
groupCount,
|
groupCount,
|
||||||
pull.code === '400' ? bannersDual[pull.banner.fullName][1].name : pull.banner.name,
|
pull.code === '400' ? bannersDual[pull.banner.fullName][1].name : pull.banner.name,
|
||||||
|
pull.code === '400' ? 'Wish 2' : '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const bgColor = pull.striped ? 'ffeeeeee' : 'ffffffff';
|
const bgColor = pull.striped ? 'ffeeeeee' : 'ffffffff';
|
||||||
for (let i = 1; i <= 8; i++) {
|
for (let i = 1; i <= 9; i++) {
|
||||||
row.getCell(i).fill = {
|
row.getCell(i).fill = {
|
||||||
type: 'pattern',
|
type: 'pattern',
|
||||||
pattern: 'solid',
|
pattern: 'solid',
|
||||||
|
|
|
@ -364,7 +364,8 @@
|
||||||
"This feature is still in BETA! Please make a backup first by going to the Settings menu then Export to Excel.",
|
"This feature is still in BETA! Please make a backup first by going to the Settings menu then Export to Excel.",
|
||||||
"Wishes with the same timestamp and reward name will NOT be touched (existing wishes will not be rewritten)",
|
"Wishes with the same timestamp and reward name will NOT be touched (existing wishes will not be rewritten)",
|
||||||
"This feature will only append and prepend wishes (nothing will be inserted in the middle of the list)",
|
"This feature will only append and prepend wishes (nothing will be inserted in the middle of the list)",
|
||||||
"Currently, the importer can only support excel files with an ENGLISH reward name"
|
"Currently, the importer can only support excel files with an ENGLISH reward name",
|
||||||
|
"Please change the website language first according to your excel file language"
|
||||||
],
|
],
|
||||||
"selectFile": {
|
"selectFile": {
|
||||||
"default": "Drag & drop Paimon.moe excel file here, or click here to select",
|
"default": "Drag & drop Paimon.moe excel file here, or click here to select",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { t } from 'svelte-i18n';
|
import { t, dictionary, locale } from 'svelte-i18n';
|
||||||
import { Workbook, ValueType } from 'exceljs';
|
import { Workbook, ValueType } from 'exceljs';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
@ -103,20 +103,34 @@
|
||||||
const { path, data } = await readLocalData(id);
|
const { path, data } = await readLocalData(id);
|
||||||
const { append, prepend } = added[id];
|
const { append, prepend } = added[id];
|
||||||
|
|
||||||
const beginning = prepend.map((e) => ({
|
const beginning = prepend.map((e) => {
|
||||||
id: e[2],
|
const d = {
|
||||||
time: e[1],
|
id: e[2],
|
||||||
type: e[0],
|
time: e[1],
|
||||||
pity: 0,
|
type: e[0],
|
||||||
manualInput: true,
|
pity: 0,
|
||||||
}));
|
manualInput: true,
|
||||||
const end = append.map((e) => ({
|
};
|
||||||
id: e[2],
|
|
||||||
time: e[1],
|
if (e[3] !== undefined) {
|
||||||
type: e[0],
|
d.code = e[3];
|
||||||
pity: 0,
|
}
|
||||||
manualInput: true,
|
return d;
|
||||||
}));
|
});
|
||||||
|
const end = append.map((e) => {
|
||||||
|
const d = {
|
||||||
|
id: e[2],
|
||||||
|
time: e[1],
|
||||||
|
type: e[0],
|
||||||
|
pity: 0,
|
||||||
|
manualInput: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (e[3] !== undefined) {
|
||||||
|
d.code = e[3];
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
|
||||||
const combined = [...beginning, ...data, ...end];
|
const combined = [...beginning, ...data, ...end];
|
||||||
|
|
||||||
|
@ -210,6 +224,7 @@
|
||||||
const type = row.getCell(1).text.toLowerCase();
|
const type = row.getCell(1).text.toLowerCase();
|
||||||
let time = row.getCell(3);
|
let time = row.getCell(3);
|
||||||
const fullName = row.getCell(2).text;
|
const fullName = row.getCell(2).text;
|
||||||
|
const wish2 = row.getCell(9).text === 'Wish 2';
|
||||||
|
|
||||||
if (time.type === ValueType.Date) {
|
if (time.type === ValueType.Date) {
|
||||||
time = dayjs.utc(time.value).format('YYYY-MM-DD HH:mm:ss');
|
time = dayjs.utc(time.value).format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
@ -258,7 +273,11 @@
|
||||||
throw 'unknown reward name';
|
throw 'unknown reward name';
|
||||||
}
|
}
|
||||||
|
|
||||||
wishes.push([type, time, name]);
|
const w = [type, time, name];
|
||||||
|
if (wish2) {
|
||||||
|
w[3] = '400';
|
||||||
|
}
|
||||||
|
wishes.push(w);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('from excel', category, wishes.length);
|
console.log('from excel', category, wishes.length);
|
||||||
|
@ -270,24 +289,41 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readGachaExportExcel(workbook) {
|
async function readGachaExportExcel(workbook) {
|
||||||
const bannerCategories = {
|
const itemNames = {};
|
||||||
'character-event': 'Character Event Wish',
|
for (const [k, v] of Object.entries($dictionary[$locale])) {
|
||||||
'weapon-event': 'Weapon Event Wish',
|
itemNames[v] = k;
|
||||||
standard: 'Permanent Wish',
|
}
|
||||||
beginners: 'Novice Wishes',
|
console.log(itemNames);
|
||||||
};
|
|
||||||
|
const bannerCategories = ['character-event', 'weapon-event', 'standard', 'beginners'];
|
||||||
|
const bannerCodes = ['301', '302', '200', '100'];
|
||||||
|
|
||||||
const weapons = Object.values(weaponList);
|
const weapons = Object.values(weaponList);
|
||||||
const chars = Object.values(characters);
|
const chars = Object.values(characters);
|
||||||
|
|
||||||
for (const [id, category] of Object.entries(bannerCategories)) {
|
const typeWeaponTranslate = $t('wish.detail.weapon');
|
||||||
const sheet = workbook.getWorksheet(category);
|
const typeCharacterTranslate = $t('wish.detail.character');
|
||||||
|
|
||||||
|
for (let i = 0; i < 4; i++) {
|
||||||
|
const sheet = workbook.worksheets[i];
|
||||||
|
const id = bannerCategories[i];
|
||||||
|
let code = bannerCodes[i];
|
||||||
const wishes = [];
|
const wishes = [];
|
||||||
sheet.eachRow((row, index) => {
|
sheet.eachRow((row, index) => {
|
||||||
if (index === 1) return;
|
if (index === 1) return;
|
||||||
const type = row.getCell(3).text.toLowerCase();
|
const typeRaw = row.getCell(3).text;
|
||||||
|
let type = typeRaw;
|
||||||
|
if (typeWeaponTranslate === typeRaw) {
|
||||||
|
type = 'weapon';
|
||||||
|
} else if (typeCharacterTranslate === typeRaw) {
|
||||||
|
type = 'character';
|
||||||
|
}
|
||||||
|
|
||||||
let time = row.getCell(1);
|
let time = row.getCell(1);
|
||||||
const fullName = row.getCell(2).text;
|
const fullName = itemNames[row.getCell(2).text];
|
||||||
|
if (i === 0) {
|
||||||
|
code = row.getCell(7).text.indexOf('2') > -1 ? '400' : '301';
|
||||||
|
}
|
||||||
|
|
||||||
if (time.type === ValueType.Date) {
|
if (time.type === ValueType.Date) {
|
||||||
time = dayjs.utc(time.value).format('YYYY-MM-DD HH:mm:ss');
|
time = dayjs.utc(time.value).format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
@ -299,9 +335,9 @@
|
||||||
if (type === 'weapon') {
|
if (type === 'weapon') {
|
||||||
const weapon = weapons.find((e) => e.name === fullName);
|
const weapon = weapons.find((e) => e.name === fullName);
|
||||||
if (weapon === undefined) {
|
if (weapon === undefined) {
|
||||||
pushToast($t('wish.excel.errorUnknownItem'), 'error');
|
pushToast($t('wish.excel.errorUnknownItem') + ` [${id} ${type} ${index}: ${fullName}]`, 'error');
|
||||||
error = {
|
error = {
|
||||||
banner: category,
|
banner: id,
|
||||||
line: index,
|
line: index,
|
||||||
name: fullName,
|
name: fullName,
|
||||||
type,
|
type,
|
||||||
|
@ -315,7 +351,7 @@
|
||||||
} else if (type === 'character') {
|
} else if (type === 'character') {
|
||||||
const character = chars.find((e) => e.name === fullName);
|
const character = chars.find((e) => e.name === fullName);
|
||||||
if (character === undefined) {
|
if (character === undefined) {
|
||||||
pushToast($t('wish.excel.errorUnknownItem'), 'error');
|
pushToast($t('wish.excel.errorUnknownItem') + ` [${id} ${type} ${index}: ${fullName}]`, 'error');
|
||||||
error = {
|
error = {
|
||||||
banner: category,
|
banner: category,
|
||||||
line: index,
|
line: index,
|
||||||
|
@ -331,15 +367,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name === '') {
|
if (name === '') {
|
||||||
pushToast($t('wish.excel.errorUnknownItem'), 'error');
|
pushToast($t('wish.excel.errorUnknownItem') + ` [${id} ${type} ${index}: ${fullName}]`, 'error');
|
||||||
loading = false;
|
loading = false;
|
||||||
throw 'unknown reward name';
|
throw 'unknown reward name';
|
||||||
}
|
}
|
||||||
|
|
||||||
wishes.push([type, time, name]);
|
wishes.push([type, time, name, code]);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('from excel', category, wishes.length);
|
console.log('from excel', id, wishes.length);
|
||||||
await parseData(id, wishes);
|
await parseData(id, wishes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,7 +655,7 @@
|
||||||
<li class="text-red-300">{$t('wish.excel.notice.0')}</li>
|
<li class="text-red-300">{$t('wish.excel.notice.0')}</li>
|
||||||
<li class="text-white">{$t('wish.excel.notice.1')}</li>
|
<li class="text-white">{$t('wish.excel.notice.1')}</li>
|
||||||
<li class="text-white">{$t('wish.excel.notice.2')}</li>
|
<li class="text-white">{$t('wish.excel.notice.2')}</li>
|
||||||
<li class="text-white">{$t('wish.excel.notice.3')}</li>
|
<li class="text-white">{$t('wish.excel.notice.4')}</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-gray-200 mb-2">{$t('wish.excel.subtitle')}</p>
|
<p class="text-gray-200 mb-2">{$t('wish.excel.subtitle')}</p>
|
||||||
|
|
|
@ -7,10 +7,7 @@ const IMAGE_CACHE = `cacheimg${IMAGE_CACHE_VER}`;
|
||||||
|
|
||||||
const IMAGE_URL = `${self.location.origin}/images/`;
|
const IMAGE_URL = `${self.location.origin}/images/`;
|
||||||
|
|
||||||
const changelog = [
|
const changelog = ['Update excel import to support other language', 'Update character guides'];
|
||||||
'Update sumeru commission achievement checklist',
|
|
||||||
'Add character & weapons release timeline (Database > Character Reruns)',
|
|
||||||
];
|
|
||||||
|
|
||||||
const channel = new BroadcastChannel('paimonmoe-sw');
|
const channel = new BroadcastChannel('paimonmoe-sw');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue