• [Alfred]为Baidu Weather Workflow更新图标


    Alfred workflow:百度天气,修改更新图标显示:

    下载:https://github.com/BobSte/weather-workflow

    原始代码是php脚本,为其增加了一个取图片的函数以及一些图片。增加到weather.php

    function getWeatherIcon($weather) {
        if ($weather == 'icon') {
            return 'cloudy2.png';
        } elseif ($weather == 'unknown') {
            return 'unknown.png';
        }
        $map = array('晴' => 'sunny.png', 
                     '晴见多云' => 'cloudy1.png',
                     '晴转多云' => 'cloudy3.png',
                     '多云转晴' => 'cloudy4.png',
                     '阴转晴' => 'cloudy4.png',
                     '多云' => 'cloudy5.png',
                     '阴' => 'overcast.png',
                     '雨' => 'light_rain.png',
                     '阵雨' => 'shower1.png',
                     '小雨' => 'shower1.png',
                     '中雨' => 'shower2.png',
                     '大雨' => 'shower3.png',
                     '暴雨' => 'shower3.png',
                     '雷阵雨' => 'tstorm1.png',
                     '雷阵雨转中雨' => 'tstorm2.png',
                     '雷阵雨转大雨' => 'tstorm3.png',
                     '雷阵雨转暴雨' => 'tstorm3.png',
                     '雨夹雪' => 'sleet.png',
                     '冰雹' => 'hail.png',
                     '阵雪' => 'snow1.png',
                     '小雪' => 'snow1.png',
                     '中雪' => 'snow2.png',
                     '大雪' => 'snow3.png',
                     '暴雪' => 'snow4.png',
                     '大暴雪' => 'snow5.png',
                     '雾' => 'mist.png',
                     '大雾' => 'fog.png',
                     '霾' => 'haze.png',
                     '雾霾' => 'haze.png',
                     );
        foreach ($map as $key => $value) {
            if ($weather == $key) {
                return $value;
            }
        }
    
        foreach (array_reverse($map) as $key => $value) {
            if (strstr($weather, $key)) {
                return $value;
            }
        }
    
        return 'unknown.png';
    }
  • 相关阅读:
    java修改应用程序标题栏
    电动双轮车
    Oracle执行计划相关(待补充)
    SQL中IN和EXISTS用法的区别
    union all与union all
    equals与hashcode
    文件上传的整个流程
    adwords与adsence
    struts2文件上传大小
    为什么是UUID做主键
  • 原文地址:https://www.cnblogs.com/Bob-wei/p/5013195.html
Copyright © 2020-2023  润新知