Browse Source

Merge pull request #621 in DESIGN/design from ~VITO/c-design:feature/10.0 to feature/10.0

* commit '6ea705b456d4bd498cc799da07a41596bf3458d1':
  REPORT-12885 设计器鸣谢名单SiteCenter修改不生效
research/10.0
vito 6 years ago
parent
commit
21bd0e0711
  1. 32
      designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java
  2. 41
      designer-realize/src/main/java/com/fr/start/SplashContext.java

32
designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java

@ -26,27 +26,49 @@ public class BBSConstants {
private static Properties PROP = null; private static Properties PROP = null;
/**
* 获取所有的感谢对象无法获取在线使用默认
* @return 感谢对象的数组
*/
public static String[] getAllGuest() { public static String[] getAllGuest() {
return loadAllGuestsInfoOnline(GUEST_KEY_ONLINE, loadAllGuestsInfo(GUEST_KEY)); return loadAllGuestsInfoOnline(GUEST_KEY_ONLINE, loadAllGuestsInfo(GUEST_KEY));
} }
/**
* 获取所有的链接无法获取在线使用默认
* @return 链接的数组
*/
public static String[] getAllLink() { public static String[] getAllLink() {
return loadAllGuestsInfoOnline(LINK_KEY_ONLINE, loadAllGuestsInfo(LINK_KEY)); return loadAllGuestsInfoOnline(LINK_KEY_ONLINE, loadAllGuestsInfo(LINK_KEY));
} }
//加载所有用户的信息, 用户名, 论坛连接 /**
* 获取所有的感谢对象手动选择策略
* @return 感谢对象的数组
*/
public static String[] getAllGuestManual(boolean isOnline) {
String guest;
if (isOnline) {
guest = CloudCenter.getInstance().acquireUrlByKind(GUEST_KEY_ONLINE, StringUtils.EMPTY);
} else {
guest = loadAllGuestsInfo(GUEST_KEY);
}
if (StringUtils.isNotEmpty(guest)) {
return guest.split("\\|");
}
return new String[0];
}
private static String loadAllGuestsInfo(String key) { private static String loadAllGuestsInfo(String key) {
return loadAttribute(key, StringUtils.EMPTY); return loadAttribute(key, StringUtils.EMPTY);
} }
//加载所有用户的信息, 用户名, 论坛连接
private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) { private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) {
String[] allGuests = new String[0];
String guest = CloudCenter.getInstance().acquireUrlByKind(key, defaultValue); String guest = CloudCenter.getInstance().acquireUrlByKind(key, defaultValue);
if (StringUtils.isNotEmpty(guest)) { if (StringUtils.isNotEmpty(guest)) {
allGuests = guest.split("\\|"); return guest.split("\\|");
} }
return allGuests; return new String[0];
} }
//如果要定制, 直接改bbs.properties就行了 //如果要定制, 直接改bbs.properties就行了

41
designer-realize/src/main/java/com/fr/start/SplashContext.java

@ -24,6 +24,7 @@ public class SplashContext {
public static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif"; public static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif";
public static final String SPLASH_CACHE_NAME = "splash_10.gif"; public static final String SPLASH_CACHE_NAME = "splash_10.gif";
private static final int FETCH_ONLINE_MAX_TIMES = 10;
private static final SplashContext SPLASH_CONTEXT = new SplashContext(); private static final SplashContext SPLASH_CONTEXT = new SplashContext();
@ -33,7 +34,8 @@ public class SplashContext {
private int loadingIndex = 0; private int loadingIndex = 0;
private String[] loading = new String[]{"..", "....", "......"}; private String[] loading = new String[]{"..", "....", "......"};
private static final String GUEST = getRandomUser(); private int fetchOnlineTimes = 0;
private String guest = StringUtils.EMPTY;
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
@ -81,6 +83,7 @@ public class SplashContext {
scheduler.scheduleAtFixedRate(new Runnable() { scheduler.scheduleAtFixedRate(new Runnable() {
@Override @Override
public void run() { public void run() {
showThanks();
loadingIndex++; loadingIndex++;
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
} }
@ -90,7 +93,6 @@ public class SplashContext {
@Override @Override
public void on(Event event, String i18n) { public void on(Event event, String i18n) {
showThanks();
moduleID = i18n; moduleID = i18n;
loadingIndex++; loadingIndex++;
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
@ -110,21 +112,42 @@ public class SplashContext {
/** /**
* 获取随机感谢人员 * 获取随机感谢人员
*/ */
private static String getRandomUser() { private String getRandomUser(String[] allGuest) {
String[] allGuest = BBSConstants.getAllGuest();
if (allGuest.length == 0) {
return StringUtils.EMPTY;
}
int num = new Random().nextInt(allGuest.length); int num = new Random().nextInt(allGuest.length);
return StringUtils.BLANK + allGuest[num]; return StringUtils.BLANK + allGuest[num];
} }
/** /**
* 展示感谢信息 * 尝试获取在线资源达到尝试上限之后使用默认值
*/
private void tryFetchOnline() {
if (StringUtils.isNotEmpty(guest)) {
return;
}
String[] allGuest;
if (fetchOnlineTimes < FETCH_ONLINE_MAX_TIMES) {
allGuest = BBSConstants.getAllGuestManual(true);
if (allGuest.length == 0) {
fetchOnlineTimes++;
return;
}
} else {
allGuest = BBSConstants.getAllGuestManual(false);
}
guest = getRandomUser(allGuest);
}
/**
* 展示感谢信息这里场景是优先使用在线名单
* 甚至可以因此可以延迟几秒显示目前是尝试
* 获取10次在线资源最大时间3秒
*/ */
private void showThanks() { private void showThanks() {
if (shouldShowThanks()) { if (shouldShowThanks()) {
updateThanksLog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Thanks_To") + GUEST); tryFetchOnline();
if (StringUtils.isNotEmpty(guest)) {
updateThanksLog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Thanks_To") + guest);
}
} }
} }

Loading…
Cancel
Save