乙巳🐍年

acc8226 的博客

windows 平台

鼠标手势绝对是效率神器。考虑到一定要有便捷的操作,高度自定义,最好能提供提供导出导入功能。最终我选择了 WGestures 系列。

【win 免费 安装版】WGestures 1 官网 | 网盘备份 | 视频介绍 | 可供导入模板

或者

【win 收费 安装版】WGestures 2 官网 | 网盘备份 | 可供导入模板。功能对比 1 代更加强大,目前售价二十出头,优惠的购买地址我放这儿了。WGestures 2 多了可以勾画字母和图案鼠标手势。

备选

  • GestureSign 免费 Windows 全局触屏手势控制软件 作者已经几年没更新了
  • 【绿色版】FastGestures鼠标/触控板/屏手势 目前还不完善,例如我将 ctrl + f9 映射快捷键的功能不太好用
阅读全文 »

windows 用户

我开源了一款免费的效率工具【win】捷键

备用

  • XMouseButtonControl 简称 xmbc 配置稍显复杂,竟然还有鼠标自然滚动翻转
  • Preme for Windows – 方便小巧的桌面增强工具
  • 【win】MyKeymap 官网 | 源码 槽点是 win 7 用不了

mac 用户

【mac】hammerspoon + 自制脚本

阅读全文 »

如果您是 Windows 的 Linux 子系统(WSL)用户,要安装 Rust,请在终端中运行以下命令,然后遵循屏幕上的指示。

1
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

如果报错 linker cc not found 则安装 sudo apt install gcc

1
2
3
4
cargo new greeting
cd ./greeting
cargo build
cargo run

通用枚举

1
2
3
4
5
6
7
8
9
@FunctionalInterface
public interface BaseEnum {
/**
* 返回的 keys 可转换为 BaseEnum
*
* @return 字符串数组
*/
String[] getKeys();
}

枚举类实现此接口,并定义映射方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.yandi.web.core.config;

public enum DocxEnum implements BaseEnum {

/**
* 服务保障
*/
SERVICE_PROTECTION("服务保障"),
/**
* 行程安排
*/
ITINERARY("行程安排"),
/**
* 住宿安排
*/
ACCOMMODATION("住宿安排"),
;

private final String title;

DocxEnum(String title) {
this.title = title;
}

public String getTitle() {
return this.title;
}

@Override
public String[] getKeys() {
// 次序和名字都可转为枚举
return new String[] {String.valueOf(this.ordinal()), this.name().toLowerCase()};
}
}

转换器统一对 BaseEnum 进行转换,对于每个枚举类型,可通过返回的 keys 来自定义转换的方式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.yandi.web.core.config;

import org.springframework.core.convert.converter.Converter;

import java.util.HashMap;
import java.util.Map;

public class BaseEnumConverter<T extends BaseEnum> implements Converter<String, T> {
private Map<String, T> enumMap = new HashMap<>();
public BaseEnumConverter(Class<T> enumType) {
T[] enums = enumType.getEnumConstants();
// 根据keys建立转换
for (T e : enums) {
for (String key : e.getKeys()) {
enumMap.put(key, e);
}
}
}

@Override
public T convert(String source) {
T t = enumMap.get(source.toLowerCase());
if (t == null) {
throw new IllegalArgumentException("无法匹配对应的枚举类型");
}
return t;
}
}

构造转换器工厂

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.yandi.web.core.config;

import org.jetbrains.annotations.NotNull;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;

import java.util.HashMap;
import java.util.Map;

public class BaseEnumConverterFactory implements ConverterFactory<String, Enum> {
private static final Map<Class, Converter> CONVERTERS = new HashMap<>();
@Override
public <T extends Enum> Converter<String, T> getConverter(@NotNull Class<T> targetType) {
// 每一个类型创建一个转换器
Converter<String, T> converter = CONVERTERS.get(targetType);
if (converter == null) {
converter = new BaseEnumConverter(targetType);
CONVERTERS.put(targetType, converter);
}
return converter;
}
}

将此 Converter 通过工厂模式提供到 springboot 中:

1
2
3
4
5
6
7
8
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverterFactory(new BaseEnumConverterFactory());
}
}

开始使用。

注意这里的 DocxEnum 用法。

1
2
3
4
5
@PostMapping("/arrangement")
public Object importData(final MultipartFile[] file, @RequestParam(name = "type") final DocxEnum docxEnum)
throws IOException {
...
}
0%