From e3b0b4af72a92eca2b3c3f9f6211b6f5ea59ca4b Mon Sep 17 00:00:00 2001
From: ZL Asica <40444637+ZL-Asica@users.noreply.github.com>
Date: Thu, 28 Nov 2024 20:25:28 -0600
Subject: [PATCH 1/3] chore: restructure, add @nuxt/ui and remove unused
dependencies
---
.npmrc | 3 +-
.vscode/settings.json | 10 +-
assets/css/{main.css => tailwind.css} | 0
components/{ui => layout}/BackToTop.vue | 0
components/{ui => layout}/ProgressBar.vue | 0
components/pages/EventList.vue | 8 +-
components/pages/SocialLinks.vue | 4 +-
components/ui/{Card.vue => CustomCard.vue} | 0
layouts/default.vue | 4 +-
nuxt.config.ts | 7 +-
package.json | 7 +-
pages/index.vue | 4 +-
pnpm-lock.yaml | 266 ++++++++++++++++++++-
tailwind.config.ts | 4 +-
14 files changed, 286 insertions(+), 31 deletions(-)
rename assets/css/{main.css => tailwind.css} (100%)
rename components/{ui => layout}/BackToTop.vue (100%)
rename components/{ui => layout}/ProgressBar.vue (100%)
rename components/ui/{Card.vue => CustomCard.vue} (100%)
diff --git a/.npmrc b/.npmrc
index c483022..cf04042 100644
--- a/.npmrc
+++ b/.npmrc
@@ -1 +1,2 @@
-shamefully-hoist=true
\ No newline at end of file
+shamefully-hoist=true
+strict-peer-dependencies=false
diff --git a/.vscode/settings.json b/.vscode/settings.json
index affd4e0..d1824fc 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -20,5 +20,13 @@
},
"editor.wordWrap": "on",
"prettier.requireConfig": true,
- "eslint.useFlatConfig": true
+ "eslint.useFlatConfig": true,
+ "files.associations": {
+ "*.css": "tailwindcss"
+ },
+ "editor.quickSuggestions": {
+ "strings": true
+ },
+ "tailwindCSS.experimental.configFile": "tailwind.config.ts",
+ "tailwindCSS.classAttributes": ["class", "className", "ngClass", "ui"]
}
diff --git a/assets/css/main.css b/assets/css/tailwind.css
similarity index 100%
rename from assets/css/main.css
rename to assets/css/tailwind.css
diff --git a/components/ui/BackToTop.vue b/components/layout/BackToTop.vue
similarity index 100%
rename from components/ui/BackToTop.vue
rename to components/layout/BackToTop.vue
diff --git a/components/ui/ProgressBar.vue b/components/layout/ProgressBar.vue
similarity index 100%
rename from components/ui/ProgressBar.vue
rename to components/layout/ProgressBar.vue
diff --git a/components/pages/EventList.vue b/components/pages/EventList.vue
index 28eb9a2..e751a8a 100644
--- a/components/pages/EventList.vue
+++ b/components/pages/EventList.vue
@@ -4,7 +4,7 @@
v-if="loading"
class="grid flex-shrink flex-grow auto-rows-min grid-cols-1 justify-items-center gap-6 md:grid-cols-2 lg:grid-cols-3"
>
-
-
+
-
-
+
diff --git a/components/pages/SocialLinks.vue b/components/pages/SocialLinks.vue
index 963c063..f548551 100644
--- a/components/pages/SocialLinks.vue
+++ b/components/pages/SocialLinks.vue
@@ -1,5 +1,5 @@
-
+
{{ $t('contact') }}
@@ -22,7 +22,7 @@
-
+
diff --git a/i18n/locales/en.json b/i18n/locales/en.json
index 69767b1..5eddf45 100644
--- a/i18n/locales/en.json
+++ b/i18n/locales/en.json
@@ -1,6 +1,7 @@
{
"nuxtSiteConfig": {
"name": "Trans in Academia! (TiA!)",
+ "titleTemplate": "%s - Site Title",
"description": "Trans in Academia! (TiA!) is an organization established by Chinese trans people in 2022. TiA! aims to document theoretical and practical knowledge from the Sinophone trans community, help trans people pursue studies, professional development, and employment, share academic knowledge related to trans issues, and produce original content from the perspective of trans people.",
"keywords": "transgender, LGBTQ+, academia, trans issues, support"
},
diff --git a/middleware/auth.global.ts b/middleware/auth.global.ts
new file mode 100644
index 0000000..2c5bcb7
--- /dev/null
+++ b/middleware/auth.global.ts
@@ -0,0 +1,36 @@
+export default defineNuxtRouteMiddleware(async (to) => {
+ if (to.path.startsWith('/dash') && to.path !== '/dash/login') {
+ const isValidToken = await validateToken();
+ if (!isValidToken) {
+ window.localStorage.removeItem('tiaAuthToken');
+ return navigateTo('/dash/login');
+ }
+ } else if (to.path === '/dash/login') {
+ const isValidToken = await validateToken();
+ if (isValidToken) {
+ return navigateTo('/dash');
+ } else {
+ window.localStorage.removeItem('tiaAuthToken');
+ }
+ }
+});
+
+const validateToken = async () => {
+ const token = window.localStorage.getItem('tiaAuthToken');
+ if (!token) {
+ return false;
+ }
+
+ try {
+ const response = await fetch('/api/auth', {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ return response.ok;
+ } catch (error) {
+ console.error('Token validation failed:', error);
+ return false;
+ }
+};
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 1f35da0..8c4d01d 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -39,6 +39,14 @@ export default defineNuxtConfig({
'@nuxthub/core',
'@nuxt/ui',
],
+ routeRules: {
+ '/': {
+ prerender: true,
+ },
+ '/dash/**': {
+ ssr: false,
+ },
+ },
ui: {
global: true,
},
@@ -81,4 +89,7 @@ export default defineNuxtConfig({
...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {}),
},
},
+ runtimeConfig: {
+ tiaAuthToken: 'token',
+ },
});
diff --git a/package.json b/package.json
index 844ed4b..9b6a5df 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,8 @@
"@nuxtjs/seo": "^2.0.2",
"nuxt": "^3.14.1592",
"vue": "latest",
- "vue-router": "latest"
+ "vue-router": "latest",
+ "vue-sonner": "^1.3.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20241127.0",
diff --git a/pages/dash/index.vue b/pages/dash/index.vue
new file mode 100644
index 0000000..8c5f3c0
--- /dev/null
+++ b/pages/dash/index.vue
@@ -0,0 +1,44 @@
+
+
+ 活动列表
+ 开发中...
+
+
+
+
+
diff --git a/pages/dash/login.vue b/pages/dash/login.vue
new file mode 100644
index 0000000..5f58956
--- /dev/null
+++ b/pages/dash/login.vue
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 372b73b..7005a83 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -32,6 +32,9 @@ importers:
vue-router:
specifier: latest
version: 4.5.0(vue@3.5.13(typescript@5.6.3))
+ vue-sonner:
+ specifier: ^1.3.0
+ version: 1.3.0
devDependencies:
'@cloudflare/workers-types':
specifier: ^4.20241127.0
@@ -5318,6 +5321,9 @@ packages:
peerDependencies:
vue: ^3.2.0
+ vue-sonner@1.3.0:
+ resolution: {integrity: sha512-jAodBy4Mri8rQjVZGQAPs4ZYymc1ywPiwfa81qU0fFl+Suk7U8NaOxIDdI1oBGLeQJqRZi/oxNIuhCLqsBmOwg==}
+
vue-tsc@2.1.10:
resolution: {integrity: sha512-RBNSfaaRHcN5uqVqJSZh++Gy/YUzryuv9u1aFWhsammDJXNtUiJMNoJ747lZcQ68wUQFx6E73y4FY3D8E7FGMA==}
hasBin: true
@@ -11632,6 +11638,8 @@ snapshots:
'@vue/devtools-api': 6.6.4
vue: 3.5.13(typescript@5.6.3)
+ vue-sonner@1.3.0: {}
+
vue-tsc@2.1.10(typescript@5.6.3):
dependencies:
'@volar/typescript': 2.4.10
diff --git a/server/api/auth.ts b/server/api/auth.ts
new file mode 100644
index 0000000..a3199a2
--- /dev/null
+++ b/server/api/auth.ts
@@ -0,0 +1,5 @@
+export default defineEventHandler(async () => {
+ return {
+ message: 'Hello, world!',
+ };
+});
diff --git a/server/middleware/auth.ts b/server/middleware/auth.ts
new file mode 100644
index 0000000..22d7801
--- /dev/null
+++ b/server/middleware/auth.ts
@@ -0,0 +1,18 @@
+export default eventHandler((event) => {
+ const authToken =
+ getHeader(event, 'Authorization')?.replace('Bearer ', '') || '';
+
+ if (
+ event.path.startsWith('/api/') &&
+ !event.path.startsWith('/api/events') &&
+ !event.path.startsWith('/api/_') &&
+ authToken !== useRuntimeConfig(event).tiaAuthToken
+ ) {
+ console.info('authToken:', authToken);
+
+ throw createError({
+ status: 401,
+ statusText: 'Unauthorized',
+ });
+ }
+});
diff --git a/tailwind.config.ts b/tailwind.config.ts
index 078417b..e6bdb87 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -12,6 +12,32 @@ export default >{
theme: {
extend: {
colors: {
+ 'dodger-blue': {
+ '50': '#f0f7fe',
+ '100': '#dcecfd',
+ '200': '#c1defc',
+ '300': '#97caf9',
+ '400': '#54a4f3',
+ '500': '#428eef',
+ '600': '#2c70e4',
+ '700': '#245bd1',
+ '800': '#234aaa',
+ '900': '#224286',
+ '950': '#192952',
+ },
+ cranberry: {
+ '50': '#fdf2f6',
+ '100': '#fce7f0',
+ '200': '#fad0e2',
+ '300': '#f8a9c8',
+ '400': '#f274a4',
+ '500': '#e94880',
+ '600': '#d82a5e',
+ '700': '#bb1b46',
+ '800': '#9b193a',
+ '900': '#811a34',
+ '950': '#4f081a',
+ },
tiaBlue: {
DEFAULT: '#54A4F3',
light: '#84C4F9',
From 16735f9a2e9e985d47f5d5943e2f975a68a4a3d7 Mon Sep 17 00:00:00 2001
From: ZL Asica <40444637+ZL-Asica@users.noreply.github.com>
Date: Thu, 28 Nov 2024 22:31:02 -0600
Subject: [PATCH 3/3] chore: remove unused props.
---
i18n/locales/en.json | 1 -
1 file changed, 1 deletion(-)
diff --git a/i18n/locales/en.json b/i18n/locales/en.json
index 5eddf45..69767b1 100644
--- a/i18n/locales/en.json
+++ b/i18n/locales/en.json
@@ -1,7 +1,6 @@
{
"nuxtSiteConfig": {
"name": "Trans in Academia! (TiA!)",
- "titleTemplate": "%s - Site Title",
"description": "Trans in Academia! (TiA!) is an organization established by Chinese trans people in 2022. TiA! aims to document theoretical and practical knowledge from the Sinophone trans community, help trans people pursue studies, professional development, and employment, share academic knowledge related to trans issues, and produce original content from the perspective of trans people.",
"keywords": "transgender, LGBTQ+, academia, trans issues, support"
},