Переглянути джерело

Merge branch 'master' of http://git.fmode.cn:3000/bin/edu-textbook

ryanemax 8 місяців тому
батько
коміт
19121690e2

Різницю між файлами не показано, бо вона завелика
+ 370 - 101
package-lock.json


+ 2 - 0
package.json

@@ -24,6 +24,7 @@
     "@ionic/angular": "^8.2.2",
     "@ngx-translate/core": "^15.0.0",
     "@types/parse": "^3.0.9",
+    "ali-oss": "^6.20.0",
     "ng-zorro-antd": "^18.0.0",
     "parse": "^5.1.0",
     "rxjs": "~7.8.0",
@@ -35,6 +36,7 @@
     "@angular/cli": "^18.0.4",
     "@angular/compiler-cli": "^18.0.0",
     "@ionic/angular-toolkit": "latest",
+    "@types/ali-oss": "^6.16.11",
     "@types/jasmine": "~5.1.0",
     "jasmine-core": "~5.1.0",
     "karma": "~6.4.0",

BIN
projects/textbook/public/img/banner.png


+ 32 - 5
projects/textbook/src/app/comp-upload/comp-upload.component.ts

@@ -3,6 +3,8 @@ import { NzUploadModule } from 'ng-zorro-antd/upload';
 import { CommonCompModule } from '../../services/common.modules';
 import { NzMessageService } from 'ng-zorro-antd/message';
 import { NzUploadChangeParam, NzUploadFile } from 'ng-zorro-antd/upload';
+import { ProvierOssAli } from './provider-oss-aliyun';
+
 @Component({
   selector: 'app-comp-upload',
   standalone: true,
@@ -24,7 +26,10 @@ export class CompUploadComponent implements OnInit {
     //   url: 'http://www.baidu.com/xxx.png'
     // },
   ];
-  constructor(private msg: NzMessageService) {}
+  ossProvider:{upload:any}|undefined
+  constructor(private msg: NzMessageService) {
+    this.ossProvider = new ProvierOssAli()
+  }
 
   ngOnInit() {
     this.fileList = this.files.map((item:any)=> {
@@ -33,16 +38,38 @@ export class CompUploadComponent implements OnInit {
       }
     })
   }
-  handleChange(info: NzUploadChangeParam): void {
+  async handleChange(info: NzUploadChangeParam) {
     console.log(info);
     if (info.file.status !== 'uploading') {
+      // 选择文件后,自动开始上传
       console.log(info.file, info.fileList);
+      let ossFileList = await this.uploadAllFileList(info?.fileList)
+      this.change.emit(ossFileList?.map(item=>item?.url))
     }
     if (info.file.status === 'done') {
-      this.msg.success(`${info.file.name} file uploaded successfully`);
+      // this.msg.success(`${info.file.name} file uploaded successfully`);
     } else if (info.file.status === 'error') {
-      this.msg.error(`${info.file.name} file upload failed.`);
+      // this.msg.error(`${info.file.name} file upload failed.`);
+    }
+
+    // this.change.emit(info.fileList)
+  }
+
+  async uploadAllFileList(fileList:Array<NzUploadFile>){
+    let ossFileList = []
+    for (let index = 0; index < fileList.length; index++) {
+      let file = fileList[index];
+      if(file){
+        let ossFile 
+        try{
+          ossFile = await this.ossProvider?.upload(file?.originFileObj);
+        }catch(err){}
+        if(ossFile){
+          ossFileList.push(ossFile)
+        }
+      }
     }
-    this.change.emit(info.fileList)
+    console.log(ossFileList)
+    return ossFileList
   }
 }

+ 37 - 0
projects/textbook/src/app/comp-upload/provider-oss-aliyun.ts

@@ -0,0 +1,37 @@
+import OSS from "ali-oss";
+import Parse from "parse";
+
+
+export class ProvierOssAli{
+    client:OSS|undefined
+    async initClient(){
+        if(this.client) return
+        // 获取STS临时口令
+        let result:any = await Parse.Cloud.run("aliOssSTS");
+        this.client = new OSS({
+            // yourRegion填写Bucket所在地域。以华东1(杭州)为例,yourRegion填写为oss-cn-hangzhou。
+            region: "oss-cn-beijing",
+            // 从STS服务获取的临时访问密钥(AccessKey ID和AccessKey Secret)。
+            accessKeyId: result?.AccessKeyId,
+            accessKeySecret: result?.AccessKeySecret,
+            // 从STS服务获取的安全令牌(SecurityToken)。
+            stsToken: result?.SecurityToken,
+            // 填写Bucket名称。
+            bucket: result?.ALI_OSS_BUCKET || "hep-textbook",
+        });
+    }
+    constructor(){
+    }
+
+    async upload(file:File,onProcess:Function){
+        await this.initClient();
+        let now = new Date();
+        let fname = `${Parse.User.current()?.id}/${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}/${now.getTime()}-${file?.name}`;
+        const r1 = await this.client?.put(fname, file);
+        console.log(file)
+        console.log('put success: %j', r1);
+        return r1
+
+    }
+
+}

+ 1 - 1
projects/textbook/src/app/comp-user/comp-user.component.scss

@@ -7,7 +7,7 @@
   height: 100%;
   z-index: 100;
   overflow: auto;
-  background: url('../../../public//img/banner-lab.png') no-repeat;
+  background: url('../../../public//img/banner.png') no-repeat;
   background-size: 100% 100%;
 }
 .title{

+ 1 - 0
projects/textbook/src/modules/login/account-info/account-info.component.ts

@@ -177,6 +177,7 @@ export class AccountInfoComponent implements OnInit {
     });
     profile?.set('telephone', params.telephone);
     profile?.set('companyType', params.companyType);
+    profile?.set('email', params.email);
     // profile?.set('idcard', params.idcard);
     profile?.set('identity', '报送联系人');
     profile?.set('identityFile', params.identityFile);

+ 17 - 17
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.html

@@ -21,14 +21,12 @@
                 >待认证</nz-tag
               >
               } @case ('已认证') {
-              <nz-tag [nzBordered]="false" [nzColor]="'green'"
-                >已认证</nz-tag
-              >
+              <nz-tag [nzBordered]="false" [nzColor]="'green'">已认证</nz-tag>
               } @case ('已禁用') {
-              <nz-tag [nzBordered]="false" [nzColor]="'red'"
-                >已禁用</nz-tag
-              >
-              } }
+              <nz-tag [nzBordered]="false" [nzColor]="'red'">已禁用</nz-tag>
+              } } @if (user.get('isDeleted')) {
+              <nz-tag nzColor="error">已删除</nz-tag>
+              }
             </div>
           </div>
           <div class="id">ID:{{ user?.id }}</div>
