Skip to content

Commit c17009f

Browse files
committed
feat: ueditor upgrade
1 parent bbb6452 commit c17009f

File tree

11 files changed

+242
-10
lines changed

11 files changed

+242
-10
lines changed

module/Cms/Admin/Controller/ModelController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ public function delete()
256256
BizException::throwsIfEmpty('记录不存在', $record);
257257
BizException::throwsIf('有栏目使用,不能删除', ModelUtil::exists('cms_cat', ['modelId' => $record['id']]));
258258
BizException::throwsIf('该模型有数据,不能删除', ModelUtil::exists('cms_content', ['modelId' => $record['id']]));
259-
ModelUtil::transactionBegin();
260259
CmsModelUtil::drop($record);
260+
ModelUtil::transactionBegin();
261261
ModelUtil::delete('cms_model', $record['id']);
262262
ModelUtil::delete('cms_model_field', ['modelId' => $record['id']]);
263263
ModelUtil::transactionCommit();

module/Member/Docs/release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- 新增:用户名长度可后台配置(默认为3)
44
- 新增:禁止注册时允许设置以授权方式注册
5+
- 新增:用户管理详情新增性别显示
56
- 优化:账号资料邮箱绑定绑定界面根据注册方式优化
67

78
---
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
4+
namespace Module\Member\Util;
5+
6+
7+
use ModStart\Core\Exception\BizException;
8+
use Module\Member\Auth\MemberUser;
9+
use Module\Vendor\Atomic\AtomicUtil;
10+
11+
class MemberAtomicUtil
12+
{
13+
public static function acquireOrFail($msg, $prefix, $memberUserId = null, $expire = 30)
14+
{
15+
if (!self::acquire($prefix, $memberUserId, $expire)) {
16+
BizException::throws($msg);
17+
}
18+
}
19+
20+
public static function acquire($prefix, $memberUserId = null, $expire = 30)
21+
{
22+
if (null === $memberUserId) {
23+
$memberUserId = MemberUser::id();
24+
}
25+
$key = $prefix . '_' . $memberUserId;
26+
return AtomicUtil::acquire($key, $expire);
27+
}
28+
29+
public static function release($prefix, $memberUserId = null)
30+
{
31+
if (null === $memberUserId) {
32+
$memberUserId = MemberUser::id();
33+
}
34+
$key = $prefix . '_' . $memberUserId;
35+
AtomicUtil::release($key);
36+
}
37+
}

module/Member/View/admin/memberUser/show.blade.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@extends('modstart::admin.dialogFrame')
22

3-
@section('pageTitle')用户 {{$record['username']}} 的信息@endsection
3+
@section('pageTitle')用户 {{\Module\Member\Util\MemberUtil::viewName($record)}} 的信息@endsection
44

55
@section('bodyContent')
66

@@ -36,6 +36,12 @@
3636
<div class="name">昵称</div>
3737
<div class="value">{{$record['nickname']?$record['nickname']:'-'}}</div>
3838
</div>
39+
@if(array_key_exists('gender',$record))
40+
<div class="ub-pair">
41+
<div class="name">性别</div>
42+
<div class="value">{{\ModStart\Core\Type\TypeUtil::name(\Module\Member\Type\Gender::class,$record['gender'])}}</div>
43+
</div>
44+
@endif
3945
@if(\ModStart\Module\ModuleManager::getModuleConfigBoolean('Member','moneyEnable',false))
4046
<div class="ub-pair">
4147
<div class="name">余额</div>

module/Vendor/Atomic/AtomicUtil.php

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717
*/
1818
class AtomicUtil
1919
{
20+
private static function autoCleanDB()
21+
{
22+
if (RandomUtil::percent(20)) {
23+
ModelUtil::model('atomic')->where('expire', '<', time())->delete();
24+
}
25+
}
26+
27+
28+
/**
29+
* 生产一个原子值,生产后可以使用 consume 消费
30+
* @param $name string
31+
* @param $value int
32+
* @param $expire int
33+
*/
2034
public static function produce($name, $value, $expire = 3600)
2135
{
2236
if (RedisUtil::isEnable()) {
@@ -29,12 +43,15 @@ public static function produce($name, $value, $expire = 3600)
2943
} else {
3044
ModelUtil::insert('atomic', ['name' => $name, 'value' => $value, 'expire' => time() + $expire]);
3145
}
32-
if (RandomUtil::percent(20)) {
33-
ModelUtil::model('atomic')->where('expire', '<', time())->delete();
34-
}
46+
self::autoCleanDB();
3547
}
3648
}
3749

