update
This commit is contained in:
@@ -1,40 +1,21 @@
|
|||||||
"use strict";
|
const o = /* @__PURE__ */ (() => {
|
||||||
const AdminFunction = (() => {
|
function a(t) {
|
||||||
function capNhatTrangThaiMenu(e) {
|
const s = $("#status_" + t);
|
||||||
!1 === e ? $("#js-admin-content-container").addClass("show-large-menu") : $("#js-admin-content-container").removeClass("show-large-menu"), $("#js-menu-big").toggleClass("hidden", e), $("#js-menu-small").toggleClass("hidden", !e), $("#js-form-search").toggleClass("menu-hide", e), localStorage.setItem(e ? "menu_big" : "menu_small", "hidden"), localStorage.removeItem(e ? "menu_small" : "menu_big");
|
s.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>'), setTimeout(() => {
|
||||||
}
|
s.html("");
|
||||||
function e(e) {
|
}, 1e3);
|
||||||
let t = null;
|
}
|
||||||
return function (...n) {
|
function n(t) {
|
||||||
const o = this, a = function () {
|
const s = $("#js-status-hottype-" + t);
|
||||||
t = null, n.length > 0 && !e && func.apply(o, n);
|
s.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>'), setTimeout(() => {
|
||||||
}, i = e && !t;
|
s.html("");
|
||||||
clearTimeout(t), t = setTimeout(a, wait), i && func.apply(o, n);
|
}, 1e3);
|
||||||
};
|
}
|
||||||
}
|
return {
|
||||||
function t(t) {
|
addProductToCategory: a,
|
||||||
$("#status_" + t).html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Đang xử lý..</span>'), setTimeout(() => {
|
markProductAsHot: n
|
||||||
$("#status_" + t).html("");
|
};
|
||||||
}, 1e3);
|
|
||||||
}
|
|
||||||
function n(e) {
|
|
||||||
$(e).keyup((() => {
|
|
||||||
$("#js-show-search").show();
|
|
||||||
}));
|
|
||||||
$("body").click((() => {
|
|
||||||
$("#js-show-search").hide();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
function o(e) {
|
|
||||||
$("#js-status-hottype-" + e).html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Đang xử lý..</span>'), setTimeout(() => {
|
|
||||||
$("#js-status-hottype-" + e).html("");
|
|
||||||
}, 1e3);
|
|
||||||
}
|
|
||||||
function i(e) {
|
|
||||||
$("#overlay").addClass("active"), $(".status-notificatiom").addClass("active"), !0 === e ? $(".status-notificatiom .content").html('<i class="fa fa-check"></i> <b>Cập nhật thành công</b>\n <p>Đơn hàng #000-368 đã được cập nhật thành công</p>') : $(".status-notificatiom .content").html('<i class="fa-solid fa-triangle-exclamation"></i> <b>Lỗi cập nhật</b><p>Có một số vấn đề với hoạt động của bạn.</p>');
|
|
||||||
}
|
|
||||||
function r() {
|
|
||||||
$("#overlay").removeClass("active"), $(".status-notificatiom").removeClass("active");
|
|
||||||
}
|
|
||||||
return { capNhatTrangThaiMenu: capNhatTrangThaiMenu, add_product_to_category: t, run_search: n, update_product_hot: o, checkForm: i, closeForm: r };
|
|
||||||
})();
|
})();
|
||||||
|
export {
|
||||||
|
o as default
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var AdminFunctions = (function () {
|
|
||||||
function toggleMenuVisibility(hideLargeMenu) {
|
|
||||||
var contentContainer = $('#js-admin-content-container');
|
|
||||||
var largeMenu = $('#js-menu-big');
|
|
||||||
var smallMenu = $('#js-menu-small');
|
|
||||||
var searchForm = $('#js-form-search');
|
|
||||||
contentContainer.toggleClass('show-large-menu', !hideLargeMenu);
|
|
||||||
largeMenu.toggleClass('hidden', hideLargeMenu);
|
|
||||||
smallMenu.toggleClass('hidden', !hideLargeMenu);
|
|
||||||
searchForm.toggleClass('menu-hide', hideLargeMenu);
|
|
||||||
localStorage.setItem(hideLargeMenu ? 'menu_big' : 'menu_small', 'hidden');
|
|
||||||
localStorage.removeItem(hideLargeMenu ? 'menu_small' : 'menu_big');
|
|
||||||
}
|
|
||||||
function debounce(func, wait, immediate) {
|
|
||||||
var timeout = null;
|
|
||||||
return function () {
|
|
||||||
var args = [];
|
|
||||||
for (var _i = 0; _i < arguments.length; _i++) {
|
|
||||||
args[_i] = arguments[_i];
|
|
||||||
}
|
|
||||||
var context = this;
|
|
||||||
var later = function () {
|
|
||||||
timeout = null;
|
|
||||||
if (!immediate)
|
|
||||||
func.apply(context, args);
|
|
||||||
};
|
|
||||||
var callNow = immediate && !timeout;
|
|
||||||
if (timeout !== null) {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
}
|
|
||||||
timeout = setTimeout(later, wait);
|
|
||||||
if (callNow)
|
|
||||||
func.apply(context, args);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function addProductToCategory(productId) {
|
|
||||||
var statusElement = $('#status_' + productId);
|
|
||||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
|
||||||
setTimeout(function () {
|
|
||||||
statusElement.html('');
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
function searchSuggestions(inputSelector) {
|
|
||||||
$(inputSelector).keyup(debounce(function () {
|
|
||||||
$('#js-show-search').show();
|
|
||||||
}, 300, false));
|
|
||||||
$('body').click(function () {
|
|
||||||
$('#js-show-search').hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function markProductAsHot(productId) {
|
|
||||||
var statusElement = $('#js-status-hottype-' + productId);
|
|
||||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
|
||||||
setTimeout(function () {
|
|
||||||
statusElement.html('');
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
toggleMenuVisibility: toggleMenuVisibility,
|
|
||||||
addProductToCategory: addProductToCategory,
|
|
||||||
searchSuggestions: searchSuggestions,
|
|
||||||
markProductAsHot: markProductAsHot
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
@@ -1,46 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
interface AdminFunctions {
|
interface AdminFunctions {
|
||||||
toggleMenuVisibility(hideLargeMenu: boolean): void;
|
|
||||||
addProductToCategory(productId: string): void;
|
addProductToCategory(productId: string): void;
|
||||||
searchSuggestions(inputSelector: string): void;
|
|
||||||
markProductAsHot(productId: string): void;
|
markProductAsHot(productId: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AdminFunctions: AdminFunctions = (() => {
|
const AdminFunctions: AdminFunctions = (() => {
|
||||||
|
|
||||||
function toggleMenuVisibility(hideLargeMenu: boolean): void {
|
|
||||||
const contentContainer = $('#js-admin-content-container');
|
|
||||||
const largeMenu = $('#js-menu-big');
|
|
||||||
const smallMenu = $('#js-menu-small');
|
|
||||||
const searchForm = $('#js-form-search');
|
|
||||||
|
|
||||||
contentContainer.toggleClass('show-large-menu', !hideLargeMenu);
|
|
||||||
largeMenu.toggleClass('hidden', hideLargeMenu);
|
|
||||||
smallMenu.toggleClass('hidden', !hideLargeMenu);
|
|
||||||
searchForm.toggleClass('menu-hide', hideLargeMenu);
|
|
||||||
|
|
||||||
localStorage.setItem(hideLargeMenu ? 'menu_big' : 'menu_small', 'hidden');
|
|
||||||
localStorage.removeItem(hideLargeMenu ? 'menu_small' : 'menu_big');
|
|
||||||
}
|
|
||||||
|
|
||||||
function debounce(func: (...args: any[]) => void, wait: number, immediate: boolean) {
|
|
||||||
let timeout: ReturnType<typeof setTimeout> | null = null;
|
|
||||||
return function (this: HTMLInputElement, ...args: any[]) {
|
|
||||||
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 addProductToCategory(productId: string): void {
|
function addProductToCategory(productId: string): void {
|
||||||
const statusElement = $('#status_' + productId);
|
const statusElement = $('#status_' + productId);
|
||||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
||||||
@@ -49,16 +15,6 @@ const AdminFunctions: AdminFunctions = (() => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchSuggestions(inputSelector: string): void {
|
|
||||||
$(inputSelector).keyup(debounce(function (this: HTMLInputElement) {
|
|
||||||
$('#js-show-search').show();
|
|
||||||
}, 300, false) as any);
|
|
||||||
|
|
||||||
$('body').click(function () {
|
|
||||||
$('#js-show-search').hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function markProductAsHot(productId: string): void {
|
function markProductAsHot(productId: string): void {
|
||||||
const statusElement = $('#js-status-hottype-' + productId);
|
const statusElement = $('#js-status-hottype-' + productId);
|
||||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
||||||
@@ -68,9 +24,9 @@ const AdminFunctions: AdminFunctions = (() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
toggleMenuVisibility,
|
|
||||||
addProductToCategory,
|
addProductToCategory,
|
||||||
searchSuggestions,
|
|
||||||
markProductAsHot
|
markProductAsHot
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
export default AdminFunctions;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "admin_hura_8",
|
"name": "admin_hura_8",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "<h1>Hướng dẫn</h1>",
|
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"build:js": "vite build",
|
||||||
"build:css": "tailwindcss -i ./assets/script/hura.global.css -o ./assets/script/hura-lib.css",
|
"build:css": "tailwindcss -i ./assets/script/hura.global.css -o ./assets/script/hura-lib.css",
|
||||||
"watch:css": "tailwindcss -i ./assets/script/hura.global.css -o ./assets/script/hura-lib.css --watch",
|
"watch:css": "tailwindcss -i ./assets/script/hura.global.css -o ./assets/script/hura-lib.css --watch",
|
||||||
|
"build": "npm run build:js && npm run build:css",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -15,7 +16,7 @@
|
|||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"type": "commonjs",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/cli": "^4.1.17",
|
"@tailwindcss/cli": "^4.1.17",
|
||||||
"autoprefixer": "^10.4.22",
|
"autoprefixer": "^10.4.22",
|
||||||
|
|||||||
@@ -1,71 +1,24 @@
|
|||||||
import { defineConfig } from "vite"
|
import { defineConfig } from "vite"
|
||||||
import injectHTML from "vite-plugin-html-inject"
|
|
||||||
import { resolve } from "node:path"
|
import { resolve } from "node:path"
|
||||||
import fs from "node:fs"
|
|
||||||
import tailwindcss from "@tailwindcss/vite"
|
|
||||||
import { fileURLToPath } from "node:url"
|
import { fileURLToPath } from "node:url"
|
||||||
|
|
||||||
const __dirname = fileURLToPath(new URL(".", import.meta.url))
|
const __dirname = fileURLToPath(new URL(".", import.meta.url))
|
||||||
|
|
||||||
const getHtmlFiles = (dir: string): string[] => {
|
|
||||||
let results: string[] = []
|
|
||||||
const list = fs.readdirSync(dir)
|
|
||||||
list.forEach((file) => {
|
|
||||||
file = resolve(dir, file)
|
|
||||||
const stat = fs.statSync(file)
|
|
||||||
if (stat && stat.isDirectory()) {
|
|
||||||
if (file.endsWith("/partials")) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
results = results.concat(getHtmlFiles(file))
|
|
||||||
} else if (file.endsWith(".html")) {
|
|
||||||
results.push(file)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return results
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize the paths to ensure consistent forward slashes
|
|
||||||
const normalizePath = (path: string): string => path.split(resolve(__dirname, "src")).join("").replace(/\\/g, "/")
|
|
||||||
|
|
||||||
// Use normalizePath function to process the paths correctly
|
|
||||||
const htmlFiles = getHtmlFiles("src")
|
|
||||||
const input = Object.fromEntries(
|
|
||||||
htmlFiles.map((file) => [normalizePath(file).replace(".html", "").replace(/^\//, ""), file])
|
|
||||||
)
|
|
||||||
|
|
||||||
const removecors = () => {
|
|
||||||
return {
|
|
||||||
name: "remove-cors",
|
|
||||||
transformIndexHtml: {
|
|
||||||
order: "post" as const,
|
|
||||||
handler(html: string) {
|
|
||||||
return html.replace(/crossorigin\s*/g, "")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: "",
|
|
||||||
server: {
|
|
||||||
open: "/",
|
|
||||||
},
|
|
||||||
publicDir: "../public",
|
|
||||||
plugins: [injectHTML(), removecors(), tailwindcss()],
|
|
||||||
root: "src",
|
|
||||||
optimizeDeps: {
|
|
||||||
include: ["filepond", "filepond-plugin-image-preview"],
|
|
||||||
},
|
|
||||||
build: {
|
build: {
|
||||||
outDir: "../html",
|
lib: {
|
||||||
emptyOutDir: true,
|
entry: {
|
||||||
|
global: resolve(__dirname, "assets/typescript/main.ts"),
|
||||||
|
},
|
||||||
|
formats: ["es"],
|
||||||
|
fileName: (format, entryName) => `${entryName}.js`,
|
||||||
|
},
|
||||||
|
outDir: "assets/script",
|
||||||
|
emptyOutDir: false,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input,
|
|
||||||
output: {
|
output: {
|
||||||
entryFileNames: `assets/script/[name].js`,
|
dir: "assets/script",
|
||||||
chunkFileNames: `assets/script/[name].js`,
|
entryFileNames: "[name].js",
|
||||||
assetFileNames: `assets/script/[name].[ext]`,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user