@@ -65,20 +63,22 @@
                 }
               </li>
               <li nz-menu-item>
-                <button nz-button nzType="link" style="color: #231c1f">
-                  <span
-                    nz-icon
-                    nzType="stop"
-                    nzTheme="outline"
-                    (click)="updateUser('已禁用')"
-                  ></span
-                  >禁用账号
+                @if (user.get('accountState') != '已禁用') {
+                <button
+                  nz-button
+                  nzType="link"
+                  (click)="updateUser('已禁用')"
+                  style="color: #231c1f"
+                >
+                  <span nz-icon nzType="stop" nzTheme="outline"></span>禁用账号
                 </button>
+                }
               </li>
               <li nz-menu-item>
                 <button
                   (click)="updateUser('删除')"
                   nz-button
+                  [disabled]="user.get('isDeleted')"
                   nzType="link"
                   style="color: #231c1f"
                 >
@@ -169,7 +169,7 @@
           <div nz-col nzSpan="8">
             <div class="lable">邮箱</div>
             <div class="value">
-              {{ user?.get("email") || "未填写" }}
+              {{ user?.get("email") || profile?.get("email") || "未填写" }}
             </div>
           </div>
           <div nz-col nzSpan="8">
@@ -252,7 +252,7 @@
   <ng-container *nzModalContent>
     <input
       nz-input
-      placeholder="请输入新的密码"
+      placeholder="密码格式可以由大小写字母或英文符号及数字组成"
       [(ngModel)]="password"
       type="text"
     />

+ 1 - 1
projects/textbook/src/modules/textbook/page-home/page-home.component.html

@@ -6,7 +6,7 @@
 <!--图片盒子-->
 <div class="landscape-box">
     <!-- Created by ai.fmode.cn imagine -->
-    <img class="landscape" src="/img/banner-lab.png" alt="feima-contest-background">
+    <img class="landscape" src="/img/banner.png" alt="feima-contest-background">
 
     <div class="landscape-text">
         <div class="landscape-title">《“十四五”普通高等教育本科国家级规划教材建设实施方案》</div>

+ 9 - 8
projects/textbook/src/schemas/Profile-list.ts

@@ -154,14 +154,15 @@ export const Profile: ParseSchema = {
       isHeader: true,
       showName: '${phone}',
     },
-    {
-      key: 'user',
-      name: '邮箱',
-      type: 'Pointer',
-      targetClass: '_User',
-      isHeader: true,
-      showName: '${email}',
-    },
+    // {
+    //   key: 'user',
+    //   name: '邮箱',
+    //   type: 'Pointer',
+    //   targetClass: '_User',
+    //   isHeader: true,
+    //   showName: '${email}',
+    // },
+    { key: 'email', name: '邮箱', type: 'String', isHeader: true },
     { key: 'identity', name: '人员类型', type: 'String', isHeader: true },
     {
       key: 'user',

+ 1 - 0
server/cloud/aliyun/func-aliyun-oss.js

@@ -50,6 +50,7 @@ function getAliyunOssAccessToken(){
     // }`, '3600', 'SessionTest' )
     // return result.credentials
     return {
+        bucket: ALI_OSS_BUCKET,
         AccessKeyId: ALI_OSS_ACCESS_KEY_ID,
         AccessKeySecret:ALI_OSS_ACCESS_KEY_SECRET,
         SecurityToken: null,

Деякі файли не було показано, через те що забагато файлів було змінено