whycxzp
2022-07-28 5d43dbde11e7b8f9614d574e93e5b1768154f188
src/main/java/com/whyc/config/StaticResourceConfig.java
@@ -30,55 +30,28 @@
        //这个是可行的,解析的时候path为*.html,校验路径admin下是否存在
        registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/");
        /*registry.addResourceHandler("/map/*").addResourceLocations("classpath:/META-INF/resources/map/");
        registry.addResourceHandler("/map/images/*").addResourceLocations("classpath:/META-INF/resources/map/images/");
        registry.addResourceHandler("/map/library/*").addResourceLocations("classpath:/META-INF/resources/map/library/");
        //registry.addResourceHandler("/login.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addR  esourceHandler("*.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/service-worker.js").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/license/**").addResourceLocations("classpath:/META-INF/resources/config/");
        registry.addResourceHandler("/js/*").addResourceLocations("classpath:/META-INF/resources/js/");
        registry.addResourceHandler("/img/*").addResourceLocations("classpath:/META-INF/resources/img/");
        registry.addResourceHandler("/theme/*").addResourceLocations("classpath:/META-INF/resources/theme/");
        registry.addResourceHandler("/theme/img/science-blue/*").addResourceLocations("classpath:/META-INF/resources/theme/img/science-blue/");
        registry.addResourceHandler("/fonts/*").addResourceLocations("classpath:/META-INF/resources/fonts/");*/
        //项目jar同级目录下,图片能通过http方式访问到,很重要!
        ApplicationHome applicationHome = new ApplicationHome(getClass());
        File jarFile = applicationHome.getDir();
        //在jar包所在目录下生成一个upload文件夹用来存储上传的图片
        //开发路径
        //String dirPath = jarFile.getParentFile().toString()+File.separator+"fg_photo_3DStation"+File.separator;
        //打包路径
        String dirPath = jarFile.toString()+File.separator+"fg_photo_3DStation"+File.separator;
        registry.addResourceHandler("/fg_photo_3DStation/**").addResourceLocations("file:/"+dirPath);
        //开发路径
        String dirPathA059 = jarFile.getParentFile().toString()+File.separator+"A059"+File.separator+"images"+File.separator;
        //打包路径
        //String dirPathA059 = jarFile.toString()+File.separator+"A059"+File.separator+"images"+File.separator;
        registry.addResourceHandler("/A059/images/**").addResourceLocations("file:"+dirPathA059);
        /**文档存储路径*/
        String baseDirPath;
        /**统一图片上传路径格式*/
        String baseDirPathmap;//百度地图
        String baseDirPath2;
        String baseDirPath2;//人脸上传地址
        if(YamlProperties.runModel == 1) {
            //开发路径
            baseDirPathmap = jarFile.getParentFile().toString()+File.separator+"baidumapv2"+File.separator;
            baseDirPath2 = jarFile.getParentFile().toString()+File.separator+"fg_photo"+File.separator;
            baseDirPath = jarFile.getParentFile().toString()+File.separator+"doc_file"+File.separator;
            baseDirPath2 = jarFile.getParentFile().toString()+File.separator+"face"+File.separator;
        }else {
            //打包路径
            baseDirPathmap = jarFile.toString()+File.separator+"baidumapv2"+File.separator;
            baseDirPath2 = jarFile.toString()+File.separator+"fg_photo"+File.separator;
            baseDirPath = jarFile.toString()+File.separator+"doc_file"+File.separator;
            baseDirPath2 = jarFile.toString()+File.separator+"face"+File.separator;
        }
        //registry.addResourceHandler("/**").addResourceLocations("file:/"+baseDirPath);
        registry.addResourceHandler("/fg_photo/**").addResourceLocations("file:/"+baseDirPath2);
        registry.addResourceHandler("/baidumapv2/**").addResourceLocations("file:/"+baseDirPathmap);
        registry.addResourceHandler("/doc_file/**").addResourceLocations("file:/"+baseDirPath);
        registry.addResourceHandler("/face/**").addResourceLocations("file:/"+baseDirPath2);
        super.addResourceHandlers(registry);