Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #107 from CCXXXI/dev
Browse files Browse the repository at this point in the history
fix(toolbox): disable sucker on web
  • Loading branch information
CCXXXI authored Oct 4, 2021
2 parents b6ad1ed + dcc3275 commit 9df27b4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/settings/trivia.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ final _trivia = [
'工具箱中卡片的长宽比为$pi...'.s,
'舔狗语录刷新后会关闭是有意为之,以此避免连点导致API请求过于频繁。'.s,
'cheater语录刷新后会关闭是因为复用了舔狗语录的代码。'.s,
'由于跨域资源共享(CORS)问题,部分功能在Web端不可用。'.s,
];

final _r = Random();
Expand Down
3 changes: 3 additions & 0 deletions lib/toolbox/toolbox_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';

import '../utils/logger.dart';
import '../utils/messages.dart';
import 'cheater.dart';
import 'juan/juan_view.dart';

Expand Down Expand Up @@ -36,6 +37,8 @@ class ToolboxLogic extends GetxController {
}

Future<String?> _getSucker() async {
if (GetPlatform.isWeb) return 'Web端不可用'.s;

final _r = Random().nextBool();
try {
final r = await Dio().get(
Expand Down
8 changes: 5 additions & 3 deletions lib/toolbox/toolbox_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ToolboxPage extends StatelessWidget {
? logic.sucker.value
: logic.sucker.value.substring(0, 16) + '……',
onTap: logic.suckerOnTap,
enabled: !GetPlatform.isWeb,
),
if (logic.cheaterEnabled.isTrue)
Tool(
Expand Down Expand Up @@ -91,19 +92,20 @@ class ToolboxPage extends StatelessWidget {

class Tool extends StatelessWidget {
const Tool(this.leading, this.title, this.subtitle,
{Key? key, this.onTap, this.onLongPress})
{Key? key, this.onTap, this.onLongPress, this.enabled = true})
: super(key: key);
final IconData leading;
final String title;
final String subtitle;
final void Function()? onTap;
final void Function()? onLongPress;
final bool enabled;

@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onTap,
onLongPress: onLongPress,
onPressed: enabled ? onTap : null,
onLongPress: enabled ? onLongPress : null,
style: ElevatedButton.styleFrom(
primary: context.theme.colorScheme.background,
onPrimary: context.theme.colorScheme.onBackground,
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'pangu.dart';
// record them manually
const appName = 'ECNU Timetable';
const packageName = 'io.github.ccxxxi.ecnu_timetable';
const version = '0.7.0';
const buildNumber = '9';
const version = '0.7.1';
const buildNumber = '10';

const release = '$packageName@$version+$buildNumber';

Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ packages:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.3"
version: "0.13.4"
http_parser:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 更美观更智能的ECNU课程表。
# Prevent the package from being accidentally published to pub.dev.
publish_to: "none"

version: 0.7.0+9
version: 0.7.1+10

environment:
sdk: ">=2.15.0-172.0.dev"
Expand Down

0 comments on commit 9df27b4

Please sign in to comment.