├── .gitignore
├── FileServerAndroid
├── .gitignore
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
├── mobile
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── settings.gradle
└── wear
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── FileServerWEBDOC
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ └── static
│ │ ├── css
│ │ ├── app.6071e8c5.css
│ │ └── chunk-vendors.d40384a8.css
│ │ ├── img
│ │ ├── joinQR.b99c3cd6.jpg
│ │ └── logo.c133518d.png
│ │ └── js
│ │ ├── app.d9a9adef.js
│ │ └── chunk-vendors.7f55b146.js
│ ├── ic_launcher-web.png
│ ├── java
│ ├── cn
│ │ └── settile
│ │ │ └── lzjyzq2
│ │ │ └── fileserver
│ │ │ ├── ExceptionCrash
│ │ │ └── CrashHandler.java
│ │ │ ├── activity
│ │ │ ├── AboutActivity.java
│ │ │ ├── HelpActivity.java
│ │ │ ├── HelpInfoActivity.java
│ │ │ ├── MainActivity.java
│ │ │ └── QRCodeActivity.java
│ │ │ ├── adapter
│ │ │ └── HelpListAdapter.java
│ │ │ └── application
│ │ │ └── myapplication.java
│ ├── database
│ │ ├── DBHelper.java
│ │ └── bean
│ │ │ ├── TempFile.java
│ │ │ └── UserBean.java
│ └── webserver
│ │ ├── WebServer.java
│ │ ├── bean
│ │ ├── DiskInfo.java
│ │ ├── FileInfo.java
│ │ └── UploaDirectoryInfo.java
│ │ ├── responsebean
│ │ ├── TempFileInfo.java
│ │ └── VersionInfo.java
│ │ └── util
│ │ ├── Config.java
│ │ ├── IPUtil.java
│ │ ├── MimeUtil.java
│ │ ├── QRCodeUtil.java
│ │ ├── ServerFileUtils.java
│ │ └── TimeUtil.java
│ ├── res
│ ├── drawable
│ │ ├── icon_help_a_off.xml
│ │ ├── icon_help_a_on.xml
│ │ ├── icon_wifi_a_off.xml
│ │ ├── icon_wifi_a_on.xml
│ │ ├── joinqr.jpg
│ │ └── main_item_image_shape.xml
│ ├── layout
│ │ ├── activity_about.xml
│ │ ├── activity_help.xml
│ │ ├── activity_help_info.xml
│ │ ├── activity_main.xml
│ │ ├── activity_permissions.xml
│ │ ├── activity_qrcode.xml
│ │ └── helpitem_layout.xml
│ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ ├── values-en
│ │ └── strings.xml
│ ├── values-zh
│ │ └── strings.xml
│ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── resources
│ └── mime.properties
├── FileServerCore
├── .idea
│ ├── encodings.xml
│ └── gradle.xml
├── build.gradle
├── build
│ └── resources
│ │ └── main
│ │ └── server.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
│ └── main
│ ├── java
│ ├── database
│ │ ├── DBHelper.java
│ │ └── bean
│ │ │ ├── TempFile.java
│ │ │ └── UserBean.java
│ └── webserver
│ │ ├── WebServer.java
│ │ ├── bean
│ │ ├── DiskInfo.java
│ │ ├── FileInfo.java
│ │ └── UploaDirectoryInfo.java
│ │ ├── client
│ │ └── ServerRunner.java
│ │ ├── responsebean
│ │ ├── TempFileInfo.java
│ │ └── VersionInfo.java
│ │ └── util
│ │ ├── Config.java
│ │ ├── Log.java
│ │ ├── MimeUtil.java
│ │ ├── ServerFileUtils.java
│ │ ├── TimeUtil.java
│ │ └── VersionUtil.java
│ └── resources
│ ├── META-INF
│ └── MANIFEST.MF
│ ├── mime.properties
│ └── server.properties
├── LICENSE
├── README.md
└── fileserverwebdoc
├── .gitignore
├── README.md
├── babel.config.js
├── package-lock.json
├── package.json
├── public
├── favicon.ico
└── index.html
├── src
├── App.vue
├── assets
│ ├── joinQR.jpg
│ ├── jz.png
│ └── logo.png
├── components
│ ├── FileItem.vue
│ ├── MyProgress.vue
│ ├── NavMenu.vue
│ └── UploadItem.vue
├── main.js
├── router.js
└── views
│ ├── About.vue
│ ├── Help.vue
│ ├── Manage.vue
│ ├── Settings.vue
│ └── UploadPanel.vue
└── vue.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 | FileServerCore/.idea/vcs.xml
25 | FileServerCore/.gradle/4.10.3/gc.properties
26 | FileServerCore/.gradle/4.10.3/fileChanges/last-build.bin
27 | FileServerCore/.gradle/4.10.3/fileContent/fileContent.lock
28 | FileServerCore/.gradle/4.10.3/fileHashes/fileHashes.bin
29 | FileServerCore/.gradle/4.10.3/fileHashes/fileHashes.lock
30 | FileServerCore/.gradle/4.10.3/javaCompile/javaCompile.lock
31 | FileServerCore/.gradle/4.10.3/javaCompile/taskHistory.bin
32 | FileServerCore/.gradle/4.10.3/taskHistory/taskHistory.bin
33 | FileServerCore/.gradle/4.10.3/taskHistory/taskHistory.lock
34 | FileServerCore/.gradle/buildOutputCleanup/buildOutputCleanup.lock
35 | FileServerCore/.gradle/buildOutputCleanup/cache.properties
36 | FileServerCore/.gradle/buildOutputCleanup/outputFiles.bin
37 | FileServerCore/.gradle/vcs-1/gc.properties
38 | FileServerCore/.idea/misc.xml
39 | FileServerCore/.idea/workspace.xml
40 | FileServerCore/gradle/wrapper/gradle-wrapper.properties
41 | FileServerCore/build/resources/main/META-INF/MANIFEST.MF
42 |
--------------------------------------------------------------------------------
/FileServerAndroid/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 |
--------------------------------------------------------------------------------
/FileServerAndroid/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.2.1'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/FileServerAndroid/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | android.enableJetifier=true
10 | android.useAndroidX=true
11 | org.gradle.jvmargs=-Xmx1536m
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 |
17 |
18 |
--------------------------------------------------------------------------------
/FileServerAndroid/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/FileServerAndroid/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "cn.settile.lzjyzq2.fileserver"
7 | minSdkVersion 15
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | compileOptions {
20 | targetCompatibility = '1.8'
21 | sourceCompatibility = '1.8'
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation 'androidx.appcompat:appcompat:1.0.0'
28 | androidTestImplementation 'androidx.test:runner:1.1.0'
29 | }
30 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FileServer
3 |
4 |
--------------------------------------------------------------------------------
/FileServerAndroid/mobile/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/FileServerAndroid/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':mobile', ':wear'
2 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "cn.settile.lzjyzq2.fileserver"
7 | minSdkVersion 22
8 | targetSdkVersion 27
9 | versionCode 9
10 | versionName "1.3.5"
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled true
15 | shrinkResources true
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | compileOptions {
20 | sourceCompatibility 1.8
21 | targetCompatibility 1.8
22 | }
23 | sourceSets { main { resources.srcDirs = ['src/main/resources', 'src/main/resources/'] } }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | implementation 'com.google.android.support:wearable:2.3.0'
29 | implementation 'androidx.percentlayout:percentlayout:1.0.0'
30 | implementation 'androidx.recyclerview:recyclerview:1.0.0'
31 | implementation 'androidx.appcompat:appcompat:1.0.2'
32 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
33 | compileOnly 'com.google.android.wearable:wearable:2.3.0'
34 | implementation 'com.ticwear:ticdesign:1.1.0'
35 | implementation 'com.yanzhenjie.permission:support:2.0.1'
36 |
37 |
38 | implementation 'javax.servlet:javax.servlet-api:4.0.1'
39 | implementation 'org.nanohttpd:nanohttpd-apache-fileupload:2.3.1'
40 | implementation 'org.nanohttpd:nanohttpd:2.3.1'
41 | implementation 'com.alibaba:fastjson:1.2.58'
42 | implementation 'com.google.zxing:core:3.4.0'
43 | implementation 'com.j256.ormlite:ormlite-android:5.1'
44 | }
45 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | ##################################通过混淆配置#################################
2 | # 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
3 | -optimizationpasses 5
4 |
5 | # 混合时不使用大小写混合,混合后的类名为小写
6 | -dontusemixedcaseclassnames
7 |
8 | # 指定不去忽略非公共库的类
9 | -dontskipnonpubliclibraryclasses
10 |
11 | # 这句话能够使我们的项目混淆后产生映射文件
12 | # 包含有类名->混淆后类名的映射关系
13 | -verbose
14 |
15 | # 指定不去忽略非公共库的类成员
16 | -dontskipnonpubliclibraryclassmembers
17 |
18 | # 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
19 | -dontpreverify
20 | -dontoptimize
21 |
22 | # 混淆时是否记录日志
23 | -verbose
24 | -ignorewarnings
25 |
26 | # 保留Annotation不混淆
27 | -keepattributes *Annotation*
28 |
29 | # 避免混淆泛型
30 | -keepattributes Signature
31 | -keepattributes Exceptions,InnerClasses
32 |
33 | -dontnote com.google.vending.licensing.ILicensingService
34 | -dontnote com.android.vending.licensing.ILicensingService
35 |
36 | # 抛出异常时保留代码行号
37 | -keepattributes SourceFile,LineNumberTable
38 | -keepattributes Deprecated,Synthetic,EnclosingMethod
39 |
40 | # 重命名抛出异常时的文件名称
41 | -renamesourcefileattribute SourceFile
42 | -keep public class * extends android.app.Activity
43 |
44 | -keep public class * extends android.app.Application {*;}
45 |
46 | -keep public class * extends android.app.Service
47 |
48 | -keep public class * extends android.content.BroadcastReceiver
49 |
50 | -keep public class * extends android.content.ContentProvider
51 |
52 | -keep public class * extends android.app.backup.BackupAgentHelper
53 |
54 | -keep public class * extends android.preference.Preference
55 | #自定义控件不要混淆
56 | -keep public class * extends android.view.View {*;}
57 | #adapter也不能混淆
58 | -keep public class * extends android.widget.BaseAdapter {*;}
59 |
60 | -keep public class * extends android.widget.CusorAdapter{*;}
61 | -keepnames class * implements java.io.Serializable #比如我们要向activity传递对象使用了Serializable接口的时候,这时候这个类及类里面#的所有内容都不能混淆
62 | -keepclassmembers class * implements java.io.Serializable {
63 | *;
64 | }
65 |
66 |
67 |
68 | -dontwarn com.alibaba.fastjson.**
69 | -keep class com.alibaba.fastjson.**{*; }
70 |
71 | -keep class webserver.bean.** {*;}
72 | -keep class webserver.responsebean.** {*;}
73 |
74 | -keep class database.bean.** {*;}
75 |
76 | -keep class com.j256.**
77 | -keepclassmembers class com.j256.** { *; }
78 | -keep enum com.j256.**
79 | -keepclassmembers enum com.j256.** { *; }
80 | -keep interface com.j256.**
81 | -keepclassmembers interface com.j256.** { *; }
82 | -keepattributes *Annotation*
83 | -keepclassmembers class * { @com.j256.ormlite.field.DatabaseField *; }
84 |
85 | -keep class com.nanohttpd.** {*;}
86 | -dontwarn org.nanohttpd.**
87 |
88 | -keep class com.yanzhenjie.permission.** {*;}
89 |
90 | -keep class javax.** {*;}
91 | -keep class javax.servlet.** {*;}
92 |
93 | -keepclassmembers class * extends android.app.Activity{
94 | public void *(android.view.View);
95 | }
96 | # 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
97 | -keepclassmembers class * {
98 | void *(**On*Event);
99 | void *(**On*Listener);
100 | }
101 | # 指定混淆是采用的算法,后面的参数是一个过滤器
102 | # 这个过滤器是谷歌推荐的算法,一般不做更改
103 | -optimizations !code/simplification/cast,!field/*,!class/merging/*
104 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/favicon.ico
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/index.html:
--------------------------------------------------------------------------------
1 |
文件上传
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/static/css/app.6071e8c5.css:
--------------------------------------------------------------------------------
1 | .g-container,.sider{height:100vh}.sider{z-index:1}.sider.break,.sider .trigger{position:absolute}.sider .trigger{top:4px;width:28px;height:28px;right:-28px;text-align:center;line-height:28px;background-color:#fff}.sider .trigger .icon{position:relative;font-size:18px}body{overflow:hidden;position:fixed;left:0;top:0}.progress-container{border-radius:100px;background-color:#f5f5f5;position:relative}.progress-container .progress-pg{background-color:#1890ff;border-radius:100px}.progress-container .progress-subpg{background-color:#52c41a;position:absolute;top:0;left:0;border-radius:100px}.progress-container .progress-errpg{background-color:#f03434;position:absolute;top:0;left:0;border-radius:100px}.uploaditem{background-color:#fff;margin:5px 0;padding-left:10px;padding-right:0;padding-top:8px;padding-bottom:8px;border:1px solid #d9d9d9;border-radius:2px}.uploaditem .name,.uploaditem .type{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.uploaditem:hover{border-color:#1890ff}.g-upload{padding-top:5px;height:auto}.g-upload p{line-height:16px}.g-upload .g-upload-drag-icon .icon{font-size:48px}.g-upload .g-upload-text{font-size:16px;color:#000}.g-upload .g-upload-hint{font-size:14px;color:grey}.g-uploadarea{display:inline-block;width:100%}.fileitem{background-color:#fff;margin:5px 0;padding-left:10px;padding-right:0;padding-top:8px;padding-bottom:8px;border:1px solid #d9d9d9;border-radius:2px}.fileitem .name,.fileitem .size{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fileitem:hover{border-color:#1890ff}.g-header{background:#fff;height:auto;padding:4px 10px}.g-header .progress{margin:10px 0}.g-header .progressbreak{margin:10px 0 10px 22px}.g-content{background-color:#fff;padding:0 10px;overflow-x:hidden;overflow-y:auto}.g-footer{background:#fff;padding:5px 10px}.filepanel{background-color:#fff;margin:5px 0;padding-left:10px;padding-right:0;padding-top:8px;padding-bottom:8px;line-height:1.5}.uploadmodal p{margin-bottom:0}.uploadmodal span{margin-left:5px}.about-content{background-color:#fff;padding:0 10px;overflow-x:hidden;overflow-y:auto;text-align:center}.about-content .version{font-size:24px;color:#000}.help-content{background-color:#fff;padding:0 10px;overflow-x:hidden;overflow-y:auto;text-align:left}.help-content .helpitem .title{font-size:15px;color:#000}.help-content .helpitem .content{margin-left:10px}.settings-content[data-v-6cd6c91e]{background-color:#fff;padding:0 10px;overflow-x:hidden;overflow-y:auto}.settings-content .settingpanel .settingitem .title[data-v-6cd6c91e],.settings-content .settingpanel .title[data-v-6cd6c91e]{font-size:15px;color:#000}
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/static/img/joinQR.b99c3cd6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/static/img/joinQR.b99c3cd6.jpg
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/static/img/logo.c133518d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/assets/FileServerWEBDOC/static/img/logo.c133518d.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/ExceptionCrash/CrashHandler.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.ExceptionCrash;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.io.PrintWriter;
6 | import java.io.StringWriter;
7 | import java.io.Writer;
8 | import java.lang.Thread.UncaughtExceptionHandler;
9 | import java.lang.reflect.Field;
10 | import java.text.DateFormat;
11 | import java.text.SimpleDateFormat;
12 | import java.util.Date;
13 | import java.util.HashMap;
14 | import java.util.Map;
15 |
16 | import android.content.Context;
17 | import android.content.pm.PackageInfo;
18 | import android.content.pm.PackageManager;
19 | import android.content.pm.PackageManager.NameNotFoundException;
20 | import android.os.Build;
21 | import android.os.Environment;
22 | import android.os.Looper;
23 | import android.util.Log;
24 | import android.widget.Toast;
25 |
26 | public class CrashHandler implements UncaughtExceptionHandler {
27 |
28 | public static final String TAG = "CrashHandler";
29 |
30 | //系统默认的UncaughtException处理类
31 | private Thread.UncaughtExceptionHandler mDefaultHandler;
32 | //CrashHandler实例
33 | private static CrashHandler INSTANCE = new CrashHandler();
34 | //程序的Context对象
35 | private Context mContext;
36 | //用来存储设备信息和异常信息
37 | private Map infos = new HashMap();
38 |
39 | //用于格式化日期,作为日志文件名的一部分
40 | private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
41 |
42 | /** 保证只有一个CrashHandler实例 */
43 | private CrashHandler() {
44 | }
45 |
46 | /** 获取CrashHandler实例 ,单例模式 */
47 | public static CrashHandler getInstance() {
48 | return INSTANCE;
49 | }
50 |
51 | /**
52 | * 初始化
53 | *
54 | * @param context
55 | */
56 | public void init(Context context) {
57 | mContext = context;
58 | //获取系统默认的UncaughtException处理器
59 | mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
60 | //设置该CrashHandler为程序的默认处理器
61 | Thread.setDefaultUncaughtExceptionHandler(this);
62 | }
63 |
64 | /**
65 | * 当UncaughtException发生时会转入该函数来处理
66 | */
67 | @Override
68 | public void uncaughtException(Thread thread, Throwable ex) {
69 | if (!handleException(ex) && mDefaultHandler != null) {
70 | //如果用户没有处理则让系统默认的异常处理器来处理
71 | mDefaultHandler.uncaughtException(thread, ex);
72 | } else {
73 | try {
74 | Thread.sleep(3000);
75 | } catch (InterruptedException e) {
76 | Log.e(TAG, "error : ", e);
77 | }
78 | //退出程序
79 | android.os.Process.killProcess(android.os.Process.myPid());
80 | System.exit(1);
81 | }
82 | }
83 |
84 | /**
85 | * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成.
86 | *
87 | * @param ex
88 | * @return true:如果处理了该异常信息;否则返回false.
89 | */
90 | private boolean handleException(Throwable ex) {
91 | if (ex == null) {
92 | return false;
93 | }
94 | //使用Toast来显示异常信息
95 | new Thread() {
96 | @Override
97 | public void run() {
98 | Looper.prepare();
99 | Toast.makeText(mContext, "很抱歉,程序出现异常,即将退出.", Toast.LENGTH_LONG).show();
100 | Looper.loop();
101 | }
102 | }.start();
103 | //收集设备参数信息
104 | collectDeviceInfo(mContext);
105 | //保存日志文件
106 | saveCrashInfo2File(ex);
107 | return true;
108 | }
109 |
110 | /**
111 | * 收集设备参数信息
112 | * @param ctx
113 | */
114 | public void collectDeviceInfo(Context ctx) {
115 | try {
116 | PackageManager pm = ctx.getPackageManager();
117 | PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
118 | if (pi != null) {
119 | String versionName = pi.versionName == null ? "null" : pi.versionName;
120 | String versionCode = pi.versionCode + "";
121 | infos.put("versionName", versionName);
122 | infos.put("versionCode", versionCode);
123 | }
124 | } catch (NameNotFoundException e) {
125 | Log.e(TAG, "an error occured when collect package info", e);
126 | }
127 | Field[] fields = Build.class.getDeclaredFields();
128 | for (Field field : fields) {
129 | try {
130 | field.setAccessible(true);
131 | infos.put(field.getName(), field.get(null).toString());
132 | Log.d(TAG, field.getName() + " : " + field.get(null));
133 | } catch (Exception e) {
134 | Log.e(TAG, "an error occured when collect crash info", e);
135 | }
136 | }
137 | }
138 |
139 | /**
140 | * 保存错误信息到文件中
141 | *
142 | * @param ex
143 | * @return 返回文件名称,便于将文件传送到服务器
144 | */
145 | private String saveCrashInfo2File(Throwable ex) {
146 |
147 | StringBuffer sb = new StringBuffer();
148 | for (Map.Entry entry : infos.entrySet()) {
149 | String key = entry.getKey();
150 | String value = entry.getValue();
151 | sb.append(key + "=" + value + "\n");
152 | }
153 |
154 | Writer writer = new StringWriter();
155 | PrintWriter printWriter = new PrintWriter(writer);
156 | ex.printStackTrace(printWriter);
157 | Throwable cause = ex.getCause();
158 | while (cause != null) {
159 | cause.printStackTrace(printWriter);
160 | cause = cause.getCause();
161 | }
162 | printWriter.close();
163 | String result = writer.toString();
164 | sb.append(result);
165 | try {
166 | long timestamp = System.currentTimeMillis();
167 | String time = formatter.format(new Date());
168 | String fileName = "crash-" + time + "-" + timestamp + ".log";
169 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
170 | String path = "/sdcard/fileserver/crash/";
171 | File dir = new File(path);
172 | if (!dir.exists()) {
173 | dir.mkdirs();
174 | }
175 | FileOutputStream fos = new FileOutputStream(path + fileName);
176 | fos.write(sb.toString().getBytes());
177 | fos.close();
178 | }
179 | return fileName;
180 | } catch (Exception e) {
181 | Log.e(TAG, "an error occured while writing file...", e);
182 | }
183 | return null;
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/activity/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.activity;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.support.wearable.activity.WearableActivity;
7 |
8 | import cn.settile.lzjyzq2.fileserver.R;
9 |
10 | public class AboutActivity extends WearableActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_about);
16 | setAmbientEnabled();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/activity/HelpActivity.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.wearable.activity.WearableActivity;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.ListView;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import cn.settile.lzjyzq2.fileserver.R;
15 | import cn.settile.lzjyzq2.fileserver.adapter.HelpListAdapter;
16 |
17 | public class HelpActivity extends WearableActivity implements AdapterView.OnItemClickListener {
18 |
19 | private ListView listView;
20 | private HelpListAdapter helpListAdapter;
21 | List data;
22 | private String TAG = "HelpActivity";
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_help);
27 | initView();
28 | }
29 |
30 | private void initView() {
31 | data = new ArrayList<>();
32 | data.add("使用步骤");
33 | data.add("上传路径");
34 | data.add("权限");
35 | data.add("网络");
36 | data.add("注意事项");
37 | data.add("微光模式");
38 | data.add("关于");
39 | helpListAdapter = new HelpListAdapter(this,R.layout.helpitem_layout,data);
40 | listView = findViewById(R.id.helplist);
41 | listView.setOnItemClickListener(this);
42 | listView.setAdapter(helpListAdapter);
43 | }
44 |
45 | @Override
46 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
47 | Intent intent;
48 | switch (data.get(position)){
49 | case "使用步骤":
50 | intent = new Intent(this,HelpInfoActivity.class);
51 | intent.putExtra("form",getString(R.string.help_useinfo_title));
52 | startActivity(intent);
53 | break;
54 | case "上传路径":
55 | intent = new Intent(this,HelpInfoActivity.class);
56 | intent.putExtra("form",getString(R.string.help_uploadpath_title));
57 | startActivity(intent);
58 | break;
59 | case "权限":
60 | intent = new Intent(this,HelpInfoActivity.class);
61 | intent.putExtra("form",getString(R.string.help_permission_title));
62 | startActivity(intent);
63 | break;
64 | case "网络":
65 | intent = new Intent(this,HelpInfoActivity.class);
66 | intent.putExtra("form",getString(R.string.help_network_title));
67 | startActivity(intent);
68 | break;
69 | case "注意事项":
70 | intent = new Intent(this,HelpInfoActivity.class);
71 | intent.putExtra("form",getString(R.string.help_careful_title));
72 | startActivity(intent);
73 | break;
74 | case "微光模式":
75 | intent = new Intent(this,HelpInfoActivity.class);
76 | intent.putExtra("form",getString(R.string.help_twilight_mode_title));
77 | startActivity(intent);
78 | break;
79 | case "关于":
80 | intent = new Intent(this,AboutActivity.class);
81 | startActivity(intent);
82 | break;
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/activity/HelpInfoActivity.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.activity;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.wearable.activity.WearableActivity;
8 | import android.widget.TextView;
9 |
10 | import cn.settile.lzjyzq2.fileserver.R;
11 | import ticwear.design.widget.ScalableTextView;
12 | import webserver.util.Config;
13 |
14 | public class HelpInfoActivity extends WearableActivity {
15 |
16 | private TextView content;
17 | private ScalableTextView title;
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_help_info);
22 | Intent intent = getIntent();
23 | content = findViewById(R.id.text_content);
24 | title = findViewById(R.id.info_title);
25 |
26 | switch (intent.getStringExtra("form")){
27 | case "上传路径":
28 | title.setText(R.string.help_uploadpath_title);
29 | content.setText(Config.getInstance().getUPLOAD());
30 | break;
31 | case "权限":
32 | title.setText(R.string.help_permission_title);
33 | content.setText(R.string.help_permission_content);
34 | break;
35 | case "网络":
36 | title.setText(R.string.help_network_title);
37 | content.setText(R.string.help_network_content);
38 | break;
39 | case "注意事项":
40 | title.setText(R.string.help_careful_title);
41 | content.setText(R.string.help_careful_content);
42 | break;
43 | case "微光模式":
44 | title.setText(R.string.help_twilight_mode_title);
45 | content.setText(R.string.help_twilight_mode_content);
46 | break;
47 | case "使用步骤":
48 | title.setText(R.string.help_useinfo_title);
49 | content.setText(R.string.help_useinfo_content);
50 | break;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.activity;
2 |
3 | import android.Manifest;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.content.Context;
7 | import android.content.DialogInterface;
8 | import android.content.Intent;
9 | import android.net.ConnectivityManager;
10 | import android.net.LinkProperties;
11 | import android.net.Network;
12 | import android.net.NetworkCapabilities;
13 | import android.net.NetworkInfo;
14 | import android.net.NetworkRequest;
15 | import android.net.wifi.WifiManager;
16 | import android.os.Build;
17 | import android.os.Bundle;
18 | import android.os.Handler;
19 | import android.os.Message;
20 | import android.provider.Settings;
21 | import android.support.wearable.activity.WearableActivity;
22 | import android.util.Log;
23 | import android.view.View;
24 | import android.view.ViewPropertyAnimator;
25 | import android.view.animation.DecelerateInterpolator;
26 | import android.widget.CompoundButton;
27 | import android.widget.ImageView;
28 | import android.widget.LinearLayout;
29 | import android.widget.TextView;
30 |
31 | import com.yanzhenjie.permission.Action;
32 | import com.yanzhenjie.permission.AndPermission;
33 | import com.yanzhenjie.permission.Rationale;
34 | import com.yanzhenjie.permission.RequestExecutor;
35 |
36 | import java.io.IOException;
37 | import java.util.Calendar;
38 | import java.util.List;
39 |
40 | import cn.settile.lzjyzq2.fileserver.R;
41 | import cn.settile.lzjyzq2.fileserver.application.myapplication;
42 | import ticwear.design.app.AlertDialog;
43 | import ticwear.design.widget.SimpleSwitch;
44 | import webserver.WebServer;
45 | import webserver.util.Config;
46 | import webserver.util.IPUtil;
47 |
48 | public class MainActivity extends WearableActivity implements View.OnClickListener, Rationale> {
49 |
50 | private static WebServer webServer;
51 | private static final String TAG = "MainActivity";
52 | protected static boolean serverflag = false;
53 | private static String ip = null;
54 | private ConnectivityManager connectivityManager;
55 | private WifiManager wifiManager;
56 | private int dialogstatus = 0;
57 | private static final int REQ_CODE_PERMISSION = 9527;
58 |
59 | private static int LASTTIME = 1564588740;
60 | private String[] mypermissions = {
61 | Manifest.permission.WRITE_EXTERNAL_STORAGE,
62 | Manifest.permission.READ_EXTERNAL_STORAGE,
63 | Manifest.permission.INTERNET,
64 | Manifest.permission.WAKE_LOCK,
65 | Manifest.permission.ACCESS_WIFI_STATE,
66 | Manifest.permission.ACCESS_NETWORK_STATE,
67 | Manifest.permission.CHANGE_NETWORK_STATE
68 | };
69 |
70 | public Handler handler = new Handler(){
71 | @Override
72 | public void handleMessage(Message msg) {
73 | switch (msg.what){
74 | case 1:
75 | wifi_status_tv.setText("http://"+(String)msg.obj);
76 | break;
77 | }
78 | }
79 | };
80 | private LinearLayout showQRCodeBtn,showHelpBtn;
81 | private TextView server_status_tv, wifi_status_tv,mainactivity_title;
82 | private SimpleSwitch start_server_switch;
83 |
84 | private ImageView wifi_img,help_img;
85 |
86 |
87 | private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback(){
88 | @Override
89 | public void onAvailable(Network network) {
90 | super.onAvailable(network);
91 | NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
92 | if(networkInfo!=null&&(networkInfo.isConnectedOrConnecting()||networkInfo.isAvailable())){
93 | ip = IPUtil.intToIp(wifiManager.getConnectionInfo().getIpAddress())+":"+ Config.getInstance().getPORT();
94 | if(wifi_status_tv !=null){
95 | Message message = Message.obtain();
96 | message.what = 1;
97 | message.obj = ip;
98 | handler.sendMessage(message);
99 | }
100 | }
101 | }
102 |
103 | @Override
104 | public void onLosing(Network network, int maxMsToLive) {
105 | super.onLosing(network, maxMsToLive);
106 | }
107 |
108 | @Override
109 | public void onLost(Network network) {
110 | super.onLost(network);
111 | NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
112 | if(networkInfo!=null&&!(networkInfo.isConnected()||networkInfo.isConnectedOrConnecting()||networkInfo.isAvailable())){
113 | runOnUiThread(new Runnable() {
114 | @Override
115 | public void run() {
116 | ip=null;
117 | wifi_status_tv.setText(R.string.wifi_status_hint);
118 | }
119 | });
120 | }
121 | }
122 |
123 | @Override
124 | public void onUnavailable() {
125 | super.onUnavailable();
126 | }
127 |
128 | @Override
129 | public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
130 | super.onCapabilitiesChanged(network, networkCapabilities);
131 | }
132 |
133 | @Override
134 | public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
135 | super.onLinkPropertiesChanged(network, linkProperties);
136 | }
137 | };
138 |
139 | @Override
140 | protected void onCreate(Bundle savedInstanceState) {
141 | super.onCreate(savedInstanceState);
142 | setContentView(R.layout.activity_main);
143 |
144 | // Enables Always-on
145 | setAmbientEnabled();
146 |
147 | if(Build.VERSION.SDK_INT >=Build.VERSION_CODES.M){
148 | AndPermission.with(this)
149 | .runtime()
150 | .permission(mypermissions)
151 | .rationale(this)
152 | .onGranted(GrantedAction)
153 | .onDenied(DeniedAction)
154 | .start();
155 | }
156 | initServer();
157 | initView();
158 | }
159 |
160 | @Override
161 | public void onEnterAmbient(Bundle ambientDetails) {
162 | super.onEnterAmbient(ambientDetails);
163 | if (wifi_img!=null){
164 | wifi_img.setImageResource(R.drawable.icon_wifi_a_on);
165 | }
166 | if (help_img!=null) {
167 | help_img.setImageResource(R.drawable.icon_help_a_on);
168 | }
169 | if(mainactivity_title!=null){
170 | mainactivity_title.setText(R.string.mainactivity_title1);
171 | }
172 | }
173 |
174 | @Override
175 | public void onExitAmbient() {
176 | super.onExitAmbient();
177 | if (wifi_img!=null){
178 | wifi_img.setImageResource(R.drawable.icon_wifi_a_off);
179 | }
180 | if (help_img!=null) {
181 | help_img.setImageResource(R.drawable.icon_help_a_off);
182 | }
183 | if(mainactivity_title!=null){
184 | mainactivity_title.setText(R.string.mainactivity_title);
185 | }
186 | }
187 |
188 | private void initServer() {
189 | webServer = new WebServer();
190 | wifiManager = (WifiManager) myapplication.getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
191 | connectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
192 | if(connectivityManager!=null){
193 | connectivityManager.registerNetworkCallback(new NetworkRequest.Builder().addTransportType(NetworkCapabilities.TRANSPORT_WIFI).build(), networkCallback);
194 | }
195 | }
196 |
197 | private void initView() {
198 | start_server_switch = findViewById(R.id.server_start_switch);
199 | showQRCodeBtn = findViewById(R.id.show_qrcode_btn);
200 | showHelpBtn = findViewById(R.id.show_help_btn);
201 | showQRCodeBtn.setOnClickListener(this);
202 | showHelpBtn.setOnClickListener(this);
203 | server_status_tv = findViewById(R.id.server_status_tv);
204 | wifi_status_tv = findViewById(R.id.wifi_status_tv);
205 |
206 | mainactivity_title = findViewById(R.id.mainactivity_title);
207 | wifi_img = findViewById(R.id.wifi_img);
208 | help_img = findViewById(R.id.help_img);
209 | if(ip!=null){
210 | wifi_status_tv.setText("http://"+ip);
211 | }
212 | start_server_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
213 | @Override
214 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
215 | if(isChecked){
216 | try {
217 | startServer();
218 | } catch (IOException e) {
219 | e.printStackTrace();
220 | serverflag = false;
221 | start_server_switch.setChecked(false);
222 | return;
223 | }
224 | server_status_tv.setText(R.string.server_status_hint_runnig);
225 | showQRCodeBtn.setVisibility(View.VISIBLE);
226 | AnimatorSet animatorSet = new AnimatorSet(); //组合动画
227 | ObjectAnimator scaleX = ObjectAnimator.ofFloat(showQRCodeBtn, "scaleX", 0f, 1f);
228 | ObjectAnimator scaleY = ObjectAnimator.ofFloat(showQRCodeBtn, "scaleY", 0f, 1f);
229 | ObjectAnimator alpha = ObjectAnimator.ofFloat(showQRCodeBtn,"alpha",0f,100f);
230 | animatorSet.setDuration(300); //动画时间
231 | animatorSet.setInterpolator(new DecelerateInterpolator()); //设置插值器
232 | animatorSet.play(scaleX).with(scaleY).with(alpha); //同时执行
233 | animatorSet.start(); //启动动画
234 | }else {
235 | stopServer();
236 | server_status_tv.setText(R.string.server_status_hint_start);
237 | showQRCodeBtn.setVisibility(View.GONE);
238 | }
239 | }
240 | });
241 |
242 | }
243 |
244 |
245 | @Override
246 | protected void onDestroy() {
247 | super.onDestroy();
248 | stopServer();
249 | }
250 | private void startServer() throws IOException {
251 | if(webServer!=null&&!serverflag) {
252 | webServer.start();
253 | serverflag = true;
254 | }
255 | }
256 | private void stopServer(){
257 | if(webServer!=null) {
258 | webServer.closeAllConnections();
259 | webServer.stop();
260 | }
261 | serverflag = false;
262 | }
263 | @Override
264 | public void onClick(View v) {
265 | switch (v.getId()){
266 | case R.id.show_help_btn:
267 | startActivity(new Intent(this, HelpActivity.class));
268 | break;
269 | case R.id.show_qrcode_btn:
270 | Intent intent = new Intent(this,QRCodeActivity.class);
271 | intent.putExtra(getString(R.string.start_qractivity_intent_flag_ip),ip);
272 | startActivity(intent);
273 | break;
274 | }
275 | }
276 |
277 | @Override
278 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
279 | switch (requestCode) {
280 | case REQ_CODE_PERMISSION:
281 | if (AndPermission.hasPermissions(this, mypermissions)) {
282 | // 有对应的权限
283 | } else {
284 | // 没有对应的权限
285 | finish();
286 | }
287 | break;
288 | }
289 | }
290 |
291 | @Override
292 | public void showRationale(Context context, List data, RequestExecutor executor) {
293 | AlertDialog.Builder builder = new AlertDialog.Builder(context);
294 | builder.setTitle(R.string.permissions_dialog_title);
295 | builder.setIcon(R.mipmap.ic_launcher_round);
296 | builder.setMessage(R.string.permissions_dialog_message_1);
297 | builder.setCancelable(false);
298 | builder.setPositiveButtonIcon(R.drawable.tic_ic_btn_ok, new DialogInterface.OnClickListener() {
299 | @Override
300 | public void onClick(DialogInterface dialog, int which) {
301 | MainActivity.this.dialogstatus=1;
302 | executor.execute();
303 | }
304 | });
305 | builder.setNegativeButtonIcon(R.drawable.tic_ic_btn_cancel, new DialogInterface.OnClickListener() {
306 | @Override
307 | public void onClick(DialogInterface dialog, int which) {
308 | executor.cancel();
309 | MainActivity.this.dialogstatus=2;
310 | }
311 | });
312 | builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
313 | @Override
314 | public void onDismiss(DialogInterface dialog) {
315 | if (MainActivity.this.dialogstatus==0){
316 | executor.cancel();
317 | }else {
318 | MainActivity.this.dialogstatus=0;
319 | }
320 | }
321 | });
322 | AlertDialog dialog = builder.create();
323 | dialog.show();
324 | }
325 |
326 | public void showSettingDialog(){
327 | this.dialogstatus = 0;
328 | AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
329 | builder.setTitle(R.string.permissions_dialog_title);
330 | builder.setIcon(R.mipmap.ic_launcher_round);
331 | builder.setCancelable(false);
332 | builder.setMessage(R.string.permissions_dialog_message_2);
333 | builder.setPositiveButtonIcon(R.drawable.tic_ic_btn_ok, new DialogInterface.OnClickListener() {
334 | @Override
335 | public void onClick(DialogInterface dialog, int which) {
336 | AndPermission.with(MainActivity.this)
337 | .runtime()
338 | .setting()
339 | .start(REQ_CODE_PERMISSION);
340 | dialogstatus = 1;
341 | }
342 | });
343 | builder.setNegativeButtonIcon(R.drawable.tic_ic_btn_cancel, new DialogInterface.OnClickListener() {
344 | @Override
345 | public void onClick(DialogInterface dialog, int which) {
346 | dialog.dismiss();
347 | }
348 | });
349 | builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
350 | @Override
351 | public void onDismiss(DialogInterface dialog) {
352 | if(dialogstatus==0){
353 | finish();
354 | MainActivity.this.finish();
355 | }else{
356 | dialogstatus = 0;
357 | }
358 | }
359 | });
360 | AlertDialog dialog = builder.create();
361 | dialog.show();
362 | }
363 | Action GrantedAction = (Action>) data -> {
364 | initServer();
365 | initView();
366 | };
367 | Action DeniedAction = (Action>) data -> {
368 | if(AndPermission.hasAlwaysDeniedPermission(MainActivity.this,data)){
369 | showSettingDialog();
370 | }else {
371 | AndPermission.with(MainActivity.this)
372 | .runtime()
373 | .permission(mypermissions)
374 | .rationale(MainActivity.this::showRationale)
375 | .onGranted(GrantedAction)
376 | .onDenied(MainActivity.this.DeniedAction)
377 | .start();
378 | }
379 | };
380 | }
381 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/activity/QRCodeActivity.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.activity;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.graphics.Color;
7 | import android.os.Bundle;
8 | import android.support.wearable.activity.WearableActivity;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import cn.settile.lzjyzq2.fileserver.R;
13 | import webserver.util.QRCodeUtil;
14 |
15 | public class QRCodeActivity extends WearableActivity {
16 |
17 | private ImageView qrImageview;
18 | private TextView showIpTv;
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_qrcode);
23 |
24 | qrImageview = findViewById(R.id.qc_img);
25 | showIpTv = findViewById(R.id.showip_tv);
26 | Intent intent = getIntent();
27 | String ip = intent.getStringExtra(getString(R.string.start_qractivity_intent_flag_ip));
28 | if(null!=ip&&""!=ip){
29 | showIpTv.setText("http://"+ip);
30 | qrImageview.setImageBitmap(QRCodeUtil.createQRCodeBitmap("http://"+ip,320,320,"UTF-8","H","1", Color.BLACK,Color.WHITE));
31 | }else {
32 | showIpTv.setText(R.string.wifi_status_hint);
33 | qrImageview.setImageResource(R.drawable.icon_wifi_a_off);
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/adapter/HelpListAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.TextView;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 |
13 | import java.util.List;
14 |
15 | import cn.settile.lzjyzq2.fileserver.R;
16 |
17 | public class HelpListAdapter extends ArrayAdapter{
18 | List list;
19 | int resource;
20 | public HelpListAdapter(@NonNull Context context, int resource,List list) {
21 | super(context, resource);
22 | this.list = list;
23 | this.resource = resource;
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 | return list.size();
29 | }
30 |
31 |
32 | @Nullable
33 | @Override
34 | public Object getItem(int position) {
35 | return list.get(position);
36 | }
37 |
38 | @NonNull
39 | @Override
40 | public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
41 | View view = LayoutInflater.from(getContext()).inflate(resource,null,false);
42 | TextView title = view.findViewById(R.id.item_title);
43 | title.setText(list.get(position));
44 | return view;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/cn/settile/lzjyzq2/fileserver/application/myapplication.java:
--------------------------------------------------------------------------------
1 | package cn.settile.lzjyzq2.fileserver.application;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.pm.PackageInfo;
6 | import android.content.pm.PackageManager;
7 |
8 | import cn.settile.lzjyzq2.fileserver.ExceptionCrash.CrashHandler;
9 |
10 | public class myapplication extends Application {
11 | private static Context mContext;
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | this.mContext = getApplicationContext();
16 | CrashHandler crashHandler = CrashHandler.getInstance();
17 | crashHandler.init(getApplicationContext());
18 | }
19 |
20 | public static Context getContext() {
21 | return mContext;
22 | }
23 | //获取版本名
24 | public static String getVersionName(Context context) {
25 | return getPackageInfo(context).versionName;
26 | }
27 |
28 | //获取版本号
29 | public static int getVersionCode(Context context) {
30 | return getPackageInfo(context).versionCode;
31 | }
32 | //通过PackageInfo得到的想要启动的应用的包名
33 | private static PackageInfo getPackageInfo(Context context) {
34 | PackageInfo pInfo = null;
35 |
36 | try {
37 | //通过PackageManager可以得到PackageInfo
38 | PackageManager pManager = context.getPackageManager();
39 | pInfo = pManager.getPackageInfo(context.getPackageName(),
40 | PackageManager.GET_CONFIGURATIONS);
41 |
42 | return pInfo;
43 | } catch (Exception e) {
44 | e.printStackTrace();
45 | }
46 | return pInfo;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/database/DBHelper.java:
--------------------------------------------------------------------------------
1 | package database;
2 |
3 | import android.database.sqlite.SQLiteDatabase;
4 |
5 | import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
6 | import com.j256.ormlite.dao.Dao;
7 | import com.j256.ormlite.dao.DaoManager;
8 | import com.j256.ormlite.support.ConnectionSource;
9 | import com.j256.ormlite.table.TableUtils;
10 |
11 | import java.sql.SQLException;
12 |
13 | import cn.settile.lzjyzq2.fileserver.application.myapplication;
14 | import database.bean.TempFile;
15 | import database.bean.UserBean;
16 |
17 | public class DBHelper extends OrmLiteSqliteOpenHelper {
18 | private static final String TAG = "DBHelper";
19 | private static DBHelper instance = new DBHelper();
20 | private static Dao TempFiledao;
21 | private static Dao UserBeanDao;
22 |
23 | public static DBHelper getInstance() {
24 | return instance;
25 | }
26 |
27 | private DBHelper(){
28 | super(myapplication.getContext(),"data.db",null,1);
29 | }
30 | @Override
31 | public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
32 | try {
33 | TableUtils.createTable(connectionSource, TempFile.class);
34 | TableUtils.createTable(connectionSource, UserBean.class);
35 | } catch (SQLException e) {
36 | e.printStackTrace();
37 | }
38 | }
39 |
40 | @Override
41 | public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
42 |
43 | }
44 |
45 | public Dao getTempFiledao() throws SQLException {
46 | if(TempFiledao == null)
47 | TempFiledao = DaoManager.createDao(getConnectionSource(),
48 | TempFile.class);
49 | return TempFiledao;
50 | }
51 | public Dao getUserBeanDao() throws SQLException {
52 | if(UserBeanDao == null)
53 | UserBeanDao = DaoManager.createDao(getConnectionSource(),
54 | UserBean.class);
55 | return UserBeanDao;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/database/bean/TempFile.java:
--------------------------------------------------------------------------------
1 | package database.bean;
2 |
3 | import com.j256.ormlite.field.DatabaseField;
4 | import com.j256.ormlite.table.DatabaseTable;
5 |
6 | @DatabaseTable(tableName = "TempFile")
7 | public class TempFile {
8 | @DatabaseField(generatedId = true)
9 | private int id;
10 | @DatabaseField
11 | private String path;
12 | @DatabaseField(unique = true)
13 | private String name;
14 | @DatabaseField
15 | private String type;
16 |
17 | public TempFile(int id, String path, String name, String type) {
18 | this.id = id;
19 | this.path = path;
20 | this.name = name;
21 | this.type = type;
22 | }
23 |
24 | public TempFile() {
25 | }
26 |
27 | public int getId() {
28 | return id;
29 | }
30 |
31 | public void setId(int id) {
32 | this.id = id;
33 | }
34 |
35 | public String getPath() {
36 | return path;
37 | }
38 |
39 | public void setPath(String path) {
40 | this.path = path;
41 | }
42 |
43 | public String getName() {
44 | return name;
45 | }
46 |
47 | public void setName(String name) {
48 | this.name = name;
49 | }
50 |
51 | public String getType() {
52 | return type;
53 | }
54 |
55 | public void setType(String type) {
56 | this.type = type;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/database/bean/UserBean.java:
--------------------------------------------------------------------------------
1 | package database.bean;
2 |
3 | import com.j256.ormlite.field.DatabaseField;
4 | import com.j256.ormlite.table.DatabaseTable;
5 |
6 | @DatabaseTable(tableName = "UserBean")
7 | public class UserBean {
8 | @DatabaseField(unique = true)
9 | private String uid;
10 | @DatabaseField
11 | private String token;
12 | @DatabaseField
13 | private long lasttime;
14 |
15 | public UserBean() {
16 | }
17 |
18 | public UserBean(String uid, String token, long lasttime) {
19 | this.uid = uid;
20 | this.token = token;
21 | this.lasttime = lasttime;
22 | }
23 |
24 | public String getUid() {
25 | return uid;
26 | }
27 |
28 | public void setUid(String uid) {
29 | this.uid = uid;
30 | }
31 |
32 | public String getToken() {
33 | return token;
34 | }
35 |
36 | public void setToken(String token) {
37 | this.token = token;
38 | }
39 |
40 | public long getLasttime() {
41 | return lasttime;
42 | }
43 |
44 | public void setLasttime(long lasttime) {
45 | this.lasttime = lasttime;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/bean/DiskInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.bean;
2 |
3 | public class DiskInfo {
4 | public long freespace;
5 | public long usedspace;
6 | public long totalspace;
7 |
8 | public DiskInfo() {
9 | }
10 |
11 | public DiskInfo(long freespace, long usedspace, long totalspace) {
12 | this.freespace = freespace;
13 | this.usedspace = usedspace;
14 | this.totalspace = totalspace;
15 | }
16 |
17 | public long getFreespace() {
18 | return freespace;
19 | }
20 |
21 | public void setFreespace(long freespace) {
22 | this.freespace = freespace;
23 | }
24 |
25 | public long getUsedspace() {
26 | return usedspace;
27 | }
28 |
29 | public void setUsedspace(long usedspace) {
30 | this.usedspace = usedspace;
31 | }
32 |
33 | public long getTotalspace() {
34 | return totalspace;
35 | }
36 |
37 | public void setTotalspace(long totalspace) {
38 | this.totalspace = totalspace;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/bean/FileInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.bean;
2 |
3 | public class FileInfo {
4 | String name;
5 | long size;
6 | long time;
7 |
8 | public FileInfo(String name, long size, long time) {
9 | this.name = name;
10 | this.size = size;
11 | this.time = time;
12 | }
13 |
14 | public FileInfo() {
15 | }
16 |
17 | public String getName() {
18 | return name;
19 | }
20 |
21 | public void setName(String name) {
22 | this.name = name;
23 | }
24 |
25 | public long getSize() {
26 | return size;
27 | }
28 |
29 | public void setSize(long size) {
30 | this.size = size;
31 | }
32 |
33 | public long getTime() {
34 | return time;
35 | }
36 |
37 | public void setTime(long time) {
38 | this.time = time;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/bean/UploaDirectoryInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.bean;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | public class UploaDirectoryInfo {
7 | List dirs;
8 | Map allfileinfo;
9 |
10 | public UploaDirectoryInfo(List dirs, Map allfileinfo) {
11 | this.dirs = dirs;
12 | this.allfileinfo = allfileinfo;
13 | }
14 |
15 | public List getDirs() {
16 | return dirs;
17 | }
18 |
19 | public void setDirs(List dirs) {
20 | this.dirs = dirs;
21 | }
22 |
23 | public Map getAllfileinfo() {
24 | return allfileinfo;
25 | }
26 |
27 | public void setAllfileinfo(Map allfileinfo) {
28 | this.allfileinfo = allfileinfo;
29 | }
30 |
31 | public UploaDirectoryInfo() {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/responsebean/TempFileInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.responsebean;
2 |
3 | public class TempFileInfo {
4 | public int id;
5 | }
6 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/responsebean/VersionInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.responsebean;
2 |
3 | public class VersionInfo {
4 | public String version;
5 |
6 | public VersionInfo() {
7 | }
8 |
9 | public String getVersion() {
10 | return version;
11 | }
12 |
13 | public void setVersion(String version) {
14 | this.version = version;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/util/Config.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import android.os.Environment;
4 | import android.util.Log;
5 | import android.widget.Toast;
6 |
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.net.ServerSocket;
11 | import java.util.Properties;
12 | import java.util.ResourceBundle;
13 |
14 | import cn.settile.lzjyzq2.fileserver.activity.MainActivity;
15 | import cn.settile.lzjyzq2.fileserver.application.myapplication;
16 |
17 | public class Config {
18 | private static Config config = new Config();
19 | private int PORT = 8081;
20 | private String WEBDOC = null;
21 | private String DISKPATH = null;
22 | private String UPLOAD = null;
23 |
24 | private Config() {
25 | WEBDOC = "FileServerWEBDOC";
26 | DISKPATH = Environment.getExternalStorageDirectory().getPath();
27 | PORT = renewPort();
28 | UPLOAD = Environment.getExternalStorageDirectory().getPath() + File.separator + "FileServerUpload";
29 | createDir(UPLOAD);
30 | }
31 |
32 | public static Config getInstance() {
33 | return config;
34 | }
35 |
36 | public int getPORT() {
37 | return PORT;
38 | }
39 |
40 | public String getWEBDOC() {
41 | return WEBDOC;
42 | }
43 |
44 | public String getDISKPATH() {
45 | return DISKPATH;
46 | }
47 |
48 | public String getUPLOAD() {
49 | return UPLOAD;
50 | }
51 |
52 | public int renewPort(){
53 | ServerSocket serverSocket = null;
54 | try {
55 | serverSocket = new ServerSocket(0);
56 | PORT = serverSocket.getLocalPort(); //Integer.parseInt(resource.getString("PORT"));
57 | serverSocket.close();
58 | } catch (IOException e) {
59 | e.printStackTrace();
60 | }
61 | return getPORT();
62 | }
63 |
64 | public static boolean canavilable() {
65 | //首先判断外部存储是否可用
66 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
67 | File sd = new File(Environment.getExternalStorageDirectory().getPath());
68 | return sd.canWrite();
69 | } else {
70 | return false;
71 | }
72 | }
73 |
74 | public static boolean createDir(String destDirName) {
75 | File dir = new File(destDirName);
76 | if (dir.exists()) {// 判断目录是否存在
77 | return false;
78 | }
79 | if (!destDirName.endsWith(File.separator)) {// 结尾是否以"/"结束
80 | destDirName = destDirName + File.separator;
81 | }
82 | if (dir.mkdirs()) {// 创建目标目录
83 | return true;
84 | } else {
85 | return false;
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/util/IPUtil.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | public class IPUtil {
4 | public static String intToIp(int ipInt) {
5 | StringBuilder sb = new StringBuilder();
6 | sb.append(ipInt & 0xFF).append(".");
7 | sb.append((ipInt >> 8) & 0xFF).append(".");
8 | sb.append((ipInt >> 16) & 0xFF).append(".");
9 | sb.append((ipInt >> 24) & 0xFF);
10 | return sb.toString();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/util/MimeUtil.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import java.util.ResourceBundle;
4 |
5 | public class MimeUtil {
6 | static MimeUtil instance = new MimeUtil();
7 | ResourceBundle resourceBundle = null;
8 |
9 | private MimeUtil() {
10 | resourceBundle = ResourceBundle.getBundle("mime");
11 | }
12 |
13 | public Boolean hasKeys(String key) {
14 | return resourceBundle.containsKey(key);
15 | }
16 |
17 | public String getMimeType(String key) {
18 | if (hasKeys(key))
19 | return resourceBundle.getString(key);
20 | return "*/*";
21 | }
22 | public String getMimeTypeforPath(String path){
23 | String type = path.substring(path.lastIndexOf('.') + 1, path.length());
24 | return getMimeType(type);
25 | }
26 |
27 | public static MimeUtil getInstance() {
28 | return instance;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/util/QRCodeUtil.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import android.graphics.Bitmap;
4 | import android.text.TextUtils;
5 |
6 | import com.google.zxing.BarcodeFormat;
7 | import com.google.zxing.EncodeHintType;
8 | import com.google.zxing.WriterException;
9 | import com.google.zxing.common.BitMatrix;
10 | import com.google.zxing.qrcode.QRCodeWriter;
11 |
12 | import java.util.Hashtable;
13 |
14 | public class QRCodeUtil {
15 | /**
16 | * 生成简单二维码
17 | *
18 | * @param content 字符串内容
19 | * @param width 二维码宽度
20 | * @param height 二维码高度
21 | * @param character_set 编码方式(一般使用UTF-8)
22 | * @param error_correction_level 容错率 L:7% M:15% Q:25% H:35%
23 | * @param margin 空白边距(二维码与边框的空白区域)
24 | * @param color_black 黑色色块
25 | * @param color_white 白色色块
26 | * @return BitMap
27 | */
28 | public static Bitmap createQRCodeBitmap(String content, int width, int height,
29 | String character_set, String error_correction_level,
30 | String margin, int color_black, int color_white) {
31 | // 字符串内容判空
32 | if (TextUtils.isEmpty(content)) {
33 | return null;
34 | }
35 | // 宽和高>=0
36 | if (width < 0 || height < 0) {
37 | return null;
38 | }
39 | try {
40 | /** 1.设置二维码相关配置 */
41 | Hashtable hints = new Hashtable<>();
42 | // 字符转码格式设置
43 | if (!TextUtils.isEmpty(character_set)) {
44 | hints.put(EncodeHintType.CHARACTER_SET, character_set);
45 | }
46 | // 容错率设置
47 | if (!TextUtils.isEmpty(error_correction_level)) {
48 | hints.put(EncodeHintType.ERROR_CORRECTION, error_correction_level);
49 | }
50 | // 空白边距设置
51 | if (!TextUtils.isEmpty(margin)) {
52 | hints.put(EncodeHintType.MARGIN, margin);
53 | }
54 | /** 2.将配置参数传入到QRCodeWriter的encode方法生成BitMatrix(位矩阵)对象 */
55 | BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
56 |
57 | /** 3.创建像素数组,并根据BitMatrix(位矩阵)对象为数组元素赋颜色值 */
58 | int[] pixels = new int[width * height];
59 | for (int y = 0; y < height; y++) {
60 | for (int x = 0; x < width; x++) {
61 | //bitMatrix.get(x,y)方法返回true是黑色色块,false是白色色块
62 | if (bitMatrix.get(x, y)) {
63 | pixels[y * width + x] = color_black;//黑色色块像素设置
64 | } else {
65 | pixels[y * width + x] = color_white;// 白色色块像素设置
66 | }
67 | }
68 | }
69 | /** 4.创建Bitmap对象,根据像素数组设置Bitmap每个像素点的颜色值,并返回Bitmap对象 */
70 | Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
71 | bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
72 | return bitmap;
73 | } catch (WriterException e) {
74 | e.printStackTrace();
75 | return null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/java/webserver/util/ServerFileUtils.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import cn.settile.lzjyzq2.fileserver.application.myapplication;
4 | import webserver.bean.DiskInfo;
5 | import webserver.bean.FileInfo;
6 | import webserver.bean.UploaDirectoryInfo;
7 |
8 | import java.io.*;
9 | import java.util.ArrayList;
10 | import java.util.Arrays;
11 | import java.util.HashMap;
12 | import java.util.List;
13 | import java.util.Map;
14 |
15 | public class ServerFileUtils {
16 | static final String TAG = "ServerFileUtils";
17 | public static String separator = System.getProperty("file.separator");
18 | // public static InputStream getInputStreamForPathInAndroid(String path){
19 | // try {
20 | // InputStream inputStream = myapplication.getContext().getAssets().open(path);
21 | // if (inputStream!=null){
22 | // return inputStream;
23 | // }
24 | // } catch (IOException e) {
25 | // e.printStackTrace();
26 | // }
27 | // return null;
28 | // }
29 |
30 | public static InputStream getInputStreamForAssets(String path) {
31 | try {
32 | InputStream inputStream = myapplication.getContext().getAssets().open(path);
33 | if (inputStream != null) {
34 | return inputStream;
35 | }
36 | } catch (IOException e) {
37 | e.printStackTrace();
38 | }
39 | return null;
40 | }
41 |
42 | public static InputStream getInputStreamForPath(String path){
43 | InputStream inputStream = null;
44 | try {
45 | inputStream = new FileInputStream(path);
46 | }catch (Exception e){
47 | e.printStackTrace();
48 | }
49 | return inputStream;
50 | }
51 |
52 | public static void SaveUploadFileToPath(String path, String filename, InputStream inputStream) {
53 | OutputStream stream = null;
54 | File file = new File(path + separator + filename);
55 | try {
56 | if (!file.exists()) {
57 | file.createNewFile();
58 | }
59 | stream = new FileOutputStream(file);
60 | byte[] bs = new byte[1024];
61 | // 读取到的数据长度
62 | int len;
63 | while ((len = inputStream.read(bs)) != -1) {
64 | stream.write(bs, 0, len);
65 | }
66 | } catch (Exception e) {
67 | e.printStackTrace();
68 | }
69 | }
70 |
71 | public static void SaveUploadFileToPath(String tempfile, String targetfile) {
72 | OutputStream stream = null;
73 | InputStream inputStream = null;
74 | File tmpfile = new File(tempfile);
75 | File file = new File(targetfile);
76 | try {
77 | if (!file.exists()) {
78 | file.createNewFile();
79 | }
80 | inputStream = new FileInputStream(tempfile);
81 | stream = new FileOutputStream(file);
82 | byte[] bs = new byte[1024];
83 | // 读取到的数据长度
84 | int len;
85 | while ((len = inputStream.read(bs)) != -1) {
86 | stream.write(bs, 0, len);
87 | }
88 | } catch (Exception e) {
89 | e.printStackTrace();
90 | }
91 | }
92 |
93 |
94 | /* ------------------ WebAPI所用 -------------------- */
95 |
96 | public static DiskInfo getDiskInfo(String path) {
97 | File file = new File(path);
98 | return new DiskInfo(file.getFreeSpace(), file.getTotalSpace() - file.getFreeSpace(), file.getTotalSpace());
99 | }
100 |
101 | public static Map getDirectoryAllFileInfo(String path) {
102 | Map allfiles = new HashMap<>();
103 | List files = new ArrayList<>();
104 | List directories = new ArrayList<>();
105 | path = getDirPath(path);
106 | File file = new File(path);
107 | File[] tempList = file.listFiles();
108 | if (tempList != null) {
109 | for (int i = 0; i < tempList.length; i++) {
110 | if (tempList[i].isFile() && tempList[i].getName().charAt(0) != '$') {
111 | files.add(new FileInfo(tempList[i].getName(), tempList[i].length(), tempList[i].lastModified()));
112 | }
113 | if (tempList[i].isDirectory() && tempList[i].getName().charAt(0) != '$') {
114 | directories.add(tempList[i].getName());
115 | }
116 | }
117 | allfiles.put("files", files);
118 | allfiles.put("directories", directories);
119 | }
120 | return allfiles;
121 | }
122 |
123 | public static UploaDirectoryInfo getUploaDirectoryInfo() {
124 | UploaDirectoryInfo info = new UploaDirectoryInfo();
125 | List listdir;
126 | String path = Config.getInstance().getUPLOAD();
127 | if (path.contains("/")) {
128 | listdir = new ArrayList<>(Arrays.asList(path.split("/")));
129 | } else if (path.contains("\\\\")) {
130 | listdir = new ArrayList<>(Arrays.asList(path.split("\\\\")));
131 | } else {
132 | listdir = new ArrayList<>();
133 | }
134 | info.setDirs(listdir);
135 | info.setAllfileinfo(getDirectoryAllFileInfo(Config.getInstance().getUPLOAD() + separator));
136 | return info;
137 | }
138 |
139 | public static Boolean mkdir(String dir, String name) {
140 | File file = new File(getDirPath(dir) + name);
141 | if (!file.exists()) {
142 | file.mkdirs();
143 | return true;
144 | }
145 | return false;
146 | }
147 |
148 | public static InputStream DownloadFile(String path, String name) {
149 | return getInputStreamForPath(getDirPath(path) + name);
150 | }
151 |
152 | public static Boolean DeleteFile(String path, String name) {
153 | File file = new File(getDirPath(path) + name);
154 | if (file.exists()) {
155 | return DeleteFile(file);
156 | }
157 | return false;
158 | }
159 |
160 | public static Boolean DeleteFile(File file) {
161 | if (!file.exists()) {
162 | return false;
163 | }
164 | if (file.isDirectory()) {
165 | File[] files = file.listFiles();
166 | for (File f : files) {
167 | DeleteFile(f);
168 | }
169 | }
170 | return file.delete();
171 | }
172 |
173 | public static Boolean RemoveTo(String oldpath, String newpath, String name) {
174 | File file = new File(getDirPath(oldpath) + name);
175 | if (file.exists())
176 | if (file.renameTo(new File(getDirPath(newpath) + name)))
177 | return true;
178 | return false;
179 | }
180 |
181 | public static Boolean RenameTo(String path, String oldname, String newname) {
182 | File file = new File(getDirPath(path) + oldname);
183 | if (file.exists())
184 | if (file.renameTo(new File(getDirPath(path) + newname)))
185 | return true;
186 | return false;
187 | }
188 |
189 | public static String getDirPath(String path) {
190 | if (path.charAt(path.length() - 1) != '/' || path.charAt(path.length() - 1) != '\\')
191 | path = path + separator;
192 | return path;
193 | }
194 |
195 | public static List getDirs(String path) {
196 | List directories = new ArrayList<>();
197 | path = getDirPath(path);
198 | File file = new File(path);
199 | File[] tempList = file.listFiles();
200 | if (tempList != null) {
201 | for (int i = 0; i < tempList.length; i++) {
202 | if (tempList[i].isDirectory() && tempList[i].getName().charAt(0) != '$') {
203 | directories.add(tempList[i].getName());
204 | }
205 | }
206 | }
207 | return directories;
208 | }
209 |
210 | public static String getPathforArray(String[] path){
211 | StringBuilder pathbuilder = new StringBuilder();
212 | pathbuilder.append(separator);
213 | for (int i=0;i
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/drawable/icon_help_a_on.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/drawable/icon_wifi_a_off.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/drawable/icon_wifi_a_on.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/drawable/joinqr.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/drawable/joinqr.jpg
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/drawable/main_item_image_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
18 |
23 |
24 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/layout/activity_help.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
20 |
23 |
24 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/layout/activity_help_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
21 |
22 |
28 |
29 |
30 |
31 |
34 |
35 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 |
16 |
26 |
27 |
28 |
38 |
39 |
43 |
44 |
48 |
49 |
54 |
55 |
60 |
61 |
67 |
68 |
69 |
73 |
74 |
75 |
82 |
83 |
90 |
94 |
95 |
101 |
102 |
107 |
108 |
109 |
110 |
118 |
125 |
131 |
132 |
136 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/layout/activity_permissions.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/layout/activity_qrcode.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
18 |
23 |
24 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/layout/helpitem_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/FileServerAndroid/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/values-en/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | FileServer
4 | No WIFI
5 | Closed
6 | Running
7 | ip
8 | Lack of permission
9 | Lack of necessary permissions, if you want to continue using please confirm
10 | OK
11 | Cancel
12 | Lack of necessary permissions. Continue to use Confirm and allow permissions in the settings. Otherwise, you will quit the program.
13 | See QR-Code
14 | Help
15 | Help
16 | Main
17 | File Server
18 | No content
19 | Unknown
20 | Upload Path
21 | The default upload path:
22 | permission
23 |
24 | Notes: The running time needs to read, store and modify the files. Lack of necessary permissions will lead to the failure of running, so do not close the necessary permissions.\n
25 | Network: If the watch is TicWear, please go to Settings-Privilege Management-FileServer and set the mobile data privilege to "Opened".\n
26 | Storage: You need to write and read local content, so please keep storage privileges open in the settings.
27 |
28 | Careful
29 | Background running:The application supports background running. If it is no longer in use, please manually slide to the right to close the main interface to end the application running to reduce power consumption.
30 | Twiliglt mode
31 | When the watches are not operated for a long time, the application will enter the low-light mode. At this time, it is necessary to click the interface to exit the low-light mode and continue to use the application.
32 | Twiliglt mode
33 | Network
34 |
35 | Note: If the watch is TicWear, please go to Settings - Privilege Management - FileServer and set the Mobile Data Privilege to "Opened".\n
36 | Network Requirements: Watches need to be connected to WIFI and connected to the same LAN as PCs or mobile phones. \n
37 | Content Loading: For the first time, it may be slower to open the web page. Please wait patiently. If there is no response, please check whether the connected network and the inputted address are correct.\n
38 |
39 | Use steps
40 |
41 | ①Consent authority\n
42 | ②If the watch is TicWear, please go to Settings - Privilege Management - FileServer and set the Mobile Data Privilege to "Opened".\n
43 | ③On the home page, click on the switch next to the file service to start the service.\n
44 | ④Enter the displayed IP address in the browser address bar, or use the mobile phone to scan the QR-Code to open the web address.\n
45 | ⑤When not in use, click on the switch next to the file service to close the service and save electricity.\n
46 | ⑥After the end of use, slide to the right and end the application process.
47 | If the watch is TicWear, please go to Settings-Privilege Management-FileServer and set the mobile data privilege to \"Opened\".
48 | QQ:287474030
49 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/values-zh/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | FileServer
4 | WIFI尚未连接
5 | 未启动
6 | 已启动
7 | ip
8 | 缺少权限
9 | 缺少必要的权限,如要继续使用请确认
10 | 确认
11 | 取消
12 | 缺少必要的权限,要继续使用请确认,并在设置中允许权限,否则会退出程序
13 | 点击查看二维码
14 | 查看帮助
15 | 帮助
16 | 主页
17 | 文件服务
18 | 无
19 | 无
20 | 上传路径
21 | 默认上传路径为:
22 | 权限
23 |
24 | 注意事项:运行时需要对文件进行读取、存储、修改,缺少必要的权限会导致无法运行,所以请勿关闭必要的权限。\n
25 | 网络:若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。\n
26 | 存储:需要写入读取本地内容,所以请在设置中保持存储权限开启。
27 |
28 | 注意事项
29 | 后台运行:应用支持后台运行,如果不用请手动向右滑动关闭主界面来结束应用程序的运行。
30 | 微光模式
31 | 当长时间不对手表进行操作后,应用会进入微光模式,此时需要先点击一次界面来退出微光模式,来继续使用应用。
32 | 微光模式中
33 | 网络
34 |
35 | 注意事项:若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。\n
36 | 网络需求:手表需连接WIFI,且与PC或手机连入在同一局域网。\n
37 | 内容加载:首次使用,打开网页时可能速度较慢,请耐心等待,如有未响应等问题,请检查连接的网络和输入的网址是否正确。\n
38 |
39 | 使用步骤
40 |
41 | ①授予权限\n
42 | ②若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。
43 | ③在主页中点击文件服务旁的开关启动服务。\n
44 | ④在浏览器地址栏中输入显示的IP地址,或使用手机扫描二维码打开网址。\n
45 | ⑤暂不使用时,点击文件服务旁的开关关闭服务,节省电量。\n
46 | ⑥结束使用后,向右滑动,结束应用进程。
47 |
48 | 若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。
49 | QQ:287474030
50 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 0dp
8 |
9 |
14 | 5dp
15 |
16 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FileServer
3 | WIFI尚未连接
4 | 未启动
5 | 已启动
6 | ip
7 | 缺少权限
8 | 缺少必要的权限,如要继续使用请确认
9 | 确认
10 | 取消
11 | 缺少必要的权限,要继续使用请确认,并在设置中允许权限,否则会退出程序
12 | 点击查看二维码
13 | 查看帮助
14 | 使用帮助
15 | 主页
16 | 微光模式中
17 | 文件服务
18 | 无
19 | 无
20 | 上传路径
21 | 默认上传路径为:
22 | 权限
23 |
24 | 注意事项:运行时需要对文件进行读取、存储、修改,缺少必要的权限会导致无法运行,所以请勿关闭必要的权限。\n
25 | 网络:若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。\n
26 | 存储:需要写入读取本地内容,所以请在设置中保持存储权限开启。
27 |
28 | 注意事项
29 | 后台运行:应用支持后台运行,如果不再使用时,请手动向右滑动关闭主界面来结束应用程序的运行,来减少电量的消耗。
30 | 微光模式
31 | 当长时间不对手表进行操作后,应用会进入微光模式,此时需要先点击一次界面来退出微光模式,来继续使用应用。
32 | 网络
33 |
34 | 注意事项:若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。\n
35 | 网络需求:手表需连接WIFI,且与PC或手机连入在同一局域网。\n
36 | 内容加载:首次使用,打开网页时可能速度较慢,请耐心等待,如有未响应等问题,请检查连接的网络和输入的网址是否正确。\n
37 |
38 | 使用步骤
39 |
40 | ①授予权限\n
41 | ②若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。
42 | ③在主页中点击文件服务旁的开关启动服务。\n
43 | ④在浏览器地址栏中输入显示的IP地址,或使用手机扫描二维码打开网址。\n
44 | ⑤暂不使用时,点击文件服务旁的开关关闭服务,节省电量。\n
45 | ⑥结束使用后,向右滑动,结束应用进程。
46 |
47 | 若手表为TicWear,请转至设置-权限管理-FileServer中,将移动数据权限设置为“已开启”。
48 | QQ:287474030
49 |
50 |
--------------------------------------------------------------------------------
/FileServerAndroid/wear/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/FileServerCore/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/FileServerCore/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/FileServerCore/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | }
4 |
5 | group 'cn.lzjyzq2.settile.fileserver'
6 | version '1.0'
7 |
8 | sourceCompatibility = 1.8
9 |
10 | repositories {
11 | mavenCentral()
12 | }
13 | tasks.withType(JavaCompile) {
14 | options.encoding = "UTF-8"
15 | }
16 | dependencies {
17 | testCompile group: 'junit', name: 'junit', version: '4.12'
18 | compile 'javax.servlet:javax.servlet-api:4.0.1'
19 | compile 'org.nanohttpd:nanohttpd-apache-fileupload:2.3.1'
20 | compile 'org.nanohttpd:nanohttpd:2.3.1'
21 | compile 'com.alibaba:fastjson:1.2.58'
22 | compile 'org.xerial:sqlite-jdbc:3.27.2.1'
23 | compile 'com.j256.ormlite:ormlite-jdbc:5.1'
24 | }
25 |
--------------------------------------------------------------------------------
/FileServerCore/build/resources/main/server.properties:
--------------------------------------------------------------------------------
1 | WEBDOC = G:/java project/FileServer/FileServerWebDOC
2 | DISKPATH = G:/
3 | PORT = 8080
4 | UPLOAD = G:/java project/FileServer/FileServerWebDOC/upload
--------------------------------------------------------------------------------
/FileServerCore/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/FileServerCore/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/FileServerCore/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'fileserver'
2 |
3 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/database/DBHelper.java:
--------------------------------------------------------------------------------
1 | package database;
2 |
3 | import com.j256.ormlite.dao.Dao;
4 | import com.j256.ormlite.dao.DaoManager;
5 | import com.j256.ormlite.jdbc.JdbcConnectionSource;
6 | import com.j256.ormlite.support.ConnectionSource;
7 | import com.j256.ormlite.table.DatabaseTableConfig;
8 | import com.j256.ormlite.table.TableUtils;
9 | import database.bean.TempFile;
10 | import database.bean.UserBean;
11 |
12 | import java.sql.SQLException;
13 |
14 | public class DBHelper {
15 | private static final String TAG = "DBHelper";
16 | private static Dao TempFiledao;
17 | private static Dao UserBeanDao;
18 |
19 | public static Dao getTempFileDao() throws SQLException {
20 | if (TempFiledao == null) {
21 | TempFiledao = DaoManager.createDao(getConnectionSource(),
22 | TempFile.class);
23 | }
24 | return TempFiledao;
25 | }
26 |
27 | public static Dao getUserBeanDao() throws SQLException {
28 | if (UserBeanDao == null) {
29 | UserBeanDao = DaoManager.createDao(getConnectionSource(),
30 | UserBean.class);
31 | }
32 | return UserBeanDao;
33 | }
34 |
35 | public static void init() {
36 | try {
37 | TableUtils.createTableIfNotExists(getConnectionSource(), TempFile.class);
38 | // if (TableUtils.createTableIfNotExists(getConnectionSource(), UserBean.class) > 0) {
39 | // getUserBeanDao().create(new UserBean());
40 | // }
41 | } catch (Exception exception) {
42 | exception.printStackTrace();
43 | }
44 | }
45 |
46 | public static ConnectionSource getConnectionSource() throws SQLException {
47 | String connectionString = "jdbc:sqlite:data.db";
48 | return new JdbcConnectionSource(connectionString);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/database/bean/TempFile.java:
--------------------------------------------------------------------------------
1 | package database.bean;
2 |
3 | import com.j256.ormlite.field.DatabaseField;
4 | import com.j256.ormlite.table.DatabaseTable;
5 |
6 | @DatabaseTable(tableName = "TempFile")
7 | public class TempFile {
8 | @DatabaseField(generatedId = true)
9 | private int id;
10 | @DatabaseField
11 | private String path;
12 | @DatabaseField(unique = true)
13 | private String name;
14 | @DatabaseField
15 | private String type;
16 |
17 | public TempFile(int id, String path, String name, String type) {
18 | this.id = id;
19 | this.path = path;
20 | this.name = name;
21 | this.type = type;
22 | }
23 |
24 | public TempFile() {
25 | }
26 |
27 | public int getId() {
28 | return id;
29 | }
30 |
31 | public void setId(int id) {
32 | this.id = id;
33 | }
34 |
35 | public String getPath() {
36 | return path;
37 | }
38 |
39 | public void setPath(String path) {
40 | this.path = path;
41 | }
42 |
43 | public String getName() {
44 | return name;
45 | }
46 |
47 | public void setName(String name) {
48 | this.name = name;
49 | }
50 |
51 | public String getType() {
52 | return type;
53 | }
54 |
55 | public void setType(String type) {
56 | this.type = type;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/database/bean/UserBean.java:
--------------------------------------------------------------------------------
1 | package database.bean;
2 |
3 | import com.j256.ormlite.field.DatabaseField;
4 | import com.j256.ormlite.table.DatabaseTable;
5 |
6 | @DatabaseTable(tableName = "UserBean")
7 | public class UserBean {
8 | @DatabaseField(unique = true)
9 | private String uid;
10 | @DatabaseField
11 | private String token;
12 | @DatabaseField
13 | private long lasttime;
14 | @DatabaseField
15 | private UserType userType;
16 |
17 | public UserBean() {
18 | }
19 |
20 | public UserBean(String uid, String token, long lasttime) {
21 | this.uid = uid;
22 | this.token = token;
23 | this.lasttime = lasttime;
24 | }
25 |
26 | public String getUid() {
27 | return uid;
28 | }
29 |
30 | public void setUid(String uid) {
31 | this.uid = uid;
32 | }
33 |
34 | public String getToken() {
35 | return token;
36 | }
37 |
38 | public void setToken(String token) {
39 | this.token = token;
40 | }
41 |
42 | public long getLasttime() {
43 | return lasttime;
44 | }
45 |
46 | public void setLasttime(long lasttime) {
47 | this.lasttime = lasttime;
48 | }
49 |
50 | public static String createToken(String s){
51 |
52 | return "";
53 | }
54 |
55 | enum UserType{
56 | Admin,Normal
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/bean/DiskInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.bean;
2 |
3 | public class DiskInfo {
4 | public long freespace;
5 | public long usedspace;
6 | public long totalspace;
7 |
8 | public DiskInfo() {
9 | }
10 |
11 | public DiskInfo(long freespace, long usedspace, long totalspace) {
12 | this.freespace = freespace;
13 | this.usedspace = usedspace;
14 | this.totalspace = totalspace;
15 | }
16 |
17 | public long getFreespace() {
18 | return freespace;
19 | }
20 |
21 | public void setFreespace(long freespace) {
22 | this.freespace = freespace;
23 | }
24 |
25 | public long getUsedspace() {
26 | return usedspace;
27 | }
28 |
29 | public void setUsedspace(long usedspace) {
30 | this.usedspace = usedspace;
31 | }
32 |
33 | public long getTotalspace() {
34 | return totalspace;
35 | }
36 |
37 | public void setTotalspace(long totalspace) {
38 | this.totalspace = totalspace;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/bean/FileInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.bean;
2 |
3 | public class FileInfo {
4 | String name;
5 | long size;
6 | long time;
7 |
8 | public FileInfo(String name, long size, long time) {
9 | this.name = name;
10 | this.size = size;
11 | this.time = time;
12 | }
13 |
14 | public FileInfo() {
15 | }
16 |
17 | public String getName() {
18 | return name;
19 | }
20 |
21 | public void setName(String name) {
22 | this.name = name;
23 | }
24 |
25 | public long getSize() {
26 | return size;
27 | }
28 |
29 | public void setSize(long size) {
30 | this.size = size;
31 | }
32 |
33 | public long getTime() {
34 | return time;
35 | }
36 |
37 | public void setTime(long time) {
38 | this.time = time;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/bean/UploaDirectoryInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.bean;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | public class UploaDirectoryInfo {
7 | List dirs;
8 | Map allfileinfo;
9 |
10 | public UploaDirectoryInfo(List dirs, Map allfileinfo) {
11 | this.dirs = dirs;
12 | this.allfileinfo = allfileinfo;
13 | }
14 |
15 | public List getDirs() {
16 | return dirs;
17 | }
18 |
19 | public void setDirs(List dirs) {
20 | this.dirs = dirs;
21 | }
22 |
23 | public Map getAllfileinfo() {
24 | return allfileinfo;
25 | }
26 |
27 | public void setAllfileinfo(Map allfileinfo) {
28 | this.allfileinfo = allfileinfo;
29 | }
30 |
31 | public UploaDirectoryInfo() {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/client/ServerRunner.java:
--------------------------------------------------------------------------------
1 | package webserver.client;
2 |
3 | import webserver.WebServer;
4 | import webserver.util.Log;
5 | import webserver.util.VersionUtil;
6 |
7 | import java.io.IOException;
8 | import java.util.Scanner;
9 |
10 | public class ServerRunner{
11 |
12 | private static final String TAG = "ServerRunner";
13 | private static WebServer webServer;
14 | public static void main(String[] args) {
15 | Log.e(TAG, VersionUtil.getInstance().getVersion());
16 | webServer = new WebServer();
17 | try {
18 | webServer.start();
19 | }catch (Exception e){
20 | Log.e(TAG,e.toString());
21 | }
22 | Scanner scanner = new Scanner(System.in);
23 | String command;
24 | while ((command=scanner.next())!=null){
25 | switch (command){
26 | case "start":
27 | if(webServer!=null&&!webServer.isAlive()) {
28 | try {
29 | webServer.start();
30 | } catch (IOException e) {
31 | Log.e(TAG,e.toString());
32 | }
33 | }
34 | break;
35 | case "stop":
36 | if(webServer!=null) {
37 | webServer.closeAllConnections();
38 | webServer.stop();
39 | }
40 | break;
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/responsebean/TempFileInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.responsebean;
2 |
3 | public class TempFileInfo {
4 | public int id;
5 | }
6 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/responsebean/VersionInfo.java:
--------------------------------------------------------------------------------
1 | package webserver.responsebean;
2 |
3 | public class VersionInfo {
4 | public String version;
5 |
6 | public VersionInfo() {
7 | }
8 |
9 | public String getVersion() {
10 | return version;
11 | }
12 |
13 | public void setVersion(String version) {
14 | this.version = version;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/util/Config.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import java.net.ServerSocket;
4 | import java.util.ResourceBundle;
5 |
6 | public class Config {
7 | private static Config config = new Config();
8 | private int PORT = 8080;
9 | private String WEBDOC = null;
10 | private String DISKPATH = null;
11 | private String UPLOAD = null;
12 | private Config(){
13 | ResourceBundle resource = ResourceBundle.getBundle("server");
14 | try {
15 | WEBDOC = resource.getString("WEBDOC");
16 | DISKPATH = resource.getString("DISKPATH");
17 | ServerSocket serverSocket = new ServerSocket(0); //读取空闲的可用端口
18 | PORT = serverSocket.getLocalPort(); //Integer.parseInt(resource.getString("PORT"));
19 | serverSocket.close();
20 | UPLOAD = resource.getString("UPLOAD");
21 | } catch (Exception e) {
22 | e.printStackTrace();
23 | }
24 | }
25 | public static Config getInstance(){
26 | return config;
27 | }
28 |
29 | public int getPORT() {
30 | return PORT;
31 | }
32 |
33 | public String getWEBDOC() {
34 | return WEBDOC;
35 | }
36 |
37 | public String getDISKPATH() {
38 | return DISKPATH;
39 | }
40 |
41 | public String getUPLOAD() {
42 | return UPLOAD;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/util/Log.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import static java.lang.System.out;
4 |
5 | public class Log {
6 | class LogType {
7 | public static final int i = 30;
8 | public static final int e = 31;
9 | public static final int m = 34;
10 | }
11 |
12 | private static final String color_head_h = "\033[";
13 | private static final String color_head_e = "m";
14 | private static final String color_end = "\033[0m";
15 | private static final String e_color = "36";
16 |
17 | public static void e(String tag, String msg) {
18 | log(LogType.e, tag, msg);
19 | }
20 |
21 | public static void i(String tag, String msg) {
22 | log(LogType.i, tag, msg);
23 | }
24 |
25 | public static void m(String tag, String msg) {
26 | log(LogType.m, tag, msg);
27 | }
28 |
29 | private static void log(int logType, String tag, String msg) {
30 | out.println(color_head_h + logType + color_head_e + "[" + tag + "][" + TimeUtil.getNowTime() + "]:" + msg + color_end);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/util/MimeUtil.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import java.util.ResourceBundle;
4 |
5 | public class MimeUtil {
6 | static MimeUtil instance = new MimeUtil();
7 | ResourceBundle resourceBundle = null;
8 |
9 | private MimeUtil() {
10 | resourceBundle = ResourceBundle.getBundle("mime");
11 | }
12 |
13 | public Boolean hasKeys(String key) {
14 | return resourceBundle.containsKey(key);
15 | }
16 |
17 | public String getMimeType(String key) {
18 | if (hasKeys(key))
19 | return resourceBundle.getString(key);
20 | return "*/*";
21 | }
22 | public String getMimeTypeforPath(String path){
23 | String type = path.substring(path.lastIndexOf('.') + 1, path.length());
24 | return getMimeType(type);
25 | }
26 |
27 | public static MimeUtil getInstance() {
28 | return instance;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/util/ServerFileUtils.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import webserver.bean.DiskInfo;
4 | import webserver.bean.FileInfo;
5 | import webserver.bean.UploaDirectoryInfo;
6 |
7 | import java.io.*;
8 | import java.util.*;
9 |
10 | public class ServerFileUtils {
11 | static final String TAG = "ServerFileUtils";
12 | public static String separator = System.getProperty("file.separator");
13 |
14 | public static InputStream getInputStreamForPath(String path) {
15 | InputStream stream = null;
16 | File file = new File(path);
17 | try {
18 | if (file.exists()) {
19 | stream = new FileInputStream(path);
20 | }
21 | } catch (Exception e) {
22 | e.printStackTrace();
23 | }
24 | return stream;
25 | }
26 |
27 | public static void SaveUploadFileToPath(String path, String filename, InputStream inputStream) {
28 | OutputStream stream = null;
29 | File file = new File(path + separator + filename);
30 | try {
31 | if (!file.exists()) {
32 | file.createNewFile();
33 | }
34 | stream = new FileOutputStream(file);
35 | byte[] bs = new byte[1024];
36 | // 读取到的数据长度
37 | int len;
38 | while ((len = inputStream.read(bs)) != -1) {
39 | stream.write(bs, 0, len);
40 | }
41 | } catch (Exception e) {
42 | e.printStackTrace();
43 | }
44 | }
45 |
46 | public static void SaveUploadFileToPath(String tempfile, String targetfile) {
47 | OutputStream stream = null;
48 | InputStream inputStream = null;
49 | File tmpfile = new File(tempfile);
50 | File file = new File(targetfile);
51 | try {
52 | if (!file.exists()) {
53 | file.createNewFile();
54 | }
55 | inputStream = new FileInputStream(tempfile);
56 | stream = new FileOutputStream(file);
57 | byte[] bs = new byte[1024];
58 | // 读取到的数据长度
59 | int len;
60 | while ((len = inputStream.read(bs)) != -1) {
61 | stream.write(bs, 0, len);
62 | }
63 | } catch (Exception e) {
64 | e.printStackTrace();
65 | }
66 | }
67 |
68 |
69 | /* ------------------ WebAPI所用 -------------------- */
70 |
71 | public static DiskInfo getDiskInfo(String path) {
72 | File file = new File(path);
73 | return new DiskInfo(file.getFreeSpace(), file.getTotalSpace() - file.getFreeSpace(), file.getTotalSpace());
74 | }
75 |
76 | public static Map getDirectoryAllFileInfo(String path) {
77 | Map allfiles = new HashMap<>();
78 | List files = new ArrayList<>();
79 | List directories = new ArrayList<>();
80 | path = getDirPath(path);
81 | File file = new File(path);
82 | File[] tempList = file.listFiles();
83 | if(tempList!=null){
84 | for (int i = 0; i < tempList.length; i++) {
85 | if (tempList[i].isFile()&&tempList[i].getName().charAt(0)!='$') {
86 | files.add(new FileInfo(tempList[i].getName(),tempList[i].length(),tempList[i].lastModified()));
87 | }
88 | if (tempList[i].isDirectory()&&tempList[i].getName().charAt(0)!='$') {
89 | directories.add(tempList[i].getName());
90 | }
91 | }
92 | allfiles.put("files", files);
93 | allfiles.put("directories", directories);
94 | }
95 | return allfiles;
96 | }
97 |
98 | public static UploaDirectoryInfo getUploaDirectoryInfo() {
99 | UploaDirectoryInfo info = new UploaDirectoryInfo();
100 | List listdir;
101 | String path = Config.getInstance().getUPLOAD();
102 | if (path.contains("/")) {
103 | listdir = new ArrayList<>(Arrays.asList(path.split("/")));
104 | } else if(path.contains("\\\\")){
105 | listdir = new ArrayList<>(Arrays.asList(path.split("\\\\")));
106 | }else {
107 | listdir = new ArrayList<>();
108 | }
109 | info.setDirs(listdir);
110 | info.setAllfileinfo(getDirectoryAllFileInfo(Config.getInstance().getUPLOAD() + separator));
111 | return info;
112 | }
113 |
114 | public static Boolean mkdir(String dir, String name) {
115 | File file = new File(getDirPath(dir) + name);
116 | if (!file.exists()) {
117 | file.mkdirs();
118 | return true;
119 | }
120 | return false;
121 | }
122 |
123 | public static InputStream DownloadFile(String path, String name) {
124 | return getInputStreamForPath(getDirPath(path) + name);
125 | }
126 |
127 | public static Boolean DeleteFile(String path, String name) {
128 | File file = new File(getDirPath(path) + name);
129 | if (file.exists()) {
130 | return DeleteFile(file);
131 | }
132 | return false;
133 | }
134 | public static Boolean DeleteFile(File file){
135 | if (!file.exists()) {
136 | return false;
137 | }
138 | if (file.isDirectory()) {
139 | File[] files = file.listFiles();
140 | for (File f : files) {
141 | DeleteFile(f);
142 | }
143 | }
144 | return file.delete();
145 | }
146 |
147 | public static Boolean RemoveTo(String oldpath, String newpath, String name) {
148 | File file = new File(getDirPath(oldpath) + name);
149 | if (file.exists())
150 | if (file.renameTo(new File(getDirPath(newpath) + name)))
151 | return true;
152 | return false;
153 | }
154 |
155 | public static Boolean RenameTo(String path, String oldname, String newname) {
156 | File file = new File(getDirPath(path)+oldname);
157 | if (file.exists())
158 | if (file.renameTo(new File(getDirPath(path)+newname)))
159 | return true;
160 | return false;
161 | }
162 |
163 | public static String getDirPath(String path) {
164 | if (path.charAt(path.length() - 1) != '/' || path.charAt(path.length() - 1) != '\\')
165 | path = path + separator;
166 | return path;
167 | }
168 | public static List getDirs(String path) {
169 | List directories = new ArrayList<>();
170 | path = getDirPath(path);
171 | File file = new File(path);
172 | File[] tempList = file.listFiles();
173 | if(tempList!=null){
174 | for (int i = 0; i < tempList.length; i++) {
175 | if (tempList[i].isDirectory()&&tempList[i].getName().charAt(0)!='$') {
176 | directories.add(tempList[i].getName());
177 | }
178 | }
179 | }
180 | return directories;
181 | }
182 |
183 | }
184 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/util/TimeUtil.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import java.util.Calendar;
4 |
5 | public class TimeUtil {
6 | public static String getNowTime(){
7 | return Calendar.getInstance().get(Calendar.YEAR)+"."+
8 | (Calendar.getInstance().get(Calendar.MONTH)+1)+"."+
9 | Calendar.getInstance().get(Calendar.DAY_OF_MONTH)+" "
10 | + Calendar.getInstance().get(Calendar.HOUR_OF_DAY)+":"
11 | + Calendar.getInstance().get(Calendar.MINUTE)+":"
12 | + Calendar.getInstance().get(Calendar.SECOND);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/java/webserver/util/VersionUtil.java:
--------------------------------------------------------------------------------
1 | package webserver.util;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.util.Properties;
6 | import java.util.ResourceBundle;
7 |
8 | public class VersionUtil {
9 | static VersionUtil instance = new VersionUtil();
10 | Properties properties;
11 | private VersionUtil() {
12 | properties = new Properties();
13 | InputStream in = VersionUtil.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
14 | try {
15 | properties.load(in);
16 | } catch (IOException e) {
17 | e.printStackTrace();
18 | }
19 | }
20 |
21 | public String getVersion(){
22 | return properties.getProperty("Manifest-Version");
23 | }
24 |
25 | public static VersionUtil getInstance() {
26 | return instance;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: webserver.client.ServerRunner
3 | Class-Path: lib\fastjson-1.2.58.jar lib\ormlite-core-5.1.jar lib\ormlite
4 | -jdbc-5.1.jar lib\commons-fileupload-1.3.1.jar lib\commons-io-2.2.jar l
5 | ib\javax.servlet-api-4.0.1.jar lib\hamcrest-core-1.3.jar lib\nanohttpd-
6 | apache-fileupload-2.3.1.jar lib\nanohttpd-2.3.1.jar lib\sqlite-jdbc-3.2
7 | 7.2.1.jar
8 |
9 |
--------------------------------------------------------------------------------
/FileServerCore/src/main/resources/server.properties:
--------------------------------------------------------------------------------
1 | WEBDOC = G:/java project/FileServer/fileserverwebdoc/dist
2 | DISKPATH = F:/
3 | PORT = 8081
4 | UPLOAD = G:/java project/FileServer/fileserverwebdoc/upload
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FileServer
2 | 基于NanoHttpd二次开发的WebServer,用于文件上传
3 | ---
4 | ## FileServerCore
5 | - 便于移植到Android上的核心
6 | 1. 使用IDEA打开FileServerRCore
7 | 2. 配置 src/main/resources/server.properties
8 | - WEBDOC = FileServerWebDOC的根目录
9 | - DISKPATH = 上传文件所在的磁盘根目录
10 | - PORT = 端口号
11 | - UPLOAD = 上传文件夹所在路径
12 | 3. run main/webserver/client/ServerRunner.main()
13 | 4. 当需进行一个版本的新更新时,应更新 MANIFEST.MF 中的版本号
14 | ---
15 | ## FileServerAndroid
16 | - 包含Phone与Wear两个Model
17 | - 当前仅移植Wear Model
18 | 1. 使用Android Studio打开FileServerAndroid
19 | 2. build wear
20 | ---
21 | ## FileServerWebDoc
22 | - 前端页面
23 | - 使用Vue.js与AntD前端框架开发
24 | 1. 克隆到本地后,应按照 https://vue.ant.design/docs/vue/use-with-vue-cli-cn/ 配置依赖
25 | - 可使用vue ui打开可视化UI进行配置
26 | 2. 需要的依赖有
27 | - 运行依赖
28 | - VueRouter
29 | - axios
30 | - 开发依赖
31 | - less
32 | - less loader
33 | 3. 可使用 npm run serve 进行热更新测试
34 | 4. 可使用 npm run build 进行编译
35 | - 编译后静态页面内容应在 文件夹根目录/dist/ 文件夹下
36 | ---
37 | ### 加入群交流
38 | 
39 |
40 | ### 如果喜欢可以捐助~~~
41 | 
42 |
--------------------------------------------------------------------------------
/fileserverwebdoc/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 |
--------------------------------------------------------------------------------
/fileserverwebdoc/README.md:
--------------------------------------------------------------------------------
1 | # fileserverwebdoc
2 |
3 | ## Project setup
4 | ```
5 | npm install
6 | ```
7 |
8 | ### Compiles and hot-reloads for development
9 | ```
10 | npm run serve
11 | ```
12 |
13 | ### Compiles and minifies for production
14 | ```
15 | npm run build
16 | ```
17 |
18 | ### Run your tests
19 | ```
20 | npm run test
21 | ```
22 |
23 | ### Lints and fixes files
24 | ```
25 | npm run lint
26 | ```
27 |
28 | ### Customize configuration
29 | See [Configuration Reference](https://cli.vuejs.org/config/).
30 |
--------------------------------------------------------------------------------
/fileserverwebdoc/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app'
4 | ],
5 | "plugins": [
6 | [
7 | "import",
8 | { libraryName: "ant-design-vue", libraryDirectory: "es", style: true }
9 | ]
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/fileserverwebdoc/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fileserverwebdoc",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "ant-design-vue": "^1.3.10",
12 | "axios": "^0.21.1",
13 | "vue": "^2.6.10",
14 | "vue-router": "^3.0.3"
15 | },
16 | "devDependencies": {
17 | "@vue/cli-plugin-babel": "^3.8.0",
18 | "@vue/cli-plugin-eslint": "^3.8.0",
19 | "@vue/cli-service": "^3.8.0",
20 | "babel-eslint": "^10.0.1",
21 | "babel-plugin-import": "^1.12.0",
22 | "eslint": "^5.16.0",
23 | "eslint-plugin-vue": "^5.0.0",
24 | "less": "^3.9.0",
25 | "less-loader": "^5.0.0",
26 | "vue-template-compiler": "^2.6.10"
27 | },
28 | "eslintConfig": {
29 | "root": true,
30 | "env": {
31 | "node": true
32 | },
33 | "extends": [
34 | "plugin:vue/essential",
35 | "eslint:recommended"
36 | ],
37 | "rules": {},
38 | "parserOptions": {
39 | "parser": "babel-eslint"
40 | }
41 | },
42 | "postcss": {
43 | "plugins": {
44 | "autoprefixer": {}
45 | }
46 | },
47 | "browserslist": [
48 | "> 1%",
49 | "last 2 versions"
50 | ]
51 | }
52 |
--------------------------------------------------------------------------------
/fileserverwebdoc/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/fileserverwebdoc/public/favicon.ico
--------------------------------------------------------------------------------
/fileserverwebdoc/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 文件上传
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
17 |
18 |
19 |
20 |
21 |
55 |
56 |
88 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/assets/joinQR.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/fileserverwebdoc/src/assets/joinQR.jpg
--------------------------------------------------------------------------------
/fileserverwebdoc/src/assets/jz.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/fileserverwebdoc/src/assets/jz.png
--------------------------------------------------------------------------------
/fileserverwebdoc/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lzjyzq2/FileServer/89d46d2c78e9ad00d86fb055ee9300ee6071579b/fileserverwebdoc/src/assets/logo.png
--------------------------------------------------------------------------------
/fileserverwebdoc/src/components/FileItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 | {{type=='file'?this.itemdata.name:this.itemdata}}
16 |
17 | {{ type=='file'?getfilesize:'-'}}
18 | {{type=='file'?gettime:'-'}}
19 |
20 |
21 |
22 |
23 | {{breakpoint?'':'打开'}}
24 | {{breakpoint?'':'移动'}}
25 | {{breakpoint?'':'重命名'}}
26 | {{breakpoint?'':'下载'}}
27 | {{breakpoint?'':'删除'}}
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
118 |
143 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/components/MyProgress.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
22 |
23 |
48 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/components/NavMenu.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 | 文件上传
11 |
12 |
13 | 文件管理
14 |
15 |
16 | 设置
17 |
18 |
19 | 使用帮助
20 |
21 |
22 | 关于
23 |
24 |
25 |
26 |
27 |
63 |
65 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/components/UploadItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{this.itemdata.file.name}}
5 | {{this.itemdata.info.type}}
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
38 |
63 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import { Layout,Menu,Icon,Button,List,Row,Col,Checkbox,Breadcrumb,Popover,Modal,Input,Spin,Tree,Message,Divider } from 'ant-design-vue';
3 | import App from "./App";
4 | import axios from 'axios';
5 | import router from './router';
6 | Vue.use(Layout);
7 | Vue.use(Menu);
8 | Vue.use(Icon);
9 | Vue.use(Button);
10 | Vue.use(List);
11 | Vue.use(Row);
12 | Vue.use(Col);
13 | Vue.use(Checkbox);
14 | Vue.use(Breadcrumb);
15 | Vue.use(Popover);
16 | Vue.use(Modal);
17 | Vue.use(Input);
18 | Vue.use(Spin);
19 | Vue.use(Tree);
20 | Vue.use(Divider);
21 | axios.defaults.withCredentials=true;
22 | Vue.prototype.axios = axios;
23 | Vue.prototype.$message = Message;
24 | Vue.config.productionTip = false;
25 |
26 | new Vue({
27 | router,
28 | render: h => h(App)
29 | }).$mount('#app')
30 | router.beforeEach(
31 | (to, from, next) => {
32 | /* 路由发生变化修改页面title */
33 | if (to.meta.title) {
34 | document.title = to.meta.title
35 | }
36 | next()
37 | }
38 | )
--------------------------------------------------------------------------------
/fileserverwebdoc/src/router.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Router from 'vue-router';
3 | import UploadPanel from './views/UploadPanel';
4 | import Manage from './views/Manage';
5 | import About from './views/About';
6 | import Help from './views/Help';
7 | import Settings from './views/Settings';
8 | Vue.use(Router)
9 |
10 | export default new Router({
11 | mode: 'history',
12 | routes: [
13 | {
14 | path: '/',
15 | name: 'uploadpanel',
16 | component: UploadPanel,
17 | meta: {
18 | title: '文件上传'
19 | }
20 | },
21 | {
22 | path: '/manage',
23 | name: 'manage',
24 | component: Manage,//component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
25 | meta: {
26 | title: '文件管理'
27 | }
28 | },
29 | {
30 | path: '/settings',
31 | name:'settings',
32 | component:Settings,
33 | meta:{
34 | title:'设置'
35 | }
36 | },
37 | {
38 | path: '/about',
39 | name: 'about',
40 | component: About,
41 | meta: {
42 | title: '关于'
43 | }
44 | },
45 | {
46 | path: '/help',
47 | name: 'help',
48 | component: Help,
49 | meta: {
50 | title: '使用帮助'
51 | }
52 | }
53 | ]
54 | })
55 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/views/About.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Version:{{version}}
5 | 本软件用于文件上传,远程文件管理、访问等功能
6 | 由setTile lzjyzq2制作
7 | 可以扫描下方二维码进群反馈交流
8 |
9 |
10 | 觉得好用的话,可以捐助~~~
11 |
12 |
13 |
14 |
38 |
39 |
52 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/views/Help.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 注意事项
4 |
5 |
注意事项
6 |
7 |
●由于安全考虑,建议仅在局域网环境下运行。
8 |
●当前设置仅支持清理缓存。
9 |
10 |
11 | 文件上传
12 |
13 |
上传路径
14 |
●{{uploadpath}}
15 |
16 |
17 |
18 |
上传文件类型
19 |
●不支持文件夹、无扩展名、或不常见的扩展类型的文件。
20 |
21 |
22 |
操作
23 |
24 |
●拖拽或点击上传区域选择文件,支持多选。
25 |
●当上传文件大小超过剩余容量容量时,会显示通知。请自行移除部分上传文件,以免上传出错。
26 |
●当开始上传后,会禁止移除上传文件。
27 |
28 |
29 | 文件管理
30 |
31 |
上传文件
32 |
33 |
●不支持文件夹、无扩展名、或不常见的扩展类型的文件。
34 |
●仅支持单个文件上传。
35 |
●上传目录为当前浏览文件夹。
36 |
37 |
38 |
39 |
下载文件
40 |
41 |
●当选中文件包括文件夹时,无法下载。
42 |
●下载多个文件时,若浏览器提示是否允许下载多个文件,请点击允许。
43 |
44 |
45 |
46 |
52 |
53 |
54 |
新建文件夹
55 |
56 |
●不允许新文件夹名称包含.\/:*?"<>|
57 |
58 |
59 |
60 |
重命名文件
61 |
62 |
●不允许新文件夹名称包含\/:*?"<>|
63 |
●(.)不允许在开头和结尾。
64 |
65 |
66 |
67 |
打开文件
68 |
69 |
●能被浏览器浏览的文件,能被正常打开浏览。(图片、txt文本文件、常见格式视频等)
70 |
71 |
72 | 设置
73 |
74 |
清理临时文件与缓存
75 |
76 |
●清理软件运行时产生的临时文件与缓存。
77 |
78 |
79 |
80 |
81 |
103 |
104 |
122 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/views/Settings.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
29 |
49 |
--------------------------------------------------------------------------------
/fileserverwebdoc/src/views/UploadPanel.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
34 |
35 |
36 |
44 |
45 |
46 |
49 |
50 |
51 |
272 |
319 |
--------------------------------------------------------------------------------
/fileserverwebdoc/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | css: {
3 | loaderOptions: {
4 | less: {
5 | modifyVars: {
6 | 'primary-color': '#1890ff',
7 | 'link-color': '#1890ff',
8 | 'border-radius-base': '2px',
9 | 'border-color-base':'#d9d9d9'
10 | },
11 | javascriptEnabled: true
12 | }
13 | }
14 | },
15 | productionSourceMap: false,
16 | publicPath: '',
17 | assetsDir: 'static'
18 | }
--------------------------------------------------------------------------------