Skip to content

Commit 53820de

Browse files
photo stroke size and color, remove empry cell button and page margin added
1 parent 1aee4f0 commit 53820de

File tree

10 files changed

+187
-97
lines changed

10 files changed

+187
-97
lines changed

changelogs.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
1.0.9
2+
* Improvements
3+
1. Fix bug in Custom Front and Back card in CardMaker
4+
* Added
5+
1. photo border stroke and stroke color on photosheet maker
6+
2. Margin in photosheet maker
7+
3. Button: Removed Empty Cell in PhotoSheet Maker
8+
19
1.0.8
210
* Improvements
311
* get computerName on app start
@@ -12,8 +20,7 @@
1220
* hide gap field if grid layout selected to 1 in photoSheet maker
1321
* Added
1422
1. Skeleton for photosheet page in photoSheet Maker
15-
2. Custom Front and Back card in CardMaker - undone
16-
3. re arrange the images in photoSheet maker - undone
23+
2. Custom Front and Back card in CardMaker
1724

1825
1.0.7
1926
* Added

electron-builder.json5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
output: 'release/${version}',
1212
},
1313
files: ['dist-electron', 'dist'],
14+
asarUnpack: ['dist/assets/*.css'],
1415
win: {
1516
target: 'nsis',
1617
icon: 'public/favicon.ico',

electron/main/express-app.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ class expressAppClass {
521521
res.json(o);
522522
}
523523

524-
525524
expressAppClass.db.write()
526525
expressAppClass.win?.webContents.send('reloadDatabase')
527526
return;

electron/main/index.ts

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL
2525
? path.join(process.env.DIST_ELECTRON, '../public')
2626
: process.env.DIST;
2727

28+
const isDev = !app.isPackaged || process.env.NODE_ENV === 'development';
29+
2830
// Disable GPU Acceleration for Windows 7
2931
if (release().startsWith('6.1')) app.disableHardwareAcceleration();
3032

@@ -63,6 +65,12 @@ app.setLoginItemSettings({
6365
args: ['--hidden']
6466
});
6567

68+
// Global settings for dev and production
69+
if (!process.env.VITE_DEV_SERVER_URL) {
70+
// For production
71+
Menu.setApplicationMenu(null)
72+
}
73+
6674

6775
async function createWindow() {
6876

@@ -104,15 +112,11 @@ async function createWindow() {
104112
const contextMenu = Menu.buildFromTemplate([
105113
{
106114
label: 'Show App',
107-
click: () => {
108-
win?.show();
109-
},
115+
click: () => win?.show(),
110116
},
111117
{
112-
label: 'Quit',
113-
click: () => {
114-
app.quit();
115-
},
118+
label: 'Close App',
119+
click: () => app.quit(),
116120
},
117121
]);
118122
tray.setToolTip('MotionPrinter');
@@ -528,12 +532,10 @@ ipcMain.on("printFile", async (event, file: any) => {
528532
})
529533

530534

531-
ipcMain.on('generate-pdf', async (event, obj: { htmlContent: string, isPrint?: boolean, printPDF?: boolean, filename?: string, }) => {
532-
533-
console.log('generate-pdf')
535+
ipcMain.on('generate-pdf', async (event, obj: { htmlContent: string, head: string, isPrint?: boolean, printPDF?: boolean, filename?: string }) => {
534536

535537
const win = new BrowserWindow({
536-
show: false,
538+
show: isDev,
537539
webPreferences: {
538540
nodeIntegration: true,
539541
contextIsolation: false,
@@ -542,11 +544,42 @@ ipcMain.on('generate-pdf', async (event, obj: { htmlContent: string, isPrint?: b
542544

543545
try {
544546

545-
await win.loadURL(`data:text/html;charset=UTF-8,${encodeURIComponent(obj.htmlContent)}`);
547+
let cssFiles: string[] = []
548+
549+
if (!isDev) {
550+
console.log("Running in production mode");
551+
const cssDir = path.join(process.resourcesPath, 'app.asar.unpacked/dist/assets');
552+
const files = fs.readdirSync(cssDir);
553+
554+
// Read all .css files
555+
cssFiles = files
556+
.filter(file => file.endsWith('.css'))
557+
.map(file => fs.readFileSync(path.join(cssDir, file), 'utf8'));
558+
559+
}
560+
561+
const htmlContent = `
562+
<!DOCTYPE html>
563+
<html>
564+
<head>
565+
${cssFiles.map((el, i) => `<style type="text/css" id="inserted-${i}">${el}</style>`).join('\n')}
566+
${obj.head}
567+
</head>
568+
<body>
569+
${obj.htmlContent}
570+
</body>
571+
</html>
572+
`;
573+
574+
await win.loadURL(`data:text/html;charset=UTF-8,${encodeURIComponent(htmlContent)}`);
575+
576+
await sleep(500);
577+
546578

547579
if (obj?.printPDF) {
548580
console.log('Printing to PDF...')
549581
const pdfOptions = {
582+
color: true,
550583
margins: {
551584
marginType: 'printableArea' as "printableArea", // 'none', 'printableArea', or custom
552585
top: 0,
@@ -601,4 +634,17 @@ ipcMain.on('generate-pdf', async (event, obj: { htmlContent: string, isPrint?: b
601634
console.error(error)
602635
}
603636

637+
});
638+
639+
const fsPromise = require('fs').promises;
640+
ipcMain.handle('read-css-file', async (event, fileUrl) => {
641+
try {
642+
// Convert file:// URL to filesystem path
643+
const filePath = fileUrl.replace('file://', '');
644+
// Read the CSS file from app.asar
645+
const content = await fsPromise.readFile(filePath, 'utf-8');
646+
return content;
647+
} catch (error: any) {
648+
throw new Error(`Failed to read CSS file: ${error.message}`);
649+
}
604650
});

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "motionprinter",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"description": "MotionPrinter makes your printing easy.",
55
"author": "Abu Sufiyan<abusufiyan@engineer.com>",
66
"license": "MIT",
@@ -71,8 +71,10 @@
7171
"dependencies": {
7272
"@canopassoftware/vue-file-upload": "^1.0.8",
7373
"@radix-icons/vue": "^1.0.0",
74+
"@tanstack/vue-table": "^8.21.2",
7475
"@tato30/vue-pdf": "^1.11.3",
7576
"@types/sleep": "^6.3.0",
77+
"asar": "^3.2.0",
7678
"axios": "^1.7.9",
7779
"body-parser": "^1.20.2",
7880
"canvas": "^3.0.1",
@@ -108,7 +110,8 @@
108110
"tailwindcss-animate": "^1.0.7",
109111
"uuid": "^11.0.4",
110112
"vee-validate": "^4.15.0",
111-
"vue-sonner": "^1.3.0"
113+
"vue-sonner": "^1.3.0",
114+
"vue3-colorpicker": "^2.3.0"
112115
},
113116
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
114117
}

src/components/Footer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ footer.footer.bg-white.px-5.py-4.border-t( class="dark:bg-gray-900" )
2020
p
2121
| Made with &#10084; in
2222
img.inline.w-auto.mx-1(:src="flagUrl" style="height: 2cap")
23-
| by #[a.uppercase.font-medium.font-sm(href="https://yourabusufiyan.pages.dev/" class="hover:underline" target="_blank") abu sufiyan ]
23+
| by #[a.uppercase.font-medium.font-sm(href="https://yourabusufiyan.pages.dev/" class="hover:underline" target="_blank") abu sufiyan's Team ]
2424
</template>

src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import App from './App.vue';
66
import './samples/node-api';
77
import router from './router/router';
88

9+
import Vue3ColorPicker from "vue3-colorpicker";
10+
import "vue3-colorpicker/style.css";
11+
912
const app = createApp(App);
1013

1114
const messages = Object.fromEntries(
@@ -30,6 +33,7 @@ app.use(
3033
);
3134
app.use(createPinia());
3235
app.use(router);
36+
app.use(Vue3ColorPicker);
3337

3438
app.mount('#app').$nextTick(() => {
3539
postMessage({ payload: 'removeLoading' }, '*');

0 commit comments

Comments
 (0)