李志伟 3 anos atrás
pai
commit
b18073ba04

+ 0
- 60
src/api/oss.js Ver arquivo

@@ -1,60 +0,0 @@
1
-import OSS from 'ali-oss'
2
-import request from '@/utils/request'
3
-
4
-let client
5
-let stsInfo
6
-
7
-/**
8
- * 获取 OSS-STS 临时凭证
9
- * @returns
10
- */
11
-export const getSTSToken = () => request({ url: '/admin/oss-sts' })
12
-
13
-/**
14
- * 获取 OSS 客户端
15
- * @returns
16
- */
17
-export function getOSSClient() {
18
-  if (client) {
19
-    return Promise.resolve(client)
20
-  }
21
-
22
-  return getSTSToken().then((sts) => {
23
-    stsInfo = sts.data
24
-    client = new OSS({
25
-      accessKeyId: sts.data.accessKeyId,
26
-      accessKeySecret: sts.data.accessKeySecret,
27
-      stsToken: sts.data.stsToken,
28
-      bucket: sts.data.bucket,
29
-      endpoint: sts.data.endpoint,
30
-      refreshSTSTokenInterval: 25 * 60 * 1000, // 每25min刷新一次
31
-      refreshSTSToken: () => {
32
-        return getSTSToken().then((res) => {
33
-          return {
34
-            accessKeyId: res.accessKeyId,
35
-            accessKeySecret: res.accessKeySecret,
36
-            stsToken: res.stsToken
37
-          }
38
-        })
39
-      }
40
-    })
41
-
42
-    return client
43
-  })
44
-}
45
-
46
-/**
47
- * 上传文件到 OSS
48
- * @param {*} file
49
- * @returns
50
- */
51
-export function upload(file) {
52
-  return getOSSClient().then(() => {
53
-    const data = new FormData()
54
-    data.append('file', file)
55
-    const now = new Date()
56
-    const fileName = `${stsInfo.path}/${now.valueOf()}-${file.name}`
57
-
58
-    return client.put(fileName, file).then((res) => res.url)
59
-  })
60
-}

+ 0
- 46
src/api/schoolTerm.js Ver arquivo

@@ -1,46 +0,0 @@
1
-import request from '@/utils/request'
2
-
3
-/**
4
-* 保存学期
5
-* @param {*} data
6
-* @returns
7
-*/
8
-export const saveSchoolTerm = (data) => request({
9
-  url: '/admin/school-term',
10
-  method: 'post',
11
-  data
12
-})
13
-
14
-/**
15
- * 学期列表
16
- * @param {*} params
17
- * @returns
18
- */
19
-export const getSchoolTermList = (params) => request({
20
-  url: '/admin/school-term', params
21
-})
22
-
23
-/**
24
- * 删除学期
25
- * @param {*} data
26
- * @returns
27
- */
28
-export const deleteSchoolTerm = (id) => request({
29
-  url: `/admin/school-term/${id}`, method: 'delete'
30
-})
31
-/**
32
- * 更新学期
33
- * @param {*} data
34
- * @returns
35
- */
36
-export const UpdateSchoolTerm = (data, id) => request({
37
-  url: `/admin/school-term/${id}`, method: 'put', data
38
-})
39
-/**
40
- * 查询学期详情
41
- * @param {*} params
42
- * @returns
43
- */
44
-export const getSchoolTermDetail = (id) => request({
45
-  url: `/admin/school-term/${id}`
46
-})

+ 0
- 68
src/components/UploadImage/index.vue Ver arquivo

@@ -1,68 +0,0 @@
1
-<template>
2
-  <div class="uploadClass">
3
-    <el-upload
4
-      action="#"
5
-      list-type="picture-card"
6
-      :file-list="fileList"
7
-      :limit="1"
8
-      :on-remove="handleRemove"
9
-      :on-change="handleChange"
10
-      :auto-upload="false"
11
-      @http-request="customUploadFile"
12
-    >
13
-      <i class="el-icon-plus" />
14
-    </el-upload>
15
-  </div>
16
-</template>
17
-<script>
18
-import { uploadFile } from '@/utils/upload'
19
-export default {
20
-  props: {
21
-    icon: String
22
-  },
23
-  data() {
24
-    return {
25
-      dialogImageUrl: undefined,
26
-      dialogVisible: false,
27
-      fileList: []
28
-    }
29
-  },
30
-  watch: {
31
-    icon() {
32
-      if (this.icon) {
33
-        this.fileList = [{ name: 'image', url: this.icon }]
34
-      } else {
35
-        this.fileList = []
36
-      }
37
-    }
38
-  },
39
-  methods: {
40
-    customUploadFile(val) {
41
-      uploadFile({ file: val, onSuccess: this.onSuccess, onError: this.onError })
42
-    },
43
-    onSuccess(url) {
44
-      this.$emit('handleChange', url)
45
-    },
46
-    onError(e) {
47
-    },
48
-    handleRemove(file, fileList) {
49
-      this.fileList = []
50
-      this.$emit('handleDeleteIcon', true)
51
-    },
52
-    handleChange(file, fileList) {
53
-      this.customUploadFile(file.raw)
54
-    }
55
-  }
56
-}
57
-</script>
58
-<style>
59
-.uploadClass .el-upload--picture-card {
60
-  width: 100px;
61
-  height: 100px;
62
-  line-height: 106px;
63
-}
64
-.el-upload-list--picture-card .el-upload-list__item {
65
-  width: 100px;
66
-  height: 100px;
67
-}
68
-</style>