50+
/**
51+
* 消费一个原子值
52+
* @param $name string
53+
* @return bool 是否成功
54+
*/
3855
public static function consume($name)
3956
{
4057
if (RedisUtil::isEnable()) {
@@ -44,9 +61,7 @@ public static function consume($name)
4461
}
4562
return false;
4663
} else {
47-
if (RandomUtil::percent(20)) {
48-
ModelUtil::model('atomic')->where('expire', '<', time())->delete();
49-
}
64+
self::autoCleanDB();
5065
ModelUtil::transactionBegin();
5166
$atomic = ModelUtil::getWithLock('atomic', ['name' => $name]);
5267
if (empty($atomic)) {
@@ -64,6 +79,10 @@ public static function consume($name)
6479
}
6580
}
6681

82+
/**
83+
* 移除一个原子值
84+
* @param $name
85+
*/
6786
public static function remove($name)
6887
{
6988
if (RedisUtil::isEnable()) {
@@ -73,4 +92,66 @@ public static function remove($name)
7392
ModelUtil::delete('atomic', ['name' => $name]);
7493
}
7594
}
95+
96+
/**
97+
* 请求一个互斥锁
98+
* acquire 后必须 release
99+
* @param $name string
100+
* @param $expire int
101+
* @return bool 是否成功
102+
*/
103+
public static function acquire($name, $expire = 30)
104+
{
105+
if (RedisUtil::isEnable()) {
106+
$key = "Atomic:$name";
107+
if (RedisUtil::setnx($key, time() + $expire)) {
108+
RedisUtil::expire($key, $expire);
109+
return true;
110+
}
111+
$ts = RedisUtil::get($key);
112+
if ($ts < time()) {
113+
RedisUtil::delete($key);
114+
return self::acquire($name, $expire);
115+
}
116+
return false;
117+
} else {
118+
self::autoCleanDB();
119+
ModelUtil::transactionBegin();
120+
$atomic = ModelUtil::getWithLock('atomic', ['name' => $name]);
121+
$ts = time() + $expire;
122+
if (empty($atomic)) {
123+
ModelUtil::insert('atomic', [
124+
'name' => $name,
125+
'value' => 1,
126+
'expire' => $ts
127+
]);
128+
ModelUtil::transactionCommit();
129+
return true;
130+
}
131+
if ($atomic['expire'] < time()) {
132+
ModelUtil::update('atomic', ['name' => $name], [
133+
'value' => 1,
134+
'expire' => $ts
135+
]);
136+
ModelUtil::transactionCommit();
137+
return true;
138+
}
139+
ModelUtil::transactionCommit();
140+
return false;
141+
}
142+
}
143+
144+
/**
145+
* 释放一个互斥锁
146+
* @param $name string
147+
*/
148+
public static function release($name)
149+
{
150+
if (RedisUtil::isEnable()) {
151+
$key = "Atomic:$name";
152+
RedisUtil::delete($key);
153+
} else {
154+
ModelUtil::delete('atomic', ['name' => $name]);
155+
}
156+
}
76157
}

module/Vendor/Docs/release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- 新增:任务调度新增上次运行时间设定
66
- 新增:任务调度记录调度日志和调度结果
77
- 新增:补全部分数据库模型文件
8+
- 新增:订单状态新增加支付成功取消,优化临界点支付异常问题
89

910
---
1011

module/Vendor/Type/OrderStatus.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ class OrderStatus implements BaseType
1111
const WAIT_CONFIRM = 3;
1212

1313
const COMPLETED = 50;
14+
15+
// 订单过期,支付成功的订单
16+
const CANCEL_PAID = 97;
1417
const CANCEL_EXPIRED = 98;
1518
const CANCEL = 99;
16-
const CANCEL_QUEUE = 100;
19+
20+
// const CANCEL_QUEUE = 100;
1721

