🎉 Initial Commit

This commit is contained in:
LittleSheep 2023-12-10 21:58:23 +08:00
parent 7dba4810ef
commit 16aed743d9
24 changed files with 265 additions and 5502 deletions

4
application/.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"printWidth": 120,
"tabWidth": 2
}

12
application/app.vue Normal file
View File

@ -0,0 +1,12 @@
<template>
<n-message-provider>
<nuxt-layout>
<nuxt-page />
</nuxt-layout>
</n-message-provider>
</template>
<script setup lang="ts">
import { NMessageProvider } from "naive-ui";
import "@/assets/css/index.css";
</script>

View File

@ -0,0 +1,15 @@
@import "@ibm/plex/css/ibm-plex.css";
.font-mono {
font-family: "IBM Plex Mono", monospace;
}
.font-sans {
font-family: "IBM Plex Sans", sans-serif;
}
body {
font-family: "IBM Plex Sans", sans-serif;
margin: 0;
padding: 0;
}

BIN
application/bun.lockb Executable file

Binary file not shown.

View File

@ -0,0 +1,3 @@
<template>
<div>Fuxi</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div>
<nuxt-link to="/about">About</nuxt-link>
</div>
</template>

View File

@ -0,0 +1,30 @@
<template>
<div>
<n-card segmented content-style="padding: 0">
<template #header>
<div>Problems</div>
<div class="text-xs font-normal">每天进步一点点</div>
</template>
<n-list clickable hoverable>
<n-list-item v-for="item in (problems as any[])" class="px-[24px]">
<n-thing :title="item?.title">
<template #description>
<div class="text-xs flex gap-2">
<n-tag size="tiny" class="case-capital">{{ item?.type }}</n-tag>
<div>Published at {{ new Date(item?.created_at).toLocaleString() }}</div>
</div>
</template>
</n-thing>
</n-list-item>
</n-list>
</n-card>
</div>
</template>
<script setup lang="ts">
import { NCard, NList, NListItem, NThing, NTag } from "naive-ui";
const client = useSupabaseClient();
const { data: problems } = await client.from("problems").select(`*`).limit(20);
</script>

View File

@ -0,0 +1,23 @@
<template>
<n-layout>
<n-layout-header class="py-[18.5px] px-[36px]" bordered>
<nuxt-link class="brand-header" to="/">
<brand-header />
</nuxt-link>
</n-layout-header>
<n-layout-content class="h-[calc(100vh-70px)]" content-style="padding: 24px">
<slot />
</n-layout-content>
</n-layout>
</template>
<script setup lang="ts">
import { NLayout, NLayoutHeader, NLayoutContent } from "naive-ui";
</script>
<style scoped>
.brand-header {
all: unset;
cursor: pointer;
}
</style>

View File

@ -0,0 +1,24 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ["@unocss/nuxt", '@pinia/nuxt', '@nuxtjs/supabase'],
build: {
transpile:
process.env.NODE_ENV === 'production'
? [
'naive-ui',
'vueuc',
'@css-render/vue3-ssr',
'@juggle/resize-observer'
]
: ['@juggle/resize-observer']
},
vite: {
optimizeDeps: {
include:
process.env.NODE_ENV === 'development'
? ['naive-ui', 'vueuc', 'date-fns-tz/formatInTimeZone']
: []
}
}
})

View File

@ -11,8 +11,18 @@
}, },
"devDependencies": { "devDependencies": {
"@nuxt/devtools": "latest", "@nuxt/devtools": "latest",
"@nuxtjs/supabase": "latest",
"@pinia/nuxt": "latest",
"@unocss/nuxt": "^0.58.0",
"@vicons/carbon": "^0.12.0",
"naive-ui": "^2.35.0",
"nuxt": "^3.8.2", "nuxt": "^3.8.2",
"unocss": "^0.58.0",
"vue": "^3.3.10", "vue": "^3.3.10",
"vue-router": "^4.2.5" "vue-router": "^4.2.5"
},
"dependencies": {
"@ibm/plex": "^6.3.0",
"@supabase/supabase-js": "^2.39.0"
} }
} }

View File

