Skip to content

Commit

Permalink
feat: update app dependencies and try catch i18n error
Browse files Browse the repository at this point in the history
  • Loading branch information
icebergtsn committed Sep 26, 2024
1 parent 0e15b77 commit 8f66e2f
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 77 deletions.
23 changes: 17 additions & 6 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
"lint": "eslint --ext .js,.ts,.vue ./ --fix",
"format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test": "echo \"No test specified\" && exit 0",
"dev": "quasar dev",
"dev:public": "PUBLIC_URL=https://app-test.jointerminus.com quasar dev",
"dev:public:prd": "PUBLIC_URL=https://app.jointerminus.com quasar dev",
"build": "quasar build",
"build:pwa": "quasar build -m pwa"
"dev": "quasar dev",
"dev:public": "PUBLIC_URL=https://app-test.jointerminus.com quasar dev",
"dev:public:prd": "PUBLIC_URL=https://app.jointerminus.com quasar dev",
"build": "quasar build",
"build:pwa": "quasar build -m pwa"
},
"dependencies": {
"@bytetrade/core": "^0.3.53",
"@bytetrade/ui": "^0.1.12",
"@bytetrade/ui": "^0.1.12",
"@quasar/extras": "^1.16.9",
"axios": "^0.21.1",
"dompurify": "^3.1.7",
"fetch": "1.1.0",
"he": "^1.2.0",
"highlight.js": "^11.9.0",
"js-base64": "^3.7.5",
"lodash.throttle": "^4.1.1",
Expand All @@ -39,20 +41,20 @@
"vue-router": "^4.0.0"
},
"devDependencies": {
"css-minimizer-webpack-plugin": "^7.0.0",
"terser-webpack-plugin": "^5.3.10",
"@quasar/app-webpack": "^3.0.0",
"@quasar/app-webpack": "^3.0.0",
"@types/node": "^12.20.21",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"autoprefixer": "^10.4.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"dotenv": "^16.3.1",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-vue": "^9.0.0",
"prettier": "^3.2.5",
"sass": "1.33.0",
"terser-webpack-plugin": "^5.3.10",
"typescript": "^4.5.4",
"workbox-build": "^6.5.0",
"workbox-cacheable-response": "^6.5.0",
Expand Down
20 changes: 10 additions & 10 deletions frontend/quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ module.exports = configure(function (/* ctx */) {
}
]);
}
chain.plugin('terser').use(TerserPlugin, [
{
terserOptions: {
compress: {
drop_console: true,
pure_funcs: ['console.log']
}
}
}
]);
// chain.plugin('terser').use(TerserPlugin, [
// {
// terserOptions: {
// compress: {
// drop_console: true,
// pure_funcs: ['console.log']
// }
// }
// }
// ]);
chain.optimization.splitChunks({
chunks: 'all', // The type of chunk that requires code segmentation
minSize: 20000, // Minimum split file size
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/appintro/ExpendTextView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
</template>

<script lang="ts" setup>
import { onMounted, computed, ref, watch } from 'vue';
import { computed, onMounted, ref, watch } from 'vue';
import { i18n } from 'src/boot/i18n';
import { encode } from 'he';
const props = defineProps({
text: {
Expand Down Expand Up @@ -47,7 +48,7 @@ const showDescription = ref(false);
const needMore = ref(false);
const formattedDescription = computed(() => {
return props.text.replace(/(\r\n|\n|\r)/gm, '<br/>');
return encode(props.text).replace(/\r\n|\n|\r/g, '<br/>');
});
const multiRow = ref<HTMLElement | null>(null);
Expand Down
97 changes: 52 additions & 45 deletions frontend/src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,52 +348,59 @@ export function getAppFieldI18n(
field: APP_FIELD,
index = -1
) {
let key = '';
switch (field) {
case APP_FIELD.DESCRIPTION:
case APP_FIELD.TITLE:
case APP_FIELD.FULL_DESCRIPTION:
case APP_FIELD.UPGRADE_DESCRIPTION:
key = app.name + '_' + field;
break;
case APP_FIELD.ENTRANCES_NAME:
case APP_FIELD.ENTRANCES_TITLE:
if (index !== -1) {
key =
app.name +
'_' +
APP_FIELD.ENTRANCES_NAME.replace('?', index.toString());
}
break;
}
if (key) {
const exist = i18n.global.te(key);
// console.log(key, exist);
if (exist) {
return i18n.global.t(key);
const defaultConfig = () => {
switch (field) {
case APP_FIELD.DESCRIPTION:
return app.desc;
case APP_FIELD.TITLE:
case APP_FIELD.FULL_DESCRIPTION:
case APP_FIELD.UPGRADE_DESCRIPTION:
return app[field];
case APP_FIELD.ENTRANCES_NAME:
if (index !== -1) {
const array1 = app.entrances;
return array1[index].name;
} else {
return '';
}
case APP_FIELD.ENTRANCES_TITLE:
if (index !== -1) {
const array2 = app.entrances;
return array2[index].title;
} else {
return '';
}
}
}

switch (field) {
case APP_FIELD.DESCRIPTION:
return app.desc;
case APP_FIELD.TITLE:
case APP_FIELD.FULL_DESCRIPTION:
case APP_FIELD.UPGRADE_DESCRIPTION:
return app[field];
case APP_FIELD.ENTRANCES_NAME:
if (index !== -1) {
const array1 = app.entrances;
return array1[index].name;
} else {
return '';
}
case APP_FIELD.ENTRANCES_TITLE:
if (index !== -1) {
const array2 = app.entrances;
return array2[index].title;
} else {
return '';
};
try {
let key = '';
switch (field) {
case APP_FIELD.DESCRIPTION:
case APP_FIELD.TITLE:
case APP_FIELD.FULL_DESCRIPTION:
case APP_FIELD.UPGRADE_DESCRIPTION:
key = app.name + '_' + field;
break;
case APP_FIELD.ENTRANCES_NAME:
case APP_FIELD.ENTRANCES_TITLE:
if (index !== -1) {
key =
app.name +
'_' +
APP_FIELD.ENTRANCES_NAME.replace('?', index.toString());
}
break;
}
if (key) {
const exist = i18n.global.te(key);
if (exist) {
return i18n.global.t(key);
}
}
return defaultConfig();
} catch (e) {
console.log(`${app.name} ${field} i18n config error`);
console.log(e);
return defaultConfig();
}
}
2 changes: 1 addition & 1 deletion frontend/src/pages/application/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
</template>

<script lang="ts" setup>
import { ref, onMounted, watch } from 'vue';
import { ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import {
AppStoreInfo,
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,7 @@ export const useUserStore = defineStore('userStore', {

for (let i = 0; i < app.options.dependencies.length; i++) {
const dependency = app.options.dependencies[i];
if (
dependency.type === DEPENDENCIES_TYPE.application ||
dependency.type === DEPENDENCIES_TYPE.middleware
) {
if (dependency.type === DEPENDENCIES_TYPE.middleware) {
this._saveDependencies(app, dependency);

if (!nameList.includes(dependency.name)) {
Expand Down
5 changes: 5 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3452,6 +3452,11 @@ domhandler@^5.0.2, domhandler@^5.0.3:
dependencies:
domelementtype "^2.3.0"

dompurify@^3.1.7:
version "3.1.7"
resolved "https://registry.npmjs.org/dompurify/-/dompurify-3.1.7.tgz"
integrity sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==

domutils@^2.5.2, domutils@^2.8.0:
version "2.8.0"
resolved "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz"
Expand Down

0 comments on commit 8f66e2f

Please sign in to comment.