+ 0
- 54
src/components/UploadImageList/index.vue Ver arquivo

@@ -1,54 +0,0 @@
1
-<template>
2
-  <div class="uploadClass">
3
-    <el-upload
4
-      ref="upload"
5
-      class="upload-demo"
6
-      action="#"
7
-      :limit="9"
8
-      multiple
9
-      :on-remove="handleRemove"
10
-      :on-change="handleChange"
11
-      :on-exceed="handleExceed"
12
-      :auto-upload="false"
13
-      :show-file-list="false"
14
-      @http-request="customUploadFile"
15
-    >
16
-      <el-button slot="trigger" size="small" type="primary">添加图片</el-button>
17
-    </el-upload>
18
-  </div>
19
-</template>
20
-<script>
21
-import { uploadFile } from '@/utils/upload'
22
-export default {
23
-  methods: {
24
-    customUploadFile(val) {
25
-      uploadFile({ file: val, onSuccess: this.onSuccess, onError: this.onError })
26
-    },
27
-    onSuccess(url) {
28
-      this.$emit('handleChange', url)
29
-    },
30
-    onError(e) {
31
-    },
32
-    handleRemove(file, fileList) {
33
-    },
34
-    handleChange(file, fileList) {
35
-      this.customUploadFile(file.raw)
36
-      this.$refs.upload.clearFiles()
37
-    },
38
-    handleExceed(files, fileList) {
39
-      this.$message.warning('当前限制选择 9 个文件')
40
-    }
41
-  }
42
-}
43
-</script>
44
-<style>
45
-.uploadClass .el-upload--picture-card {
46
-  width: 100px;
47
-  height: 100px;
48
-  line-height: 106px;
49
-}
50
-.el-upload-list--picture-card .el-upload-list__item {
51
-  width: 100px;
52
-  height: 100px;
53
-}
54
-</style>

+ 1
- 3
src/store/index.js Ver arquivo

@@ -4,7 +4,6 @@ import getters from './getters'
4 4
 import app from './modules/app'
5 5
 import settings from './modules/settings'
6 6
 import user from './modules/user'
7
-import game from './modules/game'
8 7
 
9 8
 Vue.use(Vuex)
10 9
 
@@ -12,8 +11,7 @@ const store = new Vuex.Store({
12 11
   modules: {
13 12
     app,
14 13
     settings,
15
-    user,
16
-    game
14
+    user
17 15
   },
18 16
   getters
19 17
 })

+ 0
- 30
src/store/modules/game.js Ver arquivo

@@ -1,30 +0,0 @@
1
-const state = {
2
-  wordList: []// 设置初始特征列表
3
-}
4
-
5
-const getters = {
6
-  getwordList(state) {
7
-    return state.wordList // 返回当前特征列表
8
-  }
9
-}
10
-
11
-// 定义Mutations
12
-const mutations = {
13
-  setWordList(state, val) {
14
-    state.wordList = val // 改变当前特征列表
15
-  }
16
-}
17
-
18
-const actions = {
19
-  setWordListValue({ commit, state }, val) {
20
-    commit('setWordList', val)// 调用mutations方法
21
-  }
22
-}
23
-
24
-export default {
25
-  namespaced: true,
26
-  state,
27
-  getters,
28
-  mutations,
29
-  actions
30
-}

+ 0
- 17
src/utils/upload.js Ver arquivo

@@ -1,17 +0,0 @@
1
-import { upload } from '@/api/oss'
2
-
3
-/**
4
- * 获取 OSS 客户端
5
- * @returns
6
- */
7
-export function uploadFile({ file, onSuccess, onError }) {
8
-  upload(file).then((url) => {
9
-    onSuccess(url, file)
10
-  }).catch((e) => {
11
-    onError(e)
12
-  })
13
-
14
-  return {
15
-    abort: () => {}
16
-  }
17
-}