@ -0,0 +1,5 @@
<template>
<div class="md:max-w-[720px] mx-auto">
<problems-list />
</div>
</template>

View File

@ -0,0 +1,60 @@
<template>
<div class="h-full w-full flex flex-col gap-5 justify-center items-center">
<brand-header />
<n-card segmented class="w-[380px]">
<template #header>
<div class="text-center">Sign in</div>
<div class="text-center text-xs font-normal">With your email</div>
</template>
<n-form @submit.prevent="submit">
<n-form-item label="Email">
<n-input v-model:value="payload.email" placeholder="Your email" />
</n-form-item>
<n-form-item label="Password">
<n-input v-model:value="payload.password" type="password" placeholder="Your password" />
</n-form-item>
<n-button :loading="loading" attr-type="submit" class="w-full" type="primary">Login</n-button>
</n-form>
</n-card>
<div class="flex w-[360px] justify-between">
<nuxt-link>Haven't an account?</nuxt-link>
<helpful-links />
</div>
</div>
</template>
<script setup lang="ts">
import { NCard, NForm, NFormItem, NInput, NButton } from "naive-ui";
import { useMessage } from "naive-ui";
import { ref } from "vue";
const client = useSupabaseClient();
const message = useMessage();
const loading = ref(false);
const payload = ref({
email: "",
password: "",
});
async function submit() {
if (!payload.value.email || !payload.value.password) return;
try {
loading.value = true;
const { error } = await client.auth.signInWithPassword({
email: payload.value.email,
password: payload.value.password,
});
if (error) throw error;
message.success("Welcome back!");
navigateTo("/");
} catch (err: any) {
message.error(err.error_description || err.message);
} finally {
loading.value = false;
}
}
</script>

View File

@ -0,0 +1,31 @@
import { setup } from '@css-render/vue3-ssr'
import { defineNuxtPlugin } from '#app'
export default defineNuxtPlugin((nuxtApp) => {
if (process.server) {
const { collect } = setup(nuxtApp.vueApp)
const originalRenderMeta = nuxtApp.ssrContext?.renderMeta
nuxtApp.ssrContext = nuxtApp.ssrContext || {}
nuxtApp.ssrContext.renderMeta = () => {
if (!originalRenderMeta) {
return {
headTags: collect()
}
}
const originalMeta = originalRenderMeta()
if ('then' in originalMeta) {
return originalMeta.then((resolvedOriginalMeta) => {
return {
...resolvedOriginalMeta,
headTags: resolvedOriginalMeta['headTags'] + collect()
}
})
} else {
return {
...originalMeta,
headTags: originalMeta['headTags'] + collect()
}
}
}
}
})

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,5 @@
import { defineConfig, presetUno } from "unocss";
export default defineConfig({
presets: [presetUno({ preflight: false })],
});

View File

@ -1,75 +0,0 @@
# Nuxt 3 Minimal Starter
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install the dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm run dev
# yarn
yarn dev
# bun
bun run dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm run build
# yarn
yarn build
# bun
bun run build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm run preview
# yarn
yarn preview
# bun
bun run preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

View File

@ -1,5 +0,0 @@
<template>
<div>
<NuxtWelcome />
</div>
</template>

View File

@ -1,4 +0,0 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true }
})

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
create table public.profiles (
id uuid not null references auth.users on delete cascade,
username varchar(64),
nickname varchar(256),
school_id int8,
primary key (id)
);
alter table public.profiles enable row level security;
create policy "Public profiles are viewable by everyone." on profiles
for select using (true);
create policy "Users can insert their own profile." on profiles
for insert with check (auth.uid() = id);
create policy "Users can update own profile." on profiles
for update using (auth.uid() = id);

View File

@ -0,0 +1,19 @@
create table
public.problems (
id bigint generated by default as identity,
title text not null,
description text not null,
type character varying not null,
tags character varying[] null,
author uuid null,
is_draft boolean null default true,
is_hidden boolean null default false,
created_at timestamp with time zone null default now(),
constraint problems_pkey primary key (id),
constraint problems_author_fkey foreign key (author) references auth.users (id)
) tablespace pg_default;
alter table public.problems enable row level security;
create policy "Public problems are viewable by everyone." on problems
for select using (true);