1822
public static function getList()
1923
{
@@ -24,9 +28,10 @@ public static function getList()
2428

2529
self::COMPLETED => '已完成',
2630

31+
self::CANCEL_PAID => '支付成功取消',
2732
self::CANCEL_EXPIRED => '订单过期取消',
2833
self::CANCEL => '订单取消',
29-
self::CANCEL_QUEUE => '正在取消',
34+
// self::CANCEL_QUEUE => '正在取消',
3035
];
3136
}
3237

@@ -47,7 +52,9 @@ public static function simple()
4752
return self::filterList([
4853
self::WAIT_PAY,
4954
self::COMPLETED,
55+
self::CANCEL_PAID,
5056
self::CANCEL_EXPIRED,
57+
self::CANCEL,
5158
]);
5259
}
5360
}

vendor/modstart/modstart/resources/asset/src/lib/vue-manager.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ import vueTimeago from 'vue-timeago';
1212
import VueClipboard from 'vue-clipboard2';
1313
import {EventBus} from '@ModStartAsset/svue/lib/event-bus';
1414

15+
Vue.prototype.L = (name, ...args) => {
16+
let tpl = name
17+
if (window.lang && window.lang[name]) {
18+
tpl = window.lang[name]
19+
}
20+
if (args.length) {
21+
return StrUtil.sprintf(tpl, ...args)
22+
}
23+
return tpl
24+
}
25+
1526
Vue.use(ElementUI, {size: 'mini', zIndex: 3000});
1627
Vue.use(vueTimeago, {
1728
name: 'TimeAgo',
@@ -21,6 +32,13 @@ Vue.use(vueTimeago, {
2132
}
2233
})
2334
Vue.use(VueClipboard)
35+
Vue.prototype.$doCopyText = function (text, tips) {
36+
tips = tips || this.L('Copy Success')
37+
this.$copyText(text).then(
38+
() => Dialog.tipSuccess(tips),
39+
() => Dialog.tipError(this.L('Copy Fail'))
40+
);
41+
}
2442
Vue.prototype.$onCopySuccess = () => {
2543
Dialog.tipSuccess((window.lang && window.lang['Copy Success']) ? window.lang['Copy Success'] : 'Copy Success')
2644
}

vendor/modstart/modstart/resources/asset/src/mod/webpack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ module.exports = function (dirname, buildOption) {
261261
mode = 'development'
262262
}
263263
console.log('webpack mode -> ', mode)
264+
console.log('webpack build option -> ', buildOption)
264265
let results = []
265266
results.push(Object.assign({}, webpackConfig, {
266267
mode
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<template>
2+
<div>
3+
<audio ref="audio" :src="sound"></audio>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name: "PageNotice",
10+
props: {
11+
sound: {
12+
type: String,
13+
default: ''
14+
},
15+
},
16+
data() {
17+
return {
18+
tipTimer: null,
19+
tipTimerCount: 0,
20+
titleOld: null,
21+
}
22+
},
23+
methods: {
24+
tip(msg, type) {
25+
this.doPageTitle(msg, type)
26+
if (this.sound) {
27+
this.doPlaySound()
28+
}
29+
},
30+
doClearTimer() {
31+
clearInterval(this.tipTimer)
32+
this.tipTimer = null
33+
if (this.titleOld) {
34+
window.document.title = this.titleOld
35+
}
36+
this.tipTimerCount = 0
37+
},
38+
doPageTitle(msg, type) {
39+
type = type || '提醒'
40+
if (this.tipTimer) {
41+
this.doClearTimer()
42+
}
43+
this.titleOld = document.title
44+
this.tipTimerCount = 0
45+
this.tipTimer = setInterval(() => {
46+
this.tipTimerCount++
47+
if (this.tipTimerCount % 2 === 0) {
48+
window.document.title = '' + type + '' + msg
49+
} else {
50+
window.document.title = '' + msg
51+
}
52+
if (this.tipTimerCount > 6) {
53+
this.doClearTimer()
54+
}
55+
}, 500)
56+
},
57+
doPlaySound() {
58+
let audio = this.$refs.audio
59+
if (!audio) {
60+
return
61+
}
62+
try {
63+
audio.pause()
64+
audio.play()
65+
} catch (e) {
66+
}
67+
}
68+
}
69+
}
70+
</script>

0 commit comments

Comments
 (0)