diff --git a/package.json b/package.json index 12dd0ef6..978a6688 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "compression": "^1.7.1", + "exceljs": "^4.2.1", "polka": "next", "sirv": "^1.0.0" }, diff --git a/rollup.config.js b/rollup.config.js index 21f56a33..9ebc6f53 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -26,7 +26,10 @@ const onwarn = (warning, onwarn) => export default { client: { input: config.client.input(), - output: config.client.output(), + output: { + ...config.client.output(), + sourcemap: dev ? 'inline' : true, + }, plugins: [ replace({ 'process.browser': true, diff --git a/src/components/WishCounterHowToModal.svelte b/src/components/WishCounterHowToModal.svelte index 9107016e..c3474a64 100644 --- a/src/components/WishCounterHowToModal.svelte +++ b/src/components/WishCounterHowToModal.svelte @@ -1,24 +1,49 @@
{$t('wish.help.exportMessage')}
+ + +{$t('wish.help.consider')}
{$t('wish.help.howto.subtitle')}
{$t('wish.help.howto.press')}
diff --git a/src/data/bannerTypes.js b/src/data/bannerTypes.js
new file mode 100644
index 00000000..478dc8cf
--- /dev/null
+++ b/src/data/bannerTypes.js
@@ -0,0 +1,18 @@
+export const bannerTypes = [
+ {
+ name: 'Character Event',
+ id: 'character-event',
+ },
+ {
+ name: 'Weapon Event',
+ id: 'weapon-event',
+ },
+ {
+ name: 'Standard',
+ id: 'standard',
+ },
+ {
+ name: "Beginners' Wish",
+ id: 'beginners',
+ },
+];
diff --git a/src/functions/export.js b/src/functions/export.js
new file mode 100644
index 00000000..e3560360
--- /dev/null
+++ b/src/functions/export.js
@@ -0,0 +1,232 @@
+import { Workbook } from 'exceljs';
+import { bannerTypes } from '../data/bannerTypes';
+import { banners } from '../data/banners';
+
+import dayjs from 'dayjs';
+import { getTimeOffset } from '../stores/server';
+import { process } from './wish';
+
+const bannerCategories = {
+ 'character-event': 'Character Event',
+ 'weapon-event': 'Weapon Event',
+ standard: 'Standard',
+ beginners: "Beginners' Wish",
+};
+
+function createWorkbook() {
+ const workbook = new Workbook();
+ workbook.creator = 'Paimon.moe';
+ workbook.created = new Date();
+ workbook.modified = new Date();
+
+ return workbook;
+}
+
+/**
+ *
+ * @param {Workbook} workbook
+ */
+function addSheet(workbook) {
+ for (const [_, category] of Object.entries(bannerCategories)) {
+ workbook.addWorksheet(category, { views: [{ state: 'frozen', ySplit: 1 }] });
+ }
+ workbook.addWorksheet('Banner List');
+ workbook.addWorksheet('Information');
+}
+
+function convertBlobToBase64(blob) {
+ return new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onerror = reject;
+ reader.onload = () => {
+ resolve(reader.result);
+ };
+ reader.readAsDataURL(blob);
+ });
+}
+
+/**
+ *
+ * @param {Workbook} workbook
+ * @returns {Promise