xiongzhu 2 лет назад
Родитель
Сommit
6bfcd30a78
4 измененных файлов с 60 добавлено и 1 удалено
  1. 3 1
      src/app.module.ts
  2. 12 0
      src/download/download.controller.ts
  3. 7 0
      src/download/download.module.ts
  4. 38 0
      views/download.hbs

+ 3 - 1
src/app.module.ts

@@ -13,6 +13,7 @@ import { FileModule } from './file/file.module'
 import { UserBalanceModule } from './user-balance/user-balance.module'
 import { SysConfigModule } from './sys-config/sys-config.module'
 import { AllExceptionsFilter } from './filters/all-exceptions-filter.filter'
+import { DownloadModule } from './download/download.module';
 @Module({
     imports: [
         DevtoolsModule.register({
@@ -63,7 +64,8 @@ import { AllExceptionsFilter } from './filters/all-exceptions-filter.filter'
         AuthModule,
         FileModule,
         UserBalanceModule,
-        SysConfigModule
+        SysConfigModule,
+        DownloadModule
     ],
     controllers: [],
     providers: [

+ 12 - 0
src/download/download.controller.ts

@@ -0,0 +1,12 @@
+import { Controller, Get, Query, Render } from '@nestjs/common'
+import { Public } from 'src/auth/public.decorator'
+
+@Controller('download')
+export class DownloadController {
+    @Public()
+    @Get()
+    @Render('download')
+    async download(@Query() {}) {
+        return {}
+    }
+}

+ 7 - 0
src/download/download.module.ts

@@ -0,0 +1,7 @@
+import { Module } from '@nestjs/common';
+import { DownloadController } from './download.controller';
+
+@Module({
+  controllers: [DownloadController]
+})
+export class DownloadModule {}

+ 38 - 0
views/download.hbs

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en" class="h-full">
+    <head>
+        <meta charset="UTF-8" />
+        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
+        <title>Download NBook</title>
+        <script src="https://cdn.tailwindcss.com"></script>
+        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
+    </head>
+    <body class="h-full flex flex-col items-center justify-center">
+        <div class="text-3xl text-fuchsia-500">NBook</div>
+        <a
+            id="download"
+            target="_blank"
+            class="mt-4 mx-auto w-10/12 h-10 flex items-center justify-center text-fuchsia-500 border border-fuchsia-500 rounded bg-fuchsia-500/10 active:bg-fuchsia-500/20 transition-colors"
+        >
+            <svg
+                class="w-7 text-fuchsia-500 mr-2"
+                xmlns="http://www.w3.org/2000/svg"
+                xmlns:xlink="http://www.w3.org/1999/xlink"
+                viewBox="0 0 24 24"
+            >
+                <path
+                    d="M17.6 9.48l1.84-3.18c.16-.31.04-.69-.26-.85a.637.637 0 0 0-.83.22l-1.88 3.24a11.463 11.463 0 0 0-8.94 0L5.65 5.67a.643.643 0 0 0-.87-.2c-.28.18-.37.54-.22.83L6.4 9.48A10.78 10.78 0 0 0 1 18h22a10.78 10.78 0 0 0-5.4-8.52zM7 15.25a1.25 1.25 0 1 1 0-2.5a1.25 1.25 0 0 1 0 2.5zm10 0a1.25 1.25 0 1 1 0-2.5a1.25 1.25 0 0 1 0 2.5z"
+                    fill="currentColor"
+                ></path>
+            </svg>
+            Download
+        </a>
+    </body>
+    <script>
+        $.get("/api/sys-config/app", function (data) {
+            console.log(data);
+            $("#download").attr("href", data.value.appInfo.url);
+        });
+    </script>
+</html>