Compare commits
No commits in common. "05d11e0ea58fbbb0ccfdaf9f37027a152a8e012b" and "bb7a84259cd06a3d506a1ce72ca1822bcee1875a" have entirely different histories.
05d11e0ea5
...
bb7a84259c
@ -24,8 +24,7 @@
|
||||
<template>
|
||||
<i
|
||||
:style="{
|
||||
...$attrs.style,
|
||||
fontSize: pixi,
|
||||
fontSize: `${size}${propUnit}`,
|
||||
color: icolor || 'currentcolor',
|
||||
}"
|
||||
:class="`fa${styleMap[istyle]} fa-${name}`"
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { Grid, ItemType } from "ant-design-vue";
|
||||
import { Grid } from "ant-design-vue";
|
||||
const bp = Grid.useBreakpoint();
|
||||
const { data, status } = useAuth();
|
||||
const itemMap = ref({
|
||||
@ -22,7 +22,6 @@
|
||||
let selected: string[] = [cur.value];
|
||||
|
||||
const clickFn = (minfo) => {
|
||||
console.log("clicky", minfo);
|
||||
if (itemMap.value[minfo.key] === undefined) return;
|
||||
cur.value = itemMap.value[minfo.key];
|
||||
selected = [cur.value];
|
||||
@ -44,13 +43,12 @@
|
||||
}"
|
||||
@click="clickFn"
|
||||
:active-key="cur"
|
||||
:key="data?.user?._id"
|
||||
>
|
||||
<a-menu-item key="home"> Home </a-menu-item>
|
||||
<a-menu-item key="bands"> Bands </a-menu-item>
|
||||
<a-menu-item key="authors"> Authors </a-menu-item>
|
||||
<a-menu-item key="forum"> Message Board</a-menu-item>
|
||||
<a-sub-menu :disabled="!data?.user" v-if="!!data?.user" title="My Stuff" key="group/my-stuff">
|
||||
<a-sub-menu title="My Stuff" v-if="!!data?.user" key="group/my-stuff">
|
||||
<a-menu-item key="account"> Account </a-menu-item>
|
||||
<a-menu-item key="edit-profile"> Edit Profile </a-menu-item>
|
||||
<a-menu-item key="profile"> View Profile </a-menu-item>
|
||||
@ -62,9 +60,9 @@
|
||||
<a-menu-item key="admin" v-if="data?.user?.profile.isAdmin || false"> Admin </a-menu-item>
|
||||
<a-menu-item key="logout" v-if="!!data?.user"> Logout </a-menu-item>
|
||||
</a-menu>
|
||||
<div v-if="data?.user">
|
||||
<div>
|
||||
<nuxt-link to="/new-story">
|
||||
<a-button type="primary" tooltip="Post a New Story">
|
||||
<a-button v-if="data?.user" type="primary" tooltip="Post a New Story">
|
||||
<!-- <template #icon>
|
||||
</template> -->
|
||||
<icon istyle="regular" name="file-plus" />
|
||||
@ -72,7 +70,7 @@
|
||||
</a-button>
|
||||
</nuxt-link>
|
||||
</div>
|
||||
<div class="acbut" v-if="!data?.user">
|
||||
<div class="acbut" v-if="!data">
|
||||
<a-button size="large" @click="() => navigateTo('/auth/login')"> Login </a-button>
|
||||
<a-button size="large" type="primary" @click="() => navigateTo('/auth/register')"> Register </a-button>
|
||||
</div>
|
||||
|
@ -3,7 +3,6 @@
|
||||
import { ItemType, theme } from "ant-design-vue";
|
||||
import Icon from "../icon.vue";
|
||||
import { ISidebarItem } from "@models/sidebarEntry";
|
||||
import { NuxtLink } from "#components";
|
||||
|
||||
const { useToken } = theme;
|
||||
const { token } = useToken();
|
||||
@ -11,8 +10,8 @@
|
||||
const selState = ref<string>("");
|
||||
|
||||
const { data: injecto } = await useApiFetch<ISidebarItem[]>("/sidebar");
|
||||
let custItems = computed(() => (injecto.value || ([] as ISidebarItem[])).sort((a, b) => a.index - b.index));
|
||||
/*let items = ref<ItemType[]>([
|
||||
|
||||
let items = reactive<ItemType[]>([
|
||||
{
|
||||
key: "important",
|
||||
label: h("span", { class: "smallcaps" }, ["Pinned"]),
|
||||
@ -58,7 +57,9 @@
|
||||
name: "sparkles",
|
||||
size: 19,
|
||||
}),
|
||||
children: custItems.value.map((b) => ({
|
||||
children: (injecto.value || ([] as ISidebarItem[]))
|
||||
.sort((a, b) => a.index - b.index)
|
||||
.map((b) => ({
|
||||
key: b.url,
|
||||
label: h(
|
||||
"span",
|
||||
@ -70,12 +71,13 @@
|
||||
),
|
||||
})),
|
||||
} as SubMenuType,
|
||||
]);*/
|
||||
]);
|
||||
|
||||
// console.log("wtf", items)
|
||||
</script>
|
||||
<template>
|
||||
<!-- <client-only>-->
|
||||
<a-menu
|
||||
id="sidebar-menu"
|
||||
mode="inline"
|
||||
@select="
|
||||
({ item, key, selectedKeys }) => {
|
||||
@ -87,41 +89,37 @@
|
||||
"
|
||||
:trigger-sub-menu-action="'click'"
|
||||
v-model:active-key="selState"
|
||||
:items="items"
|
||||
:inline-indent="16"
|
||||
>
|
||||
<a-sub-menu key="important">
|
||||
<template #icon>
|
||||
<icon istyle="regular" name="thumbtack" :size="19" />
|
||||
</template>
|
||||
<!-- <a-sub-menu>
|
||||
<template #title>
|
||||
<span class="smallcaps">Pinned</span>
|
||||
</template>
|
||||
<a-menu-item key="/submission-rules">
|
||||
<template #icon>
|
||||
<icon istyle="regular" name="memo" :size="15" />
|
||||
</template>
|
||||
<b :style="{ color: token.colorInfo }">SUBMISSION RULES</b>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="/terms">
|
||||
<template #icon>
|
||||
<icon istyle="regular" name="globe" :size="15" />
|
||||
</template>
|
||||
<b>Terms of Service</b>
|
||||
</a-menu-item>
|
||||
</a-sub-menu>
|
||||
<a-sub-menu key="fun-features">
|
||||
<sidebar-icon>
|
||||
<template #icon>
|
||||
<Icon name="sparkles" istyle="regular" :size="19"/>
|
||||
</template>
|
||||
<template #title>
|
||||
<div class="smallcaps">fun features</div>
|
||||
<template #rest>
|
||||
<div class="smallcaps">
|
||||
fun features
|
||||
</div>
|
||||
</template>
|
||||
<a-menu-item v-for="item in custItems" :key="item.url">
|
||||
<span :style="{ color: item.color }">
|
||||
<nuxt-link :to="item.url">{{ item.linkTitle }}</nuxt-link>
|
||||
</span>
|
||||
</sidebar-icon>
|
||||
</template>
|
||||
<a-menu-item>
|
||||
<sidebar-icon>
|
||||
<template #icon>
|
||||
<icon name="memo" :icolor="token.colorInfo" istyle="regular" :size="13"/>
|
||||
</template>
|
||||
<template #rest>
|
||||
<nuxt-link to="/submission-rules">
|
||||
<b :style="{ color: token.colorInfo }">
|
||||
submission rules
|
||||
</b>
|
||||
</nuxt-link>
|
||||
</template>
|
||||
</sidebar-icon>
|
||||
</a-menu-item>
|
||||
</a-sub-menu>
|
||||
</a-sub-menu> -->
|
||||
</a-menu>
|
||||
<!-- </client-only>-->
|
||||
</template>
|
||||
@ -129,7 +127,4 @@
|
||||
.smallcaps {
|
||||
font-variant: small-caps;
|
||||
}
|
||||
#sidebar-menu ul {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
@ -52,8 +52,8 @@
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
ul.ant-list-items > * + * {
|
||||
<style scoped>
|
||||
.ant-list-items > * + * {
|
||||
margin-top: 1.2em;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
import { Field, FieldArray, useForm, useFieldArray } from "vee-validate";
|
||||
import { ASpin } from "#components";
|
||||
import { storySchema } from "@client/storyFormSchema";
|
||||
import { FormStory, defaultChapter, FormChapter } from "@client/types/form/story";
|
||||
import { FormStory, defaultChapter } from "@client/types/form/story";
|
||||
import { autoEdit, autoSave, debouncedAutoEdit, debouncedAutoSave } from "@client/utils";
|
||||
|
||||
import findUser from "~/components/findUser.vue";
|
||||
@ -20,16 +20,17 @@
|
||||
endpoint: string;
|
||||
endpointMethod: "put" | "post";
|
||||
submitText?: string;
|
||||
draftData?: {
|
||||
endpoint: string;
|
||||
endpointMethod: "put" | "post";
|
||||
};
|
||||
}>();
|
||||
let w;
|
||||
onMounted(() => {
|
||||
w = window;
|
||||
});
|
||||
const dc = defaultChapter;
|
||||
// data: FormStory;
|
||||
const sdata = defineModel<FormStory>("data", {
|
||||
required: true,
|
||||
});
|
||||
let drag: boolean = false;
|
||||
let drag = false;
|
||||
const expandos = ref<string[]>([]);
|
||||
|
||||
function logSubmit(values, actions) {
|
||||
@ -45,32 +46,27 @@
|
||||
otherBtnInvoked.value = false;
|
||||
await autoSave(values);
|
||||
} else {
|
||||
const { data: dat } = await useApiFetch<any>(`/story/new`, {
|
||||
const { data: dat } = await useApiFetch(`/story/new`, {
|
||||
method: "post",
|
||||
body: values,
|
||||
});
|
||||
if (dat.value.success) {
|
||||
await router.push(`/story/${dat.value.story._id}/1`);
|
||||
if (dat.success) {
|
||||
await router.push(`/story/${dat.story._id}/1`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await autoEdit(values, props.endpoint, props.endpointMethod);
|
||||
}
|
||||
}
|
||||
|
||||
function inval({ values, errors, results }) {
|
||||
logSubmit(values, undefined);
|
||||
}
|
||||
const { values, setFieldValue, handleSubmit } = useForm<FormStory>({
|
||||
keepValuesOnUnmount: true,
|
||||
validationSchema: storySchema,
|
||||
initialValues: sdata.value,
|
||||
});
|
||||
function renumber(update: (idx: number, value: FormChapter) => void) {
|
||||
for (let i = 0; i < values.chapters.length; i++) {
|
||||
const nv = values.chapters[i];
|
||||
nv.index = i + 1;
|
||||
update(i, nv);
|
||||
sdata.value.chapters[i].index = i + 1;
|
||||
}
|
||||
}
|
||||
// const { push, remove, move, fields } = useFieldArray<FormChapter>("chapters");
|
||||
const subCb = handleSubmit(onSubmit);
|
||||
|
||||
const pushHOF = (push) => (e) => {
|
||||
@ -100,18 +96,7 @@
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<form
|
||||
data-testid="storyform"
|
||||
@submit="subCb"
|
||||
@change="
|
||||
() =>
|
||||
canDraft
|
||||
? draftData
|
||||
? debouncedAutoSave(values, draftData.endpoint, draftData.endpointMethod)
|
||||
: debouncedAutoSave(values)
|
||||
: debouncedAutoEdit(values, endpoint, endpointMethod)
|
||||
"
|
||||
>
|
||||
<form data-testid="storyform" @submit="subCb" @change="() => (canDraft ? debouncedAutoSave(values) : debouncedAutoEdit(values, endpoint, endpointMethod))">
|
||||
<!-- <a-form v-bind:model="acData"> -->
|
||||
|
||||
<Field name="title" v-slot="{ value, field, errorMessage }">
|
||||
@ -127,26 +112,30 @@
|
||||
</Field>
|
||||
<a-divider />
|
||||
<!-- <test1/> -->
|
||||
<field-array name="chapters" v-slot="{ fields, push, remove, move, update }">
|
||||
<field-array name="chapters" v-slot="{ fields, push, remove, move }">
|
||||
<client-only :fallback="h(ASpin)">
|
||||
<div>
|
||||
<div v-for="(element, index) in values.chapters">
|
||||
<div v-for="(element, index) in data.chapters">
|
||||
<client-only>
|
||||
<Teleport :to="`#chapter-\\[${element.uuidKey}\\]`">
|
||||
<a-collapse v-model:active-key="expandos" collapsible="icon">
|
||||
<template #expandIcon="{ isActive }">
|
||||
<span :data-testid="`storyform.chapters[${index}].collapse`"> <RightOutlined :rotate="isActive ? 90 : undefined" /></span>
|
||||
</template>
|
||||
<a-collapse-panel :key="`${element.uuidKey}`" :data-testid="`storyform.chapters[${index}].outer`">
|
||||
<a-collapse-panel :key="`${element.uuidKey}`">
|
||||
<template #header>
|
||||
<div :data-testid="`storyform.chapters[${index}].header`" style="display: flex; align-items: center; justify-content: space-between">
|
||||
<div :data-testid="`storyform.chapters[${index}].header`" style="display: flex; justify-content: space-between">
|
||||
<span :data-testid="`storyform.chapters[${index}].titleEl`">{{ values.chapters[index]?.chapterTitle || "Untitled" }}</span>
|
||||
<a-button
|
||||
@click="
|
||||
(e) => {
|
||||
// let localFields = toRaw(fields);
|
||||
// log.debug(`${index} | ${element.index}`);
|
||||
// log.debug('fields->', localFields);
|
||||
data.chapters.splice(index, 1);
|
||||
remove(index);
|
||||
renumber(update);
|
||||
// todo renumber
|
||||
// renumber()
|
||||
}
|
||||
"
|
||||
>
|
||||
@ -183,7 +172,6 @@
|
||||
console.debug(e.moved);
|
||||
move(e.moved.oldIndex, e.moved.newIndex);
|
||||
data.chapters = lmove(data.chapters, e.moved.oldIndex, e.moved.newIndex);
|
||||
renumber(update);
|
||||
// w.tinymce.remove();
|
||||
// log.debug(toRaw(acData.chapters.map((a) => toRaw(a))));
|
||||
}
|
||||
@ -203,11 +191,3 @@
|
||||
<a-button html-type="submit" v-if="canDraft" @click="() => (otherBtnInvoked = true)"> Save for Later </a-button>
|
||||
</form>
|
||||
</template>
|
||||
<style>
|
||||
.ant-collapse-item > .ant-collapse-header {
|
||||
align-items: center !important;
|
||||
}
|
||||
.ant-collapse-header.ant-collapse-icon-collapsible-only {
|
||||
align-items: center !important;
|
||||
}
|
||||
</style>
|
||||
|
@ -39,7 +39,7 @@
|
||||
console.log(fileField.value);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('not yet');
|
||||
console.error('not yet');
|
||||
}
|
||||
}
|
||||
"
|
||||
|
@ -50,8 +50,7 @@
|
||||
<i> Nothing here but crickets. </i>
|
||||
</template>
|
||||
<a-layout class="ylayout">
|
||||
<a-layout>
|
||||
<a-layout-header class="alayhead" :style="{ backgroundColor: darkBool ? '#141414' : '#f5f5f5' }">
|
||||
<a-layout-header class="alayhead">
|
||||
<div style="display: flex; align-items: center; flex-wrap: wrap">
|
||||
<div class="siteTitle">Rockfic</div>
|
||||
<div class="stat-block">
|
||||
@ -62,21 +61,13 @@
|
||||
</div>
|
||||
<navbar v-if="!!bp['md']" :inline="false" />
|
||||
</div>
|
||||
<a-button class="mobileTrigger" type="primary" @click="() => (nav = !nav)" v-if="!bp['md']">
|
||||
<a-button class="mobileTrigger" type="primary" @click="() => (collapsed = !collapsed)" v-if="!bp['md']">
|
||||
<menu-unfold-outlined v-if="nav" />
|
||||
<menu-fold-outlined v-else />
|
||||
</a-button>
|
||||
</a-layout-header>
|
||||
<a-layout class="mlayout" has-sider style="padding-top: 1em">
|
||||
<a-layout-sider
|
||||
:trigger="null"
|
||||
:theme="darkBool ? 'dark' : 'light'"
|
||||
:collapsed="nav"
|
||||
:collapsed-width="0"
|
||||
:collapsible="true"
|
||||
v-model:collapsed="collapsed"
|
||||
v-if="!bp['md']"
|
||||
>
|
||||
<a-layout-sider :trigger="null" :collapsed="true" :collapsed-width="0" :collapsible="true" v-model:collapsed="collapsed" v-if="!bp['md']">
|
||||
<navbar inline />
|
||||
</a-layout-sider>
|
||||
<a-layout-content style="flex-grow: 1">
|
||||
@ -101,8 +92,9 @@
|
||||
:collapsed-width="0"
|
||||
:style="{
|
||||
color: col,
|
||||
right: '-3px',
|
||||
alignSelf: 'stretch',
|
||||
height: '100%',
|
||||
position: 'fixed',
|
||||
right: '0px',
|
||||
borderLeft: `2px solid ${darko ? '#fff' : '#ccc'}`,
|
||||
}"
|
||||
>
|
||||
@ -120,7 +112,6 @@
|
||||
<cfooter />
|
||||
</a-layout-footer>
|
||||
</a-layout>
|
||||
</a-layout>
|
||||
<!-- <div class="mlayout">
|
||||
<a-skeleton/>
|
||||
<a-skeleton/>
|
||||
@ -146,7 +137,7 @@
|
||||
|
||||
.sideWrap {
|
||||
height: 100vh;
|
||||
right: -3rem;
|
||||
right: -1rem;
|
||||
width: inherit;
|
||||
/* display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -4,14 +4,14 @@ import { useRoute, useRouter } from "#app";
|
||||
|
||||
const base = `/user/me`;
|
||||
|
||||
export const favourites = async (values: (any & { _id: number })[], id: number, remove: boolean, type: "story" | "author") => {
|
||||
export const favourites = (values: (any & { _id: number })[], id: number, remove: boolean, type: "story" | "author") => {
|
||||
values?.splice(
|
||||
values!.findIndex((a) => a._id == id),
|
||||
1,
|
||||
);
|
||||
const key = type === "story" ? "stories" : "authors";
|
||||
const todo = [id];
|
||||
await useApiFetch(`${base}/favs`, {
|
||||
useApiFetch(`${base}/favs`, {
|
||||
method: "put",
|
||||
body: {
|
||||
[key]: {
|
||||
@ -22,7 +22,7 @@ export const favourites = async (values: (any & { _id: number })[], id: number,
|
||||
});
|
||||
};
|
||||
|
||||
export const subscriptions = async (
|
||||
export const subscriptions = (
|
||||
values: ((any & { _id: number }) | number)[],
|
||||
id: number,
|
||||
action: "hide" | "subscribe" | "unsubscribe",
|
||||
@ -36,7 +36,7 @@ export const subscriptions = async (
|
||||
values!.findIndex((a) => a._id == id || a == id),
|
||||
1,
|
||||
);
|
||||
await useApiFetch(`${base}/${action}`, {
|
||||
useApiFetch(`${base}/${action}`, {
|
||||
body: {
|
||||
push: {
|
||||
[type]: [id],
|
||||
@ -46,7 +46,7 @@ export const subscriptions = async (
|
||||
method: "put",
|
||||
});
|
||||
} else if (action == "subscribe") {
|
||||
await useApiFetch(`${base}/subscriptions`, {
|
||||
useApiFetch(`${base}/subscriptions`, {
|
||||
body: {
|
||||
push: {
|
||||
[type]: [id],
|
||||
@ -56,7 +56,7 @@ export const subscriptions = async (
|
||||
method: "put",
|
||||
});
|
||||
} else if (action == "unsubscribe") {
|
||||
await useApiFetch(`${base}/subscriptions`, {
|
||||
useApiFetch(`${base}/subscriptions`, {
|
||||
body: {
|
||||
pull: {
|
||||
[type]: [id],
|
||||
|
@ -142,4 +142,3 @@ export const rc: RuntimeConfig & any = {
|
||||
},
|
||||
app: {},
|
||||
};
|
||||
export const doNotSelect = ["password", "auth", "ipLog"].map((b) => `-${b}`).join(" ");
|
||||
|
@ -4,7 +4,7 @@ export interface IChapter {
|
||||
title: string;
|
||||
summary: string;
|
||||
id?: number;
|
||||
index: number;
|
||||
// index: number;
|
||||
words?: number;
|
||||
notes: string;
|
||||
genre: string[];
|
||||
@ -25,9 +25,6 @@ export const Chapter = new Schema<IChapter>({
|
||||
id: {
|
||||
type: Number,
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
},
|
||||
summary: {
|
||||
type: String,
|
||||
},
|
||||
|
29
package.json
29
package.json
@ -4,9 +4,8 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev --host 127.0.0.1",
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"postinstall": "nuxt prepare",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
@ -14,27 +13,17 @@
|
||||
"@nuxt/devtools": "latest",
|
||||
"@nuxtjs/i18n": "^8.0.0-rc.9",
|
||||
"@types/uuid": "^9.0.4",
|
||||
"@vitejs/plugin-vue": "^5.0.2",
|
||||
"@vitest/browser": "^1.1.2",
|
||||
"@vitest/ui": "^1.1.3",
|
||||
"@vue/language-server": "latest",
|
||||
"@vue/test-utils": "^2.4.3",
|
||||
"happy-dom": "^12.10.3",
|
||||
"jsdom": "^23.0.1",
|
||||
"nuxt": "^3.12.3",
|
||||
"playwright": "^1.40.1",
|
||||
"playwright-core": "^1.40.1",
|
||||
"@vue/language-server": "^1.8.27",
|
||||
"nuxt": "^3.9.0",
|
||||
"prettier": "^3.0.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "latest",
|
||||
"unplugin-vue-components": "^0.26.0",
|
||||
"vitest": "^1.4.0"
|
||||
"tsconfig-to-dual-package": "^1.2.0",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design-vue/nuxt": "^1.4.1",
|
||||
"@pinia/nuxt": "^0.4.11",
|
||||
"@sidebase/nuxt-auth": "0.7.0",
|
||||
"@tinymce/tinymce-vue": "latest",
|
||||
"@sidebase/nuxt-auth": "0.7.0",
|
||||
"@types/jsonwebtoken": "^9.0.3",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/turndown": "^5.0.4",
|
||||
@ -44,7 +33,7 @@
|
||||
"axios": "^1.5.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"blueimp-md5": "^2.19.0",
|
||||
"date-fns": "latest",
|
||||
"date-fns": "^2.30.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lodash-move": "^1.1.1",
|
||||
@ -55,13 +44,13 @@
|
||||
"mongoose-sequence": "https://github.com/amansingh63/mongoose-sequence",
|
||||
"nitropack": "^2.9.4",
|
||||
"nuxi": "^3.10.0",
|
||||
"nuxt-booster": "^3.0.0",
|
||||
"nuxt-security": "^0.14.4",
|
||||
"nuxt-speedkit": "3.0.0-next.26",
|
||||
"pinia": "^2.1.6",
|
||||
"sanitize-html": "^2.11.0",
|
||||
"sharp": "^0.33.3",
|
||||
"sharp": "^0.33.2",
|
||||
"string-strip-html": "^13.4.3",
|
||||
"tinymce": "^6.7.0",
|
||||
"turndown": "^7.1.2",
|
||||
"uuid": "^9.0.1",
|
||||
"vee-validate": "^4.11.7",
|
||||
|
@ -12,24 +12,22 @@
|
||||
},
|
||||
middleware: ["auth"],
|
||||
});
|
||||
useHead({
|
||||
title: "Log In",
|
||||
});
|
||||
|
||||
const formState = reactive<FormState>({
|
||||
username: "",
|
||||
password: "",
|
||||
});
|
||||
const darkRef = inject<Ref<boolean>>("dark");
|
||||
const onFinish = async (values: any) => {
|
||||
const { signIn } = useAuth();
|
||||
|
||||
const onFinish = async (values: any) => {
|
||||
const { signIn, data } = useAuth();
|
||||
|
||||
let reso: any;
|
||||
try {
|
||||
await signIn(values, { redirect: true, callbackUrl: "/" });
|
||||
const { data } = useAuth();
|
||||
darkRef.value = data.value.user.profile.nightMode;
|
||||
if (darkRef.value) document.body.dataset.theme = "dark";
|
||||
await navigateTo("/");
|
||||
reso = await signIn(values);
|
||||
|
||||
await navigateTo({
|
||||
path: "/",
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e.data) {
|
||||
notification["error"]({
|
||||
|
@ -6,9 +6,6 @@
|
||||
signOut({
|
||||
callbackUrl: "/",
|
||||
});
|
||||
const d = inject<Ref<boolean>>("dark");
|
||||
d.value = false;
|
||||
document.body.dataset.theme = undefined;
|
||||
</script>
|
||||
<template>
|
||||
<a-typography-title :level="3"> Signed out. 👋 </a-typography-title>
|
||||
|
@ -6,18 +6,12 @@
|
||||
|
||||
const { data: bands } = (await useApiFetch<NonNullable<IBand[]>>("/band/all")) as unknown as { data: Ref<IBand[]> };
|
||||
|
||||
const {
|
||||
data: { value: rd },
|
||||
getSession,
|
||||
} = useAuth();
|
||||
await getSession({ force: true });
|
||||
let inc = ref<number>(1);
|
||||
const data = ref(rd);
|
||||
const { data: rd }: { data: any } = useAuth();
|
||||
const refresh = async () => {
|
||||
await useAuth().getSession({ force: true });
|
||||
data.value = useAuth().data.value;
|
||||
//inc.value += 1;
|
||||
rd.value = useAuth().data.value;
|
||||
};
|
||||
|
||||
const hider = subscriptions;
|
||||
if (bands.value == null) bands.value = [];
|
||||
useHead({
|
||||
@ -27,7 +21,7 @@
|
||||
<template>
|
||||
<a-list v-model:data-source="bands" :grid="bp">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item :key="item._id + inc">
|
||||
<a-list-item>
|
||||
<a-row :gutter="[5, 5]">
|
||||
<a-col>
|
||||
<nuxt-link :to="`/band/${item._id}`">
|
||||
@ -35,12 +29,12 @@
|
||||
</nuxt-link>
|
||||
</a-col>
|
||||
<!-- subscribe... -->
|
||||
<a-col v-if="data && data.user?._id" style="margin-left: auto">
|
||||
<a-col v-if="rd && rd.user?._id" style="margin-left: auto">
|
||||
<a
|
||||
v-if="!data?.user.subscriptions.bands.includes(item._id)"
|
||||
v-if="!rd?.user.subscriptions.bands.includes(item._id)"
|
||||
@click="
|
||||
async (e) => {
|
||||
await hider(bands, item._id, 'subscribe', 'bands');
|
||||
hider(bands, item._id, 'subscribe', 'bands');
|
||||
await refresh();
|
||||
}
|
||||
"
|
||||
@ -51,7 +45,7 @@
|
||||
v-else
|
||||
@click="
|
||||
async (e) => {
|
||||
await hider(bands, item._id, 'unsubscribe', 'bands');
|
||||
hider(bands, item._id, 'unsubscribe', 'bands');
|
||||
await refresh();
|
||||
}
|
||||
"
|
||||
@ -59,11 +53,11 @@
|
||||
<icon :istyle="'regular'" name="x" :size="12" />
|
||||
</a>
|
||||
</a-col>
|
||||
<a-col v-if="data?.user._id">
|
||||
<a-col v-if="rd?.user._id">
|
||||
<a
|
||||
@click="
|
||||
async (e) => {
|
||||
await hider(bands, item._id, 'hide', 'bands');
|
||||
hider(bands, item._id, 'hide', 'bands');
|
||||
await refresh();
|
||||
}
|
||||
"
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<a-typography-title :level="1" style="margin-top: 0"> The Latest Fics </a-typography-title>
|
||||
<a-typography-title :level="1"> The Latest Fics </a-typography-title>
|
||||
<story-list :last="true" prefix="/latest" />
|
||||
</div>
|
||||
</template>
|
||||
|
@ -2,12 +2,11 @@ import mongoose from "mongoose";
|
||||
import jwt from "jsonwebtoken";
|
||||
import { User } from "@models/user";
|
||||
import { log } from "@server/logger";
|
||||
import { doNotSelect } from "@server/constants";
|
||||
|
||||
export default eventHandler(async (event) => {
|
||||
const wrongMsg = "wrong credentials";
|
||||
let reqbody = await readBody(event);
|
||||
let user = await User.findOne({ username: reqbody.username }).select(doNotSelect).exec();
|
||||
let user = await User.findOne({ username: reqbody.username }).exec();
|
||||
// log.debug(reqbody, { label: "login/body" });
|
||||
// log.debug("USER -> " + user, { label: "login" });
|
||||
// log.debug("conn ->" + mongoose.connection, { label: "login" });
|
||||
@ -31,9 +30,8 @@ export default eventHandler(async (event) => {
|
||||
}
|
||||
let tok = user.generateRefreshToken(useRuntimeConfig().jwt);
|
||||
// setCookie(event, "rockfic_cookie", tok);
|
||||
const fu = user.toObject();
|
||||
return {
|
||||
user: fu,
|
||||
user,
|
||||
token: {
|
||||
refresh: tok,
|
||||
access: user.generateAccessToken(useRuntimeConfig().jwt),
|
||||
|
@ -11,12 +11,6 @@ import { messages } from "@server/constants";
|
||||
export default eventHandler(async (ev) => {
|
||||
let os: (Document<unknown, {}, IStory> & IStory) | null = await storyQuerier(ev);
|
||||
isLoggedIn(ev);
|
||||
if (!os) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
message: messages[404],
|
||||
});
|
||||
}
|
||||
if (!canModify(ev, os)) {
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
@ -29,31 +23,39 @@ export default eventHandler(async (ev) => {
|
||||
completed: body.completed,
|
||||
coAuthor: !!body.coAuthor ? body.coAuthor : null,
|
||||
};
|
||||
|
||||
for (const oc of os.chapters) {
|
||||
let filename = `/stories/${oc.id}.txt`;
|
||||
const bucket = getBucket();
|
||||
const curs = bucket.find({ filename }).limit(1);
|
||||
for await (const d of curs) {
|
||||
await bucket.delete(d._id);
|
||||
}
|
||||
}
|
||||
const cc = os.chapters;
|
||||
os.chapters = [];
|
||||
await os.save();
|
||||
for (const c of body.chapters) {
|
||||
let idx = os.chapters.findIndex((k) => k.id === c.id);
|
||||
let idx = cc.findIndex((k) => k.id === c.id);
|
||||
const cont = await bodyHandler(c);
|
||||
if (idx === -1) {
|
||||
os.chapters!.push({
|
||||
...modelFormChapter(c),
|
||||
words: countWords(cont),
|
||||
posted: new Date(Date.now()),
|
||||
});
|
||||
} else {
|
||||
os.chapters[idx] = {
|
||||
os.chapters!.push({
|
||||
...modelFormChapter(c),
|
||||
id: os.chapters[idx].id,
|
||||
// id: os.chapters[idx].id,
|
||||
words: countWords(cont),
|
||||
posted: os.chapters[idx].posted,
|
||||
};
|
||||
posted: cc[idx].posted,
|
||||
});
|
||||
}
|
||||
}
|
||||
os.chapters.sort((a, b) => a.index - b.index);
|
||||
await os.save();
|
||||
for (let i = 0; i < os.chapters.length; i++) {
|
||||
const c = os.chapters[i];
|
||||
const cont = await bodyHandler(body.chapters[i]);
|
||||
await replaceOrUploadContent(c.id ?? c._id, cont, getBucket());
|
||||
await replaceOrUploadContent(c.id ?? c._id, cont);
|
||||
}
|
||||
os = await Story.findOneAndUpdate(
|
||||
{
|
||||
|
@ -4,8 +4,6 @@
|
||||
"allowJs": true,
|
||||
"outDir": "../out",
|
||||
"noImplicitAny": false,
|
||||
"verbatimModuleSyntax": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true
|
||||
"verbatimModuleSyntax": false
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
{
|
||||
"extends": "./.nuxt/tsconfig.json",
|
||||
// https://nuxt.com/docs/guide/concepts/typescript
|
||||
"extends": "./.nuxt/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": false,
|
||||
"verbatimModuleSyntax": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"verbatimModuleSyntax": false
|
||||
// "paths": {
|
||||
// "@dbconfig": ["./lib/dbconfig.ts"],
|
||||
// "@functions": ["./lib/functions.ts"]
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user