Browse Source

Optimization and more bug fixes.

tags/v1.4.4
Ivan Bravo Bravo 1 year ago
parent
commit
e7c958a8a1
6 changed files with 71 additions and 18 deletions
  1. 1
    0
      src/.babelrc
  2. 2
    2
      src/electron-builder.js
  3. 27
    5
      src/modules/nudify/photo.js
  4. 35
    8
      src/nuxt.config.js
  5. 3
    1
      src/package.json
  6. 3
    2
      src/pages/nudify/_id.vue

+ 1
- 0
src/.babelrc View File

@@ -11,6 +11,7 @@
]
],
"plugins": [
"lodash",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-optional-chaining",

+ 2
- 2
src/electron-builder.js View File

@@ -21,8 +21,8 @@ module.exports = {
'!**/{appveyor.yml,.travis.yml,circle.yml}',
'!**/{npm-debug.log,yarn.lock,.yarn-integrity,.yarn-metadata.json}',
'!**/{jsconfig.json,electron-builder.js,.eslintrc.js,.env-cmdrc.js,.codeclimate.yml,.babelrc,tailwind.config.js,nucleus.json}',
'!**/{components,cli,layouts,middleware,mixins,pages,patches,plugins,scripts,store,third}',
'!**/{static,assets}',
'!{components,cli,layouts,middleware,mixins,pages,patches,plugins,scripts,store,third,coverage,.nuxt,test,workers}',
'!{static,assets}',
'!**/electron/src',
],
extraFiles: [

+ 27
- 5
src/modules/nudify/photo.js View File

@@ -138,6 +138,10 @@ export class Photo {
return this.running || this.finished
}

get canModify() {
return this.file.mimetype !== 'image/gif'
}

get scaleMode() {
const { scaleMode } = this.preferences.advanced

@@ -146,6 +150,11 @@ export class Photo {
return 'auto-rescale'
}

if ((scaleMode === 'cropjs' || scaleMode === 'overlay') && !this.canModify) {
// this file can't be modified
return 'auto-rescale'
}

return scaleMode
}

@@ -159,7 +168,7 @@ export class Photo {
return this.fileCrop
}

if (this.fileEditor.exists) {
if (this.canModify && this.fileEditor.exists) {
return this.fileEditor
}

@@ -246,9 +255,10 @@ export class Photo {

_setupPreferences(isMaskfin) {
this.preferences = cloneDeep(settings.preferences)
let forcedPreferences = {}

if (isMaskfin) {
const forcedPreferences = {
forcedPreferences = {
body: {
executions: 1,
randomize: false,
@@ -262,9 +272,15 @@ export class Photo {
useColorTransfer: false,
},
}

this.preferences = merge(this.preferences, forcedPreferences)
} else if (!this.canModify) {
forcedPreferences = {
advanced: {
transformMode: 'normal',
},
}
}

this.preferences = merge(this.preferences, forcedPreferences)
}

_validate() {
@@ -280,8 +296,14 @@ export class Photo {
}

_setupQueue() {
let maxTimeout = settings.processing.device === 'GPU' ? (3 * 60 * 1000) : (10 * 60 * 1000)

if (this.file.mimetype === 'image/gif') {
maxTimeout += (30 * 60 * 1000)
}

this.queue = new Queue(this._run, {
maxTimeout: settings.processing.device === 'GPU' ? (2 * 60 * 1000) : (10 * 60 * 1000),
maxTimeout,
// maxRetries: 2,
// retryDelay: 1000,
afterProcessDelay: 500,

+ 35
- 8
src/nuxt.config.js View File

@@ -92,8 +92,15 @@ module.exports = {
*
*/
purgeCSS: {
enabled: false,
whitelistPatterns: [/tooltip$/, /cropper$/, /tui$/],
enabled: true,
whitelistPatterns: [/tooltip/, /cropper/, /tui/, /color-picker/],
},

/**
*
*/
eslint: {
cache: dev,
},

/**
@@ -107,14 +114,17 @@ module.exports = {
build: {
parallel: true,

hardSource: true,
hardSource: dev,

cache: dev,

optimizeCSS: true,
extractCSS: !dev,

babel: {
sourceType: 'unambiguous',

plugins: [
'lodash',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-optional-chaining',
@@ -131,15 +141,27 @@ module.exports = {
},

loaders: {
scss: {
implementation: require('sass'),
},

imgUrl: {
limit: 10 * 1000,
},
},

terser: {
parallel: true,
},

optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},

/*
** You can extend webpack config here
*/
@@ -152,6 +174,11 @@ module.exports = {
exclude: /(node_modules)/,
})

const webpack = require('webpack')

// eslint-disable-next-line no-useless-escape
config.plugins.push(new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/))

if (isDev) {
config.devtool = 'source-map'
} else {

+ 3
- 1
src/package.json View File

@@ -27,7 +27,7 @@
"build:nuxt": "yarn production nuxt build",
"build:babel": "yarn production babel electron/src --out-dir electron/dist --minified",
"build:electron": "yarn production electron-builder --publish=never --x64",
"build": "yarn build:nuxt && yarn build:babel && yarn build:electron",
"build": "yarn build:nuxt && yarn build:babel && modclean --run && yarn build:electron",
"preview:electron": "env-cmd -e default,production,preview --no-override electron .",
"preview": "yarn build:nuxt && yarn build:babel && yarn preview:electron"
},
@@ -111,6 +111,7 @@
"@nuxtjs/tailwindcss": "^1.2.0",
"@octokit/rest": "^16.35.0",
"babel-eslint": "^10.0.3",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-module-resolver": "^3.2.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"babel-watch": "^7.0.0",
@@ -138,6 +139,7 @@
"husky": "^3.0.9",
"lint-staged": "^9.4.3",
"mocha": "^6.2.2",
"modclean": "^3.0.0-beta.1",
"nodemon": "^1.19.4",
"nyc": "^14.1.1",
"rollbar-sourcemap-webpack-plugin": "^2.5.1",

+ 3
- 2
src/pages/nudify/_id.vue View File

@@ -15,18 +15,19 @@
:href="`/nudify/${photo.id}/preferences`" />

<box-item
v-show="photo.canModify"
label="Editor"
icon="paint-brush"
:href="`/nudify/${photo.id}/editor`" />

<box-item
v-show="photo.preferences.advanced.scaleMode === 'cropjs'"
v-show="photo.canModify && photo.preferences.advanced.scaleMode === 'cropjs'"
label="Crop"
icon="crop"
:href="`/nudify/${photo.id}/crop`" />

<box-item
v-show="photo.preferences.advanced.scaleMode === 'overlay'"
v-show="photo.canModify && photo.preferences.advanced.scaleMode === 'overlay'"
label="Overlay"
icon="magic"
:href="`/nudify/${photo.id}/overlay`" />

Loading…
Cancel
Save