Skip to content

Commit e13a531

Browse files
committed
chore(*): 调整项目主体
1 parent c9f870a commit e13a531

File tree

18 files changed

+362
-104
lines changed

18 files changed

+362
-104
lines changed

package-lock.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"fastscan": "^1.0.4",
2121
"good-storage": "^1.1.0",
2222
"js-cookie": "^2.2.0",
23+
"lodash": "^4.17.11",
2324
"screenfull": "^4.2.0",
2425
"vue": "^2.6.8",
2526
"vue-awesome-swiper": "^3.1.3",

src/components/layout/Screenfull.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
}
4848
</script>
4949

50-
<style scoped lang="scss">
50+
<style lang="scss" scoped>
5151
.container {
5252
width: 40px;
5353
height: 40px;
@@ -56,10 +56,12 @@ export default {
5656
align-items: center;
5757
margin-right: 10px;
5858
cursor: pointer;
59+
5960
i {
6061
width: 40px;
6162
height: 40px;
6263
font-size: 20px;
64+
6365
&:before {
6466
display: flex;
6567
justify-content: center;

src/components/layout/User.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
:initial-image="cropImg">
6565
</croppa>
6666
</div>
67+
<div style="margin-top: 1em;">通过鼠标滚轮调节头像大小</div>
6768
</div>
6869
<div slot="footer" class="dialog-footer">
6970
<el-button @click="cropVisible = false" size="small">取 消</el-button>
@@ -109,6 +110,7 @@ import User from '@/lin/models/user'
109110
import Vue from 'vue'
110111
import Croppa from 'vue-croppa'
111112
import 'vue-croppa/dist/vue-croppa.css'
113+
import Config from '@/config'
112114
113115
Vue.use(Croppa)
114116
@@ -250,7 +252,22 @@ export default {
250252
this.clearFileInput(this.$refs.avatarInput)
251253
}
252254
},
253-
handleCrop() {},
255+
async handleCrop() {
256+
// console.log(this.$refs.croppa)
257+
const blob = await this.$refs.croppa.promisedBlob('image/jpeg', 0.8)
258+
259+
// debugger
260+
// const res = await http({
261+
const res = await this.$axios({
262+
method: 'post',
263+
url: `${Config.baseUrl}cms/file/`,
264+
data: {
265+
file: blob,
266+
},
267+
})
268+
console.log(res)
269+
// debugger
270+
},
254271
init() {
255272
const { user } = this.$store.state
256273
this.nickname = user ? user.nickname : '未登录'

src/lin/directives/authorize.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import store from '../../store'
1+
import Vue from 'vue'
2+
import store from '@/store'
23

34
function isAllowed(_auth, user, auths) {
45
if (user.isSuper) {
@@ -12,16 +13,15 @@ function isAllowed(_auth, user, auths) {
1213
return false
1314
}
1415

15-
export default {
16-
install(Vue) {
17-
Vue.directive('auth', {
18-
bind(el, binding) {
19-
const isAllow = isAllowed(binding.value, (store.state.user || {}), store.state.auths)
20-
const element = el
21-
if (!isAllow && binding.value) {
22-
element.style.display = 'none'
23-
}
24-
},
25-
})
16+
17+
Vue.directive('auth', {
18+
bind(el, binding) {
19+
const isAllow = isAllowed(binding.value, (store.state.user || {}), store.state.auths)
20+
const element = el
21+
if (!isAllow && binding.value) {
22+
element.style.display = 'none'
23+
}
2624
},
27-
}
25+
})
26+
27+
export default Vue.directive('auth')

src/lin/filter/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Vue from 'vue'
12
import Utils from '../utils/util'
23
/*
34
* 全局的过滤函数
@@ -6,7 +7,7 @@ function checkAddZone(num) {
67
return num < 10 ? `0${num.toString()}` : num
78
}
89

9-
export default {
10+
const globalFilter = {
1011

1112
filterAddress(value) { // 过滤地址
1213
if (!value) return value
@@ -96,3 +97,8 @@ export default {
9697
},
9798

9899
}
100+
101+
// 全局过滤器
102+
Object.keys(globalFilter).forEach(k => Vue.filter(k, globalFilter[k]))
103+
104+
export default globalFilter

src/lin/mixin/global.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import Vue from 'vue'
12
import { mapGetters } from 'vuex'
23

3-
export default {
4+
5+
const globalMixin = {
6+
// eslint-disable-next-line
47
install(Vue) {
58
Vue.mixin({
69
methods: {
@@ -37,3 +40,7 @@ export default {
3740
})
3841
},
3942
}
43+
44+
Vue.use(globalMixin)
45+
46+
export default globalMixin

src/lin/models/admin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/* eslint-disable class-methods-use-this */
22
import {
3-
post, get, put, _delete,
4-
} from '../utils/http'
3+
post,
4+
get,
5+
put,
6+
_delete,
7+
} from '@/lin/plugins/axios'
58

69
export default class Admin {
710
constructor(uPage = 0, uCount = 10, gPage = 0, gCount = 5) {

src/lin/models/book.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/* eslint-disable class-methods-use-this */
22
import {
3-
get, post, put, _delete,
4-
} from '../utils/http'
3+
post,
4+
get,
5+
put,
6+
_delete,
7+
} from '@/lin/plugins/axios'
58

69
// 我们通过 class 这样的语法糖使模型这个概念更加具象化,其优点:耦合性低、可维护性。
710
class Book {

src/lin/models/log.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable class-methods-use-this */
2-
import { get } from '../utils/http'
2+
import {
3+
get,
4+
} from '@/lin/plugins/axios'
35

46
class Log {
57
name = null;

src/lin/models/notify.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* eslint-disable class-methods-use-this */
2-
import { get, post, put } from '../utils/http'
2+
import {
3+
post,
4+
get,
5+
put,
6+
} from '@/lin/plugins/axios'
37
import Config from '../../config'
48
import Sse from '../utils/sse'
59

src/lin/models/user.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/* eslint-disable class-methods-use-this */
2-
import { post, get, put } from '../utils/http'
2+
import {
3+
post,
4+
get,
5+
put,
6+
// } from '@/lin/utils/http'
7+
} from '@/lin/plugins/axios'
38
import { saveTokens, saveAccessToken } from '../utils/cookie'
49

510
const SUPER_VALUE = 2

src/lin/utils/plugins.js renamed to src/lin/plugins/autoJump.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
// 定时自动登出功能, 启用后一段时间无用户操作, 则自动登出. 需在项目 config 中配置
2+
import Vue from 'vue'
13
import Config from '@/config'
24
import store from '@/store'
35

4-
const plugins = {
6+
const Plugin = {
7+
// eslint-disable-next-line
58
install(Vue) {
69
Vue.prototype.$_lin_jump = () => { // eslint-disable-line
710
if (!Config.openAutoJumpOut) {
@@ -17,4 +20,6 @@ const plugins = {
1720
},
1821
}
1922

20-
export default plugins
23+
Vue.use(Plugin)
24+
25+
export default Plugin

0 commit comments

Comments
 (0)