From eee07fab6b5bb555359dbdba09a9cf7729e3ac40 Mon Sep 17 00:00:00 2001 From: Tieptk Date: Mon, 13 May 2024 11:52:43 +0700 Subject: [PATCH] typesript --- assets/src/main.js | 65 +++++++++++++++++++ src_typescript/main2.ts => assets/src/main.ts | 20 +----- tsconfig.json | 2 +- vite.config.ts | 2 +- 4 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 assets/src/main.js rename src_typescript/main2.ts => assets/src/main.ts (78%) diff --git a/assets/src/main.js b/assets/src/main.js new file mode 100644 index 0000000..cf31a0c --- /dev/null +++ b/assets/src/main.js @@ -0,0 +1,65 @@ +"use strict"; +const AdminFunction = (() => { + function capNhatTrangThaiMenu(hideMenuBig) { + if (hideMenuBig === false) { + $('#js-admin-content-container').addClass('show-large-menu'); + } + else { + $('#js-admin-content-container').removeClass('show-large-menu'); + } + $('#js-menu-big').toggleClass('hidden', hideMenuBig); + $('#js-menu-small').toggleClass('hidden', !hideMenuBig); + $('#js-form-search').toggleClass('menu-hide', hideMenuBig); + localStorage.setItem(hideMenuBig ? 'menu_big' : 'menu_small', 'hidden'); + localStorage.removeItem(hideMenuBig ? 'menu_small' : 'menu_big'); + } + function debounce(func, wait, immediate) { + let timeout = null; + return function (...args) { + const context = this; + const later = function () { + timeout = null; + if (!immediate) + func.apply(context, args); + }; + const callNow = immediate && !timeout; + if (timeout !== null) { + clearTimeout(timeout); + } + timeout = setTimeout(later, wait); + if (callNow) + func.apply(context, args); + }; + } + function add_product_to_category(id) { + $('#status_' + id).html('Đang xử lý..'); + setTimeout(() => { + $('#status_' + id).html(''); + }, 1000); + } + function run_search(holder) { + $(holder).keyup(debounce(function () { + //const inputString = $(this).val(); + $('#js-show-search').show(); + }, 300, false)); // Cast debounce to any to avoid type inference issues + $('body').click(function () { + $("#js-show-search").hide(); + }); + } + function update_product_hot(id) { + $('#js-status-hottype-' + id).html('Đang xử lý..'); + setTimeout(() => { + $('#js-status-hottype-' + id).html(''); + }, 1000); + } + function searchSelect(holder) { + $(holder).select2(); + } + return { + capNhatTrangThaiMenu, + add_product_to_category, + run_search, + searchSelect, + update_product_hot + }; +})(); diff --git a/src_typescript/main2.ts b/assets/src/main.ts similarity index 78% rename from src_typescript/main2.ts rename to assets/src/main.ts index 5033df5..934d8de 100644 --- a/src_typescript/main2.ts +++ b/assets/src/main.ts @@ -70,29 +70,11 @@ const AdminFunction: AdminFunction = (() => { $(holder).select2(); } - function checkForm(status: boolean) { - $('#overlay').addClass('active'); - $('.status-notificatiom').addClass('active'); - if (status == true) { - $('.status-notificatiom .content').html(` Cập nhật thành công -

Đơn hàng #000-368 đã được cập nhật thành công

`); - } - else { - $('.status-notificatiom .content').html(` Lỗi cập nhật

Có một số vấn đề với hoạt động của bạn.

`); - } - } - function closeForm() { - $('#overlay').removeClass('active'); - $('.status-notificatiom').removeClass('active'); - } - return { capNhatTrangThaiMenu, add_product_to_category, run_search, searchSelect, - update_product_hot, - checkForm, - closeForm + update_product_hot }; })(); diff --git a/tsconfig.json b/tsconfig.json index f9e069a..a83baba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,6 @@ "jsx": "preserve", "moduleResolution": "node" // Thay đổi giá trị này từ 'classic' thành 'node' }, - "include": ["./src_typescript/main2.ts"], + "include": ["./assets/src/main.ts"], "exclude": ["node_modules"] } diff --git a/vite.config.ts b/vite.config.ts index 2869726..280d87c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,7 +4,7 @@ import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ build: { - outDir: 'dist', + outDir: './assets/dist', minify: false, rollupOptions: { output: {