diff --git a/lib/common/constants.dart b/lib/common/constants.dart index 851284472..145925c33 100644 --- a/lib/common/constants.dart +++ b/lib/common/constants.dart @@ -77,221 +77,221 @@ class Constants { ]; //内容来自 https://passport.bilibili.com/web/generic/country/list - static List> get internationalDialingPrefix => [ - {"id": 1, "cname": "中国大陆", "country_id": "86"}, - {"id": 5, "cname": "中国香港特别行政区", "country_id": "852"}, - {"id": 2, "cname": "中国澳门特别行政区", "country_id": "853"}, - {"id": 3, "cname": "中国台湾", "country_id": "886"}, - {"id": 4, "cname": "美国", "country_id": "1"}, - {"id": 6, "cname": "比利时", "country_id": "32"}, - {"id": 7, "cname": "澳大利亚", "country_id": "61"}, - {"id": 8, "cname": "法国", "country_id": "33"}, - {"id": 9, "cname": "加拿大", "country_id": "1"}, - {"id": 10, "cname": "日本", "country_id": "81"}, - {"id": 11, "cname": "新加坡", "country_id": "65"}, - {"id": 12, "cname": "韩国", "country_id": "82"}, - {"id": 13, "cname": "马来西亚", "country_id": "60"}, - {"id": 14, "cname": "英国", "country_id": "44"}, - {"id": 15, "cname": "意大利", "country_id": "39"}, - {"id": 16, "cname": "德国", "country_id": "49"}, - {"id": 18, "cname": "俄罗斯", "country_id": "7"}, - {"id": 19, "cname": "新西兰", "country_id": "64"}, //common:1-19 - {"id": 153, "cname": "瓦利斯群岛和富图纳群岛", "country_id": "1681"}, - {"id": 152, "cname": "葡萄牙", "country_id": "351"}, - {"id": 151, "cname": "帕劳", "country_id": "680"}, - {"id": 150, "cname": "诺福克岛", "country_id": "672"}, - {"id": 149, "cname": "挪威", "country_id": "47"}, - {"id": 148, "cname": "纽埃岛", "country_id": "683"}, - {"id": 147, "cname": "尼日利亚", "country_id": "234"}, - {"id": 146, "cname": "尼日尔", "country_id": "227"}, - {"id": 145, "cname": "尼加拉瓜", "country_id": "505"}, - {"id": 144, "cname": "尼泊尔", "country_id": "977"}, - {"id": 143, "cname": "瑙鲁", "country_id": "674"}, - {"id": 154, "cname": "格鲁吉亚", "country_id": "995"}, - {"id": 155, "cname": "瑞典", "country_id": "46"}, - {"id": 165, "cname": "沙特阿拉伯", "country_id": "966"}, - {"id": 164, "cname": "桑给巴尔岛", "country_id": "259"}, - {"id": 163, "cname": "塞舌尔共和国", "country_id": "248"}, - {"id": 162, "cname": "塞浦路斯", "country_id": "357"}, - {"id": 161, "cname": "塞内加尔", "country_id": "221"}, - {"id": 160, "cname": "塞拉利昂", "country_id": "232"}, - {"id": 159, "cname": "萨摩亚,东部", "country_id": "684"}, - {"id": 158, "cname": "萨摩亚,西部", "country_id": "685"}, - {"id": 157, "cname": "萨尔瓦多", "country_id": "503"}, - {"id": 156, "cname": "瑞士", "country_id": "41"}, - {"id": 166, "cname": "圣多美和普林西比", "country_id": "239"}, - {"id": 142, "cname": "塞尔维亚", "country_id": "381"}, - {"id": 141, "cname": "南非", "country_id": "27"}, - {"id": 128, "cname": "毛里塔尼亚", "country_id": "222"}, - {"id": 127, "cname": "毛里求斯", "country_id": "230"}, - {"id": 126, "cname": "马歇尔岛", "country_id": "692"}, - {"id": 125, "cname": "马提尼克岛", "country_id": "596"}, - {"id": 124, "cname": "马其顿", "country_id": "389"}, - {"id": 123, "cname": "马里亚纳岛", "country_id": "1670"}, - {"id": 122, "cname": "马里", "country_id": "223"}, - {"id": 121, "cname": "马拉维", "country_id": "265"}, - {"id": 120, "cname": "马耳他", "country_id": "356"}, - {"id": 119, "cname": "马尔代夫", "country_id": "960"}, - {"id": 129, "cname": "蒙古", "country_id": "976"}, - {"id": 130, "cname": "蒙特塞拉特岛", "country_id": "1664"}, - {"id": 140, "cname": "纳米比亚", "country_id": "264"}, - {"id": 139, "cname": "墨西哥", "country_id": "52"}, - {"id": 138, "cname": "莫桑比克", "country_id": "258"}, - {"id": 137, "cname": "摩纳哥", "country_id": "377"}, - {"id": 136, "cname": "摩洛哥", "country_id": "212"}, - {"id": 135, "cname": "摩尔多瓦", "country_id": "373"}, - {"id": 134, "cname": "缅甸", "country_id": "95"}, - {"id": 133, "cname": "密克罗尼西亚", "country_id": "691"}, - {"id": 132, "cname": "秘鲁", "country_id": "51"}, - {"id": 131, "cname": "孟加拉国", "country_id": "880"}, - {"id": 118, "cname": "马达加斯加", "country_id": "261"}, - {"id": 167, "cname": "圣卢西亚", "country_id": "1784"}, - {"id": 216, "cname": "智利", "country_id": "56"}, - {"id": 203, "cname": "牙买加", "country_id": "1876"}, - {"id": 202, "cname": "叙利亚", "country_id": "963"}, - {"id": 201, "cname": "匈牙利", "country_id": "36"}, - {"id": 200, "cname": "科特迪瓦", "country_id": "225"}, - {"id": 199, "cname": "希腊", "country_id": "30"}, - {"id": 198, "cname": "西班牙", "country_id": "34"}, - {"id": 197, "cname": "乌兹别克斯坦", "country_id": "998"}, - {"id": 196, "cname": "乌拉圭", "country_id": "598"}, - {"id": 195, "cname": "乌克兰", "country_id": "380"}, - {"id": 194, "cname": "乌干达", "country_id": "256"}, - {"id": 204, "cname": "亚美尼亚", "country_id": "374"}, - {"id": 205, "cname": "也门", "country_id": "967"}, - {"id": 215, "cname": "直布罗陀", "country_id": "350"}, - {"id": 214, "cname": "乍得", "country_id": "235"}, - {"id": 213, "cname": "赞比亚", "country_id": "260"}, - {"id": 212, "cname": "越南", "country_id": "84"}, - {"id": 211, "cname": "约旦", "country_id": "962"}, - {"id": 210, "cname": "印尼", "country_id": "62"}, - {"id": 209, "cname": "印度", "country_id": "91"}, - {"id": 208, "cname": "以色列", "country_id": "972"}, - {"id": 207, "cname": "伊朗", "country_id": "98"}, - {"id": 206, "cname": "伊拉克", "country_id": "964"}, - {"id": 193, "cname": "文莱", "country_id": "673"}, - {"id": 192, "cname": "委内瑞拉", "country_id": "58"}, - {"id": 191, "cname": "维珍群岛(英属)", "country_id": "1284"}, - {"id": 178, "cname": "泰国", "country_id": "66"}, - {"id": 177, "cname": "索马里", "country_id": "252"}, - {"id": 176, "cname": "所罗门群岛", "country_id": "677"}, - {"id": 175, "cname": "苏里南", "country_id": "597"}, - {"id": 174, "cname": "苏丹", "country_id": "249"}, - {"id": 173, "cname": "斯威士兰", "country_id": "268"}, - {"id": 172, "cname": "斯洛文尼亚", "country_id": "386"}, - {"id": 171, "cname": "斯洛伐克", "country_id": "421"}, - {"id": 170, "cname": "斯里兰卡", "country_id": "94"}, - {"id": 169, "cname": "圣皮埃尔和密克隆群岛", "country_id": "508"}, - {"id": 179, "cname": "坦桑尼亚", "country_id": "255"}, - {"id": 180, "cname": "汤加", "country_id": "676"}, - {"id": 190, "cname": "维珍群岛(美属)", "country_id": "1340"}, - {"id": 189, "cname": "瓦努阿图", "country_id": "678"}, - {"id": 188, "cname": "托克劳岛", "country_id": "690"}, - {"id": 187, "cname": "土库曼斯坦", "country_id": "993"}, - {"id": 186, "cname": "土耳其", "country_id": "90"}, - {"id": 185, "cname": "图瓦卢", "country_id": "688"}, - {"id": 184, "cname": "突尼斯", "country_id": "216"}, - {"id": 183, "cname": "阿森松岛", "country_id": "247"}, - {"id": 182, "cname": "特立尼达和多巴哥", "country_id": "1868"}, - {"id": 181, "cname": "特克斯和凯科斯", "country_id": "1649"}, - {"id": 168, "cname": "圣马力诺", "country_id": "378"}, - {"id": 67, "cname": "法属圭亚那", "country_id": "594"}, - {"id": 54, "cname": "不丹", "country_id": "975"}, - {"id": 53, "cname": "博茨瓦纳", "country_id": "267"}, - {"id": 52, "cname": "伯利兹", "country_id": "501"}, - {"id": 51, "cname": "玻利维亚", "country_id": "591"}, - {"id": 50, "cname": "波兰", "country_id": "48"}, - {"id": 49, "cname": "波黑", "country_id": "387"}, - {"id": 48, "cname": "波多黎各", "country_id": "1787"}, - {"id": 47, "cname": "冰岛", "country_id": "354"}, - {"id": 46, "cname": "贝宁", "country_id": "229"}, - {"id": 45, "cname": "保加利亚", "country_id": "359"}, - {"id": 55, "cname": "布基纳法索", "country_id": "226"}, - {"id": 56, "cname": "布隆迪", "country_id": "257"}, - {"id": 66, "cname": "法属波利尼西亚", "country_id": "689"}, - {"id": 65, "cname": "法罗岛", "country_id": "298"}, - {"id": 64, "cname": "厄立特里亚", "country_id": "291"}, - {"id": 63, "cname": "厄瓜多尔", "country_id": "593"}, - {"id": 62, "cname": "多米尼加代表", "country_id": "1809"}, - {"id": 61, "cname": "多米尼加", "country_id": "1767"}, - {"id": 60, "cname": "多哥", "country_id": "228"}, - {"id": 59, "cname": "迪戈加西亚岛", "country_id": "246"}, - {"id": 58, "cname": "丹麦", "country_id": "45"}, - {"id": 57, "cname": "赤道几内亚", "country_id": "240"}, - {"id": 44, "cname": "百慕大群岛", "country_id": "1441"}, - {"id": 43, "cname": "白俄罗斯", "country_id": "375"}, - {"id": 42, "cname": "巴西", "country_id": "55"}, - {"id": 29, "cname": "爱尔兰", "country_id": "353"}, - {"id": 28, "cname": "埃塞俄比亚", "country_id": "251"}, - {"id": 27, "cname": "埃及", "country_id": "20"}, - {"id": 26, "cname": "阿塞拜疆", "country_id": "994"}, - {"id": 25, "cname": "阿曼", "country_id": "968"}, - {"id": 24, "cname": "阿联酋", "country_id": "971"}, - {"id": 23, "cname": "阿根廷", "country_id": "54"}, - {"id": 22, "cname": "阿富汗", "country_id": "93"}, - {"id": 21, "cname": "阿尔及利亚", "country_id": "213"}, - {"id": 20, "cname": "阿尔巴尼亚", "country_id": "355"}, - {"id": 30, "cname": "爱沙尼亚", "country_id": "372"}, - {"id": 31, "cname": "安道尔", "country_id": "376"}, - {"id": 41, "cname": "巴拿马", "country_id": "507"}, - {"id": 40, "cname": "巴林", "country_id": "973"}, - {"id": 39, "cname": "巴拉圭", "country_id": "595"}, - {"id": 38, "cname": "巴基斯坦", "country_id": "92"}, - {"id": 37, "cname": "巴哈马群岛", "country_id": "1242"}, - {"id": 36, "cname": "巴布亚新几内亚", "country_id": "675"}, - {"id": 35, "cname": "巴巴多斯", "country_id": "1246"}, - {"id": 34, "cname": "奥地利", "country_id": "43"}, - {"id": 33, "cname": "安提瓜岛和巴布达", "country_id": "1268"}, - {"id": 32, "cname": "安哥拉", "country_id": "244"}, - {"id": 68, "cname": "非洲中部", "country_id": "236"}, - {"id": 117, "cname": "罗马尼亚", "country_id": "40"}, - {"id": 104, "cname": "科威特", "country_id": "965"}, - {"id": 103, "cname": "科摩罗", "country_id": "269"}, - {"id": 102, "cname": "开曼群岛", "country_id": "1345"}, - {"id": 101, "cname": "卡塔尔", "country_id": "974"}, - {"id": 100, "cname": "喀麦隆", "country_id": "237"}, - {"id": 99, "cname": "聚会岛", "country_id": "262"}, - {"id": 98, "cname": "津巴布韦", "country_id": "263"}, - {"id": 97, "cname": "捷克", "country_id": "420"}, - {"id": 96, "cname": "柬埔寨", "country_id": "855"}, - {"id": 95, "cname": "加蓬", "country_id": "241"}, - {"id": 105, "cname": "克罗地亚", "country_id": "385"}, - {"id": 106, "cname": "肯尼亚", "country_id": "254"}, - {"id": 116, "cname": "卢旺达", "country_id": "250"}, - {"id": 115, "cname": "卢森堡", "country_id": "352"}, - {"id": 114, "cname": "利比亚", "country_id": "218"}, - {"id": 113, "cname": "利比里亚", "country_id": "231"}, - {"id": 112, "cname": "立陶宛", "country_id": "370"}, - {"id": 111, "cname": "黎巴嫩", "country_id": "961"}, - {"id": 110, "cname": "老挝", "country_id": "856"}, - {"id": 109, "cname": "莱索托", "country_id": "266"}, - {"id": 108, "cname": "拉脱维亚", "country_id": "371"}, - {"id": 107, "cname": "库克岛", "country_id": "682"}, - {"id": 94, "cname": "加纳", "country_id": "233"}, - {"id": 93, "cname": "几内亚比绍", "country_id": "245"}, - {"id": 92, "cname": "几内亚", "country_id": "224"}, - {"id": 79, "cname": "格林纳达", "country_id": "1473"}, - {"id": 78, "cname": "哥斯达黎加", "country_id": "506"}, - {"id": 77, "cname": "哥伦比亚", "country_id": "57"}, - {"id": 76, "cname": "刚果(金)", "country_id": "243"}, - {"id": 75, "cname": "刚果", "country_id": "242"}, - {"id": 74, "cname": "冈比亚", "country_id": "220"}, - {"id": 73, "cname": "福克兰岛", "country_id": "500"}, - {"id": 72, "cname": "佛得角", "country_id": "238"}, - {"id": 71, "cname": "芬兰", "country_id": "358"}, - {"id": 70, "cname": "斐济", "country_id": "679"}, - {"id": 80, "cname": "格陵兰岛", "country_id": "299"}, - {"id": 81, "cname": "古巴", "country_id": "53"}, - {"id": 91, "cname": "吉尔吉斯斯坦", "country_id": "996"}, - {"id": 90, "cname": "吉布提", "country_id": "253"}, - {"id": 89, "cname": "基里巴斯", "country_id": "686"}, - {"id": 88, "cname": "维克岛", "country_id": "1808"}, - {"id": 87, "cname": "洪都拉斯", "country_id": "504"}, - {"id": 86, "cname": "荷兰", "country_id": "31"}, - {"id": 85, "cname": "朝鲜", "country_id": "850"}, - {"id": 84, "cname": "海地", "country_id": "509"}, - {"id": 83, "cname": "关岛", "country_id": "1671"}, - {"id": 82, "cname": "瓜德罗普岛", "country_id": "590"}, - {"id": 69, "cname": "菲律宾", "country_id": "63"}, + static const internationalDialingPrefix = [ + (id: 1, cname: "中国大陆", countryId: 86), + (id: 5, cname: "中国香港特别行政区", countryId: 852), + (id: 2, cname: "中国澳门特别行政区", countryId: 853), + (id: 3, cname: "中国台湾", countryId: 886), + (id: 4, cname: "美国", countryId: 1), + (id: 6, cname: "比利时", countryId: 32), + (id: 7, cname: "澳大利亚", countryId: 61), + (id: 8, cname: "法国", countryId: 33), + (id: 9, cname: "加拿大", countryId: 1), + (id: 10, cname: "日本", countryId: 81), + (id: 11, cname: "新加坡", countryId: 65), + (id: 12, cname: "韩国", countryId: 82), + (id: 13, cname: "马来西亚", countryId: 60), + (id: 14, cname: "英国", countryId: 44), + (id: 15, cname: "意大利", countryId: 39), + (id: 16, cname: "德国", countryId: 49), + (id: 18, cname: "俄罗斯", countryId: 7), + (id: 19, cname: "新西兰", countryId: 64), + (id: 153, cname: "瓦利斯群岛和富图纳群岛", countryId: 1681), + (id: 152, cname: "葡萄牙", countryId: 351), + (id: 151, cname: "帕劳", countryId: 680), + (id: 150, cname: "诺福克岛", countryId: 672), + (id: 149, cname: "挪威", countryId: 47), + (id: 148, cname: "纽埃岛", countryId: 683), + (id: 147, cname: "尼日利亚", countryId: 234), + (id: 146, cname: "尼日尔", countryId: 227), + (id: 145, cname: "尼加拉瓜", countryId: 505), + (id: 144, cname: "尼泊尔", countryId: 977), + (id: 143, cname: "瑙鲁", countryId: 674), + (id: 154, cname: "格鲁吉亚", countryId: 995), + (id: 155, cname: "瑞典", countryId: 46), + (id: 165, cname: "沙特阿拉伯", countryId: 966), + (id: 164, cname: "桑给巴尔岛", countryId: 259), + (id: 163, cname: "塞舌尔共和国", countryId: 248), + (id: 162, cname: "塞浦路斯", countryId: 357), + (id: 161, cname: "塞内加尔", countryId: 221), + (id: 160, cname: "塞拉利昂", countryId: 232), + (id: 159, cname: "萨摩亚,东部", countryId: 684), + (id: 158, cname: "萨摩亚,西部", countryId: 685), + (id: 157, cname: "萨尔瓦多", countryId: 503), + (id: 156, cname: "瑞士", countryId: 41), + (id: 166, cname: "圣多美和普林西比", countryId: 239), + (id: 142, cname: "塞尔维亚", countryId: 381), + (id: 141, cname: "南非", countryId: 27), + (id: 128, cname: "毛里塔尼亚", countryId: 222), + (id: 127, cname: "毛里求斯", countryId: 230), + (id: 126, cname: "马歇尔岛", countryId: 692), + (id: 125, cname: "马提尼克岛", countryId: 596), + (id: 124, cname: "马其顿", countryId: 389), + (id: 123, cname: "马里亚纳岛", countryId: 1670), + (id: 122, cname: "马里", countryId: 223), + (id: 121, cname: "马拉维", countryId: 265), + (id: 120, cname: "马耳他", countryId: 356), + (id: 119, cname: "马尔代夫", countryId: 960), + (id: 129, cname: "蒙古", countryId: 976), + (id: 130, cname: "蒙特塞拉特岛", countryId: 1664), + (id: 140, cname: "纳米比亚", countryId: 264), + (id: 139, cname: "墨西哥", countryId: 52), + (id: 138, cname: "莫桑比克", countryId: 258), + (id: 137, cname: "摩纳哥", countryId: 377), + (id: 136, cname: "摩洛哥", countryId: 212), + (id: 135, cname: "摩尔多瓦", countryId: 373), + (id: 134, cname: "缅甸", countryId: 95), + (id: 133, cname: "密克罗尼西亚", countryId: 691), + (id: 132, cname: "秘鲁", countryId: 51), + (id: 131, cname: "孟加拉国", countryId: 880), + (id: 118, cname: "马达加斯加", countryId: 261), + (id: 167, cname: "圣卢西亚", countryId: 1784), + (id: 216, cname: "智利", countryId: 56), + (id: 203, cname: "牙买加", countryId: 1876), + (id: 202, cname: "叙利亚", countryId: 963), + (id: 201, cname: "匈牙利", countryId: 36), + (id: 200, cname: "科特迪瓦", countryId: 225), + (id: 199, cname: "希腊", countryId: 30), + (id: 198, cname: "西班牙", countryId: 34), + (id: 197, cname: "乌兹别克斯坦", countryId: 998), + (id: 196, cname: "乌拉圭", countryId: 598), + (id: 195, cname: "乌克兰", countryId: 380), + (id: 194, cname: "乌干达", countryId: 256), + (id: 204, cname: "亚美尼亚", countryId: 374), + (id: 205, cname: "也门", countryId: 967), + (id: 215, cname: "直布罗陀", countryId: 350), + (id: 214, cname: "乍得", countryId: 235), + (id: 213, cname: "赞比亚", countryId: 260), + (id: 212, cname: "越南", countryId: 84), + (id: 211, cname: "约旦", countryId: 962), + (id: 210, cname: "印尼", countryId: 62), + (id: 209, cname: "印度", countryId: 91), + (id: 208, cname: "以色列", countryId: 972), + (id: 207, cname: "伊朗", countryId: 98), + (id: 206, cname: "伊拉克", countryId: 964), + (id: 193, cname: "文莱", countryId: 673), + (id: 192, cname: "委内瑞拉", countryId: 58), + (id: 191, cname: "维珍群岛(英属)", countryId: 1284), + (id: 178, cname: "泰国", countryId: 66), + (id: 177, cname: "索马里", countryId: 252), + (id: 176, cname: "所罗门群岛", countryId: 677), + (id: 175, cname: "苏里南", countryId: 597), + (id: 174, cname: "苏丹", countryId: 249), + (id: 173, cname: "斯威士兰", countryId: 268), + (id: 172, cname: "斯洛文尼亚", countryId: 386), + (id: 171, cname: "斯洛伐克", countryId: 421), + (id: 170, cname: "斯里兰卡", countryId: 94), + (id: 169, cname: "圣皮埃尔和密克隆群岛", countryId: 508), + (id: 179, cname: "坦桑尼亚", countryId: 255), + (id: 180, cname: "汤加", countryId: 676), + (id: 190, cname: "维珍群岛(美属)", countryId: 1340), + (id: 189, cname: "瓦努阿图", countryId: 678), + (id: 188, cname: "托克劳岛", countryId: 690), + (id: 187, cname: "土库曼斯坦", countryId: 993), + (id: 186, cname: "土耳其", countryId: 90), + (id: 185, cname: "图瓦卢", countryId: 688), + (id: 184, cname: "突尼斯", countryId: 216), + (id: 183, cname: "阿森松岛", countryId: 247), + (id: 182, cname: "特立尼达和多巴哥", countryId: 1868), + (id: 181, cname: "特克斯和凯科斯", countryId: 1649), + (id: 168, cname: "圣马力诺", countryId: 378), + (id: 67, cname: "法属圭亚那", countryId: 594), + (id: 54, cname: "不丹", countryId: 975), + (id: 53, cname: "博茨瓦纳", countryId: 267), + (id: 52, cname: "伯利兹", countryId: 501), + (id: 51, cname: "玻利维亚", countryId: 591), + (id: 50, cname: "波兰", countryId: 48), + (id: 49, cname: "波黑", countryId: 387), + (id: 48, cname: "波多黎各", countryId: 1787), + (id: 47, cname: "冰岛", countryId: 354), + (id: 46, cname: "贝宁", countryId: 229), + (id: 45, cname: "保加利亚", countryId: 359), + (id: 55, cname: "布基纳法索", countryId: 226), + (id: 56, cname: "布隆迪", countryId: 257), + (id: 66, cname: "法属波利尼西亚", countryId: 689), + (id: 65, cname: "法罗岛", countryId: 298), + (id: 64, cname: "厄立特里亚", countryId: 291), + (id: 63, cname: "厄瓜多尔", countryId: 593), + (id: 62, cname: "多米尼加代表", countryId: 1809), + (id: 61, cname: "多米尼加", countryId: 1767), + (id: 60, cname: "多哥", countryId: 228), + (id: 59, cname: "迪戈加西亚岛", countryId: 246), + (id: 58, cname: "丹麦", countryId: 45), + (id: 57, cname: "赤道几内亚", countryId: 240), + (id: 44, cname: "百慕大群岛", countryId: 1441), + (id: 43, cname: "白俄罗斯", countryId: 375), + (id: 42, cname: "巴西", countryId: 55), + (id: 29, cname: "爱尔兰", countryId: 353), + (id: 28, cname: "埃塞俄比亚", countryId: 251), + (id: 27, cname: "埃及", countryId: 20), + (id: 26, cname: "阿塞拜疆", countryId: 994), + (id: 25, cname: "阿曼", countryId: 968), + (id: 24, cname: "阿联酋", countryId: 971), + (id: 23, cname: "阿根廷", countryId: 54), + (id: 22, cname: "阿富汗", countryId: 93), + (id: 21, cname: "阿尔及利亚", countryId: 213), + (id: 20, cname: "阿尔巴尼亚", countryId: 355), + (id: 30, cname: "爱沙尼亚", countryId: 372), + (id: 31, cname: "安道尔", countryId: 376), + (id: 41, cname: "巴拿马", countryId: 507), + (id: 40, cname: "巴林", countryId: 973), + (id: 39, cname: "巴拉圭", countryId: 595), + (id: 38, cname: "巴基斯坦", countryId: 92), + (id: 37, cname: "巴哈马群岛", countryId: 1242), + (id: 36, cname: "巴布亚新几内亚", countryId: 675), + (id: 35, cname: "巴巴多斯", countryId: 1246), + (id: 34, cname: "奥地利", countryId: 43), + (id: 33, cname: "安提瓜岛和巴布达", countryId: 1268), + (id: 32, cname: "安哥拉", countryId: 244), + (id: 68, cname: "非洲中部", countryId: 236), + (id: 117, cname: "罗马尼亚", countryId: 40), + (id: 104, cname: "科威特", countryId: 965), + (id: 103, cname: "科摩罗", countryId: 269), + (id: 102, cname: "开曼群岛", countryId: 1345), + (id: 101, cname: "卡塔尔", countryId: 974), + (id: 100, cname: "喀麦隆", countryId: 237), + (id: 99, cname: "聚会岛", countryId: 262), + (id: 98, cname: "津巴布韦", countryId: 263), + (id: 97, cname: "捷克", countryId: 420), + (id: 96, cname: "柬埔寨", countryId: 855), + (id: 95, cname: "加蓬", countryId: 241), + (id: 105, cname: "克罗地亚", countryId: 385), + (id: 106, cname: "肯尼亚", countryId: 254), + (id: 116, cname: "卢旺达", countryId: 250), + (id: 115, cname: "卢森堡", countryId: 352), + (id: 114, cname: "利比亚", countryId: 218), + (id: 113, cname: "利比里亚", countryId: 231), + (id: 112, cname: "立陶宛", countryId: 370), + (id: 111, cname: "黎巴嫩", countryId: 961), + (id: 110, cname: "老挝", countryId: 856), + (id: 109, cname: "莱索托", countryId: 266), + (id: 108, cname: "拉脱维亚", countryId: 371), + (id: 107, cname: "库克岛", countryId: 682), + (id: 94, cname: "加纳", countryId: 233), + (id: 93, cname: "几内亚比绍", countryId: 245), + (id: 92, cname: "几内亚", countryId: 224), + (id: 79, cname: "格林纳达", countryId: 1473), + (id: 78, cname: "哥斯达黎加", countryId: 506), + (id: 77, cname: "哥伦比亚", countryId: 57), + (id: 76, cname: "刚果(金)", countryId: 243), + (id: 75, cname: "刚果", countryId: 242), + (id: 74, cname: "冈比亚", countryId: 220), + (id: 73, cname: "福克兰岛", countryId: 500), + (id: 72, cname: "佛得角", countryId: 238), + (id: 71, cname: "芬兰", countryId: 358), + (id: 70, cname: "斐济", countryId: 679), + (id: 80, cname: "格陵兰岛", countryId: 299), + (id: 81, cname: "古巴", countryId: 53), + (id: 91, cname: "吉尔吉斯斯坦", countryId: 996), + (id: 90, cname: "吉布提", countryId: 253), + (id: 89, cname: "基里巴斯", countryId: 686), + (id: 88, cname: "维克岛", countryId: 1808), + (id: 87, cname: "洪都拉斯", countryId: 504), + (id: 86, cname: "荷兰", countryId: 31), + (id: 85, cname: "朝鲜", countryId: 850), + (id: 84, cname: "海地", countryId: 509), + (id: 83, cname: "关岛", countryId: 1671), + (id: 82, cname: "瓜德罗普岛", countryId: 590), + (id: 69, cname: "菲律宾", countryId: 63), ]; } diff --git a/lib/http/common.dart b/lib/http/common.dart deleted file mode 100644 index 952d048cd..000000000 --- a/lib/http/common.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:PiliPlus/http/api.dart'; -import 'package:PiliPlus/http/init.dart'; - -class CommonHttp { - static Future unReadDynamic() async { - var res = await Request().get( - Api.getUnreadDynamic, - queryParameters: { - 'alltype_offset': 0, - 'video_offset': 0, - 'article_offset': 0, - }, - ); - if (res.data['code'] == 0) { - return { - 'status': true, - 'data': res.data['data']['update_info']['item']['count'], - }; - } else { - return { - 'status': false, - 'msg': res.data['message'], - }; - } - } -} diff --git a/lib/http/login.dart b/lib/http/login.dart index 8b7ced525..742753db4 100644 --- a/lib/http/login.dart +++ b/lib/http/login.dart @@ -30,7 +30,8 @@ class LoginHttp { 'content-type': 'application/x-www-form-urlencoded; charset=utf-8', }; - static Future> getHDcode() async { + static Future> + getHDcode() async { var params = { // 'local_id': 'Y952A395BB157D305D8A8340FC2AAECECE17', 'local_id': '0', @@ -42,9 +43,14 @@ class LoginHttp { var res = await Request().post(Api.getTVCode, queryParameters: params); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + try { + final Map data = res.data['data']; + return Success((authCode: data['auth_code'], url: data['url'])); + } catch (e) { + return Error(e.toString()); + } } else { - return {'status': false, 'msg': res.data['message']}; + return Error(res.data['message']); } } @@ -88,7 +94,7 @@ class LoginHttp { } static Future sendSmsCode({ - required String cid, + required Object cid, required String tel, // String? deviceTouristId, String? geeChallenge, @@ -264,11 +270,11 @@ class LoginHttp { required String captchaKey, required String tel, required String code, - required String cid, + required Object cid, required String key, }) async { dynamic publicKey = RSAKeyParser().parse(key); - Map data = { + Map data = { 'bili_local_id': deviceId, 'build': '2001100', 'buvid': buvid, @@ -297,7 +303,7 @@ class LoginHttp { 's_locale': 'zh_CN', 'statistics': Constants.statistics, 'tel': tel, - 'ts': (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString(), + 'ts': DateTime.now().millisecondsSinceEpoch ~/ 1000, }; AppSign.appSign(data); var res = await Request().post( diff --git a/lib/main.dart b/lib/main.dart index 176bf1ff2..f1358329b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -45,9 +45,10 @@ void main() async { Get.lazyPut(AccountService.new); HttpOverrides.global = _CustomHttpOverrides(); - await Future.wait([ - CacheManage.autoClearCache(), - if (Utils.isMobile) ...[ + CacheManage.autoClearCache(); + + if (Utils.isMobile) { + await Future.wait([ SystemChrome.setPreferredOrientations( [ DeviceOrientation.portraitUp, @@ -58,8 +59,8 @@ void main() async { ], ), setupServiceLocator(), - ], - ]); + ]); + } Request(); Request.setCookie(); @@ -92,18 +93,8 @@ void main() async { title: Constants.appName, ); windowManager.waitUntilReadyToShow(windowOptions, () async { - final windowSize = Pref.windowSize; - final windowOffset = await Utils.windowOffset; - final bounds = Rect.fromLTWH( - windowOffset.left, - windowOffset.top, - windowSize[0], - windowSize[1], - ); - await windowManager.setBounds(bounds); - if (Pref.isWindowMaximized) { - await windowManager.maximize(); - } + await windowManager.setBounds(await Utils.windowOffset & Pref.windowSize); + if (Pref.isWindowMaximized) await windowManager.maximize(); await windowManager.show(); await windowManager.focus(); }); @@ -171,7 +162,9 @@ class MyApp extends StatelessWidget { late List modes; FlutterDisplayMode.supported.then((value) { modes = value; - var storageDisplay = GStorage.setting.get(SettingBoxKey.displayMode); + final String? storageDisplay = GStorage.setting.get( + SettingBoxKey.displayMode, + ); DisplayMode? displayMode; if (storageDisplay != null) { displayMode = modes.firstWhereOrNull( diff --git a/lib/models_new/live/live_superchat/item.dart b/lib/models_new/live/live_superchat/item.dart index e046cbd7d..c533a80dd 100644 --- a/lib/models_new/live/live_superchat/item.dart +++ b/lib/models_new/live/live_superchat/item.dart @@ -2,8 +2,8 @@ import 'package:PiliPlus/models_new/live/live_superchat/user_info.dart'; import 'package:PiliPlus/utils/utils.dart'; class SuperChatItem { - dynamic id; - dynamic uid; + int id; + int? uid; int? price; String backgroundColor; String backgroundBottomColor; @@ -15,7 +15,7 @@ class SuperChatItem { bool expired = false; SuperChatItem({ - this.id, + required this.id, required this.uid, this.price, required this.backgroundColor, @@ -28,7 +28,7 @@ class SuperChatItem { }); factory SuperChatItem.fromJson(Map json) => SuperChatItem( - id: json['id'] ?? Utils.generateRandomString(8), + id: json['id'] ?? Utils.random.nextInt(2147483647), uid: json['uid'], price: json['price'] as int?, backgroundColor: json['background_color'] ?? '#EDF5FF', diff --git a/lib/pages/danmaku/view.dart b/lib/pages/danmaku/view.dart index 9c0a6bad4..b0b6ea45d 100644 --- a/lib/pages/danmaku/view.dart +++ b/lib/pages/danmaku/view.dart @@ -105,6 +105,7 @@ class _PlDanmakuState extends State { List? currentDanmakuList = _plDanmakuController .getCurrentDanmaku(currentPosition); if (currentDanmakuList != null) { + final blockColorful = playerController.blockColorful; for (DanmakuElem e in currentDanmakuList) { if (e.mode == 7) { try { @@ -120,7 +121,7 @@ class _PlDanmakuState extends State { _controller!.addDanmaku( DanmakuContentItem( e.content, - color: playerController.blockColorful + color: blockColorful ? Colors.white : DmUtils.decimalToColor(e.color), type: DmUtils.getPosition(e.mode), diff --git a/lib/pages/later/view.dart b/lib/pages/later/view.dart index 2a4298d09..d179bce31 100644 --- a/lib/pages/later/view.dart +++ b/lib/pages/later/view.dart @@ -30,8 +30,8 @@ class _LaterPageState extends State LaterController currCtr([int? index]) { final type = LaterViewType.values[index ?? _tabController.index]; - return Get.put( - LaterController(type), + return Get.putOrFind( + () => LaterController(type), tag: type.type.toString(), ); } diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 07ccb2159..2abec9b68 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -241,7 +241,7 @@ class LiveRoomController extends GetxController { Future getSuperChatMsg() async { final res = await LiveHttp.superChatMsg(roomId); - if (res.dataOrNull?.list case List list) { + if (res.dataOrNull?.list case final list?) { superChatMsg.addAll(list); } } @@ -377,7 +377,7 @@ class LiveRoomController extends GetxController { } } break; - case 'SUPER_CHAT_MESSAGE' when (showSuperChat): + case 'SUPER_CHAT_MESSAGE' when showSuperChat: final item = SuperChatItem.fromJson(obj['data']); superChatMsg.insert(0, item); if (isFullScreen || plPlayerController.isDesktopPip) { @@ -385,10 +385,8 @@ class LiveRoomController extends GetxController { } break; } - } catch (e) { - if (kDebugMode) { - debugPrint('$e,,$obj'); - } + } catch (_) { + if (kDebugMode) rethrow; } }) ..init(); diff --git a/lib/pages/live_room/superchat/superchat_card.dart b/lib/pages/live_room/superchat/superchat_card.dart index d93287028..bd5356538 100644 --- a/lib/pages/live_room/superchat/superchat_card.dart +++ b/lib/pages/live_room/superchat/superchat_card.dart @@ -43,9 +43,7 @@ class _SuperChatCardState extends State { } void _remove() { - WidgetsBinding.instance.addPostFrameCallback( - (_) => Future.delayed(const Duration(seconds: 1), _onRemove), - ); + Future.delayed(const Duration(seconds: 1), _onRemove); } void _onRemove() { diff --git a/lib/pages/live_room/superchat/superchat_panel.dart b/lib/pages/live_room/superchat/superchat_panel.dart index f2bfb3b43..d996cc684 100644 --- a/lib/pages/live_room/superchat/superchat_panel.dart +++ b/lib/pages/live_room/superchat/superchat_panel.dart @@ -30,10 +30,16 @@ class _SuperChatPanelState extends DebounceStreamState padding: const EdgeInsets.symmetric(horizontal: 12), physics: const ClampingScrollPhysics(), itemCount: widget.controller.superChatMsg.length, + findChildIndexCallback: (key) { + final index = widget.controller.superChatMsg.indexWhere( + (i) => i.id == (key as ValueKey).value, + ); + return index == -1 ? null : index; + }, itemBuilder: (context, index) { final item = widget.controller.superChatMsg[index]; return SuperChatCard( - key: Key(item.id.toString()), + key: ValueKey(item.id), item: item, onRemove: () => ctr?.add(true), ); diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 221477385..5b80171b2 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -265,7 +265,7 @@ class _LiveRoomPageState extends State child: TextButton( onPressed: () { _liveRoomController.fsSC.value = SuperChatItem.fromJson({ - "id": Utils.generateRandomString(8), + "id": Utils.random.nextInt(2147483647), "price": 66, "end_time": DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, @@ -300,7 +300,7 @@ class _LiveRoomPageState extends State } try { return SizedBox( - key: Key(item.id.toString()), + key: ValueKey(item.id), width: 255, child: Stack( clipBehavior: Clip.none, @@ -330,6 +330,7 @@ class _LiveRoomPageState extends State ), ); } catch (_) { + if (kDebugMode) rethrow; return const SizedBox.shrink(); } }), @@ -740,7 +741,7 @@ class _LiveRoomPageState extends State liveRoomController: _liveRoomController, ); return Padding( - padding: EdgeInsets.only(bottom: 12, top: !isPortrait ? 0 : 12), + padding: EdgeInsets.only(bottom: 12, top: isPortrait ? 12 : 0), child: _liveRoomController.showSuperChat ? PageView( key: pageKey, diff --git a/lib/pages/live_room/widgets/chat_panel.dart b/lib/pages/live_room/widgets/chat_panel.dart index 1e0d486b0..e8604c7e9 100644 --- a/lib/pages/live_room/widgets/chat_panel.dart +++ b/lib/pages/live_room/widgets/chat_panel.dart @@ -87,7 +87,7 @@ class LiveRoomChatPanel extends StatelessWidget { liveRoomController.superChatMsg.insert( 0, SuperChatItem.fromJson({ - "id": Utils.generateRandomString(8), + "id": Utils.random.nextInt(2147483647), "price": 66, "end_time": DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, diff --git a/lib/pages/login/controller.dart b/lib/pages/login/controller.dart index 7b61e1afd..b8e6587e8 100644 --- a/lib/pages/login/controller.dart +++ b/lib/pages/login/controller.dart @@ -5,6 +5,7 @@ import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/common/widgets/button/icon_button.dart'; import 'package:PiliPlus/common/widgets/radio_widget.dart'; import 'package:PiliPlus/http/init.dart'; +import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/login.dart'; import 'package:PiliPlus/models/common/account_type.dart'; import 'package:PiliPlus/models/login/model.dart'; @@ -26,7 +27,8 @@ class LoginPageController extends GetxController final TextEditingController smsCodeTextController = TextEditingController(); final TextEditingController cookieTextController = TextEditingController(); - late final RxMap codeInfo = RxMap({}); + late final codeInfo = + LoadingState<({String authCode, String url})>.loading().obs; late final TabController tabController; @@ -36,10 +38,7 @@ class LoginPageController extends GetxController late final RxInt qrCodeLeftTime = 180.obs; late final RxString statusQRCode = ''.obs; - late final List> internationalDialingPrefix = - Constants.internationalDialingPrefix; - late Map selectedCountryCodeId = - internationalDialingPrefix.first; + late var selectedCountryCodeId = Constants.internationalDialingPrefix.first; late String captchaKey = ''; late final RxInt smsSendCooldown = 0.obs; late int smsSendTimestamp = 0; @@ -48,6 +47,8 @@ class LoginPageController extends GetxController Timer? qrCodeTimer; Timer? smsSendCooldownTimer; + bool _isReq = false; + @override void onInit() { super.onInit(); @@ -70,46 +71,47 @@ class LoginPageController extends GetxController super.onClose(); } - void refreshQRCode() { - LoginHttp.getHDcode().then((res) { - if (res['status']) { - qrCodeTimer?.cancel(); - codeInfo.addAll(res); - qrCodeTimer = Timer.periodic(const Duration(milliseconds: 1000), (t) { - qrCodeLeftTime.value = 180 - t.tick; - if (qrCodeLeftTime <= 0) { - t.cancel(); - statusQRCode.value = '二维码已过期,请刷新'; - qrCodeLeftTime.value = 0; - return; - } + Future refreshQRCode() async { + final res = await LoginHttp.getHDcode(); + if (res.isSuccess) { + qrCodeTimer?.cancel(); + codeInfo.value = res; + qrCodeTimer = Timer.periodic(const Duration(milliseconds: 1000), (t) { + final left = 180 - t.tick; + if (left <= 0) { + t.cancel(); + statusQRCode.value = '二维码已过期,请刷新'; + qrCodeLeftTime.value = 0; + return; + } + qrCodeLeftTime.value = left; + if (_isReq || tabController.index != 2) return; - LoginHttp.codePoll(codeInfo['data']['auth_code']).then((value) async { - if (value['status']) { - t.cancel(); - statusQRCode.value = '扫码成功'; - await setAccount( - value['data'], - value['data']['cookie_info']['cookies'], - ); - Get.back(); - } else if (value['code'] == 86038) { - t.cancel(); - qrCodeLeftTime.value = 0; - } else { - statusQRCode.value = value['msg']; - } - }); + _isReq = true; + LoginHttp.codePoll(res.data.authCode).then((value) async { + _isReq = false; + if (value['status']) { + t.cancel(); + statusQRCode.value = '扫码成功'; + await setAccount( + value['data'], + value['data']['cookie_info']['cookies'], + ); + Get.back(); + } else if (value['code'] == 86038) { + t.cancel(); + qrCodeLeftTime.value = 0; + } else { + statusQRCode.value = value['msg']; + } }); - } else { - SmartDialog.showToast(res['msg']); - } - }); + }); + } } void _handleTabChange() { if (tabController.index == 2) { - if (qrCodeTimer == null || qrCodeTimer!.isActive == false) { + if (qrCodeTimer == null || !qrCodeTimer!.isActive) { refreshQRCode(); } } @@ -545,7 +547,7 @@ class LoginPageController extends GetxController tel: telTextController.text, code: smsCodeTextController.text, captchaKey: captchaKey, - cid: selectedCountryCodeId['country_id'], + cid: selectedCountryCodeId.countryId, key: key, ); if (res['status']) { @@ -608,7 +610,7 @@ class LoginPageController extends GetxController var res = await LoginHttp.sendSmsCode( tel: telTextController.text, - cid: selectedCountryCodeId['country_id'], + cid: selectedCountryCodeId.countryId, // deviceTouristId: guestId, geeValidate: captchaData.validate, geeSeccode: captchaData.seccode, diff --git a/lib/pages/login/view.dart b/lib/pages/login/view.dart index 555a878c0..607646932 100644 --- a/lib/pages/login/view.dart +++ b/lib/pages/login/view.dart @@ -1,17 +1,21 @@ import 'dart:ui'; import 'package:PiliPlus/common/constants.dart'; +import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart'; import 'package:PiliPlus/common/widgets/scroll_physics.dart'; +import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/pages/login/controller.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart' hide ContextExtensionss; import 'package:pretty_qr_code/pretty_qr_code.dart'; +import 'package:url_launcher/url_launcher.dart'; class LoginPage extends StatefulWidget { const LoginPage({super.key}); @@ -25,7 +29,7 @@ class _LoginPageState extends State { // 二维码生成时间 bool showPassword = false; GlobalKey globalKey = GlobalKey(); - final isMobile = Utils.isMobile; + bool get isMobile => kDebugMode || Utils.isMobile; Widget loginByQRCode(ThemeData theme) { return Column( @@ -70,35 +74,48 @@ class _LoginPageState extends State { icon: const Icon(Icons.save), label: const Text('保存至相册'), ), + if (isMobile) + TextButton.icon( + onPressed: () => launchUrl( + Uri.parse(_loginPageCtr.codeInfo.value.data.url), + mode: LaunchMode.externalNonBrowserApplication, + ), + icon: const Icon(Icons.open_in_browser_outlined), + label: const Text('其他应用打开'), + ), ], ), RepaintBoundary( key: globalKey, child: Obx(() { - if (_loginPageCtr.codeInfo['data']?['url'] == null) { - return Container( + return switch (_loginPageCtr.codeInfo.value) { + Loading() => Container( height: 200, width: 200, alignment: Alignment.center, child: const CircularProgressIndicator( semanticsLabel: '二维码加载中', ), - ); - } - return Container( - width: 200, - height: 200, - color: Colors.white, - padding: const EdgeInsets.all(8), - child: PrettyQrView.data( - data: _loginPageCtr.codeInfo['data']!['url']!, - decoration: const PrettyQrDecoration( - shape: PrettyQrSquaresSymbol( - color: Colors.black87, + ), + Success(:var response) => Container( + width: 200, + height: 200, + color: Colors.white, + padding: const EdgeInsets.all(8), + child: PrettyQrView.data( + data: response.url, + decoration: const PrettyQrDecoration( + shape: PrettyQrSquaresSymbol( + color: Colors.black87, + ), ), ), ), - ); + Error(:var errMsg) => errorWidget( + errMsg: errMsg, + onReload: _loginPageCtr.refreshQRCode, + ), + }; }), ), const SizedBox(height: 10), @@ -109,21 +126,27 @@ class _LoginPageState extends State { ), ), Obx( - () => GestureDetector( - onTap: () => Utils.copyText( - _loginPageCtr.codeInfo['data']?['url'] ?? '', - toastText: '已复制到剪贴板,可粘贴至已登录的app私信处发送,然后点击已发送的链接打开', - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), - child: Text( - _loginPageCtr.codeInfo['data']?['url'] ?? "", - style: theme.textTheme.labelSmall!.copyWith( - color: theme.colorScheme.onSurface.withValues(alpha: 0.4), + () { + final url = _loginPageCtr.codeInfo.value.dataOrNull?.url ?? ''; + return GestureDetector( + onTap: () => Utils.copyText( + url, + toastText: '已复制到剪贴板,可粘贴至已登录的app私信处发送,然后点击已发送的链接打开', + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 20, + ), + child: Text( + url, + style: theme.textTheme.labelSmall!.copyWith( + color: theme.colorScheme.onSurface.withValues(alpha: 0.4), + ), ), ), - ), - ), + ); + }, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), @@ -349,34 +372,31 @@ class _LoginPageState extends State { const SizedBox(width: 12), Builder( builder: (context) { - return PopupMenuButton>( + return PopupMenuButton( enabled: isMobile, padding: EdgeInsets.zero, tooltip: '选择国际冠码,' - '当前为${_loginPageCtr.selectedCountryCodeId['cname']},' - '+${_loginPageCtr.selectedCountryCodeId['country_id']}', - onSelected: (Map type) {}, + '当前为${_loginPageCtr.selectedCountryCodeId.cname},' + '+${_loginPageCtr.selectedCountryCodeId.countryId}', + onSelected: (item) { + _loginPageCtr.selectedCountryCodeId = item; + (context as Element).markNeedsBuild(); + }, initialValue: _loginPageCtr.selectedCountryCodeId, - itemBuilder: (_) => _loginPageCtr - .internationalDialingPrefix - .map((Map item) { - return PopupMenuItem>( - onTap: () { - _loginPageCtr.selectedCountryCodeId = item; - (context as Element).markNeedsBuild(); - }, + itemBuilder: (_) => + Constants.internationalDialingPrefix.map((item) { + return PopupMenuItem( value: item, child: Row( children: [ - Text(item['cname']), + Text(item.cname), const Spacer(), - Text("+${item['country_id']}"), + Text("+${item.countryId}"), ], ), ); - }) - .toList(), + }).toList(), child: Row( children: [ Icon( @@ -385,7 +405,7 @@ class _LoginPageState extends State { ), const SizedBox(width: 12), Text( - "+${_loginPageCtr.selectedCountryCodeId['country_id']}", + "+${_loginPageCtr.selectedCountryCodeId.countryId}", ), ], ), diff --git a/lib/pages/popular_series/view.dart b/lib/pages/popular_series/view.dart index ef8a9f53b..632a2a0f2 100644 --- a/lib/pages/popular_series/view.dart +++ b/lib/pages/popular_series/view.dart @@ -57,10 +57,10 @@ class _PopularSeriesPageState extends State with GridMixin { return gridSkeleton; case Success?>(:var response): Widget sliver; - if (response?.isNotEmpty == true) { + if (response != null && response.isNotEmpty == true) { sliver = SliverGrid.builder( gridDelegate: gridDelegate, - itemCount: response!.length, + itemCount: response.length, itemBuilder: (context, index) { final item = response[index]; return VideoCardH( @@ -126,7 +126,6 @@ class _PopularSeriesPageState extends State with GridMixin { showDialog( context: context, builder: (context) { - final theme = Theme.of(context); return Dialog( clipBehavior: Clip.hardEdge, child: SizedBox( @@ -140,39 +139,27 @@ class _PopularSeriesPageState extends State with GridMixin { itemBuilder: (context, index) { final item = seriesList[index]; final isCurr = index == currIndex; - Widget child = Text( - item.name!, - style: const TextStyle(fontSize: 14), - ); - if (isCurr) { - child = Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - child, - const Icon(Icons.check, size: 18), - ], - ); - } - return Material( - color: isCurr ? theme.highlightColor : null, - child: InkWell( - onTap: () { - Get.back(); - if (!isCurr) { - _controller - ..number = item.number! - ..onReload(); - } - }, - child: Padding( - padding: const EdgeInsetsGeometry.symmetric( - horizontal: 16, - ), - child: Align( - alignment: Alignment.centerLeft, - child: child, - ), - ), + return ListTile( + dense: true, + minTileHeight: 44, + selected: isCurr, + onTap: () { + Get.back(); + if (!isCurr) { + _controller + ..number = item.number! + ..onReload(); + } + }, + title: Text( + item.name!, + style: const TextStyle(fontSize: 14), + ), + trailing: isCurr + ? const Icon(Icons.check, size: 18) + : null, + contentPadding: const EdgeInsetsGeometry.symmetric( + horizontal: 16, ), ); }, diff --git a/lib/pages/video/note/controller.dart b/lib/pages/video/note/controller.dart index 15be56d5d..63fbe2194 100644 --- a/lib/pages/video/note/controller.dart +++ b/lib/pages/video/note/controller.dart @@ -7,9 +7,8 @@ import 'package:get/get.dart'; class NoteListPageCtr extends CommonListController { - NoteListPageCtr({this.oid, this.upperMid}); - final dynamic oid; - final dynamic upperMid; + NoteListPageCtr({required this.oid}); + final int oid; RxInt count = (-1).obs; @@ -37,7 +36,6 @@ class NoteListPageCtr Future> customGetData() => VideoHttp.getVideoNoteList( oid: oid, - uperMid: upperMid, page: page, ); } diff --git a/lib/pages/video/note/view.dart b/lib/pages/video/note/view.dart index 43b2f0308..035bf49fa 100644 --- a/lib/pages/video/note/view.dart +++ b/lib/pages/video/note/view.dart @@ -20,17 +20,15 @@ class NoteListPage extends CommonSlidePage { super.key, super.enableSlide, required this.heroTag, - this.oid, - this.upperMid, + required this.oid, required this.isStein, required this.title, }); - final dynamic heroTag; - final dynamic oid; - final dynamic upperMid; + final String? heroTag; + final int oid; final bool isStein; - final dynamic title; + final String? title; @override State createState() => _NoteListPageState(); @@ -39,7 +37,7 @@ class NoteListPage extends CommonSlidePage { class _NoteListPageState extends State with SingleTickerProviderStateMixin, CommonSlideMixin { late final _controller = Get.put( - NoteListPageCtr(oid: widget.oid, upperMid: widget.upperMid), + NoteListPageCtr(oid: widget.oid), tag: widget.heroTag, ); diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 3f3755ecc..4d9bc041a 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -343,8 +343,8 @@ class PlPlayerController { late int subtitlePaddingH = Pref.subtitlePaddingH; late int subtitlePaddingB = Pref.subtitlePaddingB; late double subtitleBgOpaticy = Pref.subtitleBgOpaticy; - late bool showVipDanmaku = Pref.showVipDanmaku; - late bool showSpecialDanmaku = Pref.showSpecialDanmaku; + final bool showVipDanmaku = Pref.showVipDanmaku; // loop unswitching + final bool showSpecialDanmaku = Pref.showSpecialDanmaku; late double subtitleStrokeWidth = Pref.subtitleStrokeWidth; late int subtitleFontWeight = Pref.subtitleFontWeight; diff --git a/lib/utils/accounts/account_manager/account_mgr.dart b/lib/utils/accounts/account_manager/account_mgr.dart index 14d4dc329..bd85ce582 100644 --- a/lib/utils/accounts/account_manager/account_mgr.dart +++ b/lib/utils/accounts/account_manager/account_mgr.dart @@ -55,6 +55,25 @@ class AccountManager extends Interceptor { Api.searchByType, Api.dynSearch, Api.searchArchive, + + // Api.memberInfo, + // Api.bgmDetail, + // Api.space, + // Api.spaceAudio, + // Api.spaceComic, + // Api.spaceArchive, + // Api.spaceChargingArchive, + // Api.spaceSeason, + // Api.spaceSeries, + // Api.spaceBangumi, + // Api.spaceOpus, + // Api.spaceFav, + // Api.seasonSeries, + // Api.matchInfo, + // Api.articleList, + // Api.opusDetail, + // Api.articleView, + // Api.articleInfo, }, AccountType.recommend: { Api.recommendListWeb, @@ -81,6 +100,11 @@ class AccountManager extends Interceptor { Api.liveSecondList, Api.liveRoomAreaList, Api.liveSearch, + Api.videoRelation, + Api.bgmRecommend, + Api.dynTopicRcmd, + Api.topicFeed, + Api.topicTop, }, // progress AccountType.video: { diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 5a90bf408..a0fbdc0a6 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -748,12 +748,12 @@ abstract class PiliScheme { return false; case 'video': // if (kDebugMode) debugPrint('投稿'); - final Map map = IdUtils.matchAvorBv(input: path); - if (map.isNotEmpty) { + final res = IdUtils.matchAvorBv(input: path); + if (res.isNotEmpty) { final queryParameters = uri.queryParameters; videoPush( - map['AV'], - map['BV'], + res.av, + res.bv, off: off, progress: queryParameters['dm_progress'], part: queryParameters['p'], @@ -910,11 +910,11 @@ abstract class PiliScheme { launchURL(); return false; default: - Map map = IdUtils.matchAvorBv(input: area?.split('?').first); - if (map.isNotEmpty) { + final res = IdUtils.matchAvorBv(input: area?.split('?').first); + if (res.isNotEmpty) { videoPush( - map['AV'], - map['BV'], + res.av, + res.bv, off: off, ); return true; diff --git a/lib/utils/cache_manage.dart b/lib/utils/cache_manage.dart index 3d2811897..61bed5b96 100644 --- a/lib/utils/cache_manage.dart +++ b/lib/utils/cache_manage.dart @@ -8,7 +8,9 @@ import 'package:path_provider/path_provider.dart'; abstract class CacheManage { // 获取缓存目录 - static Future loadApplicationCache() async { + static Future loadApplicationCache([ + final num maxSize = double.infinity, + ]) async { /// clear all of image in memory // clearMemoryImageCache(); /// get ImageCache @@ -20,55 +22,39 @@ abstract class CacheManage { if (Utils.isDesktop) { final dir = Directory('${tempDirectory.path}/libCachedImageData'); if (dir.existsSync()) { - return await getTotalSizeOfFilesInDir(dir); + return await getTotalSizeOfFilesInDir(dir, maxSize); } else { return 0; } } - // get_storage directory - Directory docDirectory = await getApplicationDocumentsDirectory(); - int cacheSize = 0; // 获取缓存大小 if (tempDirectory.existsSync()) { - cacheSize += await getTotalSizeOfFilesInDir(tempDirectory); + return await getTotalSizeOfFilesInDir(tempDirectory, maxSize); } - /// 获取缓存大小 dioCache - if (docDirectory.existsSync()) { - String dioCacheFileName = - '${docDirectory.path}${Platform.pathSeparator}DioCache.db'; - var dioCacheFile = File(dioCacheFileName); - if (dioCacheFile.existsSync()) { - cacheSize += await getTotalSizeOfFilesInDir(dioCacheFile); - } - } - - return cacheSize; + return 0; } - // 循环计算文件的大小(递归) + // 循环计算文件的大小 static Future getTotalSizeOfFilesInDir( - final FileSystemEntity file, - ) async { - if (file is File) { - int length = await file.length(); - return int.parse(length.toString()); - } - if (file is Directory) { - final List children = file.listSync(); - int total = 0; - for (final FileSystemEntity child in children) { - total += await getTotalSizeOfFilesInDir(child); + final Directory file, [ + final num maxSize = double.infinity, + ]) async { + final children = file.list(recursive: true); + int total = 0; + await for (final child in children) { + if (child is File) { + total += await child.length(); + if (total >= maxSize) break; } - return total; } - return 0; + return total; } // 缓存大小格式转换 static String formatSize(num value) { - List unitArr = const ['B', 'K', 'M', 'G', 'T', 'P']; + const unitArr = ['B', 'K', 'M', 'G', 'T', 'P']; int index = 0; while (value >= 1024) { index++; @@ -78,19 +64,6 @@ abstract class CacheManage { return size + unitArr.getOrElse(index, orElse: () => ''); } - /// 清除 Documents 目录下的 DioCache.db - static Future clearApplicationCache() async { - Directory directory = await getApplicationDocumentsDirectory(); - if (directory.existsSync()) { - String dioCacheFileName = - '${directory.path}${Platform.pathSeparator}DioCache.db'; - var dioCacheFile = File(dioCacheFileName); - if (dioCacheFile.existsSync()) { - dioCacheFile.delete(); - } - } - } - // 清除 Library/Caches 目录及文件缓存 static Future clearLibraryCache() async { var tempDirectory = await getTemporaryDirectory(); @@ -103,33 +76,20 @@ abstract class CacheManage { } if (tempDirectory.existsSync()) { // await appDocDir.delete(recursive: true); - final List children = tempDirectory.listSync( - recursive: false, - ); - for (final FileSystemEntity file in children) { + final children = tempDirectory.list(recursive: false); + await for (final file in children) { await file.delete(recursive: true); } } } - /// 递归方式删除目录及文件 - static Future deleteDirectory(FileSystemEntity file) async { - if (file is Directory) { - final List children = file.listSync(); - for (final FileSystemEntity child in children) { - await deleteDirectory(child); - } - } - await file.delete(); - } - static Future autoClearCache() async { if (Pref.autoClearCache) { await clearLibraryCache(); } else { final maxCacheSize = Pref.maxCacheSize; if (maxCacheSize != 0) { - final currCache = await loadApplicationCache(); + final currCache = await loadApplicationCache(maxCacheSize); if (currCache >= maxCacheSize) { await clearLibraryCache(); } diff --git a/lib/utils/id_utils.dart b/lib/utils/id_utils.dart index 490dfa00e..6ed01486b 100644 --- a/lib/utils/id_utils.dart +++ b/lib/utils/id_utils.dart @@ -15,9 +15,9 @@ abstract class IdUtils { 'FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf'; static final invData = {for (var (i, c) in data.codeUnits.indexed) c: i}; - static final bvRegex = RegExp(r'bv[0-9a-zA-Z]{10}', caseSensitive: false); + static final bvRegex = RegExp(r'bv1[0-9a-zA-Z]{9}', caseSensitive: false); static final bvRegexExact = RegExp( - r'^bv[0-9a-zA-Z]{10}$', + r'^bv1[0-9a-zA-Z]{9}$', caseSensitive: false, ); static final avRegex = RegExp(r'av(\d+)', caseSensitive: false); @@ -54,26 +54,25 @@ abstract class IdUtils { swap(bvidArr, 4, 7); bvidArr.removeRange(0, 3); - int tmp = bvidArr.fold(0, (pre, char) => pre * BASE + invData[char]!); - return ((tmp & MASK_CODE) ^ XOR_CODE).toInt(); + final tmp = bvidArr.fold(0, (pre, char) => pre * BASE + invData[char]!); + return (tmp & MASK_CODE) ^ XOR_CODE; } // 匹配 - static Map matchAvorBv({String? input}) { - final Map result = {}; + static AvBvRes matchAvorBv({String? input}) { if (input == null || input.isEmpty) { - return result; + return const (av: null, bv: null); } String? bvid = bvRegex.firstMatch(input)?.group(0); late String? aid = avRegex.firstMatch(input)?.group(1); if (bvid != null) { - result['BV'] = bvid; + return (av: null, bv: bvid); } else if (aid != null) { - result['AV'] = int.parse(aid); + return (av: int.parse(aid), bv: null); } - return result; + return const (av: null, bv: null); } static String genBuvid3() { @@ -114,3 +113,9 @@ abstract class IdUtils { return '${randomTraceId.toString()}:${randomTraceId.toString().substring(16, 32)}:0:0'; } } + +typedef AvBvRes = ({int? av, String? bv}); + +extension AvBvExt on AvBvRes { + bool get isNotEmpty => this != const (av: null, bv: null); +} diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 5e6a29156..2ade7a1e8 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -24,33 +24,36 @@ abstract class GStorage { final String path = dir.path; await Hive.initFlutter('$path/hive'); regAdapter(); - // 登录用户信息 - userInfo = await Hive.openBox( - 'userInfo', - compactionStrategy: (int entries, int deletedEntries) { - return deletedEntries > 2; - }, - ); - // 本地缓存 - localCache = await Hive.openBox( - 'localCache', - compactionStrategy: (int entries, int deletedEntries) { - return deletedEntries > 4; - }, - ); - // 设置 - setting = await Hive.openBox('setting'); - // 搜索历史 - historyWord = await Hive.openBox( - 'historyWord', - compactionStrategy: (int entries, int deletedEntries) { - return deletedEntries > 10; - }, - ); - // 视频设置 - video = await Hive.openBox('video'); - await Accounts.init(); + await Future.wait([ + // 登录用户信息 + Hive.openBox( + 'userInfo', + compactionStrategy: (int entries, int deletedEntries) { + return deletedEntries > 2; + }, + ).then((res) => userInfo = res), + // 本地缓存 + Hive.openBox( + 'localCache', + compactionStrategy: (int entries, int deletedEntries) { + return deletedEntries > 4; + }, + ).then((res) => localCache = res), + // 设置 + Hive.openBox('setting').then((res) => setting = res), + // 搜索历史 + Hive.openBox( + 'historyWord', + compactionStrategy: (int entries, int deletedEntries) { + return deletedEntries > 10; + }, + ).then((res) => historyWord = res), + // 视频设置 + Hive.openBox('video').then((res) => video = res), + + Accounts.init(), + ]); } static String exportAllSettings() { diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index 8d3e39448..5ca97d30d 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -819,10 +819,10 @@ abstract class Pref { static bool get minimizeOnExit => _setting.get(SettingBoxKey.minimizeOnExit, defaultValue: true); - static List get windowSize => _setting.get( - SettingBoxKey.windowSize, - defaultValue: const [1180.0, 720.0], - ); + static Size get windowSize { + final List? size = _setting.get(SettingBoxKey.windowSize); + return size == null ? const Size(1180.0, 720.0) : Size(size[0], size[1]); + } static List? get windowPosition => _setting.get(SettingBoxKey.windowPosition); diff --git a/lib/utils/update.dart b/lib/utils/update.dart index 28479e876..900ddec25 100644 --- a/lib/utils/update.dart +++ b/lib/utils/update.dart @@ -115,9 +115,9 @@ abstract class Update { static Future onDownload(Map data) async { SmartDialog.dismiss(); try { - void download(plat) { + void download(String plat) { if (data['assets'].isNotEmpty) { - for (dynamic i in data['assets']) { + for (Map i in data['assets']) { if (i['name'].contains(plat)) { PageUtils.launchURL(i['browser_download_url']); return; @@ -132,14 +132,8 @@ abstract class Update { AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo; // [arm64-v8a] download(androidInfo.supportedAbis.first); - } else if (Platform.isIOS) { - download('ios'); - } else if (Platform.isWindows) { - download('windows'); } else { - throw UnsupportedError( - 'unsupported platform: ${Platform.operatingSystem}', - ); + download(Platform.operatingSystem); } } catch (e) { if (kDebugMode) debugPrint('download error: $e'); diff --git a/lib/utils/url_utils.dart b/lib/utils/url_utils.dart index 7573ad8ae..a6155bf99 100644 --- a/lib/utils/url_utils.dart +++ b/lib/utils/url_utils.dart @@ -44,10 +44,10 @@ abstract class UrlUtils { String pathSegment, String redirectUrl, ) async { - final Map matchRes = IdUtils.matchAvorBv(input: pathSegment); + final matchRes = IdUtils.matchAvorBv(input: pathSegment); if (matchRes.isNotEmpty) { - int? aid = matchRes['AV']; - String? bvid = matchRes['BV']; + final aid = matchRes.av; + String? bvid = matchRes.bv; bvid ??= IdUtils.av2bv(aid!); final int? cid = await SearchHttp.ab2c(aid: aid, bvid: bvid); if (cid != null) { diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 4186f06d4..8d8a2ac40 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -28,17 +28,15 @@ abstract class Utils { static final bool isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux; - static Future<({double left, double top})> get windowOffset async { + static Future get windowOffset async { final windowPosition = Pref.windowPosition; if (windowPosition != null) { - return (left: windowPosition[0], top: windowPosition[1]); + return Offset(windowPosition[0], windowPosition[1]); } - final Size windowSize = await windowManager.getSize(); - final Offset position = await calcWindowPosition( - windowSize, + return await calcWindowPosition( + await windowManager.getSize(), Alignment.center, ); - return (left: position.dx, top: position.dy); } static Future get isWiFi async { diff --git a/pubspec.lock b/pubspec.lock index 5c05ae5e9..478d8c70d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1138,8 +1138,8 @@ packages: description: path: "libs/android/media_kit_libs_android_video" ref: "version_1.2.5" - resolved-ref: f89452bc27af26324a83961c8286d4f41432a5f9 - url: "https://github.com/My-Responsitories/media-kit.git" + resolved-ref: "902e962556c0bde4d384cd8f72b814598e5dfcf2" + url: "https://github.com/bggRGjQaUbCoE/media-kit.git" source: git version: "1.3.7" media_kit_libs_ios_video: diff --git a/pubspec.yaml b/pubspec.yaml index d3466c45a..446486554 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -245,7 +245,7 @@ dependency_overrides: font_awesome_flutter: 10.9.0 media_kit_libs_android_video: git: - url: https://github.com/My-Responsitories/media-kit.git + url: https://github.com/bggRGjQaUbCoE/media-kit.git path: libs/android/media_kit_libs_android_video ref: version_1.2.5