Files
appco_dist/.output/server/chunks/build/index-CW1FIdJs.mjs
T

360 lines
13 KiB
JavaScript

import { defineComponent, unref, ref, mergeProps, computed, withAsyncContext, watch, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrRenderAttrs, ssrRenderList, ssrInterpolate, ssrRenderStyle } from 'vue/server-renderer';
import { a as useConfigStore, u as useRouter$1, b as useUserStore, p as useCartStore, _ as __nuxt_component_0, q as useState, t as useRequestEvent, n as useIntersectionObserver, w as getProducts, o as getToken, d as api$1 } from './server.mjs';
import { P as Post, _ as _sfc_main$5 } from './PostCardSkeleton-1I8ZExkN.mjs';
import { C as CommentAddEdit, _ as _sfc_main$6, d as deletePostLike, c as createPostLike } from './moreOptionProduct-COId1EJx.mjs';
import { d as deleteSave, c as createSave } from './save-BM_TzM80.mjs';
import { u as useProductStore } from './product-C6Biv0TJ.mjs';
import { u as useAsyncData } from './asyncData-DGiCewbG.mjs';
import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs';
import { _ as _sfc_main$4 } from './FullScreenStories-BYW2TGy5.mjs';
import { u as useMediaStore } from './media-fadondUH.mjs';
import { U as UserProfilePic } from './UserProfilePic-CBi3ttKR.mjs';
import { _ as __nuxt_component_1 } from './index-CgIEYqpX.mjs';
import '../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:url';
import 'consola';
import 'ipx';
import 'node:path';
import 'node:crypto';
import 'pinia';
import '@supabase/supabase-js';
import '@babel/runtime/helpers/esm/extends';
import '@babel/runtime/helpers/esm/objectSpread2';
import '@ant-design/colors';
import '@ctrl/tinycolor';
import 'stylis';
import 'vue-types';
import 'lodash-es';
import 'axios';
import '@ant-design/icons-vue';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import './empty_user-BaUNCdgf.mjs';
import './useDateTime-D8RCoGwW.mjs';
import 'moment';
import 'moment-timezone';
import 'moment-jalaali';
import 'date-fns';
import 'date-fns/locale';
import 'swiper/vue';
import 'swiper/modules';
import './post_loading-BiySI7bp.mjs';
import './BasicIconOld-93vAWohq.mjs';
import './like-BhIOg3YL.mjs';
import 'vue-content-loader';
import './index-DN7-byVZ.mjs';
import '@vueuse/gesture';
import '@headlessui/vue';
import 'framesync';
import 'popmotion';
import 'style-value-types';
import './BasicButton-BY5Qzukq.mjs';
import './index-DWwHo7-N.mjs';
import 'throttle-debounce';
import './index-xM0P2tPp.mjs';
import 'dom-align';
import './index-DEYBOQNk.mjs';
import './shallowequal-NTdzjvNX.mjs';
import 'lodash-es/uniq.js';
import './index-D4GLYzaN.mjs';
import './FormItemContext-2mj5AJzl.mjs';
import './index-atBrDcKY.mjs';
import 'lodash-es/isPlainObject.js';
import 'resize-observer-polyfill';
import './collapseMotion-cQ2SGjCA.mjs';
import './handle-CbilF0ny.mjs';
import './BasicInput-BLgnaBLz.mjs';
import './usePrice-B-5-jXKQ.mjs';
import './media-TZzDk-n-.mjs';
import '../_/CheckOutlined.mjs';
import './useRefs-BHKrVg4I.mjs';
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
__name: "Posts",
__ssrInlineRender: true,
props: {
userPostScroll: {},
scrollSave: {}
},
async setup(__props) {
let __temp, __restore;
const router = useRouter$1();
const config = useConfigStore();
const posts = ref([]);
const total = ref(100);
const currentPage = ref(0);
const limit = ref(10);
const endPage = ref(false);
const loading = ref(false);
const addLikeLoading = ref(false);
const commentPostId = ref();
const commentVisible = ref(false);
const optionVisible = ref(false);
const optionPostId = ref();
const props = __props;
const user = useUserStore();
computed(() => props.userPostScroll === "userPostScroll");
const percent = useProductStore();
ref(null);
const reset = () => {
endPage.value = false;
posts.value = [];
total.value = 0;
};
function handleLike(isLiked, id) {
try {
addLikeLoading.value = true;
if (getToken()) {
if (isLiked) {
deletePostLike(id);
const index = posts.value.findIndex((x) => x.id === id);
posts.value[index]?.likes.splice(posts.value[index].likes?.findIndex((y) => y.user_id === user.user.id));
} else {
createPostLike(id);
const index = posts.value.findIndex((x) => x.id === id);
posts.value[index].likes.push({
product_id: id,
user_id: user.user.id
});
}
} else {
router.push({ name: "auth-login" });
api$1.warn(config.useString("pleaseLoginOrRegister"));
}
} catch (e) {
console.log(e);
} finally {
addLikeLoading.value = false;
}
}
function addCommentId(id) {
posts.value[posts.value.findIndex((x) => x.id === commentPostId.value)].comments.push({ id });
}
function handleSave(isSaved, id) {
if (getToken()) {
if (isSaved) {
deleteSave(id);
const index = posts.value.findIndex((x) => x.id === id);
posts.value[index]?.saved.splice(posts.value[index].saved?.findIndex((y) => y.user_id === user.user.id));
} else {
createSave(id);
const index = posts.value.findIndex((x) => x.id === id);
posts.value[index].saved.push({
product_id: id,
user_id: user.user.id
});
}
} else {
router.push({ name: "auth-login" });
api$1.warn(config.useString("pleaseLoginOrRegister"));
}
}
function openOption(id) {
optionPostId.value = id;
optionVisible.value = true;
}
function openComment(id) {
commentPostId.value = id;
commentVisible.value = true;
}
const request = async (page = 1) => {
try {
loading.value = true;
return await getProducts(page, limit.value);
} catch (e) {
console.error(e);
return { data: [], count: 0 };
} finally {
loading.value = false;
}
};
const isBot = useState("isBot", () => {
const event = useRequestEvent();
const ua = event?.node.req.headers["user-agent"] || "";
const bots = ["googlebot", "bingbot", "yandex", "duckduckbot", "baiduspider", "facebot", "slurp"];
console.log(ua.toLowerCase());
return bots.some((bot) => ua.toLowerCase().includes(bot));
});
if (isBot) {
const { data } = ([__temp, __restore] = withAsyncContext(() => useAsyncData("posts", async () => {
return request(1);
})), __temp = await __temp, __restore(), __temp);
} else {
console.log("real");
}
const observer = ref();
useIntersectionObserver(observer, async ([{ isIntersecting }]) => {
if (isIntersecting && !loading.value && !endPage.value) {
const nextPage = currentPage.value + 1;
const res = await request(nextPage);
if (res.data?.length) {
posts.value.push(...res.data);
currentPage.value = nextPage;
}
if (res.data?.length < limit.value) {
endPage.value = true;
}
}
});
computed(() => router.currentRoute.value.query.target || null);
const present = computed(() => percent.percentUpload);
watch(present, () => {
if (present.value == 100) {
currentPage.value = 0;
reset();
request();
}
});
return (_ctx, _push, _parent, _attrs) => {
_push(`<!--[--><div class="mt-5 pb-5vh" data-v-ae651381><!--[-->`);
ssrRenderList(posts.value, (post, index) => {
_push(ssrRenderComponent(Post, {
onOpenOption: openOption,
onOpenComment: openComment,
onHandleLike: handleLike,
onHandleSave: handleSave,
index,
post,
key: index,
scrollSave: _ctx.scrollSave,
"add-like-loading": addLikeLoading.value
}, null, _parent));
});
_push(`<!--]-->`);
if (loading.value) {
_push(ssrRenderComponent(_sfc_main$5, null, null, _parent));
} else {
_push(`<!---->`);
}
_push(`<div style="${ssrRenderStyle(!loading.value ? null : { display: "none" })}" class="w-full opacity-0 relative" data-v-ae651381> load </div></div>`);
_push(ssrRenderComponent(CommentAddEdit, {
id: commentPostId.value,
open: commentVisible.value,
"onUpdate:open": ($event) => commentVisible.value = $event,
onAddCommentId: addCommentId
}, null, _parent));
_push(ssrRenderComponent(_sfc_main$6, {
id: optionPostId.value,
open: optionVisible.value,
"onUpdate:open": ($event) => optionVisible.value = $event
}, null, _parent));
_push(`<!--]-->`);
};
}
});
const _sfc_setup$3 = _sfc_main$3.setup;
_sfc_main$3.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/components/Posts.vue");
return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
};
const Posts = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-ae651381"]]);
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
__name: "CustomStories",
__ssrInlineRender: true,
setup(__props) {
const selectedStoryId = ref(null);
ref(null);
ref(false);
useConfigStore();
useUserStore();
const mediaStore = useMediaStore();
const userStore = useUserStore();
return (_ctx, _push, _parent, _attrs) => {
_push(`<div${ssrRenderAttrs(mergeProps({ class: "stories-container -ms4" }, _attrs))} data-v-2bde2eff><div class="scroll-wrapper ps-4" data-v-2bde2eff><!--[-->`);
ssrRenderList(unref(mediaStore).users, (user2) => {
_push(`<div class="story" data-v-2bde2eff>`);
_push(ssrRenderComponent(UserProfilePic, {
src: user2.avatar,
seenStory: !user2?.stories?.length || user2.stories.every((item) => item.storyviews.find((_item) => _item.user_id === unref(userStore).user?.id || _item.user_id === "me")),
showAdd: user2.id === unref(userStore).user?.id
}, null, _parent));
_push(`<div class="w-full text-center mt1 text-xs truncate" data-v-2bde2eff>${ssrInterpolate(user2.name)}</div></div>`);
});
_push(`<!--]--></div>`);
if (selectedStoryId.value) {
_push(ssrRenderComponent(_sfc_main$4, {
id: selectedStoryId.value,
"onUpdate:id": ($event) => selectedStoryId.value = $event
}, null, _parent));
} else {
_push(`<!---->`);
}
_push(`</div>`);
};
}
});
const _sfc_setup$2 = _sfc_main$2.setup;
_sfc_main$2.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/components/CustomStories.vue");
return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const CustomStories = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2bde2eff"]]);
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
__name: "index",
__ssrInlineRender: true,
setup(__props) {
useConfigStore();
const percent = useProductStore();
useRouter$1();
useUserStore();
useCartStore();
return (_ctx, _push, _parent, _attrs) => {
const _component_ClientOnly = __nuxt_component_0;
const _component_AProgress = __nuxt_component_1;
_push(`<div${ssrRenderAttrs(_attrs)}><div class="absolute top-0 w-inherit right-0 left-0">`);
_push(ssrRenderComponent(_component_ClientOnly, null, {}, _parent));
_push(`<div class="h-90vh overflow-y-auto pb-10vh scrollHome">`);
_push(ssrRenderComponent(CustomStories, { class: "" }, null, _parent));
if (unref(percent).percentUpload != 100 && unref(percent).loading) {
_push(ssrRenderComponent(_component_AProgress, {
percent: unref(percent).percentUpload,
"show-info": false,
status: "active",
size: "small"
}, null, _parent));
} else {
_push(`<!---->`);
}
_push(ssrRenderComponent(Posts, {
"user-post-scroll": "scrollHome",
"scroll-save": "scrollPosition"
}, null, _parent));
_push(`</div></div></div>`);
};
}
});
const _sfc_setup$1 = _sfc_main$1.setup;
_sfc_main$1.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/index.vue");
return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "index",
__ssrInlineRender: true,
setup(__props) {
return (_ctx, _push, _parent, _attrs) => {
_push(ssrRenderComponent(_sfc_main$1, _attrs, null, _parent));
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/home/index.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export { _sfc_